A formally verified convergence theorem for the tug-of-war scheme of the normalized \(p\)-Laplacian

Juan J. Manfredi and Behrooz Moosavi

Every definition and theorem on the route to the main result, with the results it uses and the Lean code that proves it. Click Lean under a statement to see its source, read from the repository at commit 6884ed0.

70 statements102 Lean declarationsall formalized

1. The scheme

Definition 1.1Admissible functions✓ formalized
Formal statementgenerated from the Lean declaration
BddMeas

Let $d \in \mathbb{N}$, $v \colon \mathbb{R}^{d} \to \mathbb{R}$.

This defines a property of these parameters.

Informal statementfrom the blueprint

A function $v \colon \R^d \to \R$ is admissible if it is Borel measurable and bounded.

Used byDef. 1.2
Lean 1
/-- Bounded and measurable: the class on which the step operator is defined.
See the module docstring for why neither boundedness alone nor continuity is
the right condition. -/
structure BddMeas (v : EuclSpace d → ℝ) : Prop where
  meas : Measurable v
  bound : ∃ C, ∀ y, |v y| ≤ C
Definition 1.2The step operator✓ formalized
Formal statementgenerated from the Lean declaration
tugOfWarOp

Let $d \in \mathbb{N}$, $p, \varepsilon \in \mathbb{R}$, $v \colon \mathbb{R}^{d} \to \mathbb{R}$, $x \in \mathbb{R}^{d}$.

Its value lies in $\mathbb{R}$.

Informal statementfrom the blueprint

For $\eps > 0$ and $v$ admissible, \begin{equation*} \Op v(x) = \frac{\alpha}{2}\Bigl(\sup_{B_\eps(x)} v + \inf_{B_\eps(x)} v\Bigr) + \beta \avgint_{B_\eps(x)} v . \end{equation*}

Lean 1
/-- **The tug-of-war step operator.** -/
def tugOfWarOp (p ε : ℝ) (v : EuclSpace d → ℝ) (x : EuclSpace d) : ℝ :=
  (p - 2) / (p + (d : ℝ)) / 2 *
      (sSup (v '' ball x ε) + sInf (v '' ball x ε))
    + ((d : ℝ) + 2) / (p + (d : ℝ)) * (⨍ y in ball x ε, v y)
Theorem 1.3Monotonicity, translation, nonexpansiveness✓ formalized
Formal statementgenerated from the Lean declaration
tugOfWarOp_monotone

Let $d \in \mathbb{N}$, $p, \varepsilon \in \mathbb{R}$, $u, v \colon \mathbb{R}^{d} \to \mathbb{R}$, $x \in \mathbb{R}^{d}$.

Assume

  • $2 \le p$ hp
  • $0 < d$ hd
  • $0 < \varepsilon$ hε
  • $u\text{ is admissible (bounded and Borel measurable)}$ hu
  • $v\text{ is admissible (bounded and Borel measurable)}$ hv
  • $\forall y,\ u(y) \le v(y)$ h

Then $T_{\varepsilon} u(x) \le T_{\varepsilon} v(x)$.

tugOfWarOp_add_const

Let $d \in \mathbb{N}$, $p, \varepsilon \in \mathbb{R}$, $v \colon \mathbb{R}^{d} \to \mathbb{R}$, $K \in \mathbb{R}$, $x \in \mathbb{R}^{d}$.

Assume

  • $0 < \varepsilon$ hε
  • $v\text{ is admissible (bounded and Borel measurable)}$ hv
  • $0 < p + d$ hpd

Then $T_{\varepsilon} y \mapsto v(y) + K(x) = T_{\varepsilon} v(x) + K$.

tugOfWarOp_nonexpansive

Let $d \in \mathbb{N}$, $p, \varepsilon \in \mathbb{R}$, $u, v \colon \mathbb{R}^{d} \to \mathbb{R}$, $K \in \mathbb{R}$, $x \in \mathbb{R}^{d}$.

Assume

  • $2 \le p$ hp
  • $0 < d$ hd
  • $0 < \varepsilon$ hε
  • $0 < p + d$ hpd
  • $u\text{ is admissible (bounded and Borel measurable)}$ hu
  • $v\text{ is admissible (bounded and Borel measurable)}$ hv
  • $\forall y,\ \lvert u(y) - v(y)\rvert \le K$ h

Then $\lvert T_{\varepsilon} u(x) - T_{\varepsilon} v(x)\rvert \le K$.

Informal statementfrom the blueprint

For $u,v$ admissible: (i) $u \le v$ implies $\Op u \le \Op v$ (tugOfWarOp_monotone); (ii) $\Op(v+K) = \Op v + K$ (tugOfWarOp_add_const); (iii) $\abs{u-v} \le K$ implies $\abs{\Op u - \Op v} \le K$ (tugOfWarOp_nonexpansive).

Lean 3
PLaplacian.tugOfWarOp_monotonePlaplacian/StepOperator.lean, lines 146–165
/-- **Monotonicity of the step operator, for `2 ≤ p`.**

The hypothesis `2 ≤ p` is essential: for `1 < p < 2` the weight `α` is negative
and the `sup + inf` term is anti-monotone. -/
theorem tugOfWarOp_monotone (p ε : ℝ) (hp : 2 ≤ p) (hd : 0 < d) (hε : 0 < ε)
    {u v : EuclSpace d → ℝ} (hu : BddMeas u) (hv : BddMeas v)
    (h : ∀ y, u y ≤ v y) (x : EuclSpace d) :
    tugOfWarOp p ε u x ≤ tugOfWarOp p ε v x := by
  have hpd : 0 < p + (d : ℝ) := by positivity
  have hα : 0 ≤ (p - 2) / (p + (d : ℝ)) / 2 := by
    apply div_nonneg (div_nonneg (by linarith) hpd.le)
    norm_num
  have hβ : 0 ≤ ((d : ℝ) + 2) / (p + (d : ℝ)) := by positivity
  have hne := nonempty_ball x hε
  have hsup := sSup_image_mono (u := u) (v := v) hne (hv.bddAbove_image (ball x ε)) h
  have hinf := sInf_image_mono (u := u) (v := v) hne (hu.bddBelow_image (ball x ε)) h
  have havg := setAverage_mono_ball x (hu.integrableOn_ball x ε)
    (hv.integrableOn_ball x ε) h
  unfold tugOfWarOp
  gcongr
PLaplacian.tugOfWarOp_add_constPlaplacian/StepOperator.lean, lines 225–248
/-- **Translation equivariance of the step operator.** -/
theorem tugOfWarOp_add_const (p ε : ℝ) (hε : 0 < ε)
    {v : EuclSpace d → ℝ} (hv : BddMeas v) (K : ℝ) (x : EuclSpace d)
    (hpd : 0 < p + (d : ℝ)) :
    tugOfWarOp p ε (fun y => v y + K) x = tugOfWarOp p ε v x + K := by
  have hne : (v '' ball x ε).Nonempty :=
    ⟨v x, x, mem_ball_self hε, rfl⟩
  have hab := hv.bddAbove_image (ball x ε)
  have hbb := hv.bddBelow_image (ball x ε)
  have himg : (fun y => v y + K) '' ball x ε
      = (fun r => r + K) '' (v '' ball x ε) := by
    rw [Set.image_image]
  have havg : (⨍ y in ball x ε, (v y + K))
      = (⨍ y in ball x ε, v y) + K := by
    rw [show (fun y => v y + K) = v + (fun _ => K) from rfl,
        MeasureTheory.setAverage_add (hv.integrableOn_ball x ε)
          integrableOn_const,
        setAverage_const_ball K x hε]
  unfold tugOfWarOp
  rw [himg, sSup_image_add_const _ K hne hab,
      sInf_image_add_const _ K hne hbb, havg]
  have h1 := alpha_add_beta (d := d) p hpd
  field_simp
  ring_nf
PLaplacian.tugOfWarOp_nonexpansivePlaplacian/StepOperator.lean, lines 273–290
/-- **Nonexpansiveness in the sup norm.** -/
theorem tugOfWarOp_nonexpansive (p ε : ℝ) (hp : 2 ≤ p) (hd : 0 < d)
    (hε : 0 < ε) (hpd : 0 < p + (d : ℝ))
    {u v : EuclSpace d → ℝ} (hu : BddMeas u) (hv : BddMeas v) {K : ℝ}
    (h : ∀ y, |u y - v y| ≤ K) (x : EuclSpace d) :
    |tugOfWarOp p ε u x - tugOfWarOp p ε v x| ≤ K := by
  have h1 : tugOfWarOp p ε u x ≤ tugOfWarOp p ε v x + K := by
    have := tugOfWarOp_monotone p ε hp hd hε hu (hv.add_const' K)
      (le_add_of_abs_sub_le h) x
    rwa [tugOfWarOp_add_const p ε hε hv K x hpd] at this
  have h2 : tugOfWarOp p ε v x ≤ tugOfWarOp p ε u x + K := by
    have hsym : ∀ y, |v y - u y| ≤ K := fun y => by
      rw [abs_sub_comm]; exact h y
    have := tugOfWarOp_monotone p ε hp hd hε hv (hu.add_const' K)
      (le_add_of_abs_sub_le hsym) x
    rwa [tugOfWarOp_add_const p ε hε hu K x hpd] at this
  rw [abs_le]
  constructor <;> linarith
Proof sketch

Part (i) needs $2 \le p$ essentially: for $1<p<2$ the weight $\alpha$ is negative and the $\sup+\inf$ term is anti-monotone. Part (ii) is where $\alpha+\beta=1$ enters; (iii) follows from (i) and (ii).

Theorem 1.4Measurability of the extreme values✓ formalized
Formal statementgenerated from the Lean declaration
measurable_sSup_ballparts shown as Lean code

Let $d \in \mathbb{N}$, $v \colon \mathbb{R}^{d} \to \mathbb{R}$, $\varepsilon \in \mathbb{R}$.

Assume

  • $0 < \varepsilon$ hε
  • $\exists C,\ \forall y,\ \lvert v(y)\rvert \le C$ hb

Then Measurable fun x => sSup (v '' Metric.ball x ε).

measurable_sInf_ballparts shown as Lean code

Let $d \in \mathbb{N}$, $v \colon \mathbb{R}^{d} \to \mathbb{R}$, $\varepsilon \in \mathbb{R}$.

Assume

  • $0 < \varepsilon$ hε
  • $\exists C,\ \forall y,\ \lvert v(y)\rvert \le C$ hb

Then Measurable fun x => sInf (v '' Metric.ball x ε).

Informal statementfrom the blueprint

For $\eps>0$ and bounded $v$, the maps $x \mapsto \sup_{B_\eps(x)} v$ and $x \mapsto \inf_{B_\eps(x)} v$ are Borel measurable.

Used byThm. 1.5
Lean 2
PLaplacian.measurable_sSup_ballPlaplacian/Measurability.lean, lines 120–124
/-- **The supremum over open balls is measurable.** -/
theorem measurable_sSup_ball (v : EuclSpace d → ℝ) {ε : ℝ} (hε : 0 < ε)
    (hb : ∃ C, ∀ y, |v y| ≤ C) :
    Measurable (fun x : EuclSpace d => sSup (v '' ball x ε)) :=
  measurable_of_Ioi fun lam => (isOpen_sSup_ball_gt v hε hb lam).measurableSet
PLaplacian.measurable_sInf_ballPlaplacian/Measurability.lean, lines 126–130
/-- **The infimum over open balls is measurable.** -/
theorem measurable_sInf_ball (v : EuclSpace d → ℝ) {ε : ℝ} (hε : 0 < ε)
    (hb : ∃ C, ∀ y, |v y| ≤ C) :
    Measurable (fun x : EuclSpace d => sInf (v '' ball x ε)) :=
  measurable_of_Iio fun lam => (isOpen_sInf_ball_lt v hε hb lam).measurableSet
Proof sketch

The proof is the reason for open balls: for every $\lambda$, \begin{equation*} \Bigl\{x : \sup_{B_\eps(x)} v > \lambda\Bigr\} = \bigcup_{\{y : v(y) > \lambda\}} B_\eps(y), \end{equation*} a union of open balls.

Theorem 1.5Invariance of the admissible class✓ formalized
Formal statementgenerated from the Lean declaration
BddMeas.tugOfWarOp

Let $d \in \mathbb{N}$, $p, \varepsilon \in \mathbb{R}$, $v \colon \mathbb{R}^{d} \to \mathbb{R}$.

Assume

  • $2 \le p$ hp
  • $0 < \varepsilon$ hε
  • $0 < p + d$ hpd
  • $v\text{ is admissible (bounded and Borel measurable)}$ hv

Then $T_{\varepsilon} v\text{ is admissible (bounded and Borel measurable)}$.

Informal statementfrom the blueprint

If $v$ is admissible then so is $\Op v$.

Used byThm. 1.9
Lean 1
PLaplacian.BddMeas.tugOfWarOpPlaplacian/Invariance.lean, lines 162–177
/-- **The admissible class is invariant under the step operator.** This is what
makes the monotone iteration of the existence proof well defined. -/
theorem BddMeas.tugOfWarOp (p ε : ℝ) (hp : 2 ≤ p) (hε : 0 < ε)
    (hpd : 0 < p + (d : ℝ))
    {v : EuclSpace d → ℝ} (hv : BddMeas v) :
    BddMeas (tugOfWarOp p ε v) := by
  obtain ⟨C, hC⟩ := hv.bound
  refine ⟨?_, ⟨C, fun x => abs_tugOfWarOp_le p ε hp hε hpd hv hC x⟩⟩
  unfold PLaplacian.tugOfWarOp
  have h1 : Measurable (fun x : EuclSpace d => sSup (v '' ball x ε)) :=
    measurable_sSup_ball v hε ⟨C, hC⟩
  have h2 : Measurable (fun x : EuclSpace d => sInf (v '' ball x ε)) :=
    measurable_sInf_ball v hε ⟨C, hC⟩
  have h3 : Measurable (fun x : EuclSpace d => ⨍ y in ball x ε, v y) :=
    measurable_setAverage_ball hv.meas ε
  exact ((h1.add h2).const_mul _).add (h3.const_mul _)
Proof sketch

This makes the existence iteration meaningful, and it is false for closed balls. Measurability of the average term is separate from Theorem Theorem 1.4: it is proved by rewriting the integral over the moving ball as an integral over a fixed ball of a translated integrand and appealing to StronglyMeasurable.integral_prod_right. Preservation of the bound is convexity.

Definition 1.6The boundary strip✓ formalized
Formal statementgenerated from the Lean declaration
bdryStrip

Let $d \in \mathbb{N}$, $\Omega \subseteq \mathbb{R}^{d}$, $\varepsilon \in \mathbb{R}$.

Its value lies in $\operatorname{Set}(\mathbb{R}^{d})$.

closureEps

Let $d \in \mathbb{N}$, $\Omega \subseteq \mathbb{R}^{d}$, $\varepsilon \in \mathbb{R}$.

Its value lies in $\operatorname{Set}(\mathbb{R}^{d})$.

Informal statementfrom the blueprint

$\Gamma_\eps = \{x \notin \Omega : \operatorname{dist}(x,\Omega) \le \eps\}$ and $\Omega_\eps = \Omega \cup \Gamma_\eps$.

Lean 2
/-- The boundary strip: points outside `Ω` within distance `ε` of it.

The `≤` makes `closedBall_subset_union` hold; see the module docstring. -/
def bdryStrip (Ω : Set (EuclSpace d)) (ε : ℝ) : Set (EuclSpace d) :=
  {x | x ∉ Ω ∧ Metric.infDist x Ω ≤ ε}
/-- The set on which the data of the ε-problem is prescribed. -/
def closureEps (Ω : Set (EuclSpace d)) (ε : ℝ) : Set (EuclSpace d) :=
  Ω ∪ bdryStrip Ω ε
Lemma 1.7Closure of the problem✓ formalized
Formal statementgenerated from the Lean declaration
closedBall_subset_union

Let $d \in \mathbb{N}$, $\Omega \subseteq \mathbb{R}^{d}$, $\varepsilon \in \mathbb{R}$, $x \in \mathbb{R}^{d}$.

Assume

  • $x \in \Omega$ hx

Then $\overline{B}(x, \varepsilon) \subseteq \Omega \cup \operatorname{bdryStrip}(\Omega, \varepsilon)$.

Informal statementfrom the blueprint

For $x \in \Omega$, $\overline{B}_\eps(x) \subseteq \Omega_\eps$.

Used byThm. 1.15
Lean 1
PLaplacian.closedBall_subset_unionPlaplacian/Domain.lean, lines 75–85
/-- **The ε-problem is closed.** At a point of `Ω` the operator reads only
points of `Ω ∪ Γ_ε`, so it never needs a value that is not prescribed. -/
lemma closedBall_subset_union (Ω : Set (EuclSpace d)) {ε : ℝ}
    {x : EuclSpace d} (hx : x ∈ Ω) :
    closedBall x ε ⊆ Ω ∪ bdryStrip Ω ε := by
  intro y hy
  by_cases hyΩ : y ∈ Ω
  · exact Or.inl hyΩ
  · refine Or.inr ⟨hyΩ, ?_⟩
    calc Metric.infDist y Ω ≤ dist y x := Metric.infDist_le_dist_of_mem hx
      _ ≤ ε := Metric.mem_closedBall.1 hy
Proof sketch

See the companion for the argument.

Definition 1.8p-harmonious functions✓ formalized
Formal statementgenerated from the Lean declaration
IsPHarmonious

Let $d \in \mathbb{N}$, $p, \varepsilon \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $F, u \colon \mathbb{R}^{d} \to \mathbb{R}$.

This defines a property of these parameters.

Informal statementfrom the blueprint

Given bounded Borel $F$ on $\Gamma_\eps$, a function $u$ is $p$-harmonious with data $F$ if it is admissible, $u = \Op u$ on $\Omega$, and $u = F$ on $\Gamma_\eps$.

Lean 1
/-- **The ε-Dirichlet problem.** The dynamic programming principle is taken as
the definition of the discrete problem, not derived from a game. -/
structure IsPHarmonious (p ε : ℝ) (Ω : Set (EuclSpace d))
    (F : EuclSpace d → ℝ) (u : EuclSpace d → ℝ) : Prop where
  bddMeas : BddMeas u
  interior : ∀ x ∈ Ω, u x = tugOfWarOp p ε u x
  boundary : ∀ x ∈ bdryStrip Ω ε, u x = F x
Theorem 1.9The Perron iteration✓ formalized
Formal statementgenerated from the Lean declaration
iter

Let $d \in \mathbb{N}$, $p, \varepsilon \in \mathbb{R}$, $u_{0} \colon \mathbb{R}^{d} \to \mathbb{R}$, $\mathrm{a.\_@.\_internal.\_hyg.0} \in \mathbb{N}$, $\mathrm{a.\_@.\_internal.\_hyg.0} \in \mathbb{R}^{d}$.

Its value lies in $\mathbb{R}$.

Informal statementfrom the blueprint

From an admissible $u_0$ with $u_0 \le \Op u_0$, the sequence $u_{j+1} = \Op u_j$ has every term admissible, increases, inherits the bound on $u_0$, converges pointwise to $u = \sup_j u_j$, and $u$ is admissible.

Used byThm. 1.12
Lean 1
/-- The Perron iteration: `u₀` given, `u_{j+1} = T_ε u_j`. -/
def iter (p ε : ℝ) (u₀ : EuclSpace d → ℝ) : ℕ → (EuclSpace d → ℝ)
  | 0 => u₀
  | (j+1) => tugOfWarOp p ε (iter p ε u₀ j)
Proof sketch

See the companion for the argument.

Theorem 1.10Extreme values are nonexpansive✓ formalized
Formal statementgenerated from the Lean declaration
abs_sSup_sub_sSup_leparts shown as Lean code

Let $d \in \mathbb{N}$, $S \subseteq \mathbb{R}^{d}$, $u, v \colon \mathbb{R}^{d} \to \mathbb{R}$, $K \in \mathbb{R}$, $C \in \mathbb{R}$.

Assume

  • $S\text{ is nonempty}$ hS
  • $\forall y,\ \lvert u(y) - v(y)\rvert \le K$ hK
  • $\forall y,\ \lvert u(y)\rvert \le C$ hCu
  • $\forall y,\ \lvert v(y)\rvert \le C$ hCv

Then |sSup (u '' S) - sSup (v '' S)| ≤ K.

Informal statementfrom the blueprint

If $\abs{u-v} \le K$ pointwise then each of the three terms of $\Op$ changes by at most $K$.

Lean 1
PLaplacian.abs_sSup_sub_sSup_lePlaplacian/UnifContinuity.lean, lines 36–57
theorem abs_sSup_sub_sSup_le {S : Set (EuclSpace d)} (hS : S.Nonempty)
    {u v : EuclSpace d → ℝ} {K : ℝ} (hK : ∀ y, |u y - v y| ≤ K)
    {C : ℝ} (hCu : ∀ y, |u y| ≤ C) (hCv : ∀ y, |v y| ≤ C) :
    |sSup (u '' S) - sSup (v '' S)| ≤ K := by
  have hbu : BddAbove (u '' S) :=
    ⟨C, by rintro a ⟨y, -, rfl⟩; exact (abs_le.1 (hCu y)).2⟩
  have hbv : BddAbove (v '' S) :=
    ⟨C, by rintro a ⟨y, -, rfl⟩; exact (abs_le.1 (hCv y)).2⟩
  have h1 : sSup (u '' S) ≤ sSup (v '' S) + K := by
    refine csSup_le (hS.image u) ?_
    rintro a ⟨y, hy, rfl⟩
    have h2 : u y ≤ v y + K := by linarith [(abs_le.1 (hK y)).2]
    have h3 : v y ≤ sSup (v '' S) := le_csSup hbv ⟨y, hy, rfl⟩
    linarith
  have h4 : sSup (v '' S) ≤ sSup (u '' S) + K := by
    refine csSup_le (hS.image v) ?_
    rintro a ⟨y, hy, rfl⟩
    have h2 : v y ≤ u y + K := by linarith [(abs_le.1 (hK y)).1]
    have h3 : u y ≤ sSup (u '' S) := le_csSup hbu ⟨y, hy, rfl⟩
    linarith
  rw [abs_le]
  constructor <;> linarith
Proof sketch

Pointwise convergence would not suffice: the extreme-value terms are suprema over a ball, and a pointwise limit need not have the limit of the suprema as its supremum. remark that $\beta>0$ is needed both for uniform convergence and for the limit to satisfy the equation; Theorem Theorem 1.10 is where the second use appears.

Theorem 1.11The arithmetic of the deficit✓ formalized
Formal statementgenerated from the Lean declaration
unif_arith

Let $\alpha, \beta, M, \delta, A, S \in \mathbb{R}$.

Assume

  • $0 \le \alpha$ hα
  • $\alpha + \beta = 1$ hab
  • $M - 2 \cdot \delta \le \alpha \cdot S + \beta \cdot A$ h1
  • $S \le M + \delta$ hS
  • $\beta \cdot A \le \delta$ hA

Then $\beta \cdot M \le \delta \cdot (3 + \alpha)$.

le_zero_of_forall_lt

Let $\beta, M, \alpha \in \mathbb{R}$.

Assume

  • $0 < \beta$ hβ
  • $0 \le \alpha$ hα
  • $\forall \delta > 0,\ \beta \cdot M \le \delta \cdot (3 + \alpha)$ h

Then $M \le 0$.

Informal statementfrom the blueprint

Let $\alpha \ge 0$ with $\alpha+\beta=1$. If $M - 2\delta \le \alpha S + \beta A$ with $S \le M+\delta$ and $\beta A \le \delta$, then $\beta M \le \delta(3+\alpha)$. If moreover $\beta>0$ and this holds for every $\delta>0$, then $M \le 0$.

Lean 2
/-- **The chained inequality.** Given
`M - 2δ ≤ α S + β A`, `S ≤ M + δ` and `β A ≤ δ`, one has
`β M ≤ δ (3 + α)`.

Note that neither `0 < β` nor `0 < δ` is required: this step is algebra, using
only `α ≥ 0` and `α + β = 1`. -/
theorem unif_arith {α β M δ A S : ℝ}
    (hα : 0 ≤ α) (hab : α + β = 1)
    (h1 : M - 2 * δ ≤ α * S + β * A)
    (hS : S ≤ M + δ)
    (hA : β * A ≤ δ) :
    β * M ≤ δ * (3 + α) := by
  have hstep : α * S ≤ α * (M + δ) := mul_le_mul_of_nonneg_left hS hα
  have hexp : α * (M + δ) = α * M + α * δ := by ring
  have hbm : β * M = M - α * M := by
    have hβα : β = 1 - α := by linarith
    rw [hβα]; ring
  rw [hbm]
  linarith [h1, hstep, hexp, hA]
/-- **The limiting step.** This is where `β > 0` is used: if `β M` is bounded
by an arbitrarily small multiple of `3 + α`, then `M ≤ 0`. -/
theorem le_zero_of_forall_lt {β M α : ℝ} (hβ : 0 < β) (hα : 0 ≤ α)
    (h : ∀ δ > 0, β * M ≤ δ * (3 + α)) : M ≤ 0 := by
  by_contra hcon
  push Not at hcon
  have hpos : 0 < β * M := mul_pos hβ hcon
  obtain ⟨δ, hδpos, hδlt⟩ : ∃ δ > 0, δ * (3 + α) < β * M := by
    refine ⟨(β * M) / (2 * (3 + α)), by positivity, ?_⟩
    have h3 : 0 < 3 + α := by linarith
    rw [div_mul_eq_mul_div, div_lt_iff₀ (by positivity)]
    nlinarith [hpos, h3]
  exact absurd (h δ hδpos) (not_le.2 hδlt)
Proof sketch

See the companion for the argument.

Theorem 1.12The deficit estimate✓ formalized
Formal statementgenerated from the Lean declaration
deficitLimit_eq_zero

Let $d \in \mathbb{N}$, $p, \varepsilon \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $u_{0} \colon \mathbb{R}^{d} \to \mathbb{R}$, $C \in \mathbb{R}$, $M \in \mathbb{R}$.

Assume

  • $2 \le p$ hp
  • $0 < \varepsilon$ hε
  • $0 < d$ hd
  • $0 < p + d$ hpd
  • $\Omega\text{ is nonempty}$ _hΩ
  • $u_{0}\text{ is admissible (bounded and Borel measurable)}$ hu₀
  • $\forall y,\ \lvert u_{0}(y)\rvert \le C$ hC
  • $\forall x,\ u_{0}(x) \le T_{\varepsilon} u_{0}(x)$ hstep
  • $\operatorname{iterLimit}(p, \varepsilon, u_{0})\text{ is admissible (bounded and Borel measurable)}$ hBMu
  • $\forall \eta > 0,\ \forall \delta' > 0,\ \exists k,\ \int_{\Omega_{\varepsilon}} (\operatorname{iterLimit}(p, \varepsilon, u_{0}, y) - \operatorname{iter}(p, \varepsilon, u_{0}, k, y) \le \eta \wedge \operatorname{deficitSup}(\Omega_{\varepsilon}, \operatorname{iterLimit}(p, \varepsilon, u_{0}), \operatorname{iter}(p, \varepsilon, u_{0}, k)) \le M + \delta') \, dy$ hglob
  • $\forall k,\ \operatorname{IntegrableOn}(y \mapsto \operatorname{iterLimit}(p, \varepsilon, u_{0}, y) - \operatorname{iter}(p, \varepsilon, u_{0}, k, y), \Omega_{\varepsilon}, \lambda)$ hint
  • $\forall \delta,\ 0 < \delta \to \forall k,\ \exists x_{0} \in \Omega,\ \exists l,\ M - 2 \cdot \delta \le T_{\varepsilon} \operatorname{iter}(p, \varepsilon, u_{0}, l)(x_{0}) - T_{\varepsilon} \operatorname{iter}(p, \varepsilon, u_{0}, k)(x_{0})$ hsel

Then $M \le 0$.

Informal statementfrom the blueprint

Let $M = \lim_j \sup_{\Omega_\eps}(u - u_j)$. Given the convergence of the integrals of the deficit over $\Omega_\eps$ and the selections of the indices and the point described below, $M \le 0$.

Lean 1
/-- **Uniform convergence of the Perron iteration.** LPS Theorem 2.1.

The two limiting inputs and the index selections are taken as hypotheses; they
follow from `tendsto_setIntegral_deficit`, `tendsto_iterLimit` and the LPS
choices, and are discharged in a wrapper. Keeping them abstract isolates the
chained estimate, which is the substance.

Note that `hglob` carries two independent tolerances. The informal proof writes
`delta` for both the supremum bound and the integral bound, but they play
different roles: the integral target must absorb the factor
`beta / |B eps|` before it becomes a bound on the average term. -/
theorem deficitLimit_eq_zero (p ε : ℝ) (hp : 2 ≤ p) (hε : 0 < ε) (hd : 0 < d)
    (hpd : 0 < p + (d : ℝ))
    {Ω : Set (EuclSpace d)} (_hΩ : Ω.Nonempty)
    {u₀ : EuclSpace d → ℝ} (hu₀ : BddMeas u₀) {C : ℝ}
    (hC : ∀ y, |u₀ y| ≤ C)
    (hstep : ∀ x, u₀ x ≤ tugOfWarOp p ε u₀ x)
    (hBMu : BddMeas (iterLimit p ε u₀))
    {M : ℝ}
    (hglob : ∀ η > 0, ∀ δ' > 0, ∃ k, (∫ y in closureEps Ω ε,
      (iterLimit p ε u₀ y - iter p ε u₀ k y)) ≤ η
      ∧ deficitSup (closureEps Ω ε) (iterLimit p ε u₀)
          (iter p ε u₀ k) ≤ M + δ')
    (hint : ∀ k, MeasureTheory.IntegrableOn
      (fun y => iterLimit p ε u₀ y - iter p ε u₀ k y) (closureEps Ω ε))
    (hsel : ∀ (δ : ℝ), 0 < δ → ∀ k : ℕ, ∃ x₀ ∈ Ω, ∃ l : ℕ,
      M - 2 * δ ≤ tugOfWarOp p ε (iter p ε u₀ l) x₀
        - tugOfWarOp p ε (iter p ε u₀ k) x₀) :
    M ≤ 0 := by
  have hα : (0 : ℝ) ≤ (p - 2) / (p + (d : ℝ)) :=
    div_nonneg (by linarith) hpd.le
  have hβ : (0 : ℝ) < ((d : ℝ) + 2) / (p + (d : ℝ)) := by positivity
  have hvol : (0 : ℝ) < volume.real (ball (0 : EuclSpace d) ε) := by
    have h1 : volume (ball (0 : EuclSpace d) ε) ≠ 0 :=
      measure_ball_ne_zero 0 hε
    have h2 : volume (ball (0 : EuclSpace d) ε) ≠ ⊤ := measure_ball_lt_top.ne
    simp only [MeasureTheory.Measure.real]
    exact ENNReal.toReal_pos h1 h2
  set u := iterLimit p ε u₀ with hu
  have hCd : ∀ j y, |u y - iter p ε u₀ j y| ≤ 2 * C := fun j y =>
    abs_deficit_le p ε hp hε hd hpd hu₀ hC hstep j y
  have hnn : ∀ j y, 0 ≤ u y - iter p ε u₀ j y := fun j y =>
    deficit_nonneg p ε hp hε hd hpd hu₀ hC hstep j y
  have hBM : ∀ j, BddMeas (iter p ε u₀ j) := fun j =>
    bddMeas_iter p ε hp hε hpd hu₀ j
  refine deficitLimit_le_zero hα hβ (alpha_add_beta p hpd) ?_
  intro δ hδ
  -- the target for the global integral, chosen so the average bound is exactly δ
  set η := δ * volume.real (ball (0 : EuclSpace d) ε)
    / (((d : ℝ) + 2) / (p + (d : ℝ))) with hηdef
  have hηpos : 0 < η := by
    rw [hηdef]; positivity
  have hηeq : ((d : ℝ) + 2) / (p + (d : ℝ))
      * ((volume.real (ball (0 : EuclSpace d) ε))⁻¹ * η) = δ := by
    rw [hηdef]
    field_simp
  obtain ⟨k, hksmall, hksup⟩ := hglob η hηpos δ hδ
  obtain ⟨x₀, hx₀Ω, l, hchain⟩ := hsel δ hδ k
  refine ⟨⨍ y in ball x₀ ε, (u y - iter p ε u₀ k y),
          sSup ((fun y => u y - iter p ε u₀ k y) '' ball x₀ ε),
          ?_, ?_, ?_⟩
  · refine le_trans hchain ?_
    exact bound_one p ε hp hε hpd hBMu (hBM l) (hBM k)
      (fun y => iter_le_iterLimit p ε hp hε hd hpd hu₀ hC hstep l y)
      (hCd k) x₀
  · exact bound_two (hCd k) hksup hx₀Ω hε
  · rw [← hηeq]
    exact bound_three hε (hnn k) (hint k) hx₀Ω hβ.le hksmall
Proof sketch

This is the substantive step. Following one supposes $M>0$, fixes $\delta>0$, chooses an index $k$, a point $x_0$ nearly attaining the deficit supremum at stage $k+1$, and a late index $\ell$, and chains \[ M - 2\delta \le \alpha \sup_{B_\eps(x_0)}(u - u_k) + \beta \avgint_{B_\eps(x_0)}(u - u_k) \le \alpha(M+\delta) + \delta, \] whence $\beta M \le \delta(3+\alpha)$ and, $\beta$ being positive, $M \le 0$. Four of the findings recorded in the companion arose here.

Theorem 1.13Fixed point of a uniformly convergent iteration✓ formalized
Formal statementgenerated from the Lean declaration
exists_fixedPoint

Let $d \in \mathbb{N}$, $p, \varepsilon \in \mathbb{R}$, $u_{0} \colon \mathbb{R}^{d} \to \mathbb{R}$, $C \in \mathbb{R}$.

Assume

  • $2 \le p$ hp
  • $0 < \varepsilon$ hε
  • $0 < d$ hd
  • $0 < p + d$ hpd
  • $u_{0}\text{ is admissible (bounded and Borel measurable)}$ hu₀
  • $\forall y,\ \lvert u_{0}(y)\rvert \le C$ hC
  • $\forall x,\ u_{0}(x) \le T_{\varepsilon} u_{0}(x)$ hstep
  • $\forall \eta > 0,\ \exists N,\ \forall j \ge N,\ \forall x,\ \lvert \operatorname{iterLimit}(p, \varepsilon, u_{0}, x) - \operatorname{iter}(p, \varepsilon, u_{0}, j, x)\rvert \le \eta$ hunif

Then all of the following hold:

  • $\operatorname{iterLimit}(p, \varepsilon, u_{0})\text{ is admissible (bounded and Borel measurable)}$
  • $\forall x,\ T_{\varepsilon} \operatorname{iterLimit}(p, \varepsilon, u_{0})(x) = \operatorname{iterLimit}(p, \varepsilon, u_{0}, x)$
Informal statementfrom the blueprint

Under the hypotheses of Theorem Theorem 1.9 together with uniform convergence, the limit is admissible and satisfies $\Op u = u$.

Lean 1
PLaplacian.exists_fixedPointPlaplacian/Existence.lean, lines 35–87
/-- **Existence of a solution of the dynamic programming principle.**

Given an admissible subsolution `u₀`, the Perron iteration converges to an
admissible function that is a fixed point of the step operator. This is the
content of Theorem 2.1 of Luiro-Parviainen-Saksman, assembled from the
ingredients proved in the preceding files.

The fixed-point property is obtained by passing the operator through the
limit: `T` of the limit is the limit of the `T`-iterates by
`tugOfWarOp_nonexpansive` together with uniform convergence, and the
`T`-iterates are the iterates shifted by one, whose limit is the same. -/
theorem exists_fixedPoint (p ε : ℝ) (hp : 2 ≤ p) (hε : 0 < ε) (hd : 0 < d)
    (hpd : 0 < p + (d : ℝ))
    {u₀ : EuclSpace d → ℝ} (hu₀ : BddMeas u₀) {C : ℝ}
    (hC : ∀ y, |u₀ y| ≤ C)
    (hstep : ∀ x, u₀ x ≤ tugOfWarOp p ε u₀ x)
    (hunif : ∀ η > 0, ∃ N, ∀ j ≥ N, ∀ x,
      |iterLimit p ε u₀ x - iter p ε u₀ j x| ≤ η) :
    BddMeas (iterLimit p ε u₀)
    ∧ ∀ x, tugOfWarOp p ε (iterLimit p ε u₀) x = iterLimit p ε u₀ x := by
  have hBMu := bddMeas_iterLimit p ε hp hε hd hpd hu₀ hC hstep
  refine ⟨hBMu, fun x => ?_⟩
  -- it suffices that the difference is below every positive η
  have key : ∀ η > 0,
      |tugOfWarOp p ε (iterLimit p ε u₀) x - iterLimit p ε u₀ x| ≤ 2 * η := by
    intro η hη
    obtain ⟨N, hN⟩ := hunif η hη
    -- T of the limit is close to T of the N-th iterate
    have h1 : |tugOfWarOp p ε (iterLimit p ε u₀) x
        - tugOfWarOp p ε (iter p ε u₀ N) x| ≤ η :=
      tugOfWarOp_nonexpansive p ε hp hd hε hpd hBMu
        (bddMeas_iter p ε hp hε hpd hu₀ N)
        (fun y => hN N le_rfl y) x
    -- T of the N-th iterate is the (N+1)-st, which is close to the limit
    have h2 : |iterLimit p ε u₀ x - iter p ε u₀ (N + 1) x| ≤ η :=
      hN (N + 1) (Nat.le_succ N) x
    have h3 : iter p ε u₀ (N + 1) x = tugOfWarOp p ε (iter p ε u₀ N) x := rfl
    rw [h3] at h2
    have h4 := abs_le.1 h1
    have h5 := abs_le.1 h2
    rw [abs_le]
    constructor <;> linarith
  -- a nonnegative quantity below every positive bound is zero
  have hzero : tugOfWarOp p ε (iterLimit p ε u₀) x - iterLimit p ε u₀ x = 0 := by
    by_contra hcon
    have hpos : 0 < |tugOfWarOp p ε (iterLimit p ε u₀) x
        - iterLimit p ε u₀ x| := abs_pos.2 hcon
    obtain ⟨η, hηpos, hηlt⟩ : ∃ η > 0, 2 * η
        < |tugOfWarOp p ε (iterLimit p ε u₀) x - iterLimit p ε u₀ x| := by
      refine ⟨|tugOfWarOp p ε (iterLimit p ε u₀) x
        - iterLimit p ε u₀ x| / 4, by positivity, by linarith⟩
    exact absurd (key η hηpos) (not_le.2 hηlt)
  linarith [hzero]
Proof sketch

The fixed-point property follows by passing the operator through the limit: $\Op u$ is within $\eta$ of $\Op u_N$ by nonexpansiveness, and $\Op u_N = u_{N+1}$ is within $\eta$ of $u$ by uniform convergence.

Theorem 1.14Components of the discrete comparison✓ formalized
Formal statementgenerated from the Lean declaration
key_estimateparts shown as Lean code

Let $d \in \mathbb{N}$, $p, \varepsilon \in \mathbb{R}$, $u, v \colon \mathbb{R}^{d} \to \mathbb{R}$, $x \in \mathbb{R}^{d}$.

Assume

  • $2 \le p$ hp
  • $0 < \varepsilon$ hε
  • $0 < p + d$ hpd
  • $u\text{ is admissible (bounded and Borel measurable)}$ hu
  • $v\text{ is admissible (bounded and Borel measurable)}$ hv

Then PLaplacian.tugOfWarOp p ε v x - PLaplacian.tugOfWarOp p ε u x ≤ (p - 2) / (p + ↑d) * sSup ((fun y => v y - u y) '' Metric.ball x ε) + (↑d + 2) / (p + ↑d) * ⨍ (y : EuclSpace d) in Metric.ball x ε, v y - u y.

ae_eq_of_setAverage_eq_maxparts shown as Lean code

Let $d \in \mathbb{N}$, $f \colon \mathbb{R}^{d} \to \mathbb{R}$, $M \in \mathbb{R}$, $x \in \mathbb{R}^{d}$, $\varepsilon \in \mathbb{R}$.

Assume

  • $0 < \varepsilon$ hε
  • $\operatorname{IntegrableOn}(f, B(x, \varepsilon), \lambda)$ hint
  • $\forall y,\ f(y) \le M$ hle
  • $\fint_{B(x, \varepsilon)} (f(y) = M) \, dy$ havg

Then (fun y => M - f y) =ᵐ[MeasureTheory.volume.restrict (Metric.ball x ε)] 0.

measure_diff_max_setparts shown as Lean code

Let $d \in \mathbb{N}$, $p, \varepsilon \in \mathbb{R}$, $u, v \colon \mathbb{R}^{d} \to \mathbb{R}$, $M \in \mathbb{R}$, $x \in \mathbb{R}^{d}$.

Assume

  • $2 \le p$ hp
  • $0 < \varepsilon$ hε
  • $0 < p + d$ hpd
  • $u\text{ is admissible (bounded and Borel measurable)}$ hu
  • $v\text{ is admissible (bounded and Borel measurable)}$ hv
  • $\forall y,\ v(y) - u(y) \le M$ hMle
  • $v(x) - u(x) = M$ hMx
  • $T_{\varepsilon} v(x) - T_{\varepsilon} u(x) = v(x) - u(x)$ hfix

Then MeasureTheory.volume (Metric.ball x ε \ {y | v y - u y = M}) = 0.

inner_advance

Let $d \in \mathbb{N}$, $x, y, e \in \mathbb{R}^{d}$, $\varepsilon \in \mathbb{R}$.

Assume

  • $\lVert e\rVert = 1$ he
  • $y \in B(x + \varepsilon / 2 \cdot e, \varepsilon / 4)$ hy

Then $\operatorname{inner}(\mathbb{R}, e, x) + \varepsilon / 4 \le \operatorname{inner}(\mathbb{R}, e, y)$.

max_set_unbounded

Let $d \in \mathbb{N}$, $p, \varepsilon \in \mathbb{R}$, $e \in \mathbb{R}^{d}$, $u, v \colon \mathbb{R}^{d} \to \mathbb{R}$, $M \in \mathbb{R}$, $x_{0} \in \mathbb{R}^{d}$, $R \in \mathbb{R}$.

Assume

  • $2 \le p$ hp
  • $0 < \varepsilon$ hε
  • $0 < p + d$ hpd
  • $\lVert e\rVert = 1$ he
  • $u\text{ is admissible (bounded and Borel measurable)}$ hu
  • $v\text{ is admissible (bounded and Borel measurable)}$ hv
  • $\forall y,\ v(y) - u(y) \le M$ hMle
  • $\forall y,\ v(y) - u(y) = M \to T_{\varepsilon} v(y) - T_{\varepsilon} u(y) = v(y) - u(y)$ hfix
  • $v(x_{0}) - u(x_{0}) = M$ hx₀

Then there exists $y$ such that:

  • $v(y) - u(y) = M$
  • $R < \operatorname{inner}(\mathbb{R}, e, y)$
not_bounded_max_setparts shown as Lean code

Let $d \in \mathbb{N}$, $p, \varepsilon \in \mathbb{R}$, $e \in \mathbb{R}^{d}$, $u, v \colon \mathbb{R}^{d} \to \mathbb{R}$, $M \in \mathbb{R}$, $x_{0} \in \mathbb{R}^{d}$, $S \subseteq \mathbb{R}^{d}$.

Assume

  • $2 \le p$ hp
  • $0 < \varepsilon$ hε
  • $0 < p + d$ hpd
  • $\lVert e\rVert = 1$ he
  • $u\text{ is admissible (bounded and Borel measurable)}$ hu
  • $v\text{ is admissible (bounded and Borel measurable)}$ hv
  • $\forall y,\ v(y) - u(y) \le M$ hMle
  • $\forall y,\ v(y) - u(y) = M \to T_{\varepsilon} v(y) - T_{\varepsilon} u(y) = v(y) - u(y)$ hfix
  • $v(x_{0}) - u(x_{0}) = M$ hx₀
  • $S\text{ is bounded}$ hS
  • {y | v y - u y = M} ⊆ S hsub

Then $\mathrm{False}$.

Informal statementfrom the blueprint

For $u,v$ admissible: (i) (key_estimate) $\Op v(x) - \Op u(x) \le \alpha \sup_{B_\eps(x)}(v-u) + \beta \avgint_{B_\eps(x)}(v-u)$; (ii) (ae_eq_of_setAverage_eq_max) a function bounded by $M$ whose average equals $M$ equals $M$ almost everywhere; (iii) (measure_diff_max_set) at an attained maximum the maximum set has full measure in the ball; (iv) (inner_advance) displacement by $\tfrac{\eps}{2}e$ advances $\langle e,\cdot\rangle$ by at least $\tfrac{\eps}{4}$; (v) (max_set_unbounded) the maximum set is unbounded in every direction; (vi) (not_bounded_max_set) hence it cannot lie in a bounded set.

Lean 6
/-- **The key estimate.** -/
theorem key_estimate (p ε : ℝ) (hp : 2 ≤ p) (hε : 0 < ε)
    (hpd : 0 < p + (d : ℝ))
    {u v : EuclSpace d → ℝ} (hu : BddMeas u) (hv : BddMeas v)
    (x : EuclSpace d) :
    tugOfWarOp p ε v x - tugOfWarOp p ε u x
      ≤ (p - 2) / (p + (d : ℝ)) * sSup ((fun y => v y - u y) '' ball x ε)
        + ((d : ℝ) + 2) / (p + (d : ℝ))
            * ⨍ y in ball x ε, (v y - u y) := by
  have hne := nonempty_ball x hε
  have hdiff := hv.sub hu
  have hsup := sSup_sub_sSup_le u v (ball x ε) hne
    (hu.bddAbove_image (ball x ε)) (hdiff.bddAbove_image (ball x ε))
  have hinf := sInf_sub_sInf_le u v (ball x ε) hne
    (hv.bddBelow_image (ball x ε)) (hdiff.bddAbove_image (ball x ε))
  have havg : (⨍ y in ball x ε, v y) - (⨍ y in ball x ε, u y)
      = ⨍ y in ball x ε, (v y - u y) := by
    rw [show (fun y : EuclSpace d => v y - u y) = v - u from rfl,
        MeasureTheory.setAverage_sub (hv.integrableOn_ball x ε)
          (hu.integrableOn_ball x ε)]
  have hα : 0 ≤ (p - 2) / (p + (d : ℝ)) / 2 := by
    apply div_nonneg (div_nonneg (by linarith) hpd.le); norm_num
  unfold tugOfWarOp
  rw [← havg]
  nlinarith [hsup, hinf, hα]
PLaplacian.ae_eq_of_setAverage_eq_maxPlaplacian/Comparison.lean, lines 107–135
/-- **The a.e.-equality step.** A function bounded above by `M` whose average
over a ball equals `M` is equal to `M` almost everywhere on that ball. -/
theorem ae_eq_of_setAverage_eq_max
    {f : EuclSpace d → ℝ} {M : ℝ} (x : EuclSpace d) {ε : ℝ} (hε : 0 < ε)
    (hint : MeasureTheory.IntegrableOn f (ball x ε))
    (hle : ∀ y, f y ≤ M)
    (havg : (⨍ y in ball x ε, f y) = M) :
    (fun y => M - f y) =ᵐ[volume.restrict (ball x ε)] 0 := by
  have hcint : MeasureTheory.IntegrableOn (fun _ : EuclSpace d => M)
      (ball x ε) := integrableOn_const
  have hgint : MeasureTheory.IntegrableOn (fun y => M - f y) (ball x ε) :=
    hcint.sub hint
  refine ae_eq_zero_of_setIntegral_eq_zero hgint
    (fun y => by linarith [hle y]) ?_
  have hsub : (⨍ y in ball x ε, (M - f y)) = 0 := by
    rw [show (fun y : EuclSpace d => M - f y)
          = (fun _ : EuclSpace d => M) - f from rfl,
        MeasureTheory.setAverage_sub hcint hint,
        setAverage_const_ball M x hε, havg, sub_self]
  rw [MeasureTheory.setAverage_eq] at hsub
  have hvol : volume.real (ball x ε) ≠ 0 := by
    have h1 : volume (ball x ε) ≠ 0 := measure_ball_ne_zero x hε
    have h2 : volume (ball x ε) ≠ ⊤ := measure_ball_lt_top.ne
    simp only [MeasureTheory.Measure.real]
    exact ne_of_gt (ENNReal.toReal_pos h1 h2)
  rw [smul_eq_mul, mul_eq_zero] at hsub
  rcases hsub with h | h
  · exact absurd (inv_eq_zero.1 h) hvol
  · exact h
PLaplacian.measure_diff_max_setPlaplacian/Comparison.lean, lines 381–392
/-- **Propagation, in the form `exists_mem_displaced` consumes.** At an
attained maximum, the maximum set has full measure in the ball. -/
theorem measure_diff_max_set (p ε : ℝ) (hp : 2 ≤ p) (hε : 0 < ε)
    (hpd : 0 < p + (d : ℝ))
    {u v : EuclSpace d → ℝ} (hu : BddMeas u) (hv : BddMeas v)
    {M : ℝ} (hMle : ∀ y, v y - u y ≤ M)
    {x : EuclSpace d} (hMx : v x - u x = M)
    (hfix : tugOfWarOp p ε v x - tugOfWarOp p ε u x = v x - u x) :
    volume (ball x ε \ {y : EuclSpace d | v y - u y = M}) = 0 :=
  measure_diff_eq_zero_of_ae_mem _ x (measurableSet_max_set hu hv M)
    (ae_mem_max_set x
      (ae_eq_max_on_ball p ε hp hε hpd hu hv hMle hMx hfix))
/-- Each step advances the inner product with `e` by at least `ε / 4`. -/
theorem inner_advance (x y : EuclSpace d)
    (e : EuclSpace d) (he : ‖e‖ = 1) {ε : ℝ}
    (hy : y ∈ ball (x + (ε / 2) • e) (ε / 4)) :
    inner ℝ e x + ε / 4 ≤ inner ℝ e y := by
  have hd : ‖y - (x + (ε / 2) • e)‖ < ε / 4 := by
    rw [← dist_eq_norm]; exact mem_ball.1 hy
  have hip : inner ℝ e (y - (x + (ε / 2) • e)) ≥ -(ε / 4) := by
    have h1 := abs_real_inner_le_norm e (y - (x + (ε / 2) • e))
    rw [he, one_mul] at h1
    have h2 := abs_le.1 h1
    linarith [h2.1]
  have hexp : inner ℝ e (y - (x + (ε / 2) • e))
      = inner ℝ e y - inner ℝ e x - (ε / 2) := by
    have hee : inner ℝ e e = (1 : ℝ) := by
      rw [real_inner_self_eq_norm_sq, he, one_pow]
    rw [inner_sub_right, inner_add_right, real_inner_smul_right, hee]
    ring
  linarith [hip, hexp]
/-- **The maximum set is unbounded.** If `v - u` attains its maximum `M` at
some point and the dynamic programming principle holds wherever the maximum is
attained, then the maximum set extends arbitrarily far in any fixed
direction. -/
theorem max_set_unbounded (p ε : ℝ) (hp : 2 ≤ p) (hε : 0 < ε)
    (hpd : 0 < p + (d : ℝ))
    (e : EuclSpace d) (he : ‖e‖ = 1)
    {u v : EuclSpace d → ℝ} (hu : BddMeas u) (hv : BddMeas v)
    {M : ℝ} (hMle : ∀ y, v y - u y ≤ M)
    (hfix : ∀ y, v y - u y = M →
      tugOfWarOp p ε v y - tugOfWarOp p ε u y = v y - u y)
    {x₀ : EuclSpace d} (hx₀ : v x₀ - u x₀ = M) (R : ℝ) :
    ∃ y, v y - u y = M ∧ R < inner ℝ e y := by
  set G := {y : EuclSpace d | v y - u y = M} with hG
  have hprop : ∀ y ∈ G, volume (ball y ε \ G) = 0 := fun y hy =>
    measure_diff_max_set p ε hp hε hpd hu hv hMle hy (hfix y hy)
  obtain ⟨y, hyG, hy⟩ :=
    not_bddAbove_inner G hε e he hprop (show x₀ ∈ G from hx₀) R
  exact ⟨y, hyG, hy⟩
PLaplacian.not_bounded_max_setPlaplacian/Comparison.lean, lines 425–453
/-- **The comparison principle, contradiction form.** Under the hypotheses of
`max_set_unbounded`, the maximum set cannot be contained in a bounded set. This
is the form in which the principle is applied: for two solutions of the
`ε`-Dirichlet problem on a bounded `Ω`, the maximum of `v - u` cannot be
attained in `Ω`, so it is controlled by the boundary data. -/
theorem not_bounded_max_set (p ε : ℝ) (hp : 2 ≤ p) (hε : 0 < ε)
    (hpd : 0 < p + (d : ℝ))
    (e : EuclSpace d) (he : ‖e‖ = 1)
    {u v : EuclSpace d → ℝ} (hu : BddMeas u) (hv : BddMeas v)
    {M : ℝ} (hMle : ∀ y, v y - u y ≤ M)
    (hfix : ∀ y, v y - u y = M →
      tugOfWarOp p ε v y - tugOfWarOp p ε u y = v y - u y)
    {x₀ : EuclSpace d} (hx₀ : v x₀ - u x₀ = M)
    {S : Set (EuclSpace d)} (hS : Bornology.IsBounded S)
    (hsub : {y : EuclSpace d | v y - u y = M} ⊆ S) :
    False := by
  obtain ⟨R, hR⟩ := hS.subset_closedBall 0
  obtain ⟨y, hyG, hy⟩ :=
    max_set_unbounded p ε hp hε hpd e he hu hv hMle hfix hx₀ R
  have hmem : y ∈ closedBall (0 : EuclSpace d) R := hR (hsub hyG)
  have hnorm : ‖y‖ ≤ R := by
    rw [Metric.mem_closedBall, dist_zero_right] at hmem
    exact hmem
  have hip : inner ℝ e y ≤ R := by
    calc inner ℝ e y ≤ |inner ℝ e y| := le_abs_self _
      _ ≤ ‖e‖ * ‖y‖ := abs_real_inner_le_norm e y
      _ = ‖y‖ := by rw [he, one_mul]
      _ ≤ R := hnorm
  linarith
Proof sketch

See the companion for the argument.

Theorem 1.15Discrete comparison✓ formalized
Formal statementgenerated from the Lean declaration
comparison_of_attained

Let $d \in \mathbb{N}$, $p, \varepsilon \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $e \in \mathbb{R}^{d}$, $F, G, u, v \colon \mathbb{R}^{d} \to \mathbb{R}$, $M \in \mathbb{R}$, $x_{0} \in \mathbb{R}^{d}$.

Assume

  • $2 \le p$ hp
  • $0 < \varepsilon$ hε
  • $0 < p + d$ hpd
  • $\Omega\text{ is bounded}$ hΩbdd
  • $\lVert e\rVert = 1$ he
  • $u\text{ is }p\text{-harmonious in }\Omega\text{ with step }\varepsilon\text{ and data }F$ hu
  • $v\text{ is }p\text{-harmonious in }\Omega\text{ with step }\varepsilon\text{ and data }G$ hv
  • $\forall y,\ v(y) - u(y) \le M$ hMle
  • $\forall y,\ v(y) - u(y) = M \to y \in \Omega$ hmaxΩ
  • $v(x_{0}) - u(x_{0}) = M$ hx₀

Then $\mathrm{False}$.

Informal statementfrom the blueprint

Let $u,v$ be $p$-harmonious on a bounded $\Omega$, and $M$ such that $v-u \le M$ everywhere and $v-u=M$ only inside $\Omega$. Then $v-u$ does not attain $M$.

Lean 1
PLaplacian.comparison_of_attainedPlaplacian/ComparisonFinal.lean, lines 38–70
/-- **The comparison principle for solutions of the epsilon-Dirichlet
problem.**

If two `p`-harmonious functions have their difference attaining a positive
maximum, and that maximum is attained only inside the domain, the maximum set
is unbounded --- contradicting boundedness of the domain. Hence no positive
maximum is attained inside.

The hypothesis `hmaxΩ` is what the intended application supplies: on the
boundary strip the data satisfies `v ≤ u`, so a positive maximum of `v - u`
cannot be attained there. Isolating it keeps this theorem free of assumptions
about the behaviour of `u` and `v` outside `Ω_ε`, where the
`ε`-Dirichlet problem says nothing. -/
theorem comparison_of_attained (p ε : ℝ) (hp : 2 ≤ p) (hε : 0 < ε)
    (hpd : 0 < p + (d : ℝ))
    {Ω : Set (EuclSpace d)} (hΩbdd : Bornology.IsBounded Ω)
    (e : EuclSpace d) (he : ‖e‖ = 1)
    {F G : EuclSpace d → ℝ} {u v : EuclSpace d → ℝ}
    (hu : IsPHarmonious p ε Ω F u) (hv : IsPHarmonious p ε Ω G v)
    {M : ℝ} (hMle : ∀ y, v y - u y ≤ M)
    (hmaxΩ : ∀ y, v y - u y = M → y ∈ Ω)
    {x₀ : EuclSpace d} (hx₀ : v x₀ - u x₀ = M) :
    False := by
  -- at a point of the maximum set the dynamic programming principle holds
  have hfix : ∀ y, v y - u y = M →
      tugOfWarOp p ε v y - tugOfWarOp p ε u y = v y - u y := by
    intro y hy
    have hyΩ : y ∈ Ω := hmaxΩ y hy
    have hue : u y = tugOfWarOp p ε u y := hu.interior y hyΩ
    have hve : v y = tugOfWarOp p ε v y := hv.interior y hyΩ
    rw [← hue, ← hve]
  exact not_bounded_max_set p ε hp hε hpd e he hu.bddMeas hv.bddMeas
    hMle hfix hx₀ hΩbdd (fun y hy => hmaxΩ y hy)
Proof sketch

At an attained maximum both functions equal their operator values, so the difference is preserved by $\Op$, which supplies the fixed-point hypothesis of (vi).

2. The viscosity framework

Definition 2.1Viscosity sub- and supersolutions✓ formalized
Formal statementgenerated from the Lean declaration
IsViscositySubsolution

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $f, u \colon \mathbb{R}^{d} \to \mathbb{R}$.

This defines a property of these parameters.

Informal statementfrom the blueprint

An upper semicontinuous $u$ on $\Omega$ is a viscosity subsolution of $-\pnlap u = f$ if for every $\varphi \in C^2$ and every $x_0 \in \Omega$ at which $u - \varphi$ has a local maximum, \[ F(\nabla\varphi(x_0), D^2\varphi(x_0)) \le f(x_0) \quad\text{when } \nabla\varphi(x_0) \ne 0, \] and $F_*(D^2\varphi(x_0)) \le f(x_0)$ when $\nabla\varphi(x_0) = 0$. Supersolutions (IsViscositySupersolution) reverse the inequalities, test from below, and use $F^*$; a solution is both.

Lean 1
PLaplacian.IsViscositySubsolutionPlaplacian/Viscosity.lean, lines 145–156
/-- **Viscosity subsolution of `- Delta^N_p u = f`.** -/
structure IsViscositySubsolution (p : ℝ) (Ω : Set (EuclSpace d))
    (f : EuclSpace d → ℝ) (u : EuclSpace d → ℝ) : Prop where
  usc : UpperSemicontinuousOn u Ω
  regular : ∀ (φ : EuclSpace d → ℝ), ContDiff ℝ 2 φ →
    ∀ x₀ ∈ Ω, IsLocalMax (fun y => u y - φ y) x₀ →
      gradient φ x₀ ≠ 0 →
      viscF p (gradient φ x₀) (hess φ x₀) ≤ f x₀
  singular : ∀ (φ : EuclSpace d → ℝ), ContDiff ℝ 2 φ →
    ∀ x₀ ∈ Ω, IsLocalMax (fun y => u y - φ y) x₀ →
      gradient φ x₀ = 0 →
      viscFLower p (hess φ x₀) ≤ f x₀
Theorem 2.2Second-order condition in one variable✓ formalized
Informal statementfrom the blueprint

At an interior local maximum of a $C^2$ function of one real variable, the second derivative is nonpositive; dually at a minimum.

Used byThm. 2.3
Lean 1
PLaplacian.IsLocalMax.deriv_deriv_nonposPlaplacian/SecondOrder.lean, lines 77–127
/-- **The second-order necessary condition.** -/
theorem IsLocalMax.deriv_deriv_nonpos {g : ℝ → ℝ} (hg : ContDiff ℝ 2 g)
    (hmax : IsLocalMax g 0) : deriv (deriv g) 0 ≤ 0 := by
  by_contra hcon
  push Not at hcon
  obtain ⟨δ, hδ, hposδ⟩ := exists_interval_deriv_pos hg hcon
  -- `g'` is strictly increasing on the interval
  have hg1 : Differentiable ℝ (deriv g) := hg.differentiable_deriv_two
  have hmono : StrictMonoOn (deriv g) (Icc (-δ/2) (δ/2)) := by
    refine strictMonoOn_of_deriv_pos (convex_Icc _ _)
      (hg1.continuous.continuousOn) ?_
    intro t ht
    rw [interior_Icc] at ht
    exact hposδ t ⟨by linarith [ht.1], by linarith [ht.2]⟩
  -- Fermat: `g' 0 = 0`
  have h0 : deriv g 0 = 0 := hmax.deriv_eq_zero
  -- hence `g' > 0` on the right half
  have hpos' : ∀ t ∈ Ioc (0 : ℝ) (δ/2), 0 < deriv g t := by
    intro t ht
    have h1 : (0 : ℝ) ∈ Icc (-δ/2) (δ/2) := ⟨by linarith, by linarith⟩
    have h2 : t ∈ Icc (-δ/2) (δ/2) := ⟨by linarith [ht.1], ht.2⟩
    have := hmono h1 h2 ht.1
    rw [h0] at this
    exact this
  -- so `g` is strictly increasing on the right half
  have hgmono : StrictMonoOn g (Icc (0 : ℝ) (δ/2)) := by
    refine strictMonoOn_of_deriv_pos (convex_Icc _ _)
      (hg.continuous.continuousOn) ?_
    intro t ht
    rw [interior_Icc] at ht
    exact hpos' t ⟨ht.1, le_of_lt ht.2⟩
  -- contradicting the local maximum
  have hmaxev : ∀ᶠ y in 𝓝 (0 : ℝ), g y ≤ g 0 := hmax
  obtain ⟨η, hη, hb⟩ := Metric.eventually_nhds_iff.1 hmaxev
  have hmaxη : ∀ y, |y - 0| < η → g y ≤ g 0 := by
    intro y hy
    exact hb (by rwa [Real.dist_eq])
  obtain ⟨s, hs1, hs2, hs3⟩ :
      ∃ s : ℝ, 0 < s ∧ s ≤ δ/2 ∧ s < η := by
    have hL : (δ/4 : ℝ) ≤ δ/2 := by linarith
    have hR : (η/2 : ℝ) < η := by linarith
    refine ⟨Min.min (δ/4 : ℝ) (η/2 : ℝ), ?_, ?_, ?_⟩
    · exact lt_min (by linarith : (0:ℝ) < δ/4) (by linarith : (0:ℝ) < η/2)
    · exact le_trans (min_le_left (δ/4 : ℝ) (η/2 : ℝ)) hL
    · exact lt_of_le_of_lt (min_le_right (δ/4 : ℝ) (η/2 : ℝ)) hR
  have hsIcc : s ∈ Icc (0 : ℝ) (δ/2) := ⟨le_of_lt hs1, hs2⟩
  have hsabs : |s - 0| < η := by
    rw [sub_zero, abs_of_pos hs1]
    exact hs3
  have hlt : g 0 < g s := hgmono ⟨le_rfl, by linarith⟩ hsIcc hs1
  exact absurd (hmaxη s hsabs) (not_le.2 hlt)
Proof sketch

Mathlib's Analysis.Calculus.LocalExtr.Basic has Fermat's theorem and its tangent-cone refinements, but nothing of second order. Our proof avoids Taylor's theorem: if the second derivative were positive, continuity would keep it positive on an interval, so the first derivative would be strictly increasing there; being zero at the point by Fermat, it would then be positive to the right, making the function strictly increasing and contradicting the maximum. Each step is an application of strictMonoOn_of_deriv_pos.

Theorem 2.3Second-order condition✓ formalized
Formal statementgenerated from the Lean declaration
hess_nonpos_of_isLocalMax

Let $d \in \mathbb{N}$, $h \colon \mathbb{R}^{d} \to \mathbb{R}$, $x \in \mathbb{R}^{d}$, $v \in \mathbb{R}^{d}$.

Assume

  • $\operatorname{ContDiff}(\mathbb{R}, 2, h)$ hh
  • $\operatorname{IsLocalMax}(h, x)$ hmax

Then $((\operatorname{fderiv}(\mathbb{R}, \operatorname{fderiv}(\mathbb{R}, h), x))(v))(v) \le 0$.

Informal statementfrom the blueprint

At a local maximum of a $C^2$ function on $\R^d$ the Hessian is nonpositive as a quadratic form.

Used byThm. 2.4
Lean 1
PLaplacian.hess_nonpos_of_isLocalMaxPlaplacian/LineRestrict.lean, lines 138–152
/-- **The Hessian is nonpositive at a local maximum.** -/
theorem hess_nonpos_of_isLocalMax {h : EuclSpace d → ℝ}
    (hh : ContDiff ℝ 2 h) {x : EuclSpace d} (hmax : IsLocalMax h x)
    (v : EuclSpace d) :
    fderiv ℝ (fderiv ℝ h) x v v ≤ 0 := by
  set g : ℝ → ℝ := fun t => h (lineMap x v t) with hgdef
  have hgC : ContDiff ℝ 2 g := contDiff_restrict hh x v
  have hgmax : IsLocalMax g 0 := IsLocalMax.along_line hmax v
  have hd1 : deriv g = fun t => fderiv ℝ h (lineMap x v t) v :=
    deriv_first hh x v
  have hd2 : deriv (deriv g) 0 = fderiv ℝ (fderiv ℝ h) x v v := by
    rw [hd1]
    exact (hasDerivAt_second hh x v).deriv
  have := IsLocalMax.deriv_deriv_nonpos hgC hgmax
  rwa [hd2] at this
Proof sketch

The proof restricts to a line through the point. Three steps: the restriction attains a local maximum at the origin (IsLocalMax.along_line); its first derivative is the Fréchet derivative applied to the direction (hasDerivAt_first); and its second derivative is the Hessian at the direction twice (hasDerivAt_second). The third is the iteratedDeriv-against-iteratedFDeriv glue identified in our initial gap audit as the likely friction point of the whole development. It is resolved by ContDiff.fderiv_right, which gives that the derivative map of a $C^2$ function is itself $C^1$, followed by two chain rules and the observation that evaluation at a fixed vector is continuous linear.

Theorem 2.4Consistency with classical solutions✓ formalized
Formal statementgenerated from the Lean declaration
viscF_le_of_classical

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $u, \varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $x_{0} \in \mathbb{R}^{d}$, $f \colon \mathbb{R}^{d} \to \mathbb{R}$.

Assume

  • $2 \le p$ hp
  • $\operatorname{ContDiff}(\mathbb{R}, 2, u)$ hu
  • $\operatorname{ContDiff}(\mathbb{R}, 2, \varphi)$ hφ
  • $\operatorname{IsLocalMax}(y \mapsto u(y) - \varphi(y), x_{0})$ hmax
  • $\operatorname{viscF}(p, \operatorname{gradient}(u, x_{0}), \operatorname{hess}(u, x_{0})) \le f(x_{0})$ hclass

Then $\operatorname{viscF}(p, \operatorname{gradient}(\varphi, x_{0}), \operatorname{hess}(\varphi, x_{0})) \le f(x_{0})$.

Informal statementfrom the blueprint

Let $u, \varphi$ be $C^2$, let $u - \varphi$ have a local maximum at $x_0$ with $\nabla\varphi(x_0) \ne 0$, and suppose $u$ satisfies the operator inequality at $x_0$. Then so does $\varphi$.

Lean 1
PLaplacian.viscF_le_of_classicalPlaplacian/Consistency.lean, lines 97–117
/-- **Consistency at a regular contact point.** If `u` is `C²` and satisfies
the operator inequality at `x₀`, and `u - φ` has a local maximum there with the
gradient of `φ` nonzero, then `φ` satisfies the inequality too. -/
theorem viscF_le_of_classical {p : ℝ} (hp : 2 ≤ p)
    {u φ : EuclSpace d → ℝ} (hu : ContDiff ℝ 2 u) (hφ : ContDiff ℝ 2 φ)
    {x₀ : EuclSpace d} (hmax : IsLocalMax (fun y => u y - φ y) x₀)
    {f : EuclSpace d → ℝ}
    (hclass : viscF p (gradient u x₀) (hess u x₀) ≤ f x₀) :
    viscF p (gradient φ x₀) (hess φ x₀) ≤ f x₀ := by
  have hgrad : gradient u x₀ = gradient φ x₀ :=
    gradient_eq_of_isLocalMax (hu.differentiable (by norm_num))
      (hφ.differentiable (by norm_num)) hmax
  have hhess : ∀ v : EuclSpace d, hess u x₀ v v ≤ hess φ x₀ v v :=
    hess_le_of_isLocalMax hu hφ hmax
  have hanti : viscF p (gradient φ x₀) (hess φ x₀)
      ≤ viscF p (gradient φ x₀) (hess u x₀) :=
    viscF_antitone p hp (gradient φ x₀) (hess u x₀) (hess φ x₀) hhess
  rw [← hgrad] at hanti
  calc viscF p (gradient φ x₀) (hess φ x₀)
      ≤ viscF p (gradient u x₀) (hess u x₀) := by rw [hgrad] at hanti ⊢; exact hanti
    _ ≤ f x₀ := hclass
Proof sketch

Three inputs: the derivatives agree at the contact point, by Fermat (fderiv_eq_of_isLocalMax, and its gradient form via ext_inner_right); the Hessians are ordered, by Theorem Theorem 2.3 applied to $u - \varphi$ (hess_le_of_isLocalMax); and degenerate ellipticity transfers the inequality.

Theorem 2.5Stability: monotonicity✓ formalized
Formal statementgenerated from the Lean declaration
IsViscositySubsolution.mono

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\Omega, \Omega' \subseteq \mathbb{R}^{d}$, $f, u \colon \mathbb{R}^{d} \to \mathbb{R}$.

Assume

  • $u\text{ is a viscosity subsolution of }-\Delta_{p}^{\mathrm N} u = f\text{ in }\Omega$ h
  • $\Omega' \subseteq \Omega$ hsub

Then $u\text{ is a viscosity subsolution of }-\Delta_{p}^{\mathrm N} u = f\text{ in }\Omega'$.

Informal statementfrom the blueprint

A subsolution on $\Omega$ restricts to a subsolution on any subset, and dually.

Lean 1
PLaplacian.IsViscositySubsolution.monoPlaplacian/Stability.lean, lines 49–57
theorem IsViscositySubsolution.mono {p : ℝ} {Ω Ω' : Set (EuclSpace d)}
    {f u : EuclSpace d → ℝ} (h : IsViscositySubsolution p Ω f u)
    (hsub : Ω' ⊆ Ω) :
    IsViscositySubsolution p Ω' f u where
  usc := h.usc.mono hsub
  regular := fun φ hφ x₀ hx₀ hmax hgrad =>
    h.regular φ hφ x₀ (hsub hx₀) hmax hgrad
  singular := fun φ hφ x₀ hx₀ hmax hgrad =>
    h.singular φ hφ x₀ (hsub hx₀) hmax hgrad
Proof sketch

See the companion for the argument.

Theorem 2.6Stability: constants✓ formalized
Formal statementgenerated from the Lean declaration
IsViscositySubsolution.add_constparts shown as Lean code

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $f, u \colon \mathbb{R}^{d} \to \mathbb{R}$, $c \in \mathbb{R}$.

Assume

  • $u\text{ is a viscosity subsolution of }-\Delta_{p}^{\mathrm N} u = f\text{ in }\Omega$ h

Then PLaplacian.IsViscositySubsolution p Ω f fun y => u y + c.

Informal statementfrom the blueprint

If $u$ is a subsolution then so is $u + c$ for any constant $c$.

Lean 1
PLaplacian.IsViscositySubsolution.add_constPlaplacian/Stability.lean, lines 114–155
/-- **Adding a constant preserves subsolutions.** The operator sees only the
gradient and the Hessian, both unchanged. -/
theorem IsViscositySubsolution.add_const {p : ℝ} {Ω : Set (EuclSpace d)}
    {f u : EuclSpace d → ℝ} (h : IsViscositySubsolution p Ω f u) (c : ℝ) :
    IsViscositySubsolution p Ω f (fun y => u y + c) where
  usc := upperSemicontinuousOn_add_const h.usc c
  regular := fun φ hφ x₀ hx₀ hmax hgrad => by
    have hmax' : IsLocalMax (fun y => u y - (fun z => φ z - c) y) x₀ := by
      have heq : (fun y => u y - (fun z => φ z - c) y)
          = fun y => (u y + c) - φ y := by funext y; ring
      rw [heq]
      exact hmax
    have hφ' : ContDiff ℝ 2 (fun z => φ z - c) := hφ.sub contDiff_const
    have hgrad' : gradient (fun z => φ z - c) x₀ ≠ 0 := by
      have : gradient (fun z => φ z - c) x₀ = gradient φ x₀ := by
        have heq : (fun z => φ z - c) = fun z => φ z + (-c) := by
          funext z; ring
        rw [heq, gradient_add_const]
      rwa [this]
    have hg : gradient (fun z => φ z - c) x₀ = gradient φ x₀ := by
      have heq : (fun z => φ z - c) = fun z => φ z + (-c) := by funext z; ring
      rw [heq, gradient_add_const]
    have hh : hess (fun z => φ z - c) x₀ = hess φ x₀ := by
      have heq : (fun z => φ z - c) = fun z => φ z + (-c) := by funext z; ring
      rw [heq, hess_add_const]
    have hres := h.regular (fun z => φ z - c) hφ' x₀ hx₀ hmax' hgrad'
    rwa [hg, hh] at hres
  singular := fun φ hφ x₀ hx₀ hmax hgrad => by
    have hmax' : IsLocalMax (fun y => u y - (fun z => φ z - c) y) x₀ := by
      have heq : (fun y => u y - (fun z => φ z - c) y)
          = fun y => (u y + c) - φ y := by funext y; ring
      rw [heq]; exact hmax
    have hφ' : ContDiff ℝ 2 (fun z => φ z - c) := hφ.sub contDiff_const
    have hg : gradient (fun z => φ z - c) x₀ = gradient φ x₀ := by
      have heq : (fun z => φ z - c) = fun z => φ z + (-c) := by funext z; ring
      rw [heq, gradient_add_const]
    have hh : hess (fun z => φ z - c) x₀ = hess φ x₀ := by
      have heq : (fun z => φ z - c) = fun z => φ z + (-c) := by funext z; ring
      rw [heq, hess_add_const]
    have hgrad' : gradient (fun z => φ z - c) x₀ = 0 := by rwa [hg]
    have hres := h.singular (fun z => φ z - c) hφ' x₀ hx₀ hmax' hgrad'
    rwa [hh] at hres
Proof sketch

The operator sees only the gradient and the Hessian, both unaffected. The proof observes that testing $u+c$ against $\varphi$ is testing $u$ against $\varphi - c$, and needs gradient_add_const and hess_add_const, neither of which Mathlib has in gradient or Hessian form.

Theorem 2.7Stability: smooth perturbations✓ formalized
Formal statementgenerated from the Lean declaration
IsViscositySubsolution.add_smooth

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $f, u \colon \mathbb{R}^{d} \to \mathbb{R}$, $\psi \colon \mathbb{R}^{d} \to \mathbb{R}$, $\varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $x_{0} \in \mathbb{R}^{d}$.

Assume

  • $u\text{ is a viscosity subsolution of }-\Delta_{p}^{\mathrm N} u = f\text{ in }\Omega$ h
  • $\operatorname{ContDiff}(\mathbb{R}, 2, \psi)$ hψ
  • $\operatorname{ContDiff}(\mathbb{R}, 2, \varphi)$ hφ
  • $x_{0} \in \Omega$ hx₀
  • $\operatorname{IsLocalMax}(y \mapsto u(y) + \psi(y) - \varphi(y), x_{0})$ hmax
  • $\operatorname{gradient}(\varphi, x_{0}) - \operatorname{gradient}(\psi, x_{0}) \ne 0$ hgrad

Then $\operatorname{viscF}(p, \operatorname{gradient}(\varphi, x_{0}) - \operatorname{gradient}(\psi, x_{0}), \operatorname{hess}(\varphi, x_{0}) - \operatorname{hess}(\psi, x_{0})) \le f(x_{0})$.

Informal statementfrom the blueprint

If $u$ is a subsolution and $\psi$ is $C^2$, then at a contact point of $u + \psi$ with a test function $\varphi$, \[ F\bigl(\nabla\varphi(x_0) - \nabla\psi(x_0),\, D^2\varphi(x_0) - D^2\psi(x_0)\bigr) \le f(x_0). \]

Lean 1
PLaplacian.IsViscositySubsolution.add_smoothPlaplacian/AddSmooth.lean, lines 83–103
/-- **Stability under adding a smooth function.** -/
theorem IsViscositySubsolution.add_smooth {p : ℝ} {Ω : Set (EuclSpace d)}
    {f u : EuclSpace d → ℝ} (h : IsViscositySubsolution p Ω f u)
    {ψ : EuclSpace d → ℝ} (hψ : ContDiff ℝ 2 ψ)
    (φ : EuclSpace d → ℝ) (hφ : ContDiff ℝ 2 φ)
    {x₀ : EuclSpace d} (hx₀ : x₀ ∈ Ω)
    (hmax : IsLocalMax (fun y => (u y + ψ y) - φ y) x₀)
    (hgrad : gradient φ x₀ - gradient ψ x₀ ≠ 0) :
    viscF p (gradient φ x₀ - gradient ψ x₀)
      (hess φ x₀ - hess ψ x₀) ≤ f x₀ := by
  have hdiff : ContDiff ℝ 2 (fun z => φ z - ψ z) := hφ.sub hψ
  have hg : gradient (fun z => φ z - ψ z) x₀
      = gradient φ x₀ - gradient ψ x₀ :=
    gradient_sub (hφ.differentiable (by norm_num))
      (hψ.differentiable (by norm_num)) x₀
  have hh : hess (fun z => φ z - ψ z) x₀ = hess φ x₀ - hess ψ x₀ :=
    hess_sub hφ hψ x₀
  have hgrad' : gradient (fun z => φ z - ψ z) x₀ ≠ 0 := by rwa [hg]
  have hres := h.regular (fun z => φ z - ψ z) hdiff x₀ hx₀
    (isLocalMax_shift hmax) hgrad'
  rwa [hg, hh] at hres
Proof sketch

This cannot be converted into an inequality for $\varphi$ alone, because $F$ is not additive in either argument — the third appearance of that non-additivity. The version stated is the honest one, and also the usable one, since a convergence proof applies the subsolution property to a perturbed test function and needs exactly this.

Theorem 2.8Stability: maxima✓ formalized
Formal statementgenerated from the Lean declaration
IsViscositySubsolution.maxparts shown as Lean code

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $f, u, v \colon \mathbb{R}^{d} \to \mathbb{R}$.

Assume

  • $u\text{ is a viscosity subsolution of }-\Delta_{p}^{\mathrm N} u = f\text{ in }\Omega$ hu
  • $v\text{ is a viscosity subsolution of }-\Delta_{p}^{\mathrm N} u = f\text{ in }\Omega$ hv

Then PLaplacian.IsViscositySubsolution p Ω f fun y => max (u y) (v y).

IsViscositySubsolution.finsetSup'parts shown as Lean code

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $f \colon \mathbb{R}^{d} \to \mathbb{R}$, $\iota$ be a type, $s \in \operatorname{Finset}(\iota)$, $u \colon \iota \to \mathbb{R}^{d} \to \mathbb{R}$.

Assume

  • $s\text{ is nonempty}$ hs
  • $\forall i \in s,\ u(i)\text{ is a viscosity subsolution of }-\Delta_{p}^{\mathrm N} u = f\text{ in }\Omega$ hu

Then PLaplacian.IsViscositySubsolution p Ω f fun y => s.sup' hs fun i => u i y.

Informal statementfrom the blueprint

The maximum of two subsolutions is a subsolution, and hence so is the maximum over any nonempty finite family. Dually for minima of supersolutions.

Lean 2
PLaplacian.IsViscositySubsolution.maxPlaplacian/MaxSub.lean, lines 75–93
/-- **The maximum of two subsolutions is a subsolution.** -/
theorem IsViscositySubsolution.max {p : ℝ} {Ω : Set (EuclSpace d)}
    {f u v : EuclSpace d → ℝ}
    (hu : IsViscositySubsolution p Ω f u)
    (hv : IsViscositySubsolution p Ω f v) :
    IsViscositySubsolution p Ω f (fun y => max (u y) (v y)) where
  usc := UpperSemicontinuousOn.sup hu.usc hv.usc
  regular := fun φ hφ x₀ hx₀ hmax hgrad => by
    rcases max_cases (u x₀) (v x₀) with ⟨heq, -⟩ | ⟨heq, -⟩
    · exact hu.regular φ hφ x₀ hx₀
        (isLocalMax_of_attains_left hmax heq.symm) hgrad
    · exact hv.regular φ hφ x₀ hx₀
        (isLocalMax_of_attains_right hmax heq.symm) hgrad
  singular := fun φ hφ x₀ hx₀ hmax hgrad => by
    rcases max_cases (u x₀) (v x₀) with ⟨heq, -⟩ | ⟨heq, -⟩
    · exact hu.singular φ hφ x₀ hx₀
        (isLocalMax_of_attains_left hmax heq.symm) hgrad
    · exact hv.singular φ hφ x₀ hx₀
        (isLocalMax_of_attains_right hmax heq.symm) hgrad
PLaplacian.IsViscositySubsolution.finsetSup'Plaplacian/FinSup.lean, lines 57–79
/-- The maximum over a nonempty finite family of subsolutions. -/
theorem IsViscositySubsolution.finsetSup' {p : ℝ} {Ω : Set (EuclSpace d)}
    {f : EuclSpace d → ℝ} {ι : Type*} (s : Finset ι) (hs : s.Nonempty)
    (u : ι → EuclSpace d → ℝ)
    (hu : ∀ i ∈ s, IsViscositySubsolution p Ω f (u i)) :
    IsViscositySubsolution p Ω f (fun y => s.sup' hs (fun i => u i y)) := by
  induction hs using Finset.Nonempty.cons_induction with
  | singleton i =>
      have h := hu i (by simp)
      have heq : (fun y => ({i} : Finset ι).sup'
          (Finset.singleton_nonempty i) (fun j => u j y)) = u i := by
        funext y
        simp
      rw [heq]
      exact h
  | cons i t hit ht ih =>
      have hui : IsViscositySubsolution p Ω f (u i) := hu i (by simp)
      have hut : ∀ j ∈ t, IsViscositySubsolution p Ω f (u j) := by
        intro j hj
        exact hu j (by simp [hj])
      have hih := ih hut
      simp only [Finset.sup'_cons ht]
      exact IsViscositySubsolution.max hui hih
Proof sketch

The argument is a case split on which function attains the maximum at the contact point: if $u(x_0)$ attains it, then $u - \varphi$ has a local maximum at $x_0$ too, since $u(y) - \varphi(y) \le \max(u,v)(y) - \varphi(y) \le \max(u,v)(x_0) - \varphi(x_0) = u(x_0) - \varphi(x_0)$. The finite case follows by induction. The infinite case is a different theorem; see the companion.

Theorem 2.9Monotonicity of the set average✓ formalized
Formal statementgenerated from the Lean declaration
setAverage_monoparts shown as Lean code

Let $\alpha$ be a type, $\mu \in \operatorname{Measure}(\alpha)$, $s \subseteq \alpha$, $f, g \colon \alpha \to \mathbb{R}$.

Assume

  • $\operatorname{MeasurableSpace}(\alpha)$
  • $s\text{ is measurable}$ hs
  • $\operatorname{IntegrableOn}(f, s, \mu)$ hf
  • $\operatorname{IntegrableOn}(g, s, \mu)$ hg
  • $\forall x \in s,\ f(x) \le g(x)$ h

Then ⨍ (x : α) in s, f x ∂μ ≤ ⨍ (x : α) in s, g x ∂μ.

Informal statementfrom the blueprint

For $\mu$ a measure, $s$ measurable, and $f \le g$ integrable on $s$: $\avgint_s f \le \avgint_s g$.

Used byThm. 3.4
Lean 1
PLaplacian.setAverage_monoPlaplacian/Average.lean, lines 65–78
/-- **Monotonicity of the set average.** No hypothesis on `μ s` is needed:
`setAverage_eq` is unconditional, and `(μ.real s)⁻¹` is nonnegative even when
`μ s = 0` or `μ s = ∞`, where the junk-value convention makes it `0`. -/
theorem setAverage_mono {α : Type*} [MeasurableSpace α] {μ : Measure α}
    {s : Set α} (hs : MeasurableSet s) {f g : α → ℝ}
    (hf : IntegrableOn f s μ) (hg : IntegrableOn g s μ)
    (h : ∀ x ∈ s, f x ≤ g x) :
    (⨍ x in s, f x ∂μ) ≤ ⨍ x in s, g x ∂μ := by
  have hint : (∫ x in s, f x ∂μ) ≤ ∫ x in s, g x ∂μ :=
    setIntegral_mono_on hf hg hs h
  have hnn : (0 : ℝ) ≤ (μ.real s)⁻¹ := by positivity
  rw [setAverage_eq, setAverage_eq]
  simp only [smul_eq_mul]
  exact mul_le_mul_of_nonneg_left hint hnn
Proof sketch

No hypothesis on $\mu(s)$ is needed: the unfolding $\avgint_s f = \mu(s)^{-1}\!\int_s f$ is unconditional, and $\mu(s)^{-1}$ is nonnegative even when $\mu(s) \in \{0,\infty\}$, where the junk-value convention makes it $0$. The lemma is absent from Mathlib at the revision this development pins, and is a natural candidate for a pull request.

Theorem 2.10Moments of the ball✓ formalized
Formal statementgenerated from the Lean declaration
integral_coord_ball_eq_zero

Let $d \in \mathbb{N}$, $i \in \operatorname{Fin}(d)$, $r \in \mathbb{R}$.

Then $\int_{B(0, r)} (\operatorname{z.ofLp}(i) = 0) \, dz$.

integral_mul_coord_ball_eq_zero

Let $d \in \mathbb{N}$, $i, j \in \operatorname{Fin}(d)$, $r \in \mathbb{R}$.

Assume

  • $i \ne j$ hij

Then $\int_{B(0, r)} (\operatorname{z.ofLp}(i) \cdot \operatorname{z.ofLp}(j) = 0) \, dz$.

Informal statementfrom the blueprint

For $r>0$, $d \ge 1$ and $i \ne j$: $\int_{B_r(0)} z_i = 0$, $\int_{B_r(0)} z_i z_j = 0$, and $\avgint_{B_1(0)} z_i^2 = 1/(d+2)$.

Used byThm. 3.3
Lean 3
PLaplacian.integral_coord_ball_eq_zeroPlaplacian/BallMoments.lean, lines 87–92
/-- **The odd moments of a centred ball vanish.** -/
theorem integral_coord_ball_eq_zero (i : Fin d) (r : ℝ) :
    (∫ z in ball (0 : EuclSpaceM d) r, z i) = 0 := by
  have h1 := integral_neg_coord_ball i r
  have h2 := integral_neg_coord_ball' i r
  linarith [h1, h2]
PLaplacian.integral_mul_coord_ball_eq_zeroPlaplacian/BallMoments.lean, lines 202–211
/-- **The off-diagonal second moments of a centred ball vanish.**

Flipping the sign of the `i`-th coordinate preserves both Lebesgue measure and
the ball, but negates `z i * z j` when `j ≠ i`. Hence the integral equals its
own negative, so it is zero. -/
theorem integral_mul_coord_ball_eq_zero (i j : Fin d) (hij : i ≠ j) (r : ℝ) :
    (∫ z in ball (0 : EuclSpaceM d) r, z.ofLp i * z.ofLp j) = 0 := by
  have h1 := integral_flip_mul_coord i j r
  have h2 := integral_flip_mul_coord_neg i j hij r
  linarith [h1, h2]
PLaplacian.setAverage_sq_coord_unitBallPlaplacian/BallMoments.lean, lines 388–396
/-- **The diagonal second moment of the unit ball: the `1/(d+2)` of the
asymptotic expansion.** -/
theorem setAverage_sq_coord_unitBall [Nontrivial (EuclSpaceM d)] (hd : 0 < d)
    (i : Fin d) :
    (⨍ z in Metric.ball (0 : EuclSpaceM d) 1, (z.ofLp i) ^ 2)
      = 1 / (d + 2 : ℝ) := by
  rw [MeasureTheory.setAverage_eq, integral_sq_coord_unitBall hd i, smul_eq_mul]
  have hpos := volumeReal_unitBall_pos (d := d)
  field_simp
Proof sketch

Three mechanisms. Odd moments follow from $z \mapsto -z$. Off-diagonal moments need a reflection in a single coordinate, since negating all of them leaves $z_i z_j$ fixed; Mathlib has no such map, so we build it as a linear isometry equivalence (flipCoordEquiv). Diagonal moments admit no reflection argument: one sums over coordinates, uses $\sum_i z_i^2 = \abs{z}^2$, and divides by $d$ using invariance under coordinate permutations, which is free from LinearIsometryEquiv.piLpCongrLeft. The radial reduction is integral_fun_norm_addHaar, whose presence in Mathlib was the most consequential finding of our initial audit: it is the difference between a routine development and a research problem.

3. The asymptotic expansion

Theorem 3.1Second-order Taylor bound✓ formalized
Formal statementgenerated from the Lean declaration
taylor_two_bounded

Let $d \in \mathbb{N}$, $\varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $x, z \in \mathbb{R}^{d}$.

Assume

  • $\operatorname{ContDiff}(\mathbb{R}, 3, \varphi)$ hφ

Then there exists $C$ such that:

  • $\lvert \varphi(x + z) - \varphi(x) - (\operatorname{fderiv}(\mathbb{R}, \varphi, x))(z) - 1 / 2 \cdot ((\operatorname{fderiv}(\mathbb{R}, \operatorname{fderiv}(\mathbb{R}, \varphi), x))(z))(z)\rvert \le C / 6$
Informal statementfrom the blueprint

For $\varphi \in C^3$ and any $x, z$ there is a constant $C$, depending on $z$, with \[ \Bigl\lvert \varphi(x+z) - \varphi(x) - D\varphi(x)z - \tfrac12 D^2\varphi(x)(z,z) \Bigr\rvert \le \frac{C}{6} . \]

Lean 1
PLaplacian.taylor_two_boundedPlaplacian/TaylorBound.lean, lines 64–100
/-- **The several-variable expansion with an explicit cubic remainder.**

For each direction `z` there is a constant `C`, depending on `z`, such that
the second-order Taylor error is bounded by `C / 6`. The constant is the
supremum of the third derivative along the segment, which exists by
compactness --- its value is never needed. -/
theorem taylor_two_bounded {φ : EuclSpace d → ℝ} (hφ : ContDiff ℝ 3 φ)
    (x z : EuclSpace d) :
    ∃ C : ℝ, |φ (x + z) - φ x - fderiv ℝ φ x z
        - (1/2) * fderiv ℝ (fderiv ℝ φ) x z z| ≤ C / 6 := by
  obtain ⟨C, hC⟩ := exists_bound_deriv_three hφ x z
  obtain ⟨ξ, hξ, hres⟩ := taylor_two_deriv
    (fun t : ℝ => φ (lineMap x z t)) (contDiff_restrict_three hφ x z)
  refine ⟨C, ?_⟩
  -- identify the three polynomial terms
  rw [deriv_restrict (hφ.of_le (by norm_num)) x z] at hres
  rw [(hasDerivAt_second_at (hφ.of_le (by norm_num)) x z 0).deriv] at hres
  simp only [lineMap, one_smul, zero_smul, add_zero] at hres
  -- align the bound with the remainder term
  have halign : (fun s : ℝ => φ (lineMap x z s))
      = fun s : ℝ => φ (x + s • z) := by
    funext s; simp [lineMap]
  rw [halign] at hC
  have hinner : (fun t : ℝ => (fderiv ℝ φ (x + t • z)) z)
      = deriv (fun s : ℝ => φ (x + s • z)) := by
    rw [← halign, deriv_restrict (hφ.of_le (by norm_num)) x z]
    funext t; simp [lineMap]
  rw [hinner] at hres
  -- the remainder is bounded
  have hξIcc : ξ ∈ Icc (0:ℝ) 1 := ⟨le_of_lt hξ.1, le_of_lt hξ.2⟩
  have hbd := hC ξ hξIcc
  set R := deriv (deriv (deriv fun s : ℝ => φ (x + s • z))) ξ with hR
  have hE : φ (x + z) - φ x - fderiv ℝ φ x z
      - (1/2) * fderiv ℝ (fderiv ℝ φ) x z z = (1/6) * R := by
    linarith [hres]
  rw [hE, abs_mul, abs_of_nonneg (by norm_num : (0:ℝ) ≤ 1/6)]
  linarith [hbd]
Proof sketch

See the companion for the argument.

Theorem 3.2The C2 error✓ formalized
Formal statementgenerated from the Lean declaration
err2_le

Let $d \in \mathbb{N}$, $\varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $x \in \mathbb{R}^{d}$, $\eta, \delta \in \mathbb{R}$, $w \in \mathbb{R}^{d}$.

Assume

  • $\operatorname{ContDiff}(\mathbb{R}, 2, \varphi)$ hφ
  • $0 < \eta$ hη
  • $\forall v,\ \lVert v\rVert < \delta \to \lVert \operatorname{fderiv}(\mathbb{R}, \varphi, x + v) - \operatorname{fderiv}(\mathbb{R}, \varphi, x) - (\operatorname{fderiv}(\mathbb{R}, \operatorname{fderiv}(\mathbb{R}, \varphi), x))(v)\rVert \le \eta \cdot \lVert v\rVert$ hbd
  • $\lVert w\rVert < \delta$ hw

Then $\lvert \operatorname{err2}(\varphi, x, w)\rvert \le \eta \cdot \lVert w\rVert ^{2}$.

exists_taylorErr_le

Let $d \in \mathbb{N}$, $\varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $x \in \mathbb{R}^{d}$, $\eta \in \mathbb{R}$.

Assume

  • $\operatorname{ContDiff}(\mathbb{R}, 2, \varphi)$ hφ
  • $0 < \eta$ hη

Then there exists $\delta > 0$ such that:

  • $\forall w,\ \lVert w\rVert < \delta \to \lvert \operatorname{taylorErr}(\varphi, x, w)\rvert \le \eta \cdot \lVert w\rVert ^{2}$
Informal statementfrom the blueprint

For $\varphi \in C^2$, $x$ and $\eta > 0$ there is $\delta > 0$ with \[ \Bigl\lvert \varphi(x+w) - \varphi(x) - D\varphi(x)w - \tfrac12 D^2\varphi(x)(w,w) \Bigr\rvert \le \eta \norm{w}^2 \qquad\text{for } \norm{w} < \delta . \]

Used byThm. 3.9
Lean 2
/-- **The second-order Taylor error bound for a `C²` function.**

Given the derivative bound, the error at `w` is at most the same bound. -/
theorem err2_le {φ : EuclSpace d → ℝ} (hφ : ContDiff ℝ 2 φ)
    (x : EuclSpace d) {η δ : ℝ} (hη : 0 < η)
    (hbd : ∀ v : EuclSpace d, ‖v‖ < δ →
      ‖fderiv ℝ φ (x + v) - fderiv ℝ φ x
          - fderiv ℝ (fderiv ℝ φ) x v‖ ≤ η * ‖v‖)
    {w : EuclSpace d} (hw : ‖w‖ < δ) :
    |err2 φ x w| ≤ η * ‖w‖ ^ 2 := by
  -- the scalar function along the ray
  set g : ℝ → ℝ := fun s => err2 φ x (s • w) with hg
  -- its derivative
  have hderiv : ∀ t ∈ Icc (0:ℝ) 1,
      HasDerivWithinAt g
        (fderiv ℝ φ (x + t • w) w - fderiv ℝ φ x w
          - t * fderiv ℝ (fderiv ℝ φ) x w w) (Icc (0:ℝ) 1) t := by
    intro t _
    exact (hasDerivAt_err2 hφ x w t).hasDerivWithinAt
  -- and its bound
  have hdbd : ∀ t ∈ Icc (0:ℝ) 1,
      ‖fderiv ℝ φ (x + t • w) w - fderiv ℝ φ x w
          - t * fderiv ℝ (fderiv ℝ φ) x w w‖ ≤ η * ‖w‖ ^ 2 := by
    intro t ht
    exact err2_deriv_bound hφ x hη hbd hw ht
  -- the mean value inequality
  have hmv : ‖g 1 - g 0‖ ≤ η * ‖w‖ ^ 2 * ‖(1:ℝ) - 0‖ :=
    Convex.norm_image_sub_le_of_norm_hasDerivWithin_le hderiv hdbd
      (convex_Icc 0 1) (by norm_num) (by norm_num)
  -- g 0 = 0 and g 1 = err2 φ x w
  have hg0 : g 0 = 0 := by
    rw [hg]; simp only [zero_smul]; exact err2_zero' φ x
  have hg1 : g 1 = err2 φ x w := by
    rw [hg]; simp only [one_smul]
  rw [hg0, hg1, sub_zero] at hmv
  simpa using hmv
PLaplacian.exists_taylorErr_lePlaplacian/C2Expand.lean, lines 66–74
/-- **The `C²` estimate for the expansion's error.** -/
theorem exists_taylorErr_le {φ : EuclSpace d → ℝ} (hφ : ContDiff ℝ 2 φ)
    (x : EuclSpace d) {η : ℝ} (hη : 0 < η) :
    ∃ δ > 0, ∀ w : EuclSpace d, ‖w‖ < δ →
      |taylorErr φ x w| ≤ η * ‖w‖ ^ 2 := by
  obtain ⟨δ, hδ, hbd⟩ := exists_err2_le hφ x hη
  refine ⟨δ, hδ, fun w hw => ?_⟩
  rw [taylorErr_eq_err2]
  exact hbd w hw
Proof sketch

No third derivative appears. The route is:

Theorem 3.3Average of a quadratic✓ formalized
Formal statementgenerated from the Lean declaration
setAverage_quadraticparts shown as Lean code

Let $d \in \mathbb{N}$, X : EuclSpace d →L[ℝ] EuclSpace d →L[ℝ] ℝ, $\varepsilon \in \mathbb{R}$.

Assume

  • $\mathbb{R}^{d}\text{ is nontrivial}$
  • $0 < d$ hd
  • $0 < \varepsilon$ hε

Then $\fint_{B(0, \varepsilon)} ((X(z))(z) = \varepsilon ^{2} / (d + 2) \cdot \operatorname{laplacianOf}(X)) \, dz$.

Informal statementfrom the blueprint

For a continuous bilinear form $X$ and $\eps > 0$, \[ \avgint_{B_\eps(0)} X(z,z)\,dz = \frac{\eps^2}{d+2}\,\Lambda(X) . \]

Used byThm. 3.4
Lean 1
PLaplacian.setAverage_quadraticPlaplacian/QuadAverage.lean, lines 160–194
/-- **The average of a quadratic form over a centred ball.**

The theorem the moment computations of `Plaplacian.BallMoments` were built
for: the average of `X z z` over a ball of radius `ε` is `ε² / (d+2)` times
the trace. -/
theorem setAverage_quadratic [Nontrivial (EuclSpace d)] (hd : 0 < d)
    (X : EuclSpace d →L[ℝ] EuclSpace d →L[ℝ] ℝ) {ε : ℝ} (hε : 0 < ε) :
    (⨍ z in ball (0 : EuclSpace d) ε, X z z)
      = ε ^ 2 / ((d : ℝ) + 2) * laplacianOf X := by
  have hexp : (⨍ z in ball (0 : EuclSpace d) ε, X z z)
      = ⨍ z in ball (0 : EuclSpace d) ε,
          ∑ i : Fin d, ∑ j : Fin d, (z.ofLp i) * (z.ofLp j)
            * X (EuclideanSpace.single i (1:ℝ))
                (EuclideanSpace.single j (1:ℝ)) := by
    congr 1
    funext z
    exact quadratic_expand X z
  rw [hexp]
  rw [setAverage_finsetSum Finset.univ _ _
      (fun i _ => integrableOn_inner_sum X i ε)]
  have hstep : ∀ i : Fin d,
      (⨍ z in ball (0 : EuclSpace d) ε, ∑ j : Fin d, (z.ofLp i) * (z.ofLp j)
          * X (EuclideanSpace.single i (1:ℝ))
              (EuclideanSpace.single j (1:ℝ)))
        = ε ^ 2 / ((d : ℝ) + 2)
          * X (EuclideanSpace.single i (1:ℝ))
              (EuclideanSpace.single i (1:ℝ)) := by
    intro i
    rw [setAverage_finsetSum Finset.univ _ _
        (fun j _ => integrableOn_term X i j ε)]
    rw [Finset.sum_congr rfl (fun j _ => setAverage_term hd X i j hε)]
    exact inner_sum_collapse X i
  rw [Finset.sum_congr rfl (fun i _ => hstep i)]
  unfold laplacianOf
  rw [Finset.mul_sum]
Proof sketch

This is the theorem the moment computations of Theorem Theorem 2.10 were built for. Expanding $X(z,z)$ in coordinates, the off-diagonal terms vanish by the mixed moments and the diagonal terms each contribute $\eps^2/(d+2)$, so the surviving sum is the trace. The moments were stated for the unit ball and had to be redone at radius $\eps$; the companion records why the obvious route failed.

Theorem 3.4Expansion of the average✓ formalized
Formal statementgenerated from the Lean declaration
setAverage_expansion

Let $d \in \mathbb{N}$, $\varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $x \in \mathbb{R}^{d}$, $\varepsilon \in \mathbb{R}$.

Assume

  • $\mathbb{R}^{d}\text{ is nontrivial}$
  • $0 < d$ hd
  • $\operatorname{ContDiff}(\mathbb{R}, 2, \varphi)$ hφ
  • $0 < \varepsilon$ hε

Then $\fint_{B(x, \varepsilon)} (\varphi(y) = \varphi(x) + \varepsilon ^{2} / (2 \cdot (d + 2)) \cdot \operatorname{laplacianOf}(\operatorname{hess}(\varphi, x)) + \fint_{B(0, \varepsilon)} \operatorname{taylorErr}(\varphi, x, z) \, dz) \, dy$.

Informal statementfrom the blueprint

For $\varphi \in C^3$, $0 < \eps$ and $0 < d$, \[ \avgint_{B_\eps(x)} \varphi = \varphi(x) + \frac{\eps^2}{2(d+2)}\,\dlap\varphi(x) + \avgint_{B_\eps(0)} \mathrm{err} , \] where $\mathrm{err}$ is the Taylor error of Theorem Theorem 3.1.

Used byThm. 3.8
Lean 1
PLaplacian.setAverage_expansionPlaplacian/AvgExpansion.lean, lines 94–141
/-- **The average expansion with an explicit error term.**

The average of `φ` over a ball equals the value at the centre plus the
quadratic term, plus the average of the Taylor error. The linear term drops
out by the odd moments; the quadratic term is the Laplacian by the second
moments.

The error term is left as an average rather than estimated, so that the
statement is exact. Bounding it is `setAverage_taylorErr_le` below. -/
theorem setAverage_expansion [Nontrivial (EuclSpace d)] (hd : 0 < d)
    {φ : EuclSpace d → ℝ} (hφ : ContDiff ℝ 2 φ) (x : EuclSpace d) {ε : ℝ}
    (hε : 0 < ε) :
    (⨍ y in ball x ε, φ y)
      = φ x + ε ^ 2 / (2 * ((d : ℝ) + 2)) * laplacianOf (hess φ x)
        + ⨍ z in ball (0 : EuclSpace d) ε, taylorErr φ x z := by
  rw [setAverage_ball_translate φ x ε]
  have hdec : (fun z : EuclSpace d => φ (x + z))
      = fun z => φ x + fderiv ℝ φ x z
        + (1/2) * fderiv ℝ (fderiv ℝ φ) x z z + taylorErr φ x z := by
    funext z
    exact taylor_decomp φ x z
  rw [hdec]
  -- split the average across the four terms
  have hsplit : (⨍ z in ball (0 : EuclSpace d) ε,
        (φ x + fderiv ℝ φ x z
          + (1/2) * fderiv ℝ (fderiv ℝ φ) x z z + taylorErr φ x z))
      = (⨍ z in ball (0 : EuclSpace d) ε, φ x)
        + (⨍ z in ball (0 : EuclSpace d) ε, fderiv ℝ φ x z)
        + (⨍ z in ball (0 : EuclSpace d) ε,
            (1/2) * fderiv ℝ (fderiv ℝ φ) x z z)
        + (⨍ z in ball (0 : EuclSpace d) ε, taylorErr φ x z) := by
    have hc : MeasureTheory.IntegrableOn (fun _ : EuclSpace d => φ x)
        (ball (0 : EuclSpace d) ε) := integrableOn_const
    have hl := integrableOn_linear φ x ε
    have hq := integrableOn_quad φ x ε
    have he := integrableOn_taylorErr hφ x ε
    rw [show (fun z : EuclSpace d => φ x + fderiv ℝ φ x z
          + (1/2) * fderiv ℝ (fderiv ℝ φ) x z z + taylorErr φ x z)
        = ((fun _ : EuclSpace d => φ x) + (fun z => fderiv ℝ φ x z)
            + (fun z => (1/2) * fderiv ℝ (fderiv ℝ φ) x z z))
          + (fun z => taylorErr φ x z) from rfl]
    rw [MeasureTheory.setAverage_add (((hc.add hl).add hq)) he,
        MeasureTheory.setAverage_add (hc.add hl) hq,
        MeasureTheory.setAverage_add hc hl]
  rw [hsplit, setAverage_const_ball (φ x) 0 hε,
      setAverage_fderiv_eq_zero φ x ε,
      setAverage_hess_term hd φ x hε]
  ring
Proof sketch

The linear term vanishes by the odd moments; the quadratic term is Theorem Theorem 3.3. The error is left as an average rather than estimated, so the statement is exact.

Theorem 3.5Localization of the maximizer✓ formalized
Formal statementgenerated from the Lean declaration
localize_maximizer

Let $d \in \mathbb{N}$, $\varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $x, y \in \mathbb{R}^{d}$, $\varepsilon, E \in \mathbb{R}$.

Assume

  • $\operatorname{gradient}(\varphi, x) \ne 0$ hx
  • $0 < \varepsilon$ hε
  • $\lVert y - x\rVert \le \varepsilon$ hball
  • $\varphi(x + (y - x)) \ge \varphi(x + \varepsilon \cdot \operatorname{gradDir}(\varphi, x))$ hdom
  • $\operatorname{taylorErr}(\varphi, x, y - x) - \operatorname{taylorErr}(\varphi, x, \varepsilon \cdot \operatorname{gradDir}(\varphi, x)) \le E$ hE

Then $\lVert y - x - \varepsilon \cdot \operatorname{gradDir}(\varphi, x)\rVert ^{2} \le 2 \cdot \varepsilon \cdot ((\lVert \operatorname{fderiv}(\mathbb{R}, \operatorname{fderiv}(\mathbb{R}, \varphi), x)\rVert \cdot \varepsilon ^{2} + E) / \lVert \operatorname{gradient}(\varphi, x)\rVert)$.

Informal statementfrom the blueprint

Let $y$ maximize $\varphi$ on $\overline{B}_\eps(x)$, with $\nabla\varphi(x) \ne 0$. If the Taylor errors at $y$ and at $x+\eps\nu$ differ by at most $E$, then \[ \norm{y - x - \eps\nu}^2 \le \frac{2\eps\bigl(\norm{D^2\varphi(x)}\eps^2 + E\bigr)} {\abs{\nabla\varphi(x)}} . \]

Used byThm. 3.6
Lean 1
PLaplacian.localize_maximizerPlaplacian/LocalizeMax.lean, lines 54–92
/-- **Localization of the maximizer.**

If `y` maximizes `φ` on the closed ball and the Taylor errors at the two
points differ by at most `E`, then

  `‖y - x - ε ν‖² ≤ 2 ε (‖D²φ x‖ ε² + E) / ‖∇φ x‖`.

With `E` of order `ε³` this is `O(ε³)`, so the maximizer is within
`O(ε^{3/2})` of the shifted point. -/
theorem localize_maximizer {φ : EuclSpace d → ℝ} {x y : EuclSpace d}
    (hx : gradient φ x ≠ 0) {ε E : ℝ} (hε : 0 < ε)
    (hball : ‖y - x‖ ≤ ε)
    (hdom : φ (x + (y - x)) ≥ φ (x + ε • gradDir φ x))
    (hE : taylorErr φ x (y - x) - taylorErr φ x (ε • gradDir φ x) ≤ E) :
    ‖y - x - ε • gradDir φ x‖ ^ 2
      ≤ 2 * ε * ((‖fderiv ℝ (fderiv ℝ φ) x‖ * ε ^ 2 + E)
          / ‖gradient φ x‖) := by
  have hgpos : (0:ℝ) < ‖gradient φ x‖ := norm_pos_iff.2 hx
  -- the shift has norm ε
  have hshift : ‖ε • gradDir φ x‖ ≤ ε := by
    rw [norm_smul, norm_gradDir hx, Real.norm_eq_abs, abs_of_pos hε, mul_one]
  -- the quadratic difference
  have hquad := quad_diff_le (φ := φ) x hball hshift hε
  -- the total bound K
  set K := ‖fderiv ℝ (fderiv ℝ φ) x‖ * ε ^ 2 + E with hK
  have hKbd : (1 / 2) * fderiv ℝ (fderiv ℝ φ) x (y - x) (y - x)
        + taylorErr φ x (y - x)
      - ((1 / 2) * fderiv ℝ (fderiv ℝ φ) x (ε • gradDir φ x)
            (ε • gradDir φ x)
          + taylorErr φ x (ε • gradDir φ x)) ≤ K := by
    rw [hK]
    linarith [hquad, hE]
  -- the deficit
  have hdef := deficit_le hx hdom hKbd
  have hc : ε - inner ℝ (gradDir φ x) (y - x) ≤ K / ‖gradient φ x‖ := by
    rw [le_div_iff₀ hgpos]
    linarith [hdef]
  -- polarization
  exact norm_sub_shift_le x y (norm_gradDir hx) hε hball (by linarith [hc])
Proof sketch

Our own analysis had identified this as the hardest single step in the project. It reduces to a polarization identity. Since $y$ maximizes, $\varphi(y) \ge \varphi(x+\eps\nu)$, and expanding both about $x$ makes the linear functional nearly maximal on the ball; since that functional attains its maximum only at $\eps\nu$, a deficit $c = \eps - \langle\nu, y-x\rangle$ bounds the squared distance, because \[ \norm{y - x - \eps\nu}^2 = \norm{y-x}^2 - 2\eps\langle\nu, y-x\rangle + \eps^2 \le 2\eps c \] using $\norm{y-x} \le \eps$. The Taylor comparison makes $c$ of order $\eps^2$, so the maximizer lies within $O(\eps^{3/2})$ of the shifted point.

Theorem 3.6Expansion of the extreme values✓ formalized
Formal statementgenerated from the Lean declaration
sSup_lower_infLapparts shown as Lean code

Let $d \in \mathbb{N}$, $\varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $x \in \mathbb{R}^{d}$, $\varepsilon \in \mathbb{R}$.

Assume

  • $\operatorname{ContDiff}(\mathbb{R}, 3, \varphi)$ hφ
  • $\operatorname{gradient}(\varphi, x) \ne 0$ hx
  • $0 < \varepsilon$ hε

Then φ x + ε * ‖gradient φ x‖ + ε ^ 2 / 2 * PLaplacian.infLaplacianOf (gradient φ x) (fderiv ℝ (fderiv ℝ φ) x) + PLaplacian.taylorErr φ x (ε • PLaplacian.gradDir φ x) ≤ sSup (φ '' Metric.closedBall x ε).

sSup_upper_infLapparts shown as Lean code

Let $d \in \mathbb{N}$, $\varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $x \in \mathbb{R}^{d}$, $\varepsilon \in \mathbb{R}$.

Assume

  • $\operatorname{ContDiff}(\mathbb{R}, 3, \varphi)$ hφ
  • $\operatorname{gradient}(\varphi, x) \ne 0$ hx
  • $0 < \varepsilon$ hε

Then there exists $y \in \overline{B}(x, \varepsilon)$ such that:

  • sSup ( φ '' Metric.closedBall x ε ) ≤ φ x + ε * ‖ gradient φ x ‖ + ε ^ 2 / 2 * PLaplacian.infLaplacianOf ( gradient φ x ) ( fderiv ℝ ( fderiv ℝ φ ) x ) + 1 / 2 * ( ‖ fderiv ℝ ( fderiv ℝ φ ) x ‖ * ‖ y - x - ε • PLaplacian.gradDir φ x ‖ * ( ‖ y - x ‖ + ‖ ε • PLaplacian.gradDir φ x ‖ ) ) + PLaplacian.taylorErr φ x ( y - x )
Informal statementfrom the blueprint

For $\varphi \in C^3$ with $\nabla\varphi(x) \ne 0$, the supremum over $\overline{B}_\eps(x)$ is bounded below by $\varphi(x) + \eps\abs{\nabla\varphi(x)} + \tfrac{\eps^2}{2}\inflap\varphi(x)$ plus the Taylor error at the shifted point, and above by the same expression with the error at a maximizer plus the quadratic comparison term.

Used byThm. 3.8
Lean 2
/-- **The lower bound, with the infinity Laplacian identified.** -/
theorem sSup_lower_infLap {φ : EuclSpace d → ℝ} (hφ : ContDiff ℝ 3 φ)
    {x : EuclSpace d} (hx : gradient φ x ≠ 0) {ε : ℝ} (hε : 0 < ε) :
    φ x + ε * ‖gradient φ x‖
        + (ε ^ 2 / 2) * infLaplacianOf (gradient φ x)
            (fderiv ℝ (fderiv ℝ φ) x)
        + taylorErr φ x (ε • gradDir φ x)
      ≤ sSup (φ '' closedBall x ε) := by
  have h := sSup_lower_bound hφ hx hε
  rwa [quad_at_shift x ε] at h
/-- **The upper bound, with the quadratic term compared to the target.** -/
theorem sSup_upper_infLap {φ : EuclSpace d → ℝ} (hφ : ContDiff ℝ 3 φ)
    {x : EuclSpace d} (hx : gradient φ x ≠ 0) {ε : ℝ} (hε : 0 < ε) :
    ∃ y ∈ closedBall x ε,
      sSup (φ '' closedBall x ε)
        ≤ φ x + ε * ‖gradient φ x‖
          + (ε ^ 2 / 2) * infLaplacianOf (gradient φ x)
              (fderiv ℝ (fderiv ℝ φ) x)
          + (1 / 2) * (‖fderiv ℝ (fderiv ℝ φ) x‖
              * ‖(y - x) - ε • gradDir φ x‖
              * (‖y - x‖ + ‖ε • gradDir φ x‖))
          + taylorErr φ x (y - x) := by
  obtain ⟨y, hyMem, hyLe⟩ := sSup_upper_bound hφ hx hε
  refine ⟨y, hyMem, ?_⟩
  have hcmp := quad_diff_bound (fderiv ℝ (fderiv ℝ φ) x) (y - x)
    (ε • gradDir φ x)
  have hcmp' := (abs_le.1 hcmp).2
  have hq := quad_at_shift (φ := φ) x ε
  -- the quadratic term at the maximizer, in terms of the target
  have hstep : (1 / 2) * fderiv ℝ (fderiv ℝ φ) x (y - x) (y - x)
      ≤ (ε ^ 2 / 2) * infLaplacianOf (gradient φ x)
            (fderiv ℝ (fderiv ℝ φ) x)
        + (1 / 2) * (‖fderiv ℝ (fderiv ℝ φ) x‖
            * ‖(y - x) - ε • gradDir φ x‖
            * (‖y - x‖ + ‖ε • gradDir φ x‖)) := by
    have hqq : (1 / 2) * fderiv ℝ (fderiv ℝ φ) x (ε • gradDir φ x)
        (ε • gradDir φ x)
        = (ε ^ 2 / 2) * infLaplacianOf (gradient φ x)
            (fderiv ℝ (fderiv ℝ φ) x) := hq
    linarith [hcmp', hqq]
  linarith [hyLe, hstep]
Proof sketch

The gap between the two is the difference of $D^2\varphi(x)$ at $y-x$ and at $\eps\nu$, bounded by $\norm{D^2\varphi(x)}\,\norm{(y-x)-\eps\nu}\, (\norm{y-x}+\eps)$ through the bilinear identity $X(u,u) - X(v,v) = X(u-v,u) + X(v,u-v)$; with Theorem Theorem 3.5 that is $O(\eps^{5/2})$.

Theorem 3.7Extreme values of a quadratic✓ formalized
Formal statementgenerated from the Lean declaration
quad_le_lamMax_ballparts shown as Lean code

Let $d \in \mathbb{N}$, X : EuclSpace d →L[ℝ] EuclSpace d →L[ℝ] ℝ, $z \in \mathbb{R}^{d}$, $\varepsilon \in \mathbb{R}$.

Assume

  • $\lVert z\rVert \le \varepsilon$ hz
  • $z \ne 0$ hzne
  • $0 \le \operatorname{lamMax}(X)$ hpos

Then $(X(z))(z) \le \varepsilon ^{2} \cdot \operatorname{lamMax}(X)$.

Informal statementfrom the blueprint

Where $\nabla\varphi(x) = 0$ the linear term is absent, and for $\norm{z} \le \eps$, $z \ne 0$ and $\lambda_{\max}(X) \ge 0$, \[ X(z,z) \le \eps^2\,\lambda_{\max}(X) . \]

Used byThm. 4.8
Lean 1
PLaplacian.quad_le_lamMax_ballPlaplacian/Singular.lean, lines 73–87
/-- **The quadratic form over the ball is at most `ε²` times the largest
eigenvalue**, provided that eigenvalue is nonnegative --- which holds whenever
the form is not negative definite, and in particular at a maximum. -/
theorem quad_le_lamMax_ball (X : EuclSpace d →L[ℝ] EuclSpace d →L[ℝ] ℝ)
    {z : EuclSpace d} {ε : ℝ} (hz : ‖z‖ ≤ ε) (hzne : z ≠ 0)
    (hpos : 0 ≤ lamMax X) :
    X z z ≤ ε ^ 2 * lamMax X := by
  rw [quad_eq_norm_sq_mul X hzne]
  have h1 : infLaplacianOf z X ≤ lamMax X :=
    infLaplacianOf_le_lamMax hzne X
  have h2 : ‖z‖ ^ 2 ≤ ε ^ 2 := by
    have h0 : (0:ℝ) ≤ ‖z‖ := norm_nonneg z
    nlinarith [hz, h0]
  have h3 : (0:ℝ) ≤ ‖z‖ ^ 2 := by positivity
  nlinarith [h1, h2, h3, hpos]
Proof sketch

So at a singular point the expansion produces $\lambda_{\max}$ for the supremum and $\lambda_{\min}$ for the infimum — exactly the closed-form envelopes of the viscosity predicates. The envelopes are therefore not a convention but what the asymptotics give, which closes the circle between Layers 2 and 3.

Theorem 3.8The asymptotic expansion✓ formalized
Formal statementgenerated from the Lean declaration
tugOfWarOp_expansion_final

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $x \in \mathbb{R}^{d}$, $\varepsilon \in \mathbb{R}$.

Assume

  • $\mathbb{R}^{d}\text{ is nontrivial}$
  • $0 < d$ hd
  • $0 < p + d$ hpd
  • $\operatorname{ContDiff}(\mathbb{R}, 3, \varphi)$ hφ
  • $\operatorname{gradient}(\varphi, x) \ne 0$ hx
  • $0 < \varepsilon$ hε

Then there exists $E$ such that:

  • $T_{\varepsilon} \varphi(x) = \varphi(x) + \varepsilon ^{2} / (2 \cdot (p + d)) \cdot \operatorname{normPLapOf}(p, \operatorname{gradient}(\varphi, x), \operatorname{fderiv}(\mathbb{R}, \operatorname{fderiv}(\mathbb{R}, \varphi), x)) + E$
Informal statementfrom the blueprint

For $\varphi \in C^3$ with $\nabla\varphi(x) \ne 0$, $\eps > 0$, $0 < d$ and $0 < p + d$, there is $E$ with \[ \Op\varphi(x) = \varphi(x) + \frac{\eps^2}{2(p+d)}\,\pnlap\varphi(x) + E . \]

Lean 1
PLaplacian.tugOfWarOp_expansion_finalPlaplacian/Expansion.lean, lines 48–67
/-- **The asymptotic expansion of the step operator.**

For a `C³` test function with nonvanishing gradient, the step operator equals
the value at the point plus the normalized `p`-Laplacian term, plus an error
term. -/
theorem tugOfWarOp_expansion_final [Nontrivial (EuclSpace d)] (hd : 0 < d)
    (p : ℝ) (hpd : 0 < p + (d : ℝ)) {φ : EuclSpace d → ℝ}
    (hφ : ContDiff ℝ 3 φ) {x : EuclSpace d} (hx : gradient φ x ≠ 0)
    {ε : ℝ} (hε : 0 < ε) :
    ∃ E : ℝ,
      tugOfWarOp p ε φ x
        = φ x + ε ^ 2 / (2 * (p + (d : ℝ)))
            * normPLapOf p (gradient φ x) (fderiv ℝ (fderiv ℝ φ) x)
          + E := by
  obtain ⟨e₁, lo, hi, hS, hlo, hhi⟩ := extreme_avg_threaded hφ hx hε
  have hA := setAverage_expansion hd (hφ.of_le (by norm_num)) x hε
  refine ⟨(p - 2) / (p + (d : ℝ)) * e₁
    + ((d : ℝ) + 2) / (p + (d : ℝ))
        * (⨍ z in ball (0 : EuclSpace d) ε, taylorErr φ x z), ?_⟩
  exact tugOfWarOp_expansion_normPLap p hpd ε φ x hS hA
Proof sketch

Assembling: the extreme values of the operator are over open balls and the expansion was proved over closed ones, so sSup_ball_eq_closedBall is needed — the one place in the development where the choice of open balls must be paid for rather than merely respected. Then the two halves are substituted and the weights combined, with \[ \alpha \cdot \tfrac{\eps^2}{2} I + \beta \cdot \tfrac{\eps^2}{2(d+2)} L = \frac{\eps^2}{2(p+d)}\bigl[(p-2) I + L\bigr] , \] the factor $d+2$ from the moments cancelling against $\beta$'s numerator.

Theorem 3.9Cubic rate of the Taylor error✓ formalized
Formal statementgenerated from the Lean declaration
taylorErr_le_cubic

Let $d \in \mathbb{N}$, $\varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $x \in \mathbb{R}^{d}$, $\varepsilon \in \mathbb{R}$.

Assume

  • $\operatorname{ContDiff}(\mathbb{R}, 3, \varphi)$ hφ

Then there exists $K$ such that:

  • $\forall z,\ \lVert z\rVert \le \varepsilon \to \lvert \operatorname{taylorErr}(\varphi, x, z)\rvert \le K \cdot \lVert z\rVert ^{3}$
Informal statementfrom the blueprint

For $\varphi \in C^3$, $x$ and $\eps$ there is $K$, independent of the increment, with \[ \abs{\mathrm{err}(z)} \le K \norm{z}^3 \qquad\text{for all } \norm{z} \le \eps . \]

Used byThm. 3.10
Lean 1
PLaplacian.taylorErr_le_cubicPlaplacian/ErrRate.lean, lines 59–103
/-- **The Taylor error, at a cubic rate.** -/
theorem taylorErr_le_cubic {φ : EuclSpace d → ℝ} (hφ : ContDiff ℝ 3 φ)
    (x : EuclSpace d) (ε : ℝ) :
    ∃ K : ℝ, ∀ z : EuclSpace d, ‖z‖ ≤ ε →
      |taylorErr φ x z| ≤ K * ‖z‖ ^ 3 := by
  obtain ⟨C, hC⟩ := deriv_three_cubic_bound hφ x ε
  refine ⟨C, fun z hz => ?_⟩
  -- Taylor at order two on the restriction
  obtain ⟨ξ, hξ, hres⟩ := taylor_two_deriv
    (fun s : ℝ => φ (x + s • z)) (by
      have h := contDiff_restrict_three hφ x z
      simpa [lineMap] using h)
  -- the three polynomial terms
  have hd1 : deriv (fun s : ℝ => φ (x + s • z)) 0
      = fderiv ℝ φ x z := by
    have h := hasDerivAt_first (hφ.of_le (by norm_num)) x z 0
    simp only [lineMap, zero_smul, add_zero] at h
    exact h.deriv
  have hd2 : deriv (deriv (fun s : ℝ => φ (x + s • z))) 0
      = fderiv ℝ (fderiv ℝ φ) x z z := by
    have h := hasDerivAt_second_at (hφ.of_le (by norm_num)) x z 0
    simp only [lineMap, zero_smul, add_zero] at h
    have hfun : deriv (fun s : ℝ => φ (x + s • z))
        = fun t => fderiv ℝ φ (x + t • z) z := by
      funext t
      have ht := hasDerivAt_first (hφ.of_le (by norm_num)) x z t
      simp only [lineMap] at ht
      exact ht.deriv
    rw [hfun]
    exact h.deriv
  -- the remainder, bounded cubically
  have hmem : x + ξ • z ∈ closedBall x ε :=
    mem_closedBall_segment x z hz (le_of_lt hξ.1) (le_of_lt hξ.2)
  have hbd := hC z hz ξ hmem
  -- assemble
  have herr : taylorErr φ x z
      = (1 / 6) * deriv (deriv (deriv (fun s : ℝ => φ (x + s • z)))) ξ := by
    unfold taylorErr
    simp only [one_smul, zero_smul, add_zero] at hres
    rw [hd1, hd2] at hres
    linarith [hres]
  rw [herr, abs_mul, abs_of_nonneg (by norm_num : (0:ℝ) ≤ 1/6)]
  nlinarith [hbd, abs_nonneg
    (deriv (deriv (deriv (fun s : ℝ => φ (x + s • z)))) ξ),
    pow_nonneg (norm_nonneg z) 3]
Proof sketch

The cubic dependence is recovered by bounding the composition rather than identifying the third derivative pointwise. The third derivative of $t \mapsto \varphi(x+tz)$ contains three factors of $z$, and norm_iteratedFDeriv_comp_le exposes them: with the line map's derivatives bounded by $\norm{z}^i$ — order one is exactly $\norm{z}$, and all higher orders vanish, the map being affine — the composition bound gives $3!\,C\,\norm{z}^3$.

Theorem 3.10Rate of the averaged error✓ formalized
Formal statementgenerated from the Lean declaration
setAverage_taylorErr_le

Let $d \in \mathbb{N}$, $\varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $x \in \mathbb{R}^{d}$, $\varepsilon \in \mathbb{R}$.

Assume

  • $\operatorname{ContDiff}(\mathbb{R}, 3, \varphi)$ hφ
  • $0 < \varepsilon$ hε

Then there exists $K$ such that:

  • $\fint_{B(0, \varepsilon)} (\operatorname{taylorErr}(\varphi, x, z) \le K \cdot \varepsilon ^{3}) \, dz$
Informal statementfrom the blueprint

The average of the error over the ball satisfies $\avgint_{B_\eps(0)} \mathrm{err} \le K\eps^3$.

Used byThm. 3.11
Lean 1
PLaplacian.setAverage_taylorErr_lePlaplacian/AvgErrBound.lean, lines 46–61
/-- **The average of the Taylor error, bounded cubically.** -/
theorem setAverage_taylorErr_le {φ : EuclSpace d → ℝ} (hφ : ContDiff ℝ 3 φ)
    (x : EuclSpace d) {ε : ℝ} (hε : 0 < ε) :
    ∃ K : ℝ, (⨍ z in ball (0 : EuclSpace d) ε, taylorErr φ x z)
      ≤ K * ε ^ 3 := by
  obtain ⟨K, hK⟩ := taylorErr_le_on_ball hφ x hε
  refine ⟨K, ?_⟩
  have hmono : (⨍ z in ball (0 : EuclSpace d) ε, taylorErr φ x z)
      ≤ ⨍ _z in ball (0 : EuclSpace d) ε, K * ε ^ 3 := by
    refine setAverage_mono measurableSet_ball
      (integrableOn_taylorErr (hφ.of_le (by norm_num)) x ε) integrableOn_const ?_
    intro z hz
    have h := hK z hz
    exact le_of_abs_le h
  rw [setAverage_const_ball (K * ε ^ 3) 0 hε] at hmono
  exact hmono
Proof sketch

An average of a function bounded above by a constant is bounded by that constant, which is setAverage_mono against the constant function — the lemma of Theorem Theorem 2.9, absent from Mathlib, used here for the purpose it was proved for.

Theorem 3.11The expansion with an explicit rate✓ formalized
Formal statementgenerated from the Lean declaration
tugOfWarOp_expansion_boundedparts shown as Lean code

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\varepsilon \in \mathbb{R}$, $\varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $x \in \mathbb{R}^{d}$, $e_{1}, e_{2}, B_{1}, B_{2} \in \mathbb{R}$.

Assume

  • $2 \le p$ hp
  • $0 < p + d$ hpd
  • (sSup (φ '' Metric.ball x ε) + sInf (φ '' Metric.ball x ε)) / 2 = φ x + ε ^ 2 / 2 * PLaplacian.infLaplacianOf (gradient φ x) (fderiv ℝ (fderiv ℝ φ) x) + e₁ hS
  • $\fint_{B(x, \varepsilon)} (\varphi(y) = \varphi(x) + \varepsilon ^{2} / (2 \cdot (d + 2)) \cdot \operatorname{laplacianOf}(\operatorname{fderiv}(\mathbb{R}, \operatorname{fderiv}(\mathbb{R}, \varphi), x)) + e_{2}) \, dy$ hA
  • $\lvert e_{1}\rvert \le B_{1}$ hB₁
  • $\lvert e_{2}\rvert \le B_{2}$ hB₂

Then there exists $E$ such that:

  • $T_{\varepsilon} \varphi(x) = \varphi(x) + \varepsilon ^{2} / (2 \cdot (p + d)) \cdot \operatorname{normPLapOf}(p, \operatorname{gradient}(\varphi, x), \operatorname{fderiv}(\mathbb{R}, \operatorname{fderiv}(\mathbb{R}, \varphi), x)) + E$
  • $\lvert E\rvert \le B_{1} + B_{2}$
Informal statementfrom the blueprint

For $2 \le p$, if the two halves have errors bounded by $B_1$ and $B_2$, then \[ \Op\varphi(x) = \varphi(x) + \frac{\eps^2}{2(p+d)}\,\pnlap\varphi(x) + E , \qquad \abs{E} \le B_1 + B_2 . \]

Used byThm. 4.5
Lean 1
PLaplacian.tugOfWarOp_expansion_boundedPlaplacian/OpBounded.lean, lines 47–72
/-- **The expansion with a bounded error.**

Given the two halves with their errors bounded by `B₁` and `B₂`, the operator
expands with total error at most `B₁ + B₂`. -/
theorem tugOfWarOp_expansion_bounded (p : ℝ) (hp : 2 ≤ p)
    (hpd : 0 < p + (d : ℝ)) (ε : ℝ) (φ : EuclSpace d → ℝ)
    (x : EuclSpace d) {e₁ e₂ B₁ B₂ : ℝ}
    (hS : (sSup (φ '' ball x ε) + sInf (φ '' ball x ε)) / 2
        = φ x + (ε ^ 2 / 2)
            * infLaplacianOf (gradient φ x) (fderiv ℝ (fderiv ℝ φ) x) + e₁)
    (hA : (⨍ y in ball x ε, φ y)
        = φ x + ε ^ 2 / (2 * ((d : ℝ) + 2))
            * laplacianOf (fderiv ℝ (fderiv ℝ φ) x) + e₂)
    (hB₁ : |e₁| ≤ B₁) (hB₂ : |e₂| ≤ B₂) :
    ∃ E : ℝ,
      tugOfWarOp p ε φ x
          = φ x + ε ^ 2 / (2 * (p + (d : ℝ)))
              * normPLapOf p (gradient φ x) (fderiv ℝ (fderiv ℝ φ) x) + E
        ∧ |E| ≤ B₁ + B₂ := by
  refine ⟨(p - 2) / (p + (d : ℝ)) * e₁
    + ((d : ℝ) + 2) / (p + (d : ℝ)) * e₂, ?_, ?_⟩
  · exact tugOfWarOp_expansion_normPLap p hpd ε φ x hS hA
  · calc |(p - 2) / (p + (d : ℝ)) * e₁
            + ((d : ℝ) + 2) / (p + (d : ℝ)) * e₂|
        ≤ |e₁| + |e₂| := weighted_error_le p hp hpd e₁ e₂
      _ ≤ B₁ + B₂ := by linarith [hB₁, hB₂]
Proof sketch

The weights satisfy $\abs{\alpha}, \abs{\beta} \le 1$ for $2 \le p$, so they do not amplify: a rate for each half gives a rate for the total. Instantiating with Theorem Theorem 3.10 and the localization estimate, $\abs{E} = O(\eps^{5/2}) = o(\eps^2)$.

4. The viscosity property of the relaxed limits

Theorem 4.1The half-relaxed limits✓ formalized
Formal statementgenerated from the Lean declaration
lbar_le_ubar

Let $d \in \mathbb{N}$, $u \colon \mathbb{R} \to \mathbb{R}^{d} \to \mathbb{R}$, $C \in \mathbb{R}$, $x \in \mathbb{R}^{d}$.

Assume

  • $\forall \varepsilon, y,\ \lvert u_{\varepsilon}(y)\rvert \le C$ hC

Then $\underline{u}(x) \le \overline{u}(x)$.

upperSemicontinuous_ubar

Let $d \in \mathbb{N}$, $u \colon \mathbb{R} \to \mathbb{R}^{d} \to \mathbb{R}$, $C \in \mathbb{R}$.

Assume

  • $\forall \varepsilon, y,\ \lvert u_{\varepsilon}(y)\rvert \le C$ hC

Then $\overline{u}\text{ is upper semicontinuous}$.

lowerSemicontinuous_lbar

Let $d \in \mathbb{N}$, $u \colon \mathbb{R} \to \mathbb{R}^{d} \to \mathbb{R}$, $C \in \mathbb{R}$.

Assume

  • $\forall \varepsilon, y,\ \lvert u_{\varepsilon}(y)\rvert \le C$ hC

Then $\underline{u}\text{ is lower semicontinuous}$.

Informal statementfrom the blueprint

For a uniformly bounded family the two limits are finite and ordered, the upper one is upper semicontinuous and the lower one lower semicontinuous.

Lean 3
/-- **The lower limit does not exceed the upper.** -/
theorem lbar_le_ubar (u : ℝ → EuclSpace d → ℝ) {C : ℝ}
    (hC : ∀ ε y, |u ε y| ≤ C) (x : EuclSpace d) :
    lbar u x ≤ ubar u x := by
  unfold lbar ubar
  exact Filter.liminf_le_limsup
    (isBoundedUnder_le_of_bound u hC x)
    (isBoundedUnder_ge_of_bound u hC x)
PLaplacian.upperSemicontinuous_ubarPlaplacian/Semicont.lean, lines 83–98
/-- **The upper limit is upper semicontinuous.** -/
theorem upperSemicontinuous_ubar (u : ℝ → EuclSpace d → ℝ) {C : ℝ}
    (hC : ∀ ε y, |u ε y| ≤ C) :
    UpperSemicontinuous (ubar u) := by
  intro x a ha
  -- an intermediate value
  obtain ⟨b, hb1, hb2⟩ := exists_between ha
  obtain ⟨S, hS, V, hV, hbd⟩ := exists_prod_nhds_of_ubar_lt u hC x hb1
  -- shrink to an open subset, which is a neighbourhood of each of its points
  obtain ⟨W, hWV, hWopen, hxW⟩ := _root_.mem_nhds_iff.1 hV
  filter_upwards [hWopen.mem_nhds hxW] with y hyW
  have hWy : W ∈ nhds y := hWopen.mem_nhds hyW
  have hle : ubar u y ≤ b :=
    ubar_le_of_bound u hC hS
      (fun ε hεS w hwW => le_of_lt (hbd ε hεS w (hWV hwW))) hWy
  linarith [hle, hb2]
PLaplacian.lowerSemicontinuous_lbarPlaplacian/LowerSemi.lean, lines 76–90
/-- **The lower limit is lower semicontinuous.** -/
theorem lowerSemicontinuous_lbar (u : ℝ → EuclSpace d → ℝ) {C : ℝ}
    (hC : ∀ ε y, |u ε y| ≤ C) :
    LowerSemicontinuous (lbar u) := by
  refine upperSemiContinuous_neg_iff.mp ?_
  have heq : (- lbar u)
      = ubar (fun ε y => - u ε y) := by
    funext y
    change - lbar u y = _
    rw [lbar_eq_neg_ubar_neg, neg_neg]
  rw [heq]
  refine upperSemicontinuous_ubar (fun ε y => - u ε y) (C := C) ?_
  intro ε y
  rw [abs_neg]
  exact hC ε y
Proof sketch

Finiteness requires the bound to be uniform in $\eps$, and this is where a fact recorded in the companion — that the reals are not a complete lattice, so an unbounded supremum is a junk value — binds after being recorded two layers earlier without consequence. The bound is available: Theorem Theorem 1.13 bounds a solution by the bound on the initial datum, with no dependence on $\eps$, so one datum serves the whole family.

Theorem 4.2Approximate comparison through the operator✓ formalized
Formal statementgenerated from the Lean declaration
dpp_comparison_approx

Let $d \in \mathbb{N}$, $p, \varepsilon \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $F, u, \varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $y \in \mathbb{R}^{d}$, $c, \kappa \in \mathbb{R}$.

Assume

  • $2 \le p$ hp
  • $0 < \varepsilon$ hε
  • $0 < p + d$ hpd
  • $u\text{ is }p\text{-harmonious in }\Omega\text{ with step }\varepsilon\text{ and data }F$ hu
  • $\varphi\text{ is admissible (bounded and Borel measurable)}$ hφ
  • $y \in \Omega$ hy
  • $\forall w \in B(y, \varepsilon),\ u(w) - \varphi(w) \le c$ hle
  • $c - \kappa \le u(y) - \varphi(y)$ hnear

Then $\varphi(y) \le T_{\varepsilon} \varphi(y) + \kappa$.

Informal statementfrom the blueprint

Let $u$ be $p$-harmonious at $y \in \Omega$ for the parameter $\eps$, and let $\varphi$ be bounded and measurable. If $u - \varphi \le c$ on $B_\eps(y)$ and $u(y) - \varphi(y) \ge c - \kappa$, then \[ \varphi(y) \le \Op\varphi(y) + \kappa . \]

Lean 1
PLaplacian.dpp_comparison_approxPlaplacian/ApproxCmp.lean, lines 54–76
/-- **The approximate comparison.** -/
theorem dpp_comparison_approx {p ε : ℝ} (hp : 2 ≤ p) (hε : 0 < ε)
    (hpd : 0 < p + (d : ℝ))
    {Ω : Set (EuclSpace d)} {F u φ : EuclSpace d → ℝ}
    (hu : IsPHarmonious p ε Ω F u) (hφ : BddMeas φ)
    {y : EuclSpace d} (hy : y ∈ Ω) {c κ : ℝ}
    (hle : ∀ w ∈ ball y ε, u w - φ w ≤ c)
    (hnear : c - κ ≤ u y - φ y) :
    φ y ≤ tugOfWarOp p ε φ y + κ := by
  -- u ≤ φ + c on the ball
  have hup : ∀ w ∈ ball y ε, u w ≤ φ w + c := by
    intro w hw
    linarith [hle w hw]
  have hψ : BddMeas (fun w => φ w + c) := bddMeas_add_const hφ c
  -- monotonicity
  have hmono : tugOfWarOp p ε u y
      ≤ tugOfWarOp p ε (fun w => φ w + c) y :=
    tugOfWarOp_mono_ball p ε hp hε hpd hu.bddMeas hψ y hup
  rw [tugOfWarOp_add_const p ε hε hφ c y hpd] at hmono
  -- the dynamic programming principle
  rw [← hu.interior y hy] at hmono
  -- and the near-equality
  linarith [hmono, hnear]
Proof sketch

The proof uses three results of Layer 1 in one argument. Monotonicity pushes $u \le \varphi + c$ through the operator, translation equivariance pulls the constant out, and the dynamic programming principle replaces $\Op u(y)$ by $u(y) \ge \varphi(y) + c - \kappa$.

Theorem 4.3Near-maximizers✓ formalized
Formal statementgenerated from the Lean declaration
exists_near_sup_cubeparts shown as Lean code

Let $d \in \mathbb{N}$, $u \colon \mathbb{R} \to \mathbb{R}^{d} \to \mathbb{R}$, $C \in \mathbb{R}$, $\varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $B \in \mathbb{R}$, $x_{0} \in \mathbb{R}^{d}$, $r \in \mathbb{R}$, $\varepsilon \in \mathbb{R}$.

Assume

  • $\forall \varepsilon, y,\ \lvert u_{\varepsilon}(y)\rvert \le C$ hC
  • $\forall y,\ \lvert \varphi(y)\rvert \le B$ hB
  • $0 < r$ hr
  • $0 < \varepsilon$ hε

Then there exists $y \in \overline{B}(x_{0}, r)$ such that:

  • sSup ( ( fun w => u ε w - φ w ) '' Metric.closedBall x₀ r ) - ε ^ 3 < u ε y - φ y
le_sup_on_ballparts shown as Lean code

Let $d \in \mathbb{N}$, $u \colon \mathbb{R} \to \mathbb{R}^{d} \to \mathbb{R}$, $C \in \mathbb{R}$, $\varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $B \in \mathbb{R}$, $x_{0} \in \mathbb{R}^{d}$, $r, \varepsilon \in \mathbb{R}$, $w \in \mathbb{R}^{d}$.

Assume

  • $\forall \varepsilon, y,\ \lvert u_{\varepsilon}(y)\rvert \le C$ hC
  • $\forall y,\ \lvert \varphi(y)\rvert \le B$ hB
  • $w \in \overline{B}(x_{0}, r)$ a._@._internal._hyg.0

Then u ε w - φ w ≤ sSup ((fun w => u ε w - φ w) '' Metric.closedBall x₀ r).

Informal statementfrom the blueprint

For each $\eps > 0$ there is $y_\eps \in \overline{B}_r(x_0)$ with $S_\eps - \eps^3 < u_\eps(y_\eps) - \varphi(y_\eps)$, and $u_\eps - \varphi \le S_\eps$ on $\overline{B}_r(x_0)$.

Used byThm. 4.4
Lean 2
PLaplacian.exists_near_sup_cubePlaplacian/NearSup.lean, lines 83–102
/-- **The near-maximizer at tolerance `ε³`**, for the family on a closed ball.

The tolerance depends on the parameter, which is exactly what the earlier
set-up could not provide. -/
theorem exists_near_sup_cube (u : ℝ → EuclSpace d → ℝ) {C : ℝ}
    (hC : ∀ ε y, |u ε y| ≤ C) {φ : EuclSpace d → ℝ} {B : ℝ}
    (hB : ∀ y, |φ y| ≤ B) (x₀ : EuclSpace d) {r : ℝ} (hr : 0 < r)
    {ε : ℝ} (hε : 0 < ε) :
    ∃ y ∈ closedBall x₀ r,
      sSup ((fun w => u ε w - φ w) '' closedBall x₀ r) - ε ^ 3
        < u ε y - φ y := by
  have hs : (closedBall x₀ r).Nonempty := ⟨x₀, mem_closedBall_self hr.le⟩
  have hbdd : BddAbove ((fun w => u ε w - φ w) '' closedBall x₀ r) := by
    refine ⟨C + B, ?_⟩
    rintro a ⟨w, _, rfl⟩
    have h1 := abs_le.1 (hC ε w)
    have h2 := abs_le.1 (hB w)
    linarith [h1.2, h2.1]
  have hτ : (0:ℝ) < ε ^ 3 := by positivity
  exact exists_near_sup hs hbdd hτ
/-- The family minus the test function is bounded by its supremum on the
ball, which is the comparison's first hypothesis. -/
theorem le_sup_on_ball (u : ℝ → EuclSpace d → ℝ) {C : ℝ}
    (hC : ∀ ε y, |u ε y| ≤ C) {φ : EuclSpace d → ℝ} {B : ℝ}
    (hB : ∀ y, |φ y| ≤ B) (x₀ : EuclSpace d) {r ε : ℝ} :
    ∀ w ∈ closedBall x₀ r,
      u ε w - φ w ≤ sSup ((fun w => u ε w - φ w) '' closedBall x₀ r) := by
  intro w hw
  have hbdd : BddAbove ((fun w => u ε w - φ w) '' closedBall x₀ r) := by
    refine ⟨C + B, ?_⟩
    rintro a ⟨v, _, rfl⟩
    have h1 := abs_le.1 (hC ε v)
    have h2 := abs_le.1 (hB v)
    linarith [h1.2, h2.1]
  exact le_csSup hbdd ⟨w, hw, rfl⟩
Proof sketch

Convergence to the point of contact. The standard argument extracts a convergent subsequence of the $y_\eps$ and uses the strictness to identify its limit. We do not extract a sequence.

Theorem 4.4Near-maximizers approach the contact point✓ formalized
Formal statementgenerated from the Lean declaration
nearmax_frequently_in_ballparts shown as Lean code

Let $d \in \mathbb{N}$, $u \colon \mathbb{R} \to \mathbb{R}^{d} \to \mathbb{R}$, $C \in \mathbb{R}$, $\varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $B \in \mathbb{R}$, $x_{0} \in \mathbb{R}^{d}$, $r, \rho \in \mathbb{R}$, $y \colon \mathbb{R} \to \mathbb{R}^{d}$.

Assume

  • $\forall \varepsilon, y,\ \lvert u_{\varepsilon}(y)\rvert \le C$ hC
  • $\varphi\text{ is continuous}$ hφ
  • $\forall y,\ \lvert \varphi(y)\rvert \le B$ hB
  • $0 < r$ hr
  • $0 < \rho$ hρ
  • $\operatorname{IsStrictMaxOn}(w \mapsto \overline{u}(w) - \varphi(w), x_{0}, r)$ hstrict
  • $\forall \varepsilon > 0,\ y_{\varepsilon} \in \overline{B}(x_{0}, r) \wedge \operatorname{supBall}(u, \varphi, x_{0}, r, \varepsilon) - \varepsilon ^{3} < u_{\varepsilon}(y_{\varepsilon}) - \varphi(y_{\varepsilon})$ hy

Then ∃ᶠ (ε : ℝ) in nhdsWithin 0 (Set.Ioi 0), y ε ∈ Metric.ball x₀ ρ.

Informal statementfrom the blueprint

For every $\rho > 0$, frequently as $\eps \to 0^+$, $y_\eps \in B_\rho(x_0)$.

Lean 1
PLaplacian.nearmax_frequently_in_ballPlaplacian/NearFreq.lean, lines 61–95
/-- **The near-maximizer is frequently within any radius of the base
point.** -/
theorem nearmax_frequently_in_ball (u : ℝ → EuclSpace d → ℝ) {C : ℝ}
    (hC : ∀ ε y, |u ε y| ≤ C) {φ : EuclSpace d → ℝ}
    (hφ : Continuous φ) {B : ℝ} (hB : ∀ y, |φ y| ≤ B)
    {x₀ : EuclSpace d} {r ρ : ℝ} (hr : 0 < r) (hρ : 0 < ρ)
    (hstrict : IsStrictMaxOn (fun w => ubar u w - φ w) x₀ r)
    (y : ℝ → EuclSpace d)
    (hy : ∀ ε > 0, y ε ∈ closedBall x₀ r ∧
      supBall u φ x₀ r ε - ε ^ 3 < u ε (y ε) - φ (y ε)) :
    ∃ᶠ ε in nhdsWithin (0 : ℝ) (Set.Ioi 0), y ε ∈ ball x₀ ρ := by
  -- the gap on the annulus
  obtain ⟨η, hη, hgap⟩ := annulus_gap u hC hφ hρ hstrict
  set M := ubar u x₀ - φ x₀ with hM
  -- the family below M - η/2 on the annulus, eventually
  have hgap' : ∀ w ∈ annulus x₀ ρ r, ubar u w - φ w < M - η / 2 := by
    intro w hw; have := hgap w hw; linarith [this, hη]
  obtain ⟨S, hS, hbdS⟩ := uniform_bound_annulus u hC hφ hB hgap'
  -- the supremum frequently above M - η/4
  have hsup := frequently_supBall_large u hC hφ hB x₀ hr
    (by linarith : (0:ℝ) < η / 4)
  -- the cube eventually below η/4, and the parameter positive
  have hcube := eventually_cube_lt (by linarith : (0:ℝ) < η / 4)
  have hpos : ∀ᶠ ε in nhdsWithin (0 : ℝ) (Set.Ioi 0), 0 < ε :=
    self_mem_nhdsWithin
  -- combine
  have hev : ∀ᶠ ε in nhdsWithin (0 : ℝ) (Set.Ioi 0),
      ε ∈ S ∧ ε ^ 3 < η / 4 ∧ 0 < ε :=
    ((show ∀ᶠ ε in nhdsWithin (0 : ℝ) (Set.Ioi 0), ε ∈ S from hS).and
      (hcube.and hpos))
  refine (hsup.and_eventually hev).mono ?_
  rintro ε ⟨hsupε, hεS, hεcube, hεpos⟩
  obtain ⟨hmem, hnear⟩ := hy ε hεpos
  refine nearmax_in_ball (hbdS ε hεS) hmem hnear ?_
  linarith [hsupε, hεcube]
Proof sketch

The argument works on the annulus $A = \overline{B}_r(x_0) \setminus B_\rho(x_0)$, in four steps.

  1. A gap on the annulus (annulus_gap). $\overline{u} - \varphi$ is upper semicontinuous and $A$ is compact, so the maximum over $A$ is attained (UpperSemicontinuousOn.exists_isMaxOn); no point of $A$ is $x_0$, so by strictness it is $M - \eta$ for some $\eta > 0$.
  2. A uniform eventual bound (uniform_bound_annulus). At each point of $A$ the family minus $\varphi$ is eventually below $M - \eta/2$ on a product neighbourhood; the neighbourhoods cover $A$, a finite subcover exists, and the intersection of the finitely many parameter sets is still a filter member. Mathlib has a lemma packaging this argument, IsCompact.eventually_forall_of_forall_eventually, but it works with the two-sided neighbourhood of a pair, while the relaxed filter is one-sided in the parameter, so its hypothesis is stronger than the one available. The subcover is done by hand.
  3. The supremum is frequently large (frequently_supBall_large). Near-contact gives, frequently on the product filter, a point of the ball with value above $M - \eta/4$, so $S_\eps > M - \eta/4$. That statement mentions the parameter alone, so it projects off the product filter (frequently_fst_of_prod).
  4. Exclusion (nearmax_in_ball). Frequently, then, $u_\eps(y_\eps) - \varphi(y_\eps) > S_\eps - \eps^3 > M - \eta/2$, which is incompatible with $y_\eps \in A$.

Compactness is used once, on the annulus, to make a pointwise bound uniform; everything else runs along the filter.

Theorem 4.5The expansion, uniformly in the base point✓ formalized
Formal statementgenerated from the Lean declaration
expansion_uniformparts shown as Lean code

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $x_{0} \in \mathbb{R}^{d}$.

Assume

  • $\mathbb{R}^{d}\text{ is nontrivial}$
  • $0 < d$ hd
  • $2 \le p$ hp
  • $0 < p + d$ hpd
  • $\operatorname{ContDiff}(\mathbb{R}, 3, \varphi)$ hφ
  • $\operatorname{gradient}(\varphi, x_{0}) \ne 0$ hx₀

Then there exists $\rho > 0$ such that:

  • ∃ H K Ka g, 0 < g ∧ 0 ≤ K ∧ 0 ≤ H ∧ 0 ≤ Ka ∧ ∀ y ∈ Metric.ball x₀ ρ, ∀ (ε : ℝ), 0 < ε → ε ≤ ρ → ∃ E, PLaplacian.tugOfWarOp p ε φ y = φ y + ε ^ 2 / (2 * (p + ↑d)) * PLaplacian.normPLapOf p (gradient φ y) (fderiv ℝ (fderiv ℝ φ) y) + E ∧ |E| ≤ H * ε * √(2 * ε * ((H * ε ^ 2 + 2 * K * ε ^ 3) / g)) + K * ε ^ 3 + Ka * ε ^ 3
eventually_bound_leparts shown as Lean code

Let $H, K, \mathrm{Ka}, g, \eta \in \mathbb{R}$.

Assume

  • $0 < \eta$ hη

Then ∀ᶠ (ε : ℝ) in nhdsWithin 0 (Set.Ioi 0), H * ε * √(2 * ε * ((H * ε ^ 2 + 2 * K * ε ^ 3) / g)) + K * ε ^ 3 + Ka * ε ^ 3 ≤ η * ε ^ 2.

Informal statementfrom the blueprint

Let $\varphi \in C^3$ with $\nabla\varphi(x_0) \ne 0$. There are $\rho > 0$ and constants $H, K, K_a \ge 0$ and $g > 0$ such that for every $y \in B_\rho(x_0)$ and every $0 < \eps \le \rho$, \[ \Op\varphi(y) = \varphi(y) + \frac{\eps^2}{2(p+d)}\,\pnlap\varphi(y) + E, \qquad \abs{E} \le H\eps\sqrt{U} + (K + K_a)\,\eps^3, \quad U = \frac{2\eps(H\eps^2 + 2K\eps^3)}{g}. \] Moreover, for every $\eta > 0$, the bound is eventually at most $\eta\eps^2$.

Lean 2
PLaplacian.expansion_uniformPlaplacian/ExpUnif.lean, lines 58–119
/-- **The expansion, uniformly in the base point.** -/
theorem expansion_uniform [Nontrivial (EuclSpace d)] (hd : 0 < d)
    {p : ℝ} (hp : 2 ≤ p) (hpd : 0 < p + (d : ℝ))
    {φ : EuclSpace d → ℝ} (hφ : ContDiff ℝ 3 φ) {x₀ : EuclSpace d}
    (hx₀ : gradient φ x₀ ≠ 0) :
    ∃ ρ > 0, ∃ H K Ka g : ℝ, 0 < g ∧ 0 ≤ K ∧ 0 ≤ H ∧ 0 ≤ Ka ∧
      ∀ y ∈ ball x₀ ρ, ∀ ε : ℝ, 0 < ε → ε ≤ ρ →
        ∃ E : ℝ,
          tugOfWarOp p ε φ y
              = φ y + ε ^ 2 / (2 * (p + (d : ℝ)))
                  * normPLapOf p (gradient φ y)
                      (fderiv ℝ (fderiv ℝ φ) y) + E
            ∧ |E| ≤ (H * ε * Real.sqrt
                  (2 * ε * ((H * ε ^ 2 + 2 * K * ε ^ 3) / g))
                + K * ε ^ 3) + Ka * ε ^ 3 := by
  -- the radius and the gradient lower bound
  obtain ⟨ρ, hρ, hgrad⟩ := grad_lower_uniform (hφ.of_le (by norm_num)) hx₀
  set g := ‖gradient φ x₀‖ / 2 with hgdef
  have hg : 0 < g := by
    have : 0 < ‖gradient φ x₀‖ := norm_pos_iff.2 hx₀
    rw [hgdef]; linarith
  -- the uniform constants, on the closed ball of radius ρ
  obtain ⟨K₀, hK₀⟩ := taylorErr_le_cubic_uniform hφ x₀ ρ
  obtain ⟨Ka₀, hKa₀⟩ := avgErr_uniform hφ x₀ ρ
  obtain ⟨H₀, hH₀⟩ := hess_bound_uniform hφ x₀ ρ
  set H := max H₀ 0 with hHdef
  set Ka := max Ka₀ 0 with hKadef
  have hHnn : 0 ≤ H := le_max_right _ _
  have hKann : 0 ≤ Ka := le_max_right _ _
  set K := max K₀ 0 with hKdef
  have hK : 0 ≤ K := le_max_right _ _
  have hKge : K₀ ≤ K := le_max_left _ _
  refine ⟨ρ, hρ, H, K, Ka, g, hg, hK, hHnn, hKann,
    fun y hy ε hε hερ => ?_⟩
  have hyc : y ∈ closedBall x₀ ρ := ball_subset_closedBall hy
  -- the gradient at the base point
  have hgy : g < ‖gradient φ y‖ := hgrad y hy
  have hxy : gradient φ y ≠ 0 := by
    intro h; rw [h, norm_zero] at hgy; linarith
  -- the Taylor error bound at the base point
  have hTerr : ∀ z : EuclSpace d, ‖z‖ ≤ ε →
      |taylorErr φ y z| ≤ K * ε ^ 3 := by
    intro z hz
    have hzρ : ‖z‖ ≤ ρ := le_trans hz hερ
    have h1 := hK₀ y hyc z hzρ
    have hz3 : ‖z‖ ^ 3 ≤ ε ^ 3 := by
      have h0 : (0:ℝ) ≤ ‖z‖ := norm_nonneg z
      exact pow_le_pow_left₀ h0 hz 3
    have hz3nn : (0:ℝ) ≤ ‖z‖ ^ 3 := by positivity
    nlinarith [h1, hz3, hKge, hK, hz3nn]
  -- the two halves
  have hHy : ‖fderiv ℝ (fderiv ℝ φ) y‖ ≤ H :=
    le_trans (hH₀ y hyc) (le_max_left _ _)
  have hext := ext_avg_err_abs hφ hxy hε hK hTerr hHy hg (le_of_lt hgy)
  have havg : |⨍ z in ball (0 : EuclSpace d) ε, taylorErr φ y z|
      ≤ Ka * ε ^ 3 := by
    have h := hKa₀ y hyc ε hε hερ
    have hε3 : (0:ℝ) ≤ ε ^ 3 := by positivity
    have : Ka₀ * ε ^ 3 ≤ Ka * ε ^ 3 :=
      mul_le_mul_of_nonneg_right (le_max_left _ _) hε3
    linarith [h, this]
  exact expansion_err_le hd hp hpd hφ hε hext havg
PLaplacian.eventually_bound_lePlaplacian/ErrSmall.lean, lines 75–89
/-- **The error is eventually small against the squared parameter.** -/
theorem eventually_bound_le {H K Ka g η : ℝ} (hη : 0 < η) :
    ∀ᶠ ε in nhdsWithin (0 : ℝ) (Set.Ioi 0),
      (H * ε * Real.sqrt (2 * ε * ((H * ε ^ 2 + 2 * K * ε ^ 3) / g))
          + K * ε ^ 3) + Ka * ε ^ 3 ≤ η * ε ^ 2 := by
  have hlt : ∀ᶠ ε in nhdsWithin (0 : ℝ) (Set.Ioi 0),
      errFactor H K Ka g ε < η :=
    (tendsto_errFactor H K Ka g).eventually (eventually_lt_nhds hη)
  have hpos : ∀ᶠ ε in nhdsWithin (0 : ℝ) (Set.Ioi 0), 0 < ε :=
    self_mem_nhdsWithin
  filter_upwards [hlt, hpos] with ε hq hε
  rw [bound_eq_sq_mul hε]
  have hε2 : (0:ℝ) ≤ ε ^ 2 := by positivity
  have := mul_le_mul_of_nonneg_left (le_of_lt hq) hε2
  linarith [this]
Proof sketch

The constants are chosen once, on a single ball, before the base point and the parameter; the order of the quantifiers in the statement is its content. The last assertion holds because the bound equals $\eps^2 q(\eps)$ with $q(\eps) = H\sqrt{2\eps(H + 2K\eps)/g} + (K + K_a)\eps$, continuous and vanishing at zero (bound_eq_sq_mul, tendsto_errFactor).

Theorem 4.6Regular case, subsolution✓ formalized
Formal statementgenerated from the Lean declaration
regular_subsol

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $F \colon \mathbb{R}^{d} \to \mathbb{R}$, $u \colon \mathbb{R} \to \mathbb{R}^{d} \to \mathbb{R}$, $C \in \mathbb{R}$, $\varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $B \in \mathbb{R}$, $x_{0} \in \mathbb{R}^{d}$, $r \in \mathbb{R}$.

Assume

  • $\mathbb{R}^{d}\text{ is nontrivial}$
  • $0 < d$ hd
  • $2 \le p$ hp
  • $0 < p + d$ hpd
  • $\forall \varepsilon, y,\ \lvert u_{\varepsilon}(y)\rvert \le C$ hC
  • $\forall \varepsilon > 0,\ u_{\varepsilon}\text{ is }p\text{-harmonious in }\Omega\text{ with step }\varepsilon\text{ and data }F$ hu
  • $\operatorname{ContDiff}(\mathbb{R}, 3, \varphi)$ hφ
  • $\varphi\text{ is admissible (bounded and Borel measurable)}$ hφb
  • $\forall y,\ \lvert \varphi(y)\rvert \le B$ hB
  • $0 < r$ hr
  • $\overline{B}(x_{0}, r) \subseteq \Omega$ hΩ
  • $\operatorname{IsStrictMaxOn}(w \mapsto \overline{u}(w) - \varphi(w), x_{0}, r)$ hstrict
  • $\operatorname{gradient}(\varphi, x_{0}) \ne 0$ hx₀

Then $0 \le \operatorname{normPLapOf}(p, \operatorname{gradient}(\varphi, x_{0}), \operatorname{fderiv}(\mathbb{R}, \operatorname{fderiv}(\mathbb{R}, \varphi), x_{0}))$.

Informal statementfrom the blueprint

Let $\overline{B}_r(x_0) \subseteq \Omega$, let $\varphi$ be bounded and of class $C^3$, let $\overline{u} - \varphi$ have a strict maximum at $x_0$ on $\overline{B}_r(x_0)$, and let $\nabla\varphi(x_0) \ne 0$. Then $\pnlap\varphi(x_0) \ge 0$.

Lean 1
/-- **The regular-case subsolution inequality.** -/
theorem regular_subsol [Nontrivial (EuclSpace d)] (hd : 0 < d)
    {p : ℝ} (hp : 2 ≤ p) (hpd : 0 < p + (d : ℝ))
    {Ω : Set (EuclSpace d)} {F : EuclSpace d → ℝ}
    {u : ℝ → EuclSpace d → ℝ} {C : ℝ} (hC : ∀ ε y, |u ε y| ≤ C)
    (hu : ∀ ε > 0, IsPHarmonious p ε Ω F (u ε))
    {φ : EuclSpace d → ℝ} (hφ : ContDiff ℝ 3 φ) (hφb : BddMeas φ)
    {B : ℝ} (hB : ∀ y, |φ y| ≤ B)
    {x₀ : EuclSpace d} {r : ℝ} (hr : 0 < r) (hΩ : closedBall x₀ r ⊆ Ω)
    (hstrict : IsStrictMaxOn (fun w => ubar u w - φ w) x₀ r)
    (hx₀ : gradient φ x₀ ≠ 0) :
    0 ≤ normPLapOf p (gradient φ x₀) (fderiv ℝ (fderiv ℝ φ) x₀) := by
  by_contra hneg
  push Not at hneg
  set N := fun y => normPLapOf p (gradient φ y) (fderiv ℝ (fderiv ℝ φ) y)
    with hNdef
  set γ := -N x₀ with hγdef
  have hγ : 0 < γ := by rw [hγdef]; linarith
  -- continuity keeps the operator below -γ/2 near the maximum
  have hcont := normPLapOf_continuousAt (p := p) (hφ.of_le (by norm_num)) hx₀
  have hev1 : ∀ᶠ y in nhds x₀, N y < -γ / 2 :=
    hcont.eventually (eventually_lt_nhds (by rw [hγdef]; linarith))
  rw [Metric.eventually_nhds_iff] at hev1
  obtain ⟨ρ₁, hρ₁, hN⟩ := hev1
  -- the uniform expansion
  obtain ⟨ρ₂, hρ₂, H, K, Ka, g, _hg, _hK, _hH, _hKa, hexp⟩ :=
    expansion_uniform hd hp hpd hφ hx₀
  set η := γ / (8 * (p + (d : ℝ))) with hηdef
  have hη : 0 < η := by rw [hηdef]; positivity
  -- the radius for the near-maximizer
  set ρ := min (min ρ₁ ρ₂) (r / 2) with hρdef
  have hρ : 0 < ρ := by
    rw [hρdef]; exact lt_min (lt_min hρ₁ hρ₂) (by linarith)
  -- the near-maximizer as a function of the parameter
  have hex : ∀ ε : ℝ, 0 < ε → ∃ z ∈ closedBall x₀ r,
      sSup ((fun w => u ε w - φ w) '' closedBall x₀ r) - ε ^ 3
        < u ε z - φ z :=
    fun ε hε => exists_near_sup_cube u hC hB x₀ hr hε
  choose! y hymem hynear using hex
  have hfreq := nearmax_frequently_in_ball u hC hφ.continuous hB hr hρ
    hstrict y (fun ε hε => ⟨hymem ε hε, hynear ε hε⟩)
  -- the eventual conditions on the parameter
  have hsmall := eventually_bound_le (H := H) (K := K) (Ka := Ka) (g := g) hη
  have hlt : ∀ {a : ℝ}, 0 < a →
      ∀ᶠ ε in nhdsWithin (0 : ℝ) (Set.Ioi 0), ε < a := by
    intro a ha
    exact Filter.mem_of_superset (Ioo_mem_nhdsGT ha) (fun x hx => hx.2)
  have hpos : ∀ᶠ ε in nhdsWithin (0 : ℝ) (Set.Ioi 0), 0 < ε :=
    self_mem_nhdsWithin
  have hev : ∀ᶠ ε in nhdsWithin (0 : ℝ) (Set.Ioi 0),
      ((H * ε * Real.sqrt (2 * ε * ((H * ε ^ 2 + 2 * K * ε ^ 3) / g))
          + K * ε ^ 3) + Ka * ε ^ 3 ≤ η * ε ^ 2)
      ∧ ε < r / 2 ∧ ε < ρ₂ ∧ ε < η ∧ 0 < ε :=
    hsmall.and ((hlt (by linarith : (0:ℝ) < r / 2)).and
      ((hlt hρ₂).and ((hlt hη).and hpos)))
  -- a parameter satisfying all of it
  obtain ⟨ε, hyball, hbd, hεr, hερ₂, hεη, hε⟩ :=
    (hfreq.and_eventually hev).exists
  -- the near-maximizer's position
  have hyρ : dist (y ε) x₀ < ρ := hyball
  have hy₁ : y ε ∈ ball x₀ ρ₁ := by
    rw [mem_ball]
    exact lt_of_lt_of_le hyρ (le_trans (min_le_left _ _) (min_le_left _ _))
  have hy₂ : y ε ∈ ball x₀ ρ₂ := by
    rw [mem_ball]
    exact lt_of_lt_of_le hyρ (le_trans (min_le_left _ _) (min_le_right _ _))
  have hyr : dist (y ε) x₀ < r / 2 :=
    lt_of_lt_of_le hyρ (min_le_right _ _)
  -- the expansion at the near-maximizer
  obtain ⟨E, hTeq, hEbd⟩ := hexp (y ε) hy₂ ε hε (le_of_lt hερ₂)
  -- the approximate comparison at the near-maximizer
  have hyΩ : y ε ∈ Ω := hΩ (hymem ε hε)
  have hle : ∀ w ∈ ball (y ε) ε,
      u ε w - φ w ≤ sSup ((fun w => u ε w - φ w) '' closedBall x₀ r) := by
    intro w hw
    have hwc : w ∈ closedBall x₀ r := by
      rw [mem_closedBall]
      rw [mem_ball] at hw
      have := dist_triangle w (y ε) x₀
      linarith
    exact le_sup_on_ball u hC hB x₀ w hwc
  have hcmp := dpp_comparison_approx hp hε hpd (hu ε hε) hφb hyΩ hle
    (le_of_lt (hynear ε hε))
  -- combine
  rw [hTeq] at hcmp
  have hNy : N (y ε) < -γ / 2 := hN hy₁
  have hc : 0 < ε ^ 2 / (2 * (p + (d : ℝ))) := by positivity
  have hε2 : 0 < ε ^ 2 := by positivity
  have hcγ : ε ^ 2 / (2 * (p + (d : ℝ))) * (γ / 2) = 2 * η * ε ^ 2 := by
    rw [hηdef]; field_simp; ring
  have h1 : ε ^ 2 / (2 * (p + (d : ℝ))) * N (y ε) < -(2 * η * ε ^ 2) := by
    have := mul_lt_mul_of_pos_left hNy hc
    linarith [this, hcγ]
  have h2 : E ≤ η * ε ^ 2 := le_trans (le_abs_self E) (le_trans hEbd hbd)
  have h3 : ε ^ 3 < η * ε ^ 2 := by
    have : ε * ε ^ 2 < η * ε ^ 2 := mul_lt_mul_of_pos_right hεη hε2
    nlinarith [this]
  have h4 : 0 ≤ ε ^ 2 / (2 * (p + (d : ℝ))) * N (y ε) + E + ε ^ 3 := by
    simp only [hNdef] at h1 ⊢
    linarith [hcmp]
  linarith [h1, h2, h3, h4]
Proof sketch

See the companion for the argument.

Theorem 4.7Regular case, supersolution✓ formalized
Formal statementgenerated from the Lean declaration
regular_supsol

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $F \colon \mathbb{R}^{d} \to \mathbb{R}$, $u \colon \mathbb{R} \to \mathbb{R}^{d} \to \mathbb{R}$, $C \in \mathbb{R}$, $\varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $B \in \mathbb{R}$, $x_{0} \in \mathbb{R}^{d}$, $r \in \mathbb{R}$.

Assume

  • $\mathbb{R}^{d}\text{ is nontrivial}$
  • $0 < d$ hd
  • $2 \le p$ hp
  • $0 < p + d$ hpd
  • $\forall \varepsilon, y,\ \lvert u_{\varepsilon}(y)\rvert \le C$ hC
  • $\forall \varepsilon > 0,\ u_{\varepsilon}\text{ is }p\text{-harmonious in }\Omega\text{ with step }\varepsilon\text{ and data }F$ hu
  • $\operatorname{ContDiff}(\mathbb{R}, 3, \varphi)$ hφ
  • $\varphi\text{ is admissible (bounded and Borel measurable)}$ hφb
  • $\forall y,\ \lvert \varphi(y)\rvert \le B$ hB
  • $0 < r$ hr
  • $\overline{B}(x_{0}, r) \subseteq \Omega$ hΩ
  • $\forall w \in \overline{B}(x_{0}, r),\ w \ne x_{0} \to \underline{u}(x_{0}) - \varphi(x_{0}) < \underline{u}(w) - \varphi(w)$ hmin
  • $\operatorname{gradient}(\varphi, x_{0}) \ne 0$ hx₀

Then $\operatorname{normPLapOf}(p, \operatorname{gradient}(\varphi, x_{0}), \operatorname{fderiv}(\mathbb{R}, \operatorname{fderiv}(\mathbb{R}, \varphi), x_{0})) \le 0$.

Informal statementfrom the blueprint

At a strict minimum of $\underline{u} - \varphi$, under the same hypotheses, $\pnlap\varphi(x_0) \le 0$.

Used byThm. 4.13
Lean 1
PLaplacian.regular_supsolPlaplacian/Super.lean, lines 66–100
/-- **The regular-case supersolution inequality.** -/
theorem regular_supsol [Nontrivial (EuclSpace d)] (hd : 0 < d)
    {p : ℝ} (hp : 2 ≤ p) (hpd : 0 < p + (d : ℝ))
    {Ω : Set (EuclSpace d)} {F : EuclSpace d → ℝ}
    {u : ℝ → EuclSpace d → ℝ} {C : ℝ} (hC : ∀ ε y, |u ε y| ≤ C)
    (hu : ∀ ε > 0, IsPHarmonious p ε Ω F (u ε))
    {φ : EuclSpace d → ℝ} (hφ : ContDiff ℝ 3 φ) (hφb : BddMeas φ)
    {B : ℝ} (hB : ∀ y, |φ y| ≤ B)
    {x₀ : EuclSpace d} {r : ℝ} (hr : 0 < r) (hΩ : closedBall x₀ r ⊆ Ω)
    (hmin : ∀ w ∈ closedBall x₀ r, w ≠ x₀ →
      lbar u x₀ - φ x₀ < lbar u w - φ w)
    (hx₀ : gradient φ x₀ ≠ 0) :
    normPLapOf p (gradient φ x₀) (fderiv ℝ (fderiv ℝ φ) x₀) ≤ 0 := by
  -- the negated family and test function
  have hCn : ∀ ε y, |(fun ε y => -u ε y) ε y| ≤ C := by
    intro ε y; simp only; rw [abs_neg]; exact hC ε y
  have hun : ∀ ε > 0, IsPHarmonious p ε Ω (fun y => -F y)
      ((fun ε y => -u ε y) ε) :=
    fun ε hε => isPHarmonious_neg (hu ε hε)
  have hBn : ∀ y, |(fun y => -φ y) y| ≤ B := by
    intro y; simp only; rw [abs_neg]; exact hB y
  -- the strict minimum becomes a strict maximum of the negations
  have hstrict : IsStrictMaxOn
      (fun w => ubar (fun ε y => -u ε y) w - (fun y => -φ y) w) x₀ r := by
    intro w hw hne
    have h1 := lbar_eq_neg_ubar_neg u w
    have h2 := lbar_eq_neg_ubar_neg u x₀
    have h3 := hmin w hw hne
    simp only
    linarith [h1, h2, h3]
  -- the subsolution inequality for the negations
  have h := regular_subsol hd hp hpd hCn hun (contDiff_neg' hφ)
    (bddMeas_neg hφb) hBn hr hΩ hstrict (gradient_neg_ne_zero hx₀)
  rw [normPLapOf_neg] at h
  linarith [h]
Proof sketch

This is obtained from Theorem Theorem 4.6 by transport, with no part of the argument repeated. The operator is odd, $\Op(-v) = -\Op v$ (tugOfWarOp_neg), the supremum and infimum exchanging under negation; so the negated family is $p$-harmonious with negated datum (isPHarmonious_neg). A strict minimum of $\underline{u} - \varphi$ is a strict maximum of $\overline{(-u)} - (-\varphi)$, and $\pnlap(-\varphi) = -\pnlap\varphi$ (normPLapOf_neg). Transport through negation was available for the operator because the operator happens to be odd; it is not available for the comparison of Theorem Theorem 4.2, which uses monotonicity in one direction only.

Theorem 4.8The reflection bound✓ formalized
Formal statementgenerated from the Lean declaration
reflect_boundparts shown as Lean code

Let $d \in \mathbb{N}$, $\varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $y \in \mathbb{R}^{d}$, $\varepsilon, K \in \mathbb{R}$.

Assume

  • $\operatorname{ContDiff}(\mathbb{R}, 3, \varphi)$ hφ
  • $0 < \varepsilon$ hε
  • $\forall z,\ \lVert z\rVert \le \varepsilon \to \lvert \operatorname{taylorErr}(\varphi, y, z)\rvert \le K \cdot \varepsilon ^{3}$ hTerr

Then there exists $z$ such that:

  • $\lVert z\rVert \le \varepsilon$
  • ( sSup ( φ '' Metric.closedBall y ε ) + sInf ( φ '' Metric.closedBall y ε ) ) / 2 ≤ φ y + 1 / 2 * ( ( fderiv ℝ ( fderiv ℝ φ ) y ) z ) z + K * ε ^ 3
Informal statementfrom the blueprint

If $\abs{E_y(z)} \le K\eps^3$ for $\abs{z} \le \eps$, there is $z$ with $\abs{z} \le \eps$ and \[ \tfrac12\Bigl(\sup_{\overline{B}_\eps(y)}\varphi + \inf_{\overline{B}_\eps(y)}\varphi\Bigr) \le \varphi(y) + \tfrac12 D^2\varphi(y)(z,z) + K\eps^3 . \]

Used byLem. 4.9
Lean 1
/-- **The reflection bound.** The average of the supremum and infimum over the
closed ball is at most the value plus half the Hessian on some increment of
norm at most `ε`, plus the Taylor error. -/
theorem reflect_bound {φ : EuclSpace d → ℝ} (hφ : ContDiff ℝ 3 φ)
    (y : EuclSpace d) {ε K : ℝ} (hε : 0 < ε)
    (hTerr : ∀ z : EuclSpace d, ‖z‖ ≤ ε → |taylorErr φ y z| ≤ K * ε ^ 3) :
    ∃ z : EuclSpace d, ‖z‖ ≤ ε ∧
      (sSup (φ '' closedBall y ε) + sInf (φ '' closedBall y ε)) / 2
        ≤ φ y + (1 / 2) * (fderiv ℝ (fderiv ℝ φ) y z) z + K * ε ^ 3 := by
  obtain ⟨w, hw, hsup⟩ := exists_sSup_closedBall hφ.continuous y hε
  set z := w - y with hzdef
  have hz : ‖z‖ ≤ ε := norm_sub_le_of_mem hw
  have hwz : w = y + z := by rw [hzdef]; abel
  -- the reflected point is in the ball, so the infimum is below its value
  have hmem : y + -z ∈ closedBall y ε := by
    rw [mem_closedBall, dist_eq_norm]
    have : y + -z - y = -z := by abel
    rw [this, norm_neg]; exact hz
  have hbdd : BddBelow (φ '' closedBall y ε) :=
    ((isCompact_closedBall y ε).image hφ.continuous).bddBelow
  have hinf : sInf (φ '' closedBall y ε) ≤ φ (y + -z) :=
    csInf_le hbdd ⟨y + -z, hmem, rfl⟩
  -- the two expansions
  have hplus := decomp_at φ y z
  have hminus := decomp_at φ y (-z)
  have hlin : fderiv ℝ φ y (-z) = - fderiv ℝ φ y z := map_neg _ _
  have hquad : (fderiv ℝ (fderiv ℝ φ) y (-z)) (-z)
      = (fderiv ℝ (fderiv ℝ φ) y z) z := by simp
  rw [hlin, hquad] at hminus
  -- the errors
  have he1 := (abs_le.1 (hTerr z hz)).2
  have he2 := (abs_le.1 (hTerr (-z) (by rw [norm_neg]; exact hz))).2
  refine ⟨z, hz, ?_⟩
  rw [hsup, hwz]
  linarith [hinf, hplus, hminus, he1, he2]
Proof sketch

No gradient enters. Bounding $D^2\varphi(y)(z,z) \le (\lambda_{\max}^+(X) + \eta)\,\eps^2$, with $\lambda^+ = \max(\lambda, 0)$, uses the quadratic bound $X(z,z) \le \lambda_{\max}(X)\abs{z}^2$ for every $z$ (quad_le_lamMax_norm) — the layer-two version covers only $\lambda_{\max} \ge 0$ and nonzero $z$, and the negative case is exactly where the argument lives — together with continuity of the Hessian in the operator norm, uniformly in the direction (hess_quad_cont). That continuity is unavailable for the curried Hessian; it is obtained by writing the difference of the two quadratic forms as the flat second derivative applied to $(z,z)$ (iteratedFDeriv_two_apply) and bounding it by that map's operator norm. Pushing through the comparison as in the regular case gives, in the limit, \[ 0 \le (p-2)\,\lambda_{\max}^+(X) + \Lambda(X). \] This involves $\lambda_{\max}^+$, not $\lambda_{\max}$, which is why the stronger bound fails — but it suffices.

Lemma 4.9Reflection at a critical point✓ formalized
Formal statementgenerated from the Lean declaration
reflect_neg_of_envelope_posparts shown as Lean code

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, X : EuclSpace d →L[ℝ] EuclSpace d →L[ℝ] ℝ.

Assume

  • $2 \le p$ _hp
  • $0 < d$ hd
  • $0 < \operatorname{viscFLower}(p, X)$ hpos

Then $(p - 2) \cdot \operatorname{max}(\operatorname{lamMax}(X), 0) + \operatorname{laplacianOf}(X) < 0$.

Informal statementfrom the blueprint

If $F_*(X) > 0$ then $(p-2)\lambda_{\max}^+(X) + \Lambda(X) < 0$.

Used byThm. 4.10
Lean 1
PLaplacian.reflect_neg_of_envelope_posPlaplacian/SingEigen.lean, lines 104–117
/-- **The reflection quantity is negative when the envelope is positive.** -/
theorem reflect_neg_of_envelope_pos {p : ℝ} (_hp : 2 ≤ p) (hd : 0 < d)
    {X : EuclSpace d →L[ℝ] EuclSpace d →L[ℝ] ℝ}
    (hpos : 0 < viscFLower p X) :
    (p - 2) * max (lamMax X) 0 + laplacianOf X < 0 := by
  unfold viscFLower at hpos
  by_cases h : 0 ≤ lamMax X
  · rw [max_eq_left h]; linarith
  · push Not at h
    rw [max_eq_right (le_of_lt h), mul_zero, zero_add]
    have htr := laplacianOf_le_lamMax X
    have hd' : (0:ℝ) < d := by exact_mod_cast hd
    have : (d : ℝ) * lamMax X < 0 := mul_neg_of_pos_of_neg hd' h
    linarith
Proof sketch

See the companion for the argument.

Theorem 4.10Singular case, subsolution✓ formalized
Formal statementgenerated from the Lean declaration
singular_subsol

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $F \colon \mathbb{R}^{d} \to \mathbb{R}$, $u \colon \mathbb{R} \to \mathbb{R}^{d} \to \mathbb{R}$, $C \in \mathbb{R}$, $\varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $B \in \mathbb{R}$, $x_{0} \in \mathbb{R}^{d}$, $r \in \mathbb{R}$.

Assume

  • $\mathbb{R}^{d}\text{ is nontrivial}$
  • $0 < d$ hd
  • $2 \le p$ hp
  • $0 < p + d$ hpd
  • $\forall \varepsilon, y,\ \lvert u_{\varepsilon}(y)\rvert \le C$ hC
  • $\forall \varepsilon > 0,\ u_{\varepsilon}\text{ is }p\text{-harmonious in }\Omega\text{ with step }\varepsilon\text{ and data }F$ hu
  • $\operatorname{ContDiff}(\mathbb{R}, 3, \varphi)$ hφ
  • $\varphi\text{ is admissible (bounded and Borel measurable)}$ hφb
  • $\forall y,\ \lvert \varphi(y)\rvert \le B$ hB
  • $0 < r$ hr
  • $\overline{B}(x_{0}, r) \subseteq \Omega$ hΩ
  • $\operatorname{IsStrictMaxOn}(w \mapsto \overline{u}(w) - \varphi(w), x_{0}, r)$ hstrict

Then $\operatorname{viscFLower}(p, \operatorname{hess}(\varphi, x_{0})) \le 0$.

Informal statementfrom the blueprint

Let $\overline{B}_r(x_0) \subseteq \Omega$, let $\varphi$ be bounded and of class $C^3$, and let $\overline{u} - \varphi$ have a strict maximum at $x_0$ on $\overline{B}_r(x_0)$. Then $F_*(D^2\varphi(x_0)) \le 0$.

Lean 1
/-- **The singular subsolution inequality.** At a strict maximum of the upper
relaxed limit minus a bounded `C³` test function, the lower envelope is
nonpositive. No condition on the gradient is needed. -/
theorem singular_subsol [Nontrivial (EuclSpace d)] (hd : 0 < d)
    {p : ℝ} (hp : 2 ≤ p) (hpd : 0 < p + (d : ℝ))
    {Ω : Set (EuclSpace d)} {F : EuclSpace d → ℝ}
    {u : ℝ → EuclSpace d → ℝ} {C : ℝ} (hC : ∀ ε y, |u ε y| ≤ C)
    (hu : ∀ ε > 0, IsPHarmonious p ε Ω F (u ε))
    {φ : EuclSpace d → ℝ} (hφ : ContDiff ℝ 3 φ) (hφb : BddMeas φ)
    {B : ℝ} (hB : ∀ y, |φ y| ≤ B)
    {x₀ : EuclSpace d} {r : ℝ} (hr : 0 < r) (hΩ : closedBall x₀ r ⊆ Ω)
    (hstrict : IsStrictMaxOn (fun w => ubar u w - φ w) x₀ r) :
    viscFLower p (hess φ x₀) ≤ 0 := by
  by_contra hneg
  push Not at hneg
  set X := fderiv ℝ (fderiv ℝ φ) x₀ with hXdef
  have hQ := reflect_neg_of_envelope_pos hp hd (X := X) hneg
  set lp := max (lamMax X) 0 with hlpdef
  set γ := -((p - 2) * lp + laplacianOf X) with hγdef
  have hγ : 0 < γ := by rw [hγdef]; linarith
  have hp0 : 0 < p := by linarith
  -- the Hessian, uniformly near the maximum
  obtain ⟨ρ₁, hρ₁, hhess⟩ :=
    hess_quad_cont hφ x₀ (by positivity : (0:ℝ) < γ / (4 * p))
  -- the Laplacian, near the maximum
  have hlapc := continuousAt_laplacianOf (hφ.of_le (by norm_num)) x₀
  have hev1 : ∀ᶠ y in nhds x₀,
      laplacianOf (fderiv ℝ (fderiv ℝ φ) y) < laplacianOf X + γ / 4 :=
    hlapc.eventually (eventually_lt_nhds (by linarith))
  rw [Metric.eventually_nhds_iff] at hev1
  obtain ⟨ρ₂, hρ₂, hlap⟩ := hev1
  -- the uniform Taylor and average constants
  obtain ⟨K₀, hK₀⟩ := taylorErr_le_cubic_uniform hφ x₀ r
  obtain ⟨Ka₀, hKa₀⟩ := avgErr_uniform hφ x₀ r
  set K := max K₀ 0 with hKdef
  set Ka := max Ka₀ 0 with hKadef
  have hK : 0 ≤ K := le_max_right _ _
  have hKa : 0 ≤ Ka := le_max_right _ _
  -- the weights
  set α := (p - 2) / (p + (d : ℝ)) with hαdef
  set β := ((d : ℝ) + 2) / (p + (d : ℝ)) with hβdef
  have hα : 0 ≤ α := by rw [hαdef]; exact div_nonneg (by linarith) hpd.le
  have hβ : 0 ≤ β := by rw [hβdef]; positivity
  set Cc := α * K + β * Ka + 1 with hCcdef
  have hCc : 0 < Cc := by rw [hCcdef]; positivity
  -- the radius for the near-maximizer
  set ρ := min (min ρ₁ ρ₂) (r / 2) with hρdef
  have hρ : 0 < ρ := by
    rw [hρdef]; exact lt_min (lt_min hρ₁ hρ₂) (by linarith)
  have hex : ∀ ε : ℝ, 0 < ε → ∃ z ∈ closedBall x₀ r,
      sSup ((fun w => u ε w - φ w) '' closedBall x₀ r) - ε ^ 3
        < u ε z - φ z :=
    fun ε hε => exists_near_sup_cube u hC hB x₀ hr hε
  choose! y hymem hynear using hex
  have hfreq := nearmax_frequently_in_ball u hC hφ.continuous hB hr hρ
    hstrict y (fun ε hε => ⟨hymem ε hε, hynear ε hε⟩)
  -- the eventual conditions
  have hlt : ∀ {a : ℝ}, 0 < a →
      ∀ᶠ ε in nhdsWithin (0 : ℝ) (Set.Ioi 0), ε < a := by
    intro a ha
    exact Filter.mem_of_superset (Ioo_mem_nhdsGT ha) (fun x hx => hx.2)
  have hpos : ∀ᶠ ε in nhdsWithin (0 : ℝ) (Set.Ioi 0), 0 < ε :=
    self_mem_nhdsWithin
  set τ := γ / (4 * (p + (d : ℝ)) * Cc) with hτdef
  have hτ : 0 < τ := by rw [hτdef]; positivity
  have hev : ∀ᶠ ε in nhdsWithin (0 : ℝ) (Set.Ioi 0),
      ε < r / 2 ∧ ε < τ ∧ 0 < ε :=
    (hlt (by linarith : (0:ℝ) < r / 2)).and ((hlt hτ).and hpos)
  obtain ⟨ε, hyball, hεr, hετ, hε⟩ := (hfreq.and_eventually hev).exists
  -- the near-maximizer's position
  have hyρ : dist (y ε) x₀ < ρ := hyball
  have hy₁ : y ε ∈ ball x₀ ρ₁ := by
    rw [mem_ball]
    exact lt_of_lt_of_le hyρ (le_trans (min_le_left _ _) (min_le_left _ _))
  have hy₂ : dist (y ε) x₀ < ρ₂ :=
    lt_of_lt_of_le hyρ (le_trans (min_le_left _ _) (min_le_right _ _))
  have hyr : dist (y ε) x₀ < r / 2 := lt_of_lt_of_le hyρ (min_le_right _ _)
  have hyc : y ε ∈ closedBall x₀ r := hymem ε hε
  have hεR : ε ≤ r := by linarith
  -- the Taylor error bound at the near-maximizer
  have hTerr : ∀ z : EuclSpace d, ‖z‖ ≤ ε →
      |taylorErr φ (y ε) z| ≤ K * ε ^ 3 := by
    intro z hz
    have h1 := hK₀ (y ε) hyc z (le_trans hz hεR)
    have hz3 : ‖z‖ ^ 3 ≤ ε ^ 3 := pow_le_pow_left₀ (norm_nonneg z) hz 3
    have hz3nn : (0:ℝ) ≤ ‖z‖ ^ 3 := by positivity
    have hA : K₀ * ‖z‖ ^ 3 ≤ K * ‖z‖ ^ 3 :=
      mul_le_mul_of_nonneg_right (le_max_left _ _) hz3nn
    have hB : K * ‖z‖ ^ 3 ≤ K * ε ^ 3 := mul_le_mul_of_nonneg_left hz3 hK
    linarith [h1, hA, hB]
  -- the reflection bound
  obtain ⟨z, hz, hrefl⟩ := reflect_bound hφ (y ε) hε hTerr
  -- the Hessian quadratic form, bounded by the eigenvalue part
  have hq1 := hhess (y ε) hy₁ z
  have hq2 := quad_le_lamMax_norm X z
  have hz2 : ‖z‖ ^ 2 ≤ ε ^ 2 := pow_le_pow_left₀ (norm_nonneg z) hz 2
  have hz2nn : (0:ℝ) ≤ ‖z‖ ^ 2 := by positivity
  have hlpge : lamMax X ≤ lp := le_max_left _ _
  have hlpnn : 0 ≤ lp := le_max_right _ _
  have hquad : (fderiv ℝ (fderiv ℝ φ) (y ε) z) z
      ≤ (lp + γ / (4 * p)) * ε ^ 2 := by
    have hA : lamMax X * ‖z‖ ^ 2 ≤ lp * ‖z‖ ^ 2 :=
      mul_le_mul_of_nonneg_right hlpge hz2nn
    have hB : lp * ‖z‖ ^ 2 ≤ lp * ε ^ 2 :=
      mul_le_mul_of_nonneg_left hz2 hlpnn
    have hC : γ / (4 * p) * ‖z‖ ^ 2 ≤ γ / (4 * p) * ε ^ 2 :=
      mul_le_mul_of_nonneg_left hz2 (by positivity)
    have hexp : (lp + γ / (4 * p)) * ε ^ 2
        = lp * ε ^ 2 + γ / (4 * p) * ε ^ 2 := by ring
    rw [hexp]
    linarith [hq1, hq2, hA, hB, hC]
  -- the extreme-value part over the open ball
  have hext : (sSup (φ '' ball (y ε) ε) + sInf (φ '' ball (y ε) ε)) / 2
      ≤ φ (y ε) + (1 / 2) * ((lp + γ / (4 * p)) * ε ^ 2) + K * ε ^ 3 := by
    rw [sSup_ball_eq_closedBall hφ.continuous (y ε) hε,
      sInf_ball_eq_closedBall hφ.continuous (y ε) hε]
    linarith [hrefl, hquad]
  -- the average part
  have havgeq := setAverage_expansion hd (hφ.of_le (by norm_num)) (y ε) hε
  have havgerr := (abs_le.1 (hKa₀ (y ε) hyc ε hε hεR)).2
  have hε3 : (0:ℝ) ≤ ε ^ 3 := by positivity
  have hKa3 : Ka₀ * ε ^ 3 ≤ Ka * ε ^ 3 :=
    mul_le_mul_of_nonneg_right (le_max_left _ _) hε3
  have hlapy := hlap hy₂
  have hε2 : 0 < ε ^ 2 := by positivity
  have hcoefA : (0:ℝ) ≤ ε ^ 2 / (2 * ((d : ℝ) + 2)) := by positivity
  have havg : (⨍ w in ball (y ε) ε, φ w)
      ≤ φ (y ε) + ε ^ 2 / (2 * ((d : ℝ) + 2)) * (laplacianOf X + γ / 4)
        + Ka * ε ^ 3 := by
    rw [havgeq]
    have : ε ^ 2 / (2 * ((d : ℝ) + 2)) * laplacianOf (hess φ (y ε))
        ≤ ε ^ 2 / (2 * ((d : ℝ) + 2)) * (laplacianOf X + γ / 4) :=
      mul_le_mul_of_nonneg_left (le_of_lt hlapy) hcoefA
    linarith [havgerr, hKa3]
  -- the comparison at the near-maximizer
  have hyΩ : y ε ∈ Ω := hΩ hyc
  have hle : ∀ w ∈ ball (y ε) ε,
      u ε w - φ w ≤ sSup ((fun w => u ε w - φ w) '' closedBall x₀ r) := by
    intro w hw
    have hwc : w ∈ closedBall x₀ r := by
      rw [mem_closedBall]
      rw [mem_ball] at hw
      have := dist_triangle w (y ε) x₀
      linarith
    exact le_sup_on_ball u hC hB x₀ w hwc
  have hcmp := dpp_comparison_approx hp hε hpd (hu ε hε) hφb hyΩ hle
    (le_of_lt (hynear ε hε))
  rw [tugOfWarOp_eq] at hcmp
  -- combine: the weights sum to one, and the bracket is at most -γ/2
  have hsum : α + β = 1 := by
    rw [hαdef, hβdef]; field_simp; ring
  have hc1 : α * ((1 / 2) * ((lp + γ / (4 * p)) * ε ^ 2))
      = ε ^ 2 / (2 * (p + (d : ℝ))) * ((p - 2) * (lp + γ / (4 * p))) := by
    rw [hαdef]; field_simp
  have hc2 : β * (ε ^ 2 / (2 * ((d : ℝ) + 2)) * (laplacianOf X + γ / 4))
      = ε ^ 2 / (2 * (p + (d : ℝ))) * (laplacianOf X + γ / 4) := by
    rw [hβdef]; field_simp
  have hbr : (p - 2) * (lp + γ / (4 * p)) + (laplacianOf X + γ / 4)
      ≤ -(γ / 2) := by
    have : (p - 2) * (γ / (4 * p)) ≤ γ / 4 := by
      have hpγ : (p - 2) * (γ / (4 * p)) ≤ p * (γ / (4 * p)) :=
        mul_le_mul_of_nonneg_right (by linarith) (by positivity)
      have : p * (γ / (4 * p)) = γ / 4 := by field_simp
      linarith
    have hexp : (p - 2) * (lp + γ / (4 * p))
        = (p - 2) * lp + (p - 2) * (γ / (4 * p)) := by ring
    rw [hexp]
    linarith [this, hγdef]
  have hc : 0 < ε ^ 2 / (2 * (p + (d : ℝ))) := by positivity
  have hfin : α * ((sSup (φ '' ball (y ε) ε) + sInf (φ '' ball (y ε) ε)) / 2)
      + β * (⨍ w in ball (y ε) ε, φ w)
      ≤ φ (y ε) + ε ^ 2 / (2 * (p + (d : ℝ))) * (-(γ / 2))
        + (α * K + β * Ka) * ε ^ 3 := by
    have h1 := mul_le_mul_of_nonneg_left hext hα
    have h2 := mul_le_mul_of_nonneg_left havg hβ
    have h3 := mul_le_mul_of_nonneg_left hbr (le_of_lt hc)
    have e1 : α * (φ (y ε) + (1 / 2) * ((lp + γ / (4 * p)) * ε ^ 2)
          + K * ε ^ 3)
        = α * φ (y ε) + α * ((1 / 2) * ((lp + γ / (4 * p)) * ε ^ 2))
          + α * K * ε ^ 3 := by ring
    have e2 : β * (φ (y ε) + ε ^ 2 / (2 * ((d : ℝ) + 2))
          * (laplacianOf X + γ / 4) + Ka * ε ^ 3)
        = β * φ (y ε) + β * (ε ^ 2 / (2 * ((d : ℝ) + 2))
          * (laplacianOf X + γ / 4)) + β * Ka * ε ^ 3 := by ring
    have e3 : ε ^ 2 / (2 * (p + (d : ℝ)))
          * ((p - 2) * (lp + γ / (4 * p)) + (laplacianOf X + γ / 4))
        = ε ^ 2 / (2 * (p + (d : ℝ))) * ((p - 2) * (lp + γ / (4 * p)))
          + ε ^ 2 / (2 * (p + (d : ℝ))) * (laplacianOf X + γ / 4) := by ring
    have e4 : α * φ (y ε) + β * φ (y ε) = φ (y ε) := by
      rw [← add_mul, hsum, one_mul]
    have e5 : (α * K + β * Ka) * ε ^ 3 = α * K * ε ^ 3 + β * Ka * ε ^ 3 := by
      ring
    rw [e1] at h1
    rw [e2] at h2
    rw [e3] at h3
    linarith [h1, h2, h3, hc1, hc2, e4, e5]
  -- the parameter is small enough that the cube does not compensate
  have hsmall : Cc * ε ^ 3 < ε ^ 2 / (2 * (p + (d : ℝ))) * (γ / 2) := by
    have hετ' : Cc * ε < γ / (4 * (p + (d : ℝ))) := by
      have := mul_lt_mul_of_pos_left hετ hCc
      rw [hτdef] at this
      have hval : Cc * (γ / (4 * (p + (d : ℝ)) * Cc))
          = γ / (4 * (p + (d : ℝ))) := by field_simp
      linarith
    have hval2 : ε ^ 2 / (2 * (p + (d : ℝ))) * (γ / 2)
        = ε ^ 2 * (γ / (4 * (p + (d : ℝ)))) := by field_simp; ring
    rw [hval2]
    have : Cc * ε ^ 3 = ε ^ 2 * (Cc * ε) := by ring
    rw [this]
    exact mul_lt_mul_of_pos_left hετ' hε2
  have hCcexp : Cc * ε ^ 3 = (α * K + β * Ka) * ε ^ 3 + ε ^ 3 := by
    rw [hCcdef]; ring
  have hneg : ε ^ 2 / (2 * (p + (d : ℝ))) * (-(γ / 2))
      = -(ε ^ 2 / (2 * (p + (d : ℝ))) * (γ / 2)) := by ring
  linarith [hcmp, hfin, hsmall, hCcexp, hneg]
Proof sketch

There is no hypothesis on the gradient. The inequality holds at every strict maximum, singular or not; at a regular point it is weaker than Theorem Theorem 4.6, since $\mathcal{I}_q(X) \le \lambda_{\max}(X)$.

Theorem 4.11Singular case, supersolution✓ formalized
Formal statementgenerated from the Lean declaration
singular_supsol

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $F \colon \mathbb{R}^{d} \to \mathbb{R}$, $u \colon \mathbb{R} \to \mathbb{R}^{d} \to \mathbb{R}$, $C \in \mathbb{R}$, $\varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $B \in \mathbb{R}$, $x_{0} \in \mathbb{R}^{d}$, $r \in \mathbb{R}$.

Assume

  • $\mathbb{R}^{d}\text{ is nontrivial}$
  • $0 < d$ hd
  • $2 \le p$ hp
  • $0 < p + d$ hpd
  • $\forall \varepsilon, y,\ \lvert u_{\varepsilon}(y)\rvert \le C$ hC
  • $\forall \varepsilon > 0,\ u_{\varepsilon}\text{ is }p\text{-harmonious in }\Omega\text{ with step }\varepsilon\text{ and data }F$ hu
  • $\operatorname{ContDiff}(\mathbb{R}, 3, \varphi)$ hφ
  • $\varphi\text{ is admissible (bounded and Borel measurable)}$ hφb
  • $\forall y,\ \lvert \varphi(y)\rvert \le B$ hB
  • $0 < r$ hr
  • $\overline{B}(x_{0}, r) \subseteq \Omega$ hΩ
  • $\forall w \in \overline{B}(x_{0}, r),\ w \ne x_{0} \to \underline{u}(x_{0}) - \varphi(x_{0}) < \underline{u}(w) - \varphi(w)$ hmin

Then $0 \le \operatorname{viscFUpper}(p, \operatorname{hess}(\varphi, x_{0}))$.

Informal statementfrom the blueprint

At a strict minimum of $\underline{u} - \varphi$, $F^*(D^2\varphi(x_0)) \ge 0$.

Used byThm. 4.13
Lean 1
/-- **The singular supersolution inequality**, by transport. -/
theorem singular_supsol [Nontrivial (EuclSpace d)] (hd : 0 < d)
    {p : ℝ} (hp : 2 ≤ p) (hpd : 0 < p + (d : ℝ))
    {Ω : Set (EuclSpace d)} {F : EuclSpace d → ℝ}
    {u : ℝ → EuclSpace d → ℝ} {C : ℝ} (hC : ∀ ε y, |u ε y| ≤ C)
    (hu : ∀ ε > 0, IsPHarmonious p ε Ω F (u ε))
    {φ : EuclSpace d → ℝ} (hφ : ContDiff ℝ 3 φ) (hφb : BddMeas φ)
    {B : ℝ} (hB : ∀ y, |φ y| ≤ B)
    {x₀ : EuclSpace d} {r : ℝ} (hr : 0 < r) (hΩ : closedBall x₀ r ⊆ Ω)
    (hmin : ∀ w ∈ closedBall x₀ r, w ≠ x₀ →
      lbar u x₀ - φ x₀ < lbar u w - φ w) :
    0 ≤ viscFUpper p (hess φ x₀) := by
  have hCn : ∀ ε y, |(fun ε y => -u ε y) ε y| ≤ C := by
    intro ε y; simp only; rw [abs_neg]; exact hC ε y
  have hun : ∀ ε > 0, IsPHarmonious p ε Ω (fun y => -F y)
      ((fun ε y => -u ε y) ε) :=
    fun ε hε => isPHarmonious_neg (hu ε hε)
  have hBn : ∀ y, |(fun y => -φ y) y| ≤ B := by
    intro y; simp only; rw [abs_neg]; exact hB y
  have hstrict : IsStrictMaxOn
      (fun w => ubar (fun ε y => -u ε y) w - (fun y => -φ y) w) x₀ r := by
    intro w hw hne
    have h1 := lbar_eq_neg_ubar_neg u w
    have h2 := lbar_eq_neg_ubar_neg u x₀
    have h3 := hmin w hw hne
    simp only
    linarith [h1, h2, h3]
  have h := singular_subsol hd hp hpd hCn hun (contDiff_neg' hφ)
    (bddMeas_neg hφb) hBn hr hΩ hstrict
  unfold viscFLower at h
  unfold viscFUpper
  rw [hess_eq_fderiv, hess_neg, laplacianOf_neg, lamMax_neg] at h
  rw [hess_eq_fderiv]
  linarith [h]
Proof sketch

By transport, using $\lambda_{\max}(-X) = -\lambda_{\min}(X)$ (lamMax_neg). The proof of Theorem Theorem 4.10 is the longest single declaration in the development, and its first version timed out.

Theorem 4.12Strict extrema✓ formalized
Formal statementgenerated from the Lean declaration
regularize

Let $d \in \mathbb{N}$, $V, \varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $x_{0} \in \mathbb{R}^{d}$, $R \in \mathbb{R}$.

Assume

  • $\operatorname{ContDiff}(\mathbb{R}, 3, \varphi)$ hφ
  • $\operatorname{IsLocalMax}(w \mapsto V(w) - \varphi(w), x_{0})$ hmax
  • $0 < R$ hR

Then there exists $\psi, r$ such that:

  • $0 < r$
  • $r \le R$
  • $\operatorname{ContDiff}(\mathbb{R}, 3, \psi)$
  • $\psi\text{ is admissible (bounded and Borel measurable)}$
  • $\exists B,\ \forall y,\ \lvert \psi(y)\rvert \le B$
  • $\operatorname{IsStrictMaxOn}(w \mapsto V(w) - \psi(w), x_{0}, r)$
  • $\operatorname{gradient}(\psi, x_{0}) = \operatorname{gradient}(\varphi, x_{0})$
  • $\operatorname{fderiv}(\mathbb{R}, \operatorname{fderiv}(\mathbb{R}, \psi), x_{0}) = \operatorname{fderiv}(\mathbb{R}, \operatorname{fderiv}(\mathbb{R}, \varphi), x_{0})$
Informal statementfrom the blueprint

Let $\varphi \in C^3$ and let $V - \varphi$ have a local maximum at $x_0$. For every $R > 0$ there are a bounded $\psi \in C^3$ and $0 < r \le R$ such that $V - \psi$ has a strict maximum at $x_0$ on $\overline{B}_r(x_0)$, $\nabla\psi(x_0) = \nabla\varphi(x_0)$ and $D^2\psi(x_0) = D^2\varphi(x_0)$.

Used byThm. 4.13
Lean 1
/-- **Regularization.** From a local maximum of `V - φ`, a bounded `C³` test
function with a strict maximum of `V - ψ` on a closed ball, agreeing with `φ`
to second order at the base point. -/
theorem regularize {V φ : EuclSpace d → ℝ} (hφ : ContDiff ℝ 3 φ)
    {x₀ : EuclSpace d} (hmax : IsLocalMax (fun w => V w - φ w) x₀)
    {R : ℝ} (hR : 0 < R) :
    ∃ ψ : EuclSpace d → ℝ, ∃ r : ℝ, 0 < r ∧ r ≤ R ∧
      ContDiff ℝ 3 ψ ∧ BddMeas ψ ∧ (∃ B, ∀ y, |ψ y| ≤ B) ∧
      IsStrictMaxOn (fun w => V w - ψ w) x₀ r ∧
      gradient ψ x₀ = gradient φ x₀ ∧
      fderiv ℝ (fderiv ℝ ψ) x₀ = fderiv ℝ (fderiv ℝ φ) x₀ := by
  -- the bump, the perturbed function, and the cut-off one
  let χ : ContDiffBump x₀ := ⟨R, 2 * R, hR, by linarith⟩
  set ψ0 : EuclSpace d → ℝ := fun w => φ w + quart x₀ w with hψ0def
  set ψ : EuclSpace d → ℝ := fun w => χ w * ψ0 w with hψdef
  have hψ0 : ContDiff ℝ 3 ψ0 := hφ.add (contDiff_quart x₀)
  have hψ : ContDiff ℝ 3 ψ := (χ.contDiff (n := 3)).mul hψ0
  -- the cut-off function agrees with the perturbed one on the inner ball
  have hagree : ∀ w ∈ closedBall x₀ R, ψ w = ψ0 w := by
    intro w hw
    have h1 : χ w = 1 := χ.one_of_mem_closedBall hw
    simp only [hψdef, h1, one_mul]
  have hev : ψ =ᶠ[𝓝 x₀] ψ0 := by
    filter_upwards [closedBall_mem_nhds x₀ hR] with w hw
    exact hagree w hw
  -- so their derivatives agree at the base point
  have hd1 : fderiv ℝ ψ x₀ = fderiv ℝ ψ0 x₀ := hev.fderiv_eq
  have hd2 : fderiv ℝ (fderiv ℝ ψ) x₀ = fderiv ℝ (fderiv ℝ ψ0) x₀ :=
    hev.fderiv.fderiv_eq
  -- and the perturbed function has the derivatives of the original
  have hφd : Differentiable ℝ φ := hφ.differentiable (by norm_num)
  have hqd : Differentiable ℝ (quart x₀) :=
    (contDiff_quart x₀ (n := 1)).differentiable (by norm_num)
  have hψ0d1 : fderiv ℝ ψ0 = fun w => fderiv ℝ φ w + fderiv ℝ (quart x₀) w := by
    funext w; exact fderiv_add (hφd w) (hqd w)
  have hfx : fderiv ℝ ψ0 x₀ = fderiv ℝ φ x₀ := by
    rw [hψ0d1]; simp only [fderiv_quart_self, add_zero]
  have hhx : fderiv ℝ (fderiv ℝ ψ0) x₀ = fderiv ℝ (fderiv ℝ φ) x₀ := by
    rw [hψ0d1]
    have hφd2 : Differentiable ℝ (fderiv ℝ φ) :=
      (hφ.fderiv_right (m := 1) (by norm_num)).differentiable (by norm_num)
    have hqd2 : Differentiable ℝ (fderiv ℝ (quart x₀)) :=
      ((contDiff_quart x₀ (n := 2)).fderiv_right (m := 1)
        (by norm_num)).differentiable (by norm_num)
    rw [show (fun w => fderiv ℝ φ w + fderiv ℝ (quart x₀) w)
        = fderiv ℝ φ + fderiv ℝ (quart x₀) from rfl,
      fderiv_add (hφd2 x₀) (hqd2 x₀), hess_quart_self, add_zero]
  have hgrad : gradient ψ x₀ = gradient φ x₀ := by
    unfold gradient; rw [hd1, hfx]
  -- boundedness, from compact support
  have hcs : HasCompactSupport ψ := χ.hasCompactSupport.mul_right
  obtain ⟨B, hB⟩ := hψ.continuous.bounded_above_of_compact_support hcs
  have hbd : ∀ y, |ψ y| ≤ B := fun y => by
    rw [← Real.norm_eq_abs]; exact hB y
  have hbm : BddMeas ψ := ⟨hψ.continuous.measurable, ⟨B, hbd⟩⟩
  -- the strict maximum
  obtain ⟨ρ, hρ, hloc⟩ := exists_radius_of_isLocalMax hmax
  set r := min (ρ / 2) R with hrdef
  have hr : 0 < r := lt_min (by linarith) hR
  have hrR : r ≤ R := min_le_right _ _
  refine ⟨ψ, r, hr, hrR, hψ, hbm, ⟨B, hbd⟩, ?_, hgrad, by rw [hd2, hhx]⟩
  intro w hw hne
  have hwR : w ∈ closedBall x₀ R := closedBall_subset_closedBall hrR hw
  have hwρ : w ∈ ball x₀ ρ := by
    rw [mem_ball]
    rw [mem_closedBall] at hw
    have := min_le_left (ρ / 2) R
    linarith
  have hψw : ψ w = φ w + quart x₀ w := hagree w hwR
  have hψx : ψ x₀ = φ x₀ := by
    rw [hagree x₀ (mem_closedBall_self hR.le)]
    simp only [hψ0def, quart_self, add_zero]
  have hlw := hloc w hwρ
  have hqp := quart_pos hne
  change V w - ψ w < V x₀ - ψ x₀
  rw [hψw, hψx]
  linarith
Proof sketch

The statement is for a generic $V$, so that it serves the supersolution through $V = \overline{(-u)}$. With it, the four core theorems extend to $C^3$ test functions at arbitrary local extrema; this is recorded as the predicates IsViscositySubsolution3 and IsViscositySupersolution3, identical to the layer-two ones except for the class of test function (ubar_isViscositySubsolution3, lbar_isViscositySupersolution3).

Theorem 4.13From C3 to C2 test functions✓ formalized
Formal statementgenerated from the Lean declaration
visc2_reg_sub

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $F \colon \mathbb{R}^{d} \to \mathbb{R}$, $u \colon \mathbb{R} \to \mathbb{R}^{d} \to \mathbb{R}$, $C \in \mathbb{R}$, $\varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $x_{0} \in \mathbb{R}^{d}$.

Assume

  • $\mathbb{R}^{d}\text{ is nontrivial}$
  • $0 < d$ hd
  • $2 \le p$ hp
  • $0 < p + d$ hpd
  • $\Omega\text{ is open}$ hΩ
  • $\forall \varepsilon, y,\ \lvert u_{\varepsilon}(y)\rvert \le C$ hC
  • $\forall \varepsilon > 0,\ u_{\varepsilon}\text{ is }p\text{-harmonious in }\Omega\text{ with step }\varepsilon\text{ and data }F$ hu
  • $\operatorname{ContDiff}(\mathbb{R}, 2, \varphi)$ hφ
  • $x_{0} \in \Omega$ hx₀
  • $\operatorname{IsLocalMax}(y \mapsto \overline{u}(y) - \varphi(y), x_{0})$ hmax
  • $\operatorname{gradient}(\varphi, x_{0}) \ne 0$ hg

Then $\operatorname{viscF}(p, \operatorname{gradient}(\varphi, x_{0}), \operatorname{hess}(\varphi, x_{0})) \le 0$.

visc2_sing_sub

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $F \colon \mathbb{R}^{d} \to \mathbb{R}$, $u \colon \mathbb{R} \to \mathbb{R}^{d} \to \mathbb{R}$, $C \in \mathbb{R}$, $\varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $x_{0} \in \mathbb{R}^{d}$.

Assume

  • $\mathbb{R}^{d}\text{ is nontrivial}$
  • $0 < d$ hd
  • $2 \le p$ hp
  • $0 < p + d$ hpd
  • $\Omega\text{ is open}$ hΩ
  • $\forall \varepsilon, y,\ \lvert u_{\varepsilon}(y)\rvert \le C$ hC
  • $\forall \varepsilon > 0,\ u_{\varepsilon}\text{ is }p\text{-harmonious in }\Omega\text{ with step }\varepsilon\text{ and data }F$ hu
  • $\operatorname{ContDiff}(\mathbb{R}, 2, \varphi)$ hφ
  • $x_{0} \in \Omega$ hx₀
  • $\operatorname{IsLocalMax}(y \mapsto \overline{u}(y) - \varphi(y), x_{0})$ hmax

Then $\operatorname{viscFLower}(p, \operatorname{hess}(\varphi, x_{0})) \le 0$.

visc2_reg_super

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $F \colon \mathbb{R}^{d} \to \mathbb{R}$, $u \colon \mathbb{R} \to \mathbb{R}^{d} \to \mathbb{R}$, $C \in \mathbb{R}$, $\varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $x_{0} \in \mathbb{R}^{d}$.

Assume

  • $\mathbb{R}^{d}\text{ is nontrivial}$
  • $0 < d$ hd
  • $2 \le p$ hp
  • $0 < p + d$ hpd
  • $\Omega\text{ is open}$ hΩ
  • $\forall \varepsilon, y,\ \lvert u_{\varepsilon}(y)\rvert \le C$ hC
  • $\forall \varepsilon > 0,\ u_{\varepsilon}\text{ is }p\text{-harmonious in }\Omega\text{ with step }\varepsilon\text{ and data }F$ hu
  • $\operatorname{ContDiff}(\mathbb{R}, 2, \varphi)$ hφ
  • $x_{0} \in \Omega$ hx₀
  • $\operatorname{IsLocalMin}(y \mapsto \underline{u}(y) - \varphi(y), x_{0})$ hmin
  • $\operatorname{gradient}(\varphi, x_{0}) \ne 0$ hg

Then $0 \le \operatorname{viscF}(p, \operatorname{gradient}(\varphi, x_{0}), \operatorname{hess}(\varphi, x_{0}))$.

visc2_sing_super

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $F \colon \mathbb{R}^{d} \to \mathbb{R}$, $u \colon \mathbb{R} \to \mathbb{R}^{d} \to \mathbb{R}$, $C \in \mathbb{R}$, $\varphi \colon \mathbb{R}^{d} \to \mathbb{R}$, $x_{0} \in \mathbb{R}^{d}$.

Assume

  • $\mathbb{R}^{d}\text{ is nontrivial}$
  • $0 < d$ hd
  • $2 \le p$ hp
  • $0 < p + d$ hpd
  • $\Omega\text{ is open}$ hΩ
  • $\forall \varepsilon, y,\ \lvert u_{\varepsilon}(y)\rvert \le C$ hC
  • $\forall \varepsilon > 0,\ u_{\varepsilon}\text{ is }p\text{-harmonious in }\Omega\text{ with step }\varepsilon\text{ and data }F$ hu
  • $\operatorname{ContDiff}(\mathbb{R}, 2, \varphi)$ hφ
  • $x_{0} \in \Omega$ hx₀
  • $\operatorname{IsLocalMin}(y \mapsto \underline{u}(y) - \varphi(y), x_{0})$ hmin

Then $0 \le \operatorname{viscFUpper}(p, \operatorname{hess}(\varphi, x_{0}))$.

Informal statementfrom the blueprint

The four fields of the layer-two predicates hold for $\overline{u}$ and $\underline{u}$ with $C^2$ test functions at local extrema.

Used byThm. 4.14
Lean 4
/-- **The regular subsolution field, for `C²` test functions.** -/
theorem visc2_reg_sub [Nontrivial (EuclSpace d)] (hd : 0 < d)
    {p : ℝ} (hp : 2 ≤ p) (hpd : 0 < p + (d : ℝ))
    {Ω : Set (EuclSpace d)} (hΩ : IsOpen Ω) {F : EuclSpace d → ℝ}
    {u : ℝ → EuclSpace d → ℝ} {C : ℝ} (hC : ∀ ε y, |u ε y| ≤ C)
    (hu : ∀ ε > 0, IsPHarmonious p ε Ω F (u ε))
    {φ : EuclSpace d → ℝ} (hφ : ContDiff ℝ 2 φ) {x₀ : EuclSpace d}
    (hx₀ : x₀ ∈ Ω) (hmax : IsLocalMax (fun y => ubar u y - φ y) x₀)
    (hg : gradient φ x₀ ≠ 0) :
    viscF p (gradient φ x₀) (hess φ x₀) ≤ 0 := by
  have key : ∀ η > 0, viscF p (gradient φ x₀) (hess φ x₀)
      ≤ 2 * η * ((d : ℝ) + p - 2) := by
    intro η hη
    have hgP : gradient (tPoly φ x₀ η) x₀ ≠ 0 := by
      rw [gradient_tPoly_self]; exact hg
    have h := visc_reg_sub hd hp hpd hΩ hC hu (contDiff_tPoly φ x₀ η) hx₀
      (localMax_tPoly hφ hmax hη) hgP
    rw [gradient_tPoly_self] at h
    rw [viscF_shift (X := hess φ x₀) (fun v => hess_tPoly_quad φ x₀ v η) hg] at h
    linarith
  exact nonpos_of_forall_le_mul (dim_pos hd hp) key
/-- **The singular subsolution field, for `C²` test functions.** -/
theorem visc2_sing_sub [Nontrivial (EuclSpace d)] (hd : 0 < d)
    {p : ℝ} (hp : 2 ≤ p) (hpd : 0 < p + (d : ℝ))
    {Ω : Set (EuclSpace d)} (hΩ : IsOpen Ω) {F : EuclSpace d → ℝ}
    {u : ℝ → EuclSpace d → ℝ} {C : ℝ} (hC : ∀ ε y, |u ε y| ≤ C)
    (hu : ∀ ε > 0, IsPHarmonious p ε Ω F (u ε))
    {φ : EuclSpace d → ℝ} (hφ : ContDiff ℝ 2 φ) {x₀ : EuclSpace d}
    (hx₀ : x₀ ∈ Ω) (hmax : IsLocalMax (fun y => ubar u y - φ y) x₀) :
    viscFLower p (hess φ x₀) ≤ 0 := by
  have key : ∀ η > 0, viscFLower p (hess φ x₀)
      ≤ 2 * η * ((d : ℝ) + p - 2) := by
    intro η hη
    have h := visc_sing_sub hd hp hpd hΩ hC hu (contDiff_tPoly φ x₀ η) hx₀
      (localMax_tPoly hφ hmax hη)
    rw [viscFLower_shift (X := hess φ x₀) hd
      (fun v => hess_tPoly_quad φ x₀ v η)] at h
    linarith
  exact nonpos_of_forall_le_mul (dim_pos hd hp) key
PLaplacian.visc2_reg_superPlaplacian/ViscC2.lean, lines 248–269
/-- **The regular supersolution field, for `C²` test functions.** -/
theorem visc2_reg_super [Nontrivial (EuclSpace d)] (hd : 0 < d)
    {p : ℝ} (hp : 2 ≤ p) (hpd : 0 < p + (d : ℝ))
    {Ω : Set (EuclSpace d)} (hΩ : IsOpen Ω) {F : EuclSpace d → ℝ}
    {u : ℝ → EuclSpace d → ℝ} {C : ℝ} (hC : ∀ ε y, |u ε y| ≤ C)
    (hu : ∀ ε > 0, IsPHarmonious p ε Ω F (u ε))
    {φ : EuclSpace d → ℝ} (hφ : ContDiff ℝ 2 φ) {x₀ : EuclSpace d}
    (hx₀ : x₀ ∈ Ω) (hmin : IsLocalMin (fun y => lbar u y - φ y) x₀)
    (hg : gradient φ x₀ ≠ 0) :
    0 ≤ viscF p (gradient φ x₀) (hess φ x₀) := by
  have key : ∀ η > 0, -viscF p (gradient φ x₀) (hess φ x₀)
      ≤ 2 * η * ((d : ℝ) + p - 2) := by
    intro η hη
    have hgP : gradient (tPoly φ x₀ (-η)) x₀ ≠ 0 := by
      rw [gradient_tPoly_self]; exact hg
    have h := visc_reg_super hd hp hpd hΩ hC hu (contDiff_tPoly φ x₀ (-η))
      hx₀ (localMin_tPoly hφ hmin hη) hgP
    rw [gradient_tPoly_self] at h
    rw [viscF_shift (X := hess φ x₀) (fun v => hess_tPoly_quad φ x₀ v (-η))
      hg] at h
    linarith
  linarith [nonpos_of_forall_le_mul (dim_pos hd hp) key]
PLaplacian.visc2_sing_superPlaplacian/ViscC2.lean, lines 271–288
/-- **The singular supersolution field, for `C²` test functions.** -/
theorem visc2_sing_super [Nontrivial (EuclSpace d)] (hd : 0 < d)
    {p : ℝ} (hp : 2 ≤ p) (hpd : 0 < p + (d : ℝ))
    {Ω : Set (EuclSpace d)} (hΩ : IsOpen Ω) {F : EuclSpace d → ℝ}
    {u : ℝ → EuclSpace d → ℝ} {C : ℝ} (hC : ∀ ε y, |u ε y| ≤ C)
    (hu : ∀ ε > 0, IsPHarmonious p ε Ω F (u ε))
    {φ : EuclSpace d → ℝ} (hφ : ContDiff ℝ 2 φ) {x₀ : EuclSpace d}
    (hx₀ : x₀ ∈ Ω) (hmin : IsLocalMin (fun y => lbar u y - φ y) x₀) :
    0 ≤ viscFUpper p (hess φ x₀) := by
  have key : ∀ η > 0, -viscFUpper p (hess φ x₀)
      ≤ 2 * η * ((d : ℝ) + p - 2) := by
    intro η hη
    have h := visc_sing_super hd hp hpd hΩ hC hu (contDiff_tPoly φ x₀ (-η))
      hx₀ (localMin_tPoly hφ hmin hη)
    rw [viscFUpper_shift (X := hess φ x₀) hd
      (fun v => hess_tPoly_quad φ x₀ v (-η))] at h
    linarith
  linarith [nonpos_of_forall_le_mul (dim_pos hd hp) key]
Proof sketch

See the companion for the argument.

Theorem 4.14The relaxed limits are viscosity solutions✓ formalized
Formal statementgenerated from the Lean declaration
ubar_isViscositySubsolution

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $F \colon \mathbb{R}^{d} \to \mathbb{R}$, $u \colon \mathbb{R} \to \mathbb{R}^{d} \to \mathbb{R}$, $C \in \mathbb{R}$.

Assume

  • $\mathbb{R}^{d}\text{ is nontrivial}$
  • $0 < d$ hd
  • $2 \le p$ hp
  • $0 < p + d$ hpd
  • $\Omega\text{ is open}$ hΩ
  • $\forall \varepsilon, y,\ \lvert u_{\varepsilon}(y)\rvert \le C$ hC
  • $\forall \varepsilon > 0,\ u_{\varepsilon}\text{ is }p\text{-harmonious in }\Omega\text{ with step }\varepsilon\text{ and data }F$ hu

Then $\overline{u}\text{ is a viscosity subsolution of }-\Delta_{p}^{\mathrm N} u = 0\text{ in }\Omega$.

lbar_isViscositySupersolution

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $F \colon \mathbb{R}^{d} \to \mathbb{R}$, $u \colon \mathbb{R} \to \mathbb{R}^{d} \to \mathbb{R}$, $C \in \mathbb{R}$.

Assume

  • $\mathbb{R}^{d}\text{ is nontrivial}$
  • $0 < d$ hd
  • $2 \le p$ hp
  • $0 < p + d$ hpd
  • $\Omega\text{ is open}$ hΩ
  • $\forall \varepsilon, y,\ \lvert u_{\varepsilon}(y)\rvert \le C$ hC
  • $\forall \varepsilon > 0,\ u_{\varepsilon}\text{ is }p\text{-harmonious in }\Omega\text{ with step }\varepsilon\text{ and data }F$ hu

Then $\underline{u}\text{ is a viscosity supersolution of }-\Delta_{p}^{\mathrm N} u = 0\text{ in }\Omega$.

Informal statementfrom the blueprint

Let $2 \le p < \infty$, $d \ge 1$, and let $\Omega \subseteq \R^d$ be open. Let $F$ be a boundary datum and $(u_\eps)$ a family of functions with $\abs{u_\eps} \le C$ uniformly, each $u_\eps$ being $p$-harmonious in $\Omega$ with datum $F$. Then $\overline{u}$ is a viscosity subsolution and $\underline{u}$ a viscosity supersolution of $-\pnlap u = 0$ in $\Omega$, in the sense of Definition Definition 2.1.

Used byThm. 7.4
Lean 2
PLaplacian.ubar_isViscositySubsolutionPlaplacian/ViscC2.lean, lines 290–302
/-- **The upper relaxed limit is a viscosity subsolution** of the homogeneous
normalized `p`-Laplace equation, in the sense of the layer-two predicate. -/
theorem ubar_isViscositySubsolution [Nontrivial (EuclSpace d)] (hd : 0 < d)
    {p : ℝ} (hp : 2 ≤ p) (hpd : 0 < p + (d : ℝ))
    {Ω : Set (EuclSpace d)} (hΩ : IsOpen Ω) {F : EuclSpace d → ℝ}
    {u : ℝ → EuclSpace d → ℝ} {C : ℝ} (hC : ∀ ε y, |u ε y| ≤ C)
    (hu : ∀ ε > 0, IsPHarmonious p ε Ω F (u ε)) :
    IsViscositySubsolution p Ω (fun _ => 0) (ubar u) :=
  ⟨(upperSemicontinuous_ubar u hC).upperSemicontinuousOn _,
   fun _φ hφ _x₀ hx₀ hmax hg =>
     visc2_reg_sub hd hp hpd hΩ hC hu hφ hx₀ hmax hg,
   fun _φ hφ _x₀ hx₀ hmax _ =>
     visc2_sing_sub hd hp hpd hΩ hC hu hφ hx₀ hmax⟩
PLaplacian.lbar_isViscositySupersolutionPlaplacian/ViscC2.lean, lines 304–316
/-- **The lower relaxed limit is a viscosity supersolution** of the homogeneous
normalized `p`-Laplace equation, in the sense of the layer-two predicate. -/
theorem lbar_isViscositySupersolution [Nontrivial (EuclSpace d)] (hd : 0 < d)
    {p : ℝ} (hp : 2 ≤ p) (hpd : 0 < p + (d : ℝ))
    {Ω : Set (EuclSpace d)} (hΩ : IsOpen Ω) {F : EuclSpace d → ℝ}
    {u : ℝ → EuclSpace d → ℝ} {C : ℝ} (hC : ∀ ε y, |u ε y| ≤ C)
    (hu : ∀ ε > 0, IsPHarmonious p ε Ω F (u ε)) :
    IsViscositySupersolution p Ω (fun _ => 0) (lbar u) :=
  ⟨(lowerSemicontinuous_lbar u hC).lowerSemicontinuousOn _,
   fun _φ hφ _x₀ hx₀ hmin hg =>
     visc2_reg_super hd hp hpd hΩ hC hu hφ hx₀ hmin hg,
   fun _φ hφ _x₀ hx₀ hmin _ =>
     visc2_sing_super hd hp hpd hΩ hC hu hφ hx₀ hmin⟩
Proof sketch

The theorem is stated against the layer-two predicates exactly as they were defined: $C^2$ test functions, arbitrary local extrema, and both the regular and the singular fields. No restricted class of test function remains in the statement. Neither boundedness of $\Omega$ nor any regularity of $F$ is used.

5. Alexandrov, Jensen, and strict comparison

Theorem 5.1Alexandrov's theorem✓ formalized
Formal statementgenerated from the Lean declaration
alexandrov

Let $d \in \mathbb{N}$.

Then $\operatorname{AlexandrovThm}(d)$.

Informal statementfrom the blueprint

A convex function $f\colon \R^d \to \R$ is twice differentiable in the sense of Peano at almost every point: for almost every $x$ there are $q \in \R^d$ and a bilinear form $X$ with \[ f(x + h) = f(x) + \langle q, h\rangle + \tfrac12 X(h, h) + o(|h|^2). \]

Lean 1
/-- **Alexandrov's theorem.** -/
theorem alexandrov : AlexandrovThm d := by
  intro f hf
  filter_upwards [ae_good hf] with x hx
  obtain ⟨y, hJy, hdiff, hdet, hp0⟩ := hx
  set B := fderiv ℝ (proxMap f) y with hB
  have hd : HasFDerivAt (proxMap f) B y := hdiff.hasFDerivAt
  obtain ⟨Binv, hinv, _⟩ := exists_inv_of_det hdet
  set A : EuclSpace d →L[ℝ] EuclSpace d := Binv - ContinuousLinearMap.id ℝ (EuclSpace d)
    with hA
  have hAapp : ∀ v, A v = Binv v - v := fun v => by
    rw [hA, sub_apply, ContinuousLinearMap.id_apply]
  -- the linear approximation, for the chosen subgradients
  have happrox : ∀ ε > 0, ∃ δ > 0, ∀ z, ‖z - x‖ < δ →
      ‖subgradSel f z - (y - x) - A (z - x)‖ ≤ ε * ‖z - x‖ := by
    intro ε hε
    obtain ⟨δ, hδ, hb⟩ := subgrad_linear_approx hf hJy hd hinv hp0 hε
    refine ⟨δ, hδ, fun z hz => ?_⟩
    rw [hAapp]
    exact hb z (subgradSel f z) hz (subgradSel_spec hf z)
  -- the expansion, and the jet
  have hexp := fun ε hε => peano_of_approx (subgradSel_spec hf) happrox (ε := ε) hε
  exact ⟨y - x, formOfMatrix (fun i j => inner ℝ (A (obasis d i)) (obasis d j)),
    twiceDiffAt_of_expansion (quad_formOfMatrix A) hexp⟩
Proof sketch

The proximal map. For each $y$ the function $x \mapsto f(x) + \tfrac12 |x - y|^2$ has a unique minimizer $J(y)$; the difference $y - J(y)$ is a subgradient at $J(y)$; conversely $J(x + p) = x$ whenever $p$ is a subgradient at $x$; and $J$ is one-Lipschitz (prox_exists, prox_unique, prox_subgrad, prox_of_subgrad, prox_lipschitz).

Theorem 5.2Jensen's lemma✓ formalized
Formal statementgenerated from the Lean declaration
jensen_positive_measureparts shown as Lean code

Let $n \in \mathbb{N}$, $W \colon \mathbb{R}^{n} \to \mathbb{R}$, $C \in \mathbb{R}$, $x_{0}, \mathrm{xs} \in \mathbb{R}^{n}$, $r, \delta \in \mathbb{R}$.

Assume

  • $0 \le C$ hC
  • ConvexOn ℝ Set.univ fun x => W x + C / 2 * ‖x‖ ^ 2 hconv
  • $0 < r$ hr
  • $0 < \delta$ hδ
  • $\mathrm{xs} \in \overline{B}(x_{0}, r)$ hxs
  • $\forall y,\ \lVert y - x_{0}\rVert = r \to W(y) + 2 \cdot \delta \cdot r < W(\mathrm{xs})$ hsphere

Then 0 < MeasureTheory.volume {x | x ∈ Metric.ball x₀ r ∧ ∃ p, ‖p‖ ≤ δ ∧ ∀ y ∈ Metric.closedBall x₀ r, W y + inner ℝ p y ≤ W x + inner ℝ p x}.

jensen

Let $d \in \mathbb{N}$.

Then $\operatorname{JensenLemma}(d)$.

Informal statementfrom the blueprint

Let $W\colon \R^n \to \R$ be such that $W + \tfrac C2 |\cdot|^2$ is convex, and suppose $W(y) + 2\delta r < W(x_s)$ whenever $|y - x_0| = r$, for some $x_s \in \overline B(x_0, r)$. Then the set of points of $B(x_0, r)$ at which some tilt $W + \langle p, \cdot\rangle$ with $|p| \le \delta$ attains its maximum over $\overline B(x_0, r)$ has positive measure.

Lean 2
PLaplacian.jensen_positive_measurePlaplacian/JensenEucl.lean, lines 85–311
/-- **Jensen's lemma on `ℝⁿ`** [CIL92, Lemma A.3], in the form of the
*Superposition* formalization. -/
theorem jensen_positive_measure {n : ℕ} (W : EuclSpace n → ℝ) (C : ℝ)
    (hC : 0 ≤ C) (hconv : ConvexOn ℝ Set.univ (fun x => W x + C / 2 * ‖x‖ ^ 2))
    (x₀ xs : EuclSpace n) (r δ : ℝ) (hr : 0 < r) (hδ : 0 < δ)
    (hxs : xs ∈ closedBall x₀ r)
    (hsphere : ∀ y, ‖y - x₀‖ = r → W y + 2 * δ * r < W xs) :
    0 < volume {x | x ∈ ball x₀ r ∧ ∃ p : EuclSpace n, ‖p‖ ≤ δ ∧
      ∀ y ∈ closedBall x₀ r, W y + inner ℝ p y ≤ W x + inner ℝ p x} := by
  set K := {x | x ∈ ball x₀ r ∧ ∃ p : EuclSpace n, ‖p‖ ≤ δ ∧
      ∀ y ∈ closedBall x₀ r, W y + inner ℝ p y ≤ W x + inner ℝ p x} with hKdef
  -- Step 1: continuity
  have hΦc : Continuous (fun x => W x + C / 2 * ‖x‖ ^ 2) := hconv.locallyLipschitz.continuous
  have hWc : Continuous W := by
    have := hΦc.sub ((continuous_const.mul (continuous_norm.pow 2)) :
      Continuous (fun x : EuclSpace n => C / 2 * ‖x‖ ^ 2))
    convert this using 1
    funext x
    simp
  -- subgradients of Φ and the map g
  have hsub := fun x => subgrad_exists hconv x
  choose Q hQ0 using hsub
  have hQ : ∀ x z, W x + C / 2 * ‖x‖ ^ 2 + inner ℝ (Q x) (z - x) ≤ W z + C / 2 * ‖z‖ ^ 2 :=
    fun x z => hQ0 x z
  let g : EuclSpace n → EuclSpace n := fun x => C • x - Q x
  -- Step 3: uniqueness of the witness
  have huniq : ∀ x ∈ ball x₀ r, ∀ p : EuclSpace n,
      (∀ y ∈ closedBall x₀ r, W y + inner ℝ p y ≤ W x + inner ℝ p x) → p = g x := by
    intro x hx p hp
    set v := Q x - (C • x - p) with hv
    have hxr : ‖x - x₀‖ < r := by rw [mem_ball, dist_eq_norm] at hx; exact hx
    set t : ℝ := min (1 / (2 * (C + 1))) ((r - ‖x - x₀‖) / (‖v‖ + 1)) with ht
    have ht0 : 0 < t := lt_min (by positivity) (div_pos (by linarith) (by positivity))
    have ht1 : t ≤ 1 / (2 * (C + 1)) := min_le_left _ _
    have ht2 : t ≤ (r - ‖x - x₀‖) / (‖v‖ + 1) := min_le_right _ _
    have hyB : x + t • v ∈ closedBall x₀ r := by
      rw [mem_closedBall, dist_eq_norm]
      have e : x + t • v - x₀ = (x - x₀) + t • v := by abel
      rw [e]
      refine (norm_add_le _ _).trans ?_
      rw [norm_smul, Real.norm_eq_abs, abs_of_pos ht0]
      have h1 : t * (‖v‖ + 1) ≤ r - ‖x - x₀‖ := (le_div_iff₀ (by positivity)).mp ht2
      nlinarith [norm_nonneg v]
    have hup := hp _ hyB
    have hlow := hQ x (x + t • v)
    simp only [add_sub_cancel_left] at hlow
    have hn : ‖x + t • v‖ ^ 2 = ‖x‖ ^ 2 + 2 * (t * inner ℝ x v) + t ^ 2 * ‖v‖ ^ 2 := by
      rw [norm_add_sq_real, norm_smul, real_inner_smul_right, mul_pow, Real.norm_eq_abs, sq_abs]
    rw [hn, real_inner_smul_right] at hlow
    rw [inner_add_right, real_inner_smul_right] at hup
    have hvv : ‖v‖ ^ 2 = inner ℝ (Q x) v - C * inner ℝ x v + inner ℝ p v := by
      rw [← real_inner_self_eq_norm_sq]
      conv_lhs => rw [hv]
      rw [inner_sub_left, inner_sub_left, real_inner_smul_left]
      ring
    have hCt : C * t ≤ 1 / 2 := by
      have : t * (2 * (C + 1)) ≤ 1 := (le_div_iff₀ (by positivity)).mp ht1
      nlinarith
    have htv := congrArg (fun z => t * z) hvv
    have key : t * (‖v‖ ^ 2 - C / 2 * t * ‖v‖ ^ 2) ≤ 0 := by
      have : t * (‖v‖ ^ 2 - C / 2 * t * ‖v‖ ^ 2)
          = t * ‖v‖ ^ 2 - C / 2 * (t ^ 2 * ‖v‖ ^ 2) := by ring
      rw [this]
      nlinarith
    have k2 : ‖v‖ ^ 2 - C / 2 * t * ‖v‖ ^ 2 ≤ 0 := by
      by_contra hk
      push Not at hk
      linarith [mul_pos ht0 hk]
    have k3 := mul_le_mul_of_nonneg_right hCt (sq_nonneg ‖v‖)
    have hv0 : ‖v‖ ^ 2 ≤ 0 := by nlinarith [sq_nonneg ‖v‖]
    have : v = 0 := by
      have := pow_eq_zero_iff (n := 2) (two_ne_zero) |>.mp (le_antisymm hv0 (sq_nonneg _))
      exact norm_eq_zero.mp this
    rw [hv] at this
    simp only [g]
    rw [sub_eq_zero] at this
    rw [this]; abel
  -- Step 2: every small p is attained
  have hattain : ∀ p : EuclSpace n, ‖p‖ ≤ δ → ∃ x ∈ K, g x = p := by
    intro p hp
    have hcont : ContinuousOn (fun x => W x + inner ℝ p x) (closedBall x₀ r) :=
      (hWc.add (continuous_const.inner continuous_id)).continuousOn
    obtain ⟨xp, hxpB, hxpmax⟩ := (isCompact_closedBall x₀ r).exists_isMaxOn
      ⟨x₀, mem_closedBall_self hr.le⟩ hcont
    have hmax : ∀ y ∈ closedBall x₀ r, W y + inner ℝ p y ≤ W xp + inner ℝ p xp :=
      fun y hy => hxpmax hy
    have hxpin : xp ∈ ball x₀ r := by
      rw [mem_ball, dist_eq_norm]
      rw [mem_closedBall, dist_eq_norm] at hxpB
      rcases hxpB.lt_or_eq with h | h
      · exact h
      · exfalso
        have h1 := hsphere xp h
        have h2 := hmax xs hxs
        rw [mem_closedBall, dist_eq_norm] at hxs
        have c1 : |inner ℝ p (xp - x₀)| ≤ δ * r := by
          refine (abs_real_inner_le_norm _ _).trans ?_
          rw [h]; exact mul_le_mul_of_nonneg_right hp hr.le
        have c2 : |inner ℝ p (xs - x₀)| ≤ δ * r :=
          (abs_real_inner_le_norm _ _).trans (mul_le_mul hp hxs (norm_nonneg _) hδ.le)
        rw [inner_sub_right] at c1 c2
        have := (abs_le.mp c1).2
        have := (abs_le.mp c2).1
        linarith
    refine ⟨xp, ⟨hxpin, p, hp, hmax⟩, (huniq xp hxpin p hmax).symm⟩
  -- (U): upper quadratic bound at points of K
  have hU : ∀ x ∈ K, ∀ y ∈ closedBall x₀ r,
      W y + C / 2 * ‖y‖ ^ 2 ≤ W x + C / 2 * ‖x‖ ^ 2 + inner ℝ (Q x) (y - x)
        + C / 2 * ‖y - x‖ ^ 2 := by
    intro x hx y hy
    obtain ⟨hxb, p, -, hwit⟩ := hx
    have hpg := huniq x hxb p hwit
    have h1 := hwit y hy
    rw [hpg] at h1
    have e1 : inner ℝ (g x) y - inner ℝ (g x) x
        = C * inner ℝ x (y - x) - inner ℝ (Q x) (y - x) := by
      rw [← inner_sub_right]
      simp only [g]
      rw [inner_sub_left, real_inner_smul_left]
    have e2 : ‖y‖ ^ 2 = ‖x‖ ^ 2 + 2 * inner ℝ x (y - x) + ‖y - x‖ ^ 2 := by
      have : y = x + (y - x) := by abel
      conv_lhs => rw [this]
      rw [norm_add_sq_real]
    rw [e2]
    nlinarith
  -- Step 4: local Lipschitz bound for g on K
  have hlip4 : ∀ θ > 0, ∀ x1 ∈ K, ∀ x2 ∈ K, ‖x1 - x₀‖ ≤ r - θ → ‖x2 - x₀‖ ≤ r - θ →
      ‖x1 - x2‖ ≤ θ / 2 → ‖g x1 - g x2‖ ≤ 3 * C * ‖x1 - x2‖ := by
    intro θ hθ x1 hx1 x2 hx2 h1 h2 hd
    set dd := ‖x1 - x2‖ with hddef
    set Δ := Q x2 - Q x1 with hΔ
    have hg : g x1 - g x2 = C • (x1 - x2) + Δ := by
      simp only [g, hΔ, smul_sub]; abel
    have hΔb : ‖Δ‖ ≤ 2 * C * dd := by
      rcases eq_or_ne Δ 0 with h0 | h0
      · rw [h0, norm_zero]; positivity
      have hΔpos : 0 < ‖Δ‖ := norm_pos_iff.mpr h0
      have hdpos : 0 < dd := by
        rcases (norm_nonneg (x1 - x2)).eq_or_lt with h | h
        · exfalso
          have : x1 = x2 := sub_eq_zero.mp (norm_eq_zero.mp h.symm)
          exact h0 (by rw [hΔ, this, sub_self])
        · exact h
      set t := 2 * dd with htdef
      set u := (t / ‖Δ‖) • Δ with hu
      have hun : ‖u‖ = t := by
        rw [hu, norm_smul, Real.norm_eq_abs, abs_of_nonneg (by positivity)]
        field_simp
      have hyB : x1 + u ∈ closedBall x₀ r := by
        rw [mem_closedBall, dist_eq_norm]
        have : x1 + u - x₀ = (x1 - x₀) + u := by abel
        rw [this]
        refine (norm_add_le _ _).trans ?_
        rw [hun]; linarith
      have L2 := hQ x2 (x1 + u)
      have U1 := hU x1 hx1 (x1 + u) hyB
      have L1 := hQ x1 x2
      have e1 : x1 + u - x2 = u + (x1 - x2) := by abel
      have e2 : x1 + u - x1 = u := by abel
      have e3 : x2 - x1 = -(x1 - x2) := by abel
      rw [e1, inner_add_right] at L2
      rw [e2, hun] at U1
      rw [e3, inner_neg_right] at L1
      have hΔu : inner ℝ (Q x2) u - inner ℝ (Q x1) u = t * ‖Δ‖ := by
        rw [← inner_sub_left, ← hΔ, hu, real_inner_smul_right, real_inner_self_eq_norm_sq]
        field_simp
      have hΔx : -(‖Δ‖ * dd) ≤ inner ℝ (Q x2) (x1 - x2) - inner ℝ (Q x1) (x1 - x2) := by
        rw [← inner_sub_left, ← hΔ]
        exact neg_le_of_abs_le (abs_real_inner_le_norm _ _)
      have key : dd * ‖Δ‖ ≤ dd * (2 * C * dd) := by
        rw [htdef] at hΔu U1
        nlinarith
      exact le_of_mul_le_mul_left key hdpos
    rw [hg]
    refine (norm_add_le _ _).trans ?_
    rw [norm_smul, Real.norm_eq_abs, abs_of_nonneg hC]
    linarith
  -- Step 5: conclusion
  rw [pos_iff_ne_zero]
  intro hK0
  obtain ⟨c, hc⟩ := TopologicalSpace.exists_dense_seq (EuclSpace n)
  let T : ℕ → ℕ → Set (EuclSpace n) := fun m j =>
    K ∩ closedBall x₀ (r - 1 / ((m : ℝ) + 1)) ∩ closedBall (c j) (1 / (4 * ((m : ℝ) + 1)))
  have hTK : ∀ m j, T m j ⊆ K := fun m j x hx => hx.1.1
  have hTlip : ∀ m j, LipschitzOnWith (⟨3 * C, by positivity⟩ : NNReal) g (T m j) := by
    intro m j
    refine LipschitzOnWith.of_dist_le_mul fun x1 hx1 x2 hx2 => ?_
    rw [dist_eq_norm, dist_eq_norm]
    change ‖g x1 - g x2‖ ≤ 3 * C * ‖x1 - x2‖
    have hm : (0 : ℝ) < 1 / ((m : ℝ) + 1) := by positivity
    refine hlip4 (1 / ((m : ℝ) + 1)) hm x1 hx1.1.1 x2 hx2.1.1 ?_ ?_ ?_
    · have := hx1.1.2; rwa [mem_closedBall, dist_eq_norm] at this
    · have := hx2.1.2; rwa [mem_closedBall, dist_eq_norm] at this
    · have a1 := hx1.2; have a2 := hx2.2
      rw [mem_closedBall, dist_eq_norm] at a1 a2
      have : x1 - x2 = (x1 - c j) - (x2 - c j) := by abel
      rw [this]
      refine (norm_sub_le _ _).trans ?_
      have e : 1 / ((m : ℝ) + 1) / 2
          = 1 / (4 * ((m : ℝ) + 1)) + 1 / (4 * ((m : ℝ) + 1)) := by
        field_simp; ring
      rw [e]; linarith
  have hcover : K ⊆ ⋃ m, ⋃ j, T m j := by
    intro x hx
    have hxr : dist x x₀ < r := hx.1
    obtain ⟨m, hm⟩ := exists_nat_one_div_lt (sub_pos.mpr hxr)
    have hpos : (0 : ℝ) < 1 / (4 * ((m : ℝ) + 1)) := by positivity
    obtain ⟨j, hj⟩ := hc.exists_dist_lt x hpos
    refine mem_iUnion.mpr ⟨m, mem_iUnion.mpr ⟨j, ⟨hx, ?_⟩, ?_⟩⟩
    · rw [mem_closedBall]; linarith
    · rw [mem_closedBall]; exact hj.le
  have hgK : volume (g '' K) = 0 := by
    have hsubset : g '' K ⊆ ⋃ m, ⋃ j, g '' T m j := by
      rintro _ ⟨x, hx, rfl⟩
      obtain ⟨m, hm⟩ := mem_iUnion.mp (hcover hx)
      obtain ⟨j, hj⟩ := mem_iUnion.mp hm
      exact mem_iUnion.mpr ⟨m, mem_iUnion.mpr ⟨j, x, hj, rfl⟩⟩
    refine measure_mono_null hsubset
      (measure_iUnion_null fun m => measure_iUnion_null fun j => ?_)
    exact lipschitzOn_image_null (hTlip m j) (measure_mono_null (hTK m j) hK0)
  have hball : closedBall (0 : EuclSpace n) δ ⊆ g '' K := by
    intro p hp
    rw [mem_closedBall, dist_zero_right] at hp
    obtain ⟨x, hxK, hgx⟩ := hattain p hp
    exact ⟨x, hxK, hgx⟩
  have := measure_mono_null hball hgK
  exact (Metric.measure_closedBall_pos volume (0 : EuclSpace n) hδ).ne' this
/-- **Jensen's lemma on the product.** -/
theorem jensen : JensenLemma d := by
  intro w lam hconv zh r hr hstrict δ hδ
  have hH : (volume : Measure (EuclSpace d × EuclSpace d)).IsAddHaarMeasure := by
    rw [Measure.volume_eq_prod]; infer_instance
  set Φ := Φsplit d with hΦdef
  set C := max lam 0 with hCdef
  have hC0 : 0 ≤ C := le_max_right _ _
  have hCl : 0 ≤ C - lam := sub_nonneg.2 (le_max_left _ _)
  set vh := Φ.symm zh with hvh
  have hΦvh : Φ vh = zh := Φ.apply_symm_apply zh
  set W : EuclideanSpace ℝ (Fin (d + d)) → ℝ := fun v => w (Φ v) with hWdef
  -- semiconvexity of W
  have hconvW : ConvexOn ℝ univ (fun v => W v + C / 2 * ‖v‖ ^ 2) := by
    refine ⟨convex_univ, fun a _ b _ s t hs ht hst => ?_⟩
    have h1 := hconv.2 (mem_univ (Φ a)) (mem_univ (Φ b)) hs ht hst
    simp only [smul_eq_mul] at h1 ⊢
    have hΦ : Φ (s • a + t • b) = s • Φ a + t • Φ b := by
      rw [map_add, map_smul, map_smul]
    have hn1 := Φsplit_norm_sq (s • a + t • b)
    have hna := Φsplit_norm_sq a
    have hnb := Φsplit_norm_sq b
    rw [← hΦdef, hΦ] at hn1
    rw [← hΦdef] at hna hnb
    rw [← hn1, ← hna, ← hnb] at h1
    have hsq := norm_sq_convex_comb hst a b
    have hab : 0 ≤ s * t * ‖a - b‖ ^ 2 := by positivity
    have hconvsq : ‖s • a + t • b‖ ^ 2 ≤ s * ‖a‖ ^ 2 + t * ‖b‖ ^ 2 := by linarith
    have h2 := mul_le_mul_of_nonneg_left hconvsq hCl
    simp only [hWdef]
    rw [hΦ]
    nlinarith
  have hWc : Continuous W := by
    have h1 := convex_continuous hconvW
    have h2 : Continuous (fun v : EuclideanSpace ℝ (Fin (d + d)) => C / 2 * ‖v‖ ^ 2) := by
      fun_prop
    convert h1.sub h2 using 1
    funext v
    simp
  -- the strict maximum on the Euclidean ball
  have hstrE : ∀ v ∈ closedBall vh r, v ≠ vh → W v < W vh := by
    intro v hv hne
    have hz : Φ v ∈ closedBall zh r := by
      rw [mem_closedBall, dist_eq_norm, ← hΦvh, ← map_sub]
      rw [mem_closedBall, dist_eq_norm] at hv
      exact (Φsplit_norm_le _).trans hv
    have hne' : Φ v ≠ zh := by
      intro h; apply hne
      rw [← hΦvh] at h
      exact Φ.injective h
    have := hstrict (Φ v) hz hne'
    simp only [hWdef, hΦvh]
    exact this
  -- the gap on the sphere
  obtain ⟨γ, hγ, hgap⟩ : ∃ γ > 0, ∀ y ∈ sphere vh r, W y ≤ W vh - γ := by
    by_cases hS : (sphere vh r).Nonempty
    · obtain ⟨y₀, hy₀, hmax⟩ := (isCompact_sphere vh r).exists_isMaxOn hS hWc.continuousOn
      have hy₀b : y₀ ∈ closedBall vh r := sphere_subset_closedBall hy₀
      have hy₀ne : y₀ ≠ vh := by
        intro h
        rw [h, mem_sphere, dist_self] at hy₀
        linarith
      have hlt := hstrE y₀ hy₀b hy₀ne
      exact ⟨W vh - W y₀, by linarith, fun y hy => by have h' : W y ≤ W y₀ := hmax hy; linarith⟩
    · refine ⟨1, one_pos, fun y hy => ?_⟩
      exact absurd ⟨y, hy⟩ hS
  set δ' := min δ (γ / (4 * r)) with hδ'def
  have hδ' : 0 < δ' := lt_min hδ (by positivity)
  have hδ'δ : δ' ≤ δ := min_le_left _ _
  have hsphere : ∀ y, ‖y - vh‖ = r → W y + 2 * δ' * r < W vh := by
    intro y hy
    have h1 := hgap y (by rw [mem_sphere, dist_eq_norm]; exact hy)
    have h2 : δ' ≤ γ / (4 * r) := min_le_right _ _
    have h3 : 2 * δ' * r ≤ γ / 2 := by
      have := mul_le_mul_of_nonneg_right h2 (by positivity : (0:ℝ) ≤ 2 * r)
      have e : γ / (4 * r) * (2 * r) = γ / 2 := by field_simp; ring
      nlinarith
    linarith
  -- Jensen's lemma on ℝ^{d+d}
  have hpos := jensen_positive_measure W C hC0 hconvW vh vh r δ' hr hδ'
    (mem_closedBall_self hr.le) hsphere
  set KE := {x | x ∈ ball vh r ∧ ∃ p : EuclSpace (d + d), ‖p‖ ≤ δ' ∧
      ∀ y ∈ closedBall vh r, W y + inner ℝ p y ≤ W x + inner ℝ p x} with hKE
  -- Φ maps it into the product Jensen set
  have hsub : Φ '' KE ⊆ {z ∈ ball zh r | ∃ p₁ p₂ : EuclSpace d, ‖p₁‖ ≤ δ ∧ ‖p₂‖ ≤ δ ∧
      IsLocalMax (fun z' => w z' + inner ℝ p₁ z'.1 + inner ℝ p₂ z'.2) z} := by
    rintro _ ⟨v, ⟨hvb, p, hp, hmaxv⟩, rfl⟩
    refine ⟨?_, (Φ p).1, (Φ p).2, ?_, ?_, ?_⟩
    · rw [mem_ball, dist_eq_norm, ← hΦvh, ← map_sub]
      rw [mem_ball, dist_eq_norm] at hvb
      exact lt_of_le_of_lt (Φsplit_norm_le _) hvb
    · exact ((Φsplit_fst_le p).trans hp).trans hδ'δ
    · exact ((Φsplit_snd_le p).trans hp).trans hδ'δ
    · unfold IsLocalMax IsMaxFilter
      have hnb : Φ.symm ⁻¹' (ball vh r) ∈ 𝓝 (Φ v) := by
        apply Φ.symm.continuous.continuousAt.preimage_mem_nhds
        rw [Φ.symm_apply_apply]
        exact isOpen_ball.mem_nhds hvb
      filter_upwards [hnb] with z' hz'
      have hz'b : Φ.symm z' ∈ closedBall vh r := ball_subset_closedBall hz'
      have h1 := hmaxv (Φ.symm z') hz'b
      simp only [hWdef, Φ.apply_symm_apply] at h1
      rw [Φsplit_inner p (Φ.symm z'), Φsplit_inner p v] at h1
      rw [← hΦdef, Φ.apply_symm_apply] at h1
      change w z' + inner ℝ (Φ p).1 z'.1 + inner ℝ (Φ p).2 z'.2
        ≤ w (Φ v) + inner ℝ (Φ p).1 (Φ v).1 + inner ℝ (Φ p).2 (Φ v).2
      linarith
  -- positive measure transfers
  refine lt_of_lt_of_le ?_ (measure_mono hsub)
  rw [pos_iff_ne_zero]
  intro h0
  have h1 := null_image_cle volume volume Φ.symm h0
  have e : Φ.symm '' (Φ '' KE) = KE := by
    rw [Set.image_image]; simp
  rw [e] at h1
  exact (ne_of_gt hpos) h1
Proof sketch

Let $Q(x)$ be a subgradient of $W + \tfrac C2|\cdot|^2$ at $x$ and $g(x) = Cx - Q(x)$. At a point of the set the tilt is forced, $p = g(x)$; every tilt of norm at most $\delta$ is attained, the maximum being kept off the sphere by the hypothesis, so $g$ maps the set onto a ball; and $g$ is Lipschitz, with constant $3C$, on the parts of the set away from the sphere, because there $W$ is squeezed between its semiconvex lower bound and the upper bound that the maximum provides. Were the set null, its image under $g$ would be null, being a countable union of Lipschitz images of null sets; but the image contains a ball.

Theorem 5.3The theorem of sums✓ formalized
Formal statementgenerated from the Lean declaration
theoremOfSums_of_regular

Let $d \in \mathbb{N}$.

Assume

  • $\operatorname{TheoremOfSumsRegular}(d)$ hreg

Then $\operatorname{TheoremOfSums}(d)$.

theoremOfSumsRegular_of

Let $d \in \mathbb{N}$.

Assume

  • $\operatorname{AlexandrovThm}(d)$ hA
  • $\operatorname{JensenLemma}(d)$ hJ

Then $\operatorname{TheoremOfSumsRegular}(d)$.

Informal statementfrom the blueprint

The theorem of sums in the form above holds on the diagonal outright, and off the diagonal by Alexandrov's theorem and Jensen's lemma (Theorems Theorem 5.1 and Theorem 5.2), both of which are proved.

Used byThm. 5.4
Lean 2
PLaplacian.theoremOfSums_of_regularPlaplacian/SumsSplit.lean, lines 113–127
/-- **The theorem of sums, from its regular half.** -/
theorem theoremOfSums_of_regular (hreg : TheoremOfSumsRegular d) :
    TheoremOfSums d := by
  intro u v hu hv hub hvb α hα xh yh hmax
  by_cases heq : xh = yh
  · -- on the diagonal: the zero forms
    subst heq
    refine ⟨0, 0, ?_, ?_, QuadLE.refl 0, fun _ => ⟨QuadLE.refl 0, QuadLE.refl 0⟩⟩
    · rw [penaltyGrad_self]
      exact superJet_subset_cl u xh (superJet_zero_of_diag hα hmax)
    · rw [penaltyGrad_self]
      exact subJet_subset_cl v xh (subJet_zero_of_diag hα hmax)
  · -- off the diagonal: the regular half
    obtain ⟨X, Y, hX, hY, hXY⟩ := hreg u v hu hv hub hvb α hα xh yh heq hmax
    exact ⟨X, Y, hX, hY, hXY, fun h => absurd h heq⟩
PLaplacian.theoremOfSumsRegular_ofPlaplacian/SumsFinal.lean, lines 193–326
/-- **The regular half of the theorem of sums**, from Alexandrov's theorem and
Jensen's lemma. -/
theorem theoremOfSumsRegular_of (hA : AlexandrovThm d) (hJ : JensenLemma d) :
    TheoremOfSumsRegular d := by
  intro u v hu hv hub hvb α hα xh yh _hne hmax
  set q := (‖xh - yh‖ ^ 2 / α) • (xh - yh) with hqdef
  obtain ⟨K, hK, hΨ⟩ := exists_K_strict hα hub hvb hmax
  have hK0 : 0 ≤ K := by have := norm_nonneg q; linarith
  set uT := uTilde u q xh K with huT
  set vT := vTilde v q yh K with hvT
  have hu0 : uT 0 = 0 := uTilde_zero
  have hv0 : vT 0 = 0 := vTilde_zero
  have huu : UpperSemicontinuous uT := usc_uTilde hu
  have hub' : BddAbove (range uT) := bddAbove_uTilde hK hub
  have hvv : UpperSemicontinuous (fun y => -vT y) := usc_neg_vTilde hv
  have hvb' : BddAbove (range (fun y => -vT y)) := bddAbove_neg_vTilde hK hvb
  set h0 := xh - yh with hh0
  set L := lamC α h0 with hLdef
  have hL : 0 < L := lamC_pos hα h0
  set U := supConv L uT with hUdef
  set N := supConv L (fun y => -vT y) with hNdef
  have hstrict := dblW0_conv_strict (h0 := h0) hα hu0 hv0 huu hub' hvv hvb' hΨ
  obtain ⟨hU0, hN0⟩ := supConv_zero (h0 := h0) hα hu0 hv0 hub' hvb' hΨ
  have hU0' : U 0 = 0 := hU0
  have hN0' : N 0 = 0 := hN0
  -- the core
  obtain ⟨ξs, ζs, as, bs, Xs, Ys, hsup, hsub, hξ, hζ, ha, hb, hle, hXl, hYu⟩ :=
    core_sequences (u := U) (v := fun ζ => -N ζ) hA hJ hL
      (semiconvex_uconv hα hub') (semiconvex_vconv hα hvb') zero_le_one
      (by norm_num) hα hstrict
  -- the maximizers, and the jets of ũ there
  have hxe : ∀ n, ∃ x, U (ξs n) = uT x - L / 2 * ‖x - ξs n‖ ^ 2 :=
    fun n => supConv_attained hL huu hub' (ξs n)
  choose xs hxs using hxe
  have hjU : ∀ n, (as n, Xs n) ∈ SuperJet uT (xs n) :=
    fun n => superJet_of_supConv hL.le hub' (hxs n) (hsup n)
  have hgU : ∀ n, as n = L • (xs n - ξs n) :=
    fun n => supConv_grad hL.le hub' (hxs n) (hsup n)
  -- the maximizers, and the jets of ṽ there
  have hye : ∀ n, ∃ y, N (ζs n) = -vT y - L / 2 * ‖y - ζs n‖ ^ 2 :=
    fun n => supConv_attained hL hvv hvb' (ζs n)
  choose ys hys using hye
  have hsupN : ∀ n, (-(bs n), -(Ys n)) ∈ SuperJet N (ζs n) :=
    fun n => superJet_congr (by funext y; simp) (superJet_neg_of_subJet (hsub n))
  have hjN : ∀ n, (-(bs n), -(Ys n)) ∈ SuperJet (fun y => -vT y) (ys n) :=
    fun n => superJet_of_supConv hL.le hvb' (hys n) (hsupN n)
  have hgN : ∀ n, -(bs n) = L • (ys n - ζs n) :=
    fun n => supConv_grad hL.le hvb' (hys n) (hsupN n)
  have hjV : ∀ n, (bs n, Ys n) ∈ SubJet vT (ys n) := by
    intro n
    have h1 := subJet_neg_of_superJet (hjN n)
    have eY : - -Ys n = Ys n := by ext x y; simp
    rw [neg_neg, eY] at h1
    exact subJet_congr (by funext y; simp) h1
  -- the maximizers converge
  have hdU : ∀ n, xs n - ξs n = L⁻¹ • as n := by
    intro n; rw [hgU n, smul_smul, inv_mul_cancel₀ hL.ne', one_smul]
  have hdV : ∀ n, ys n - ζs n = L⁻¹ • -(bs n) := by
    intro n; rw [hgN n, smul_smul, inv_mul_cancel₀ hL.ne', one_smul]
  have hxsT : Tendsto xs atTop (𝓝 0) := by
    have h1 : Tendsto (fun n => ξs n + L⁻¹ • as n) atTop (𝓝 (0 + L⁻¹ • 0)) :=
      hξ.add (ha.const_smul L⁻¹)
    rw [smul_zero, add_zero] at h1
    refine h1.congr (fun n => ?_)
    rw [← hdU n]; abel
  have hysT : Tendsto ys atTop (𝓝 0) := by
    have h1 : Tendsto (fun n => ζs n + L⁻¹ • -(bs n)) atTop (𝓝 (0 + L⁻¹ • -0)) :=
      hζ.add (hb.neg.const_smul L⁻¹)
    rw [neg_zero, smul_zero, add_zero] at h1
    refine h1.congr (fun n => ?_)
    rw [← hdV n]; abel
  -- the values converge
  have hUc : Continuous U := semiconvex_continuous (semiconvex_uconv (h0 := h0) hα hub')
  have hNc : Continuous N := semiconvex_continuous (semiconvex_supConv hL.le hvb')
  have hvalU : Tendsto (fun n => uT (xs n)) atTop (𝓝 0) := by
    have h1 : Tendsto (fun n => U (ξs n)) atTop (𝓝 0) := by
      have := (hUc.tendsto 0).comp hξ
      rw [hU0'] at this
      exact this
    have h2 : Tendsto (fun n => L / 2 * ‖L⁻¹ • as n‖ ^ 2) atTop (𝓝 0) := by
      have := (((ha.const_smul L⁻¹).norm).pow 2).const_mul (L / 2)
      simpa using this
    have h3 := h1.add h2
    rw [add_zero] at h3
    refine h3.congr (fun n => ?_)
    have := hxs n
    rw [hdU n] at this
    linarith
  have hvalV : Tendsto (fun n => vT (ys n)) atTop (𝓝 0) := by
    have h1 : Tendsto (fun n => N (ζs n)) atTop (𝓝 0) := by
      have := (hNc.tendsto 0).comp hζ
      rw [hN0'] at this
      exact this
    have h2 : Tendsto (fun n => L / 2 * ‖L⁻¹ • -(bs n)‖ ^ 2) atTop (𝓝 0) := by
      have := (((hb.neg.const_smul L⁻¹).norm).pow 2).const_mul (L / 2)
      simpa using this
    have h3 := (h1.add h2).neg
    rw [add_zero, neg_zero] at h3
    refine h3.congr (fun n => ?_)
    have := hys n
    rw [hdV n] at this
    linarith
  -- symmetrize, and bound the entries
  have habsX : ∀ n w, |(Xs n w) w| ≤ L * ‖w‖ ^ 2 := fun n w =>
    abs_le.2 ⟨by linarith [hXl n w], (hle n w).trans (hYu n w)⟩
  have habsY : ∀ n w, |(Ys n w) w| ≤ L * ‖w‖ ^ 2 := fun n w =>
    abs_le.2 ⟨by linarith [hXl n w, hle n w], hYu n w⟩
  have hjU' : ∀ n, (as n, symmForm (Xs n)) ∈ SuperJet uT (xs n) :=
    fun n => superJet_symmForm (hjU n)
  have hjV' : ∀ n, (bs n, symmForm (Ys n)) ∈ SubJet vT (ys n) :=
    fun n => subJet_symmForm (hjV n)
  -- two extractions
  obtain ⟨Xl, φ, hφ, hXconv⟩ := exists_subseq_form (fun n => symmForm (Xs n))
    (fun n i j => symmForm_entry_le hL.le (habsX n) i j)
  obtain ⟨Yl, ψ, hψ, hYconv⟩ := exists_subseq_form (fun n => symmForm (Ys (φ n)))
    (fun n i j => symmForm_entry_le hL.le (habsY (φ n)) i j)
  have hσ : StrictMono (fun n => φ (ψ n)) := hφ.comp hψ
  have hσT := hσ.tendsto_atTop
  have hXconv' : Tendsto (fun n => ‖symmForm (Xs (φ (ψ n))) - Xl‖) atTop (𝓝 0) :=
    hXconv.comp hψ.tendsto_atTop
  refine ⟨Xl, Yl, ?_, ?_, ?_⟩
  · -- the closed superjet of u
    exact clSuperJet_u_of hK0 (fun n => hjU' (φ (ψ n))) (hxsT.comp hσT)
      (ha.comp hσT) hXconv' (hvalU.comp hσT)
  · -- the closed subjet of v
    exact clSubJet_v_of hK0 (fun n => hjV' (φ (ψ n))) (hysT.comp hσT)
      (hb.comp hσT) hYconv (hvalV.comp hσT)
  · -- X ≤ Y in the limit
    intro w
    have h1 := tendsto_form_apply hXconv' w
    have h2 := tendsto_form_apply hYconv w
    refine le_of_tendsto_of_tendsto h1 h2 (Eventually.of_forall fun n => ?_)
    have := quadLE_symmForm (hle (φ (ψ n))) w
    exact this
Proof sketch

On the diagonal the zero forms are genuine jets. Off it the proof follows , with one simplification. After translating, absorbing the penalty gradient, and subtracting $K|\xi|^4$, which makes the maximum strict, global, and the functions bounded above for $K$ large (exists_K_strict), the penalty is bounded by its exact second-order expansion (penalty_expand), and Young's inequality decouples it so that sup- and inf-convolutions of the two functions, with parameter $\lambda = 8M + 1$, inherit the strict maximum (dblW0_conv_strict). Jensen's lemma gives maxima of small linear perturbations on a set of positive measure, Alexandrov's theorem makes both convolutions twice differentiable almost everywhere, and at a common point the second-order condition along the diagonal direction gives $X \le Y$ directly (core_diag). The magic property of sup-convolutions (Crandall–Ishii–Lions, Lemma A.5) carries the jets back to the maximizers, which converge because the gradients do (superJet_of_supConv, supConv_grad); symmetrizing and extracting in coordinates gives limit forms (exists_subseq_form); and the quartic, translation and gradient are added back (superJet_u_of_uTilde).

Theorem 5.4Comparison for strict subsolutions✓ formalized
Formal statementgenerated from the Lean declaration
comparison_strict_of_AJ

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $U, V \colon \mathbb{R}^{d} \to \mathbb{R}$, $c \in \mathbb{R}$, $x \in \mathbb{R}^{d}$.

Assume

  • $0 < d$ hd
  • $2 \le p$ hp
  • $\operatorname{AlexandrovThm}(d)$ hA
  • $\operatorname{JensenLemma}(d)$ hJ
  • $\Omega\text{ is open}$ hΩo
  • $\Omega\text{ is bounded}$ hΩb
  • $U\text{ is upper semicontinuous}$ hU
  • $V\text{ is lower semicontinuous}$ hV
  • $U\text{ is bounded above}$ hUb
  • $V\text{ is bounded below}$ hVb
  • $0 < c$ hc
  • $U\text{ is a viscosity subsolution of }-\Delta_{p}^{\mathrm N} u = x \mapsto - c\text{ in }\Omega$ hsub
  • $V\text{ is a viscosity supersolution of }-\Delta_{p}^{\mathrm N} u = 0\text{ in }\Omega$ hsup
  • $\forall x \in \partial \Omega,\ U(x) \le V(x)$ hbd
  • $x \in \Omega$ a._@._internal._hyg.0

Then $U(x) \le V(x)$.

comparison_strict_full

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $U, V \colon \mathbb{R}^{d} \to \mathbb{R}$, $c \in \mathbb{R}$, $x \in \mathbb{R}^{d}$.

Assume

  • $0 < d$ hd
  • $2 \le p$ hp
  • $\Omega\text{ is open}$ hΩo
  • $\Omega\text{ is bounded}$ hΩb
  • $U\text{ is upper semicontinuous}$ hU
  • $V\text{ is lower semicontinuous}$ hV
  • $U\text{ is bounded above}$ hUb
  • $V\text{ is bounded below}$ hVb
  • $0 < c$ hc
  • $U\text{ is a viscosity subsolution of }-\Delta_{p}^{\mathrm N} u = x \mapsto - c\text{ in }\Omega$ hsub
  • $V\text{ is a viscosity supersolution of }-\Delta_{p}^{\mathrm N} u = 0\text{ in }\Omega$ hsup
  • $\forall x \in \partial \Omega,\ U(x) \le V(x)$ hbd
  • $x \in \Omega$ a._@._internal._hyg.0

Then $U(x) \le V(x)$.

Informal statementfrom the blueprint

Assume Alexandrov's theorem and Jensen's lemma, in the forms AlexandrovThm and JensenLemma below. Let $\Omega \subseteq \R^d$ be bounded and open, $2 \le p$, and $c > 0$. Let $U$ be bounded above and upper semicontinuous, and a viscosity subsolution of $-\pnlap u = -c$ in $\Omega$; let $V$ be bounded below and lower semicontinuous, and a viscosity supersolution of $-\pnlap u = 0$ in $\Omega$. If $U \le V$ on $\partial\Omega$, then $U \le V$ in $\Omega$.

Lean 2
PLaplacian.comparison_strict_of_AJPlaplacian/SumsFinal.lean, lines 330–343
/-- **The comparison principle for strict subsolutions**, from Alexandrov's
theorem and Jensen's lemma. -/
theorem comparison_strict_of_AJ (hd : 0 < d) {p : ℝ} (hp : 2 ≤ p)
    (hA : AlexandrovThm d) (hJ : JensenLemma d) {Ω : Set (EuclSpace d)}
    (hΩo : IsOpen Ω) (hΩb : Bornology.IsBounded Ω) {U V : EuclSpace d → ℝ}
    (hU : UpperSemicontinuous U) (hV : LowerSemicontinuous V)
    (hUb : BddAbove (range U)) (hVb : BddBelow (range V))
    {c : ℝ} (hc : 0 < c)
    (hsub : IsViscositySubsolution p Ω (fun _ => -c) U)
    (hsup : IsViscositySupersolution p Ω (fun _ => 0) V)
    (hbd : ∀ x ∈ frontier Ω, U x ≤ V x) :
    ∀ x ∈ Ω, U x ≤ V x :=
  comparison_strict_of_regular hd hp (theoremOfSumsRegular_of hA hJ) hΩo hΩb hU hV
    hUb hVb hc hsub hsup hbd
PLaplacian.comparison_strict_fullPlaplacian/JensenProduct.lean, lines 187–199
/-- **The comparison principle for strict subsolutions** of the normalized
`p`-Laplace equation. -/
theorem comparison_strict_full (hd : 0 < d) {p : ℝ} (hp : 2 ≤ p)
    {Ω : Set (EuclSpace d)} (hΩo : IsOpen Ω) (hΩb : Bornology.IsBounded Ω)
    {U V : EuclSpace d → ℝ}
    (hU : UpperSemicontinuous U) (hV : LowerSemicontinuous V)
    (hUb : BddAbove (range U)) (hVb : BddBelow (range V))
    {c : ℝ} (hc : 0 < c)
    (hsub : IsViscositySubsolution p Ω (fun _ => -c) U)
    (hsup : IsViscositySupersolution p Ω (fun _ => 0) V)
    (hbd : ∀ x ∈ frontier Ω, U x ≤ V x) :
    ∀ x ∈ Ω, U x ≤ V x :=
  comparison_strict_of_J hd hp jensen hΩo hΩb hU hV hUb hVb hc hsub hsup hbd
Proof sketch

Alexandrov's theorem and Jensen's lemma are classical results of real analysis, not of the theory of viscosity solutions. They entered first as hypotheses, stated as propositions; both are now proved (Theorems Theorem 5.1 and Theorem 5.2), so the theorem holds outright (comparison_strict_full). The proof was organized so that each deep result was stated first and its consumer proved from it, which fixed every interface before the analysis it rests on.

6. The comparison principle

Theorem 6.1The strong maximum principle✓ formalized
Formal statementgenerated from the Lean declaration
smp_ball_jetparts shown as Lean code

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $u \colon \mathbb{R}^{d} \to \mathbb{R}$, $x \in \mathbb{R}^{d}$, $R \in \mathbb{R}$, $y \in \mathbb{R}^{d}$.

Assume

  • $0 < d$ hd
  • $2 \le p$ hp
  • $\operatorname{UpperSemicontinuousOn}(u, \Omega)$ husc
  • ∀ w ∈ Ω, ∀ (q : EuclSpace d) (X : PLaplacian.Bilin d), (q, X) ∈ PLaplacian.SuperJet u w → q ≠ 0 → PLaplacian.viscF p q X ≤ 0 hjetc
  • $0 < R$ hR
  • $B(x, R) \subseteq \Omega$ hball
  • $\forall y \in B(x, R),\ u(y) \le u(x)$ hmax
  • $y \in B(x, R / 3)$ a._@._internal._hyg.0

Then $u(y) = u(x)$.

smp_ball

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $u \colon \mathbb{R}^{d} \to \mathbb{R}$, $x \in \mathbb{R}^{d}$, $R \in \mathbb{R}$, $y \in \mathbb{R}^{d}$.

Assume

  • $0 < d$ hd
  • $2 \le p$ hp
  • $u\text{ is a viscosity subsolution of }-\Delta_{p}^{\mathrm N} u = 0\text{ in }\Omega$ hsub
  • $0 < R$ hR
  • $B(x, R) \subseteq \Omega$ hball
  • $\forall y \in B(x, R),\ u(y) \le u(x)$ hmax
  • $y \in B(x, R / 3)$ a._@._internal._hyg.0

Then $u(y) = u(x)$.

smp_ball_min

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $V \colon \mathbb{R}^{d} \to \mathbb{R}$, $x \in \mathbb{R}^{d}$, $R \in \mathbb{R}$, $y \in \mathbb{R}^{d}$.

Assume

  • $0 < d$ hd
  • $2 \le p$ hp
  • $V\text{ is a viscosity supersolution of }-\Delta_{p}^{\mathrm N} u = 0\text{ in }\Omega$ hsup
  • $0 < R$ hR
  • $B(x, R) \subseteq \Omega$ hball
  • $\forall y \in B(x, R),\ V(x) \le V(y)$ hmin
  • $y \in B(x, R / 3)$ a._@._internal._hyg.0

Then $V(y) = V(x)$.

Informal statementfrom the blueprint

Let $u$ be upper semicontinuous on $\Omega$, and suppose that every superjet $(q, X)$ of $u$ at a point of $\Omega$ with $q \ne 0$ satisfies $F(q, X) \le 0$. If $u \le u(x)$ on $B(x, R) \subseteq \Omega$, then $u \equiv u(x)$ on $B(x, R/3)$. In particular this holds for viscosity subsolutions of $-\pnlap u = 0$; and supersolutions satisfy the corresponding minimum principle, their negations being subsolutions (IsViscositySupersolution.neg).

Lean 3
/-- **The strong maximum principle on a ball**, for an upper semicontinuous
function whose superjets with nonzero gradient satisfy the subsolution
inequality. -/
theorem smp_ball_jet (hd : 0 < d) {p : ℝ} (hp : 2 ≤ p) {Ω : Set (EuclSpace d)}
    {u : EuclSpace d → ℝ} (husc : UpperSemicontinuousOn u Ω)
    (hjetc : ∀ w ∈ Ω, ∀ (q : EuclSpace d) (X : Bilin d), (q, X) ∈ SuperJet u w →
      q ≠ 0 → viscF p q X ≤ 0)
    {x : EuclSpace d} {R : ℝ} (hR : 0 < R) (hball : ball x R ⊆ Ω)
    (hmax : ∀ y ∈ ball x R, u y ≤ u x) :
    ∀ y ∈ ball x (R / 3), u y = u x := by
  intro y₀ hy₀
  by_contra hne
  set m := u x with hm
  have hy₀x : dist y₀ x < R / 3 := hy₀
  have hy₀R : y₀ ∈ ball x R := ball_subset_ball (by linarith) hy₀
  have hlt : u y₀ < m := lt_of_le_of_ne (hmax y₀ hy₀R) hne
  -- the ball K around y₀
  have hK : closedBall y₀ (R / 2) ⊆ ball x R := by
    intro y hy
    rw [mem_closedBall] at hy
    rw [mem_ball]
    calc dist y x ≤ dist y y₀ + dist y₀ x := dist_triangle _ _ _
      _ < R := by linarith
  -- the contact set
  set S := closedBall y₀ (R / 2) ∩ {y | m ≤ u y} with hSdef
  have hxS : x ∈ S :=
    ⟨by rw [mem_closedBall, dist_comm]; linarith, by change m ≤ u x; exact le_rfl⟩
  have hSc : IsClosed S := by
    rw [← closure_subset_iff_isClosed]
    intro y hy
    have hyK : y ∈ closedBall y₀ (R / 2) :=
      closure_minimal inter_subset_left isClosed_closedBall hy
    refine ⟨hyK, ?_⟩
    change m ≤ u y
    by_contra hcon
    push Not at hcon
    have hyΩ : y ∈ Ω := hball (hK hyK)
    have hev := husc y hyΩ m hcon
    rw [eventually_nhdsWithin_iff] at hev
    have hN : {y' | y' ∈ Ω → u y' < m} ∩ ball x R ∈ 𝓝 y :=
      inter_mem hev (isOpen_ball.mem_nhds (hK hyK))
    obtain ⟨z, ⟨hz1, hz2⟩, hzS⟩ := mem_closure_iff_nhds.1 hy _ hN
    have h1 : u z < m := hz1 (hball hz2)
    have h2 : m ≤ u z := hzS.2
    linarith
  have hScpt : IsCompact S :=
    (isCompact_closedBall y₀ (R / 2)).of_isClosed_subset hSc inter_subset_left
  have hSne : S.Nonempty := ⟨x, hxS⟩
  have hy₀S : y₀ ∉ S := fun h => by have : m ≤ u y₀ := h.2; linarith
  -- the nearest contact point
  set r := infDist y₀ S with hrdef
  have hr : 0 < r := (hSc.notMem_iff_infDist_pos hSne).1 hy₀S
  have hrx : r < R / 3 := by
    have := infDist_le_dist_of_mem (x := y₀) hxS
    linarith
  obtain ⟨z, hzS, hzd⟩ := hScpt.exists_infDist_eq_dist hSne y₀
  have hzr : dist z y₀ = r := by rw [dist_comm, ← hzd]
  have hin : ∀ y, dist y y₀ < r → u y < m := by
    intro y hy
    have hyK : y ∈ closedBall y₀ (R / 2) := by rw [mem_closedBall]; linarith
    by_contra hcon
    push Not at hcon
    have hyS : y ∈ S := ⟨hyK, hcon⟩
    have := infDist_le_dist_of_mem (x := y₀) hyS
    rw [dist_comm] at this
    linarith
  have huz : u z = m := le_antisymm (hmax z (hK hzS.1)) hzS.2
  -- the parameters
  have hd1 : (1 : ℝ) ≤ d := by exact_mod_cast hd
  have hdp : 0 < (d : ℝ) + p - 2 := by linarith
  set κ := (p - 1) / (12 * ((d : ℝ) + p - 2)) with hκdef
  have hκ0 : 0 < κ := div_pos (by linarith) (by positivity)
  have hκ12 : κ * (12 * ((d : ℝ) + p - 2)) = p - 1 := by
    rw [hκdef]; field_simp
  have hκ1 : κ ≤ 1 / 12 := by
    rw [hκdef, div_le_div_iff₀ (by positivity) (by norm_num)]
    linarith
  have hκr : κ * r ≤ r / 12 := by
    have := mul_le_mul_of_nonneg_right hκ1 hr.le
    linarith
  set θ := κ * r with hθ
  have hθ0 : 0 < θ := mul_pos hκ0 hr
  set B := r ^ 2 + κ * r ^ 2 with hB
  -- the gap on the inner ball
  have hCsub : closedBall y₀ (r - θ) ⊆ closedBall y₀ (R / 2) :=
    closedBall_subset_closedBall (by linarith)
  have hCΩ : closedBall y₀ (r - θ) ⊆ Ω := fun y hy => hball (hK (hCsub hy))
  obtain ⟨y₁, hy₁C, hy₁max⟩ := UpperSemicontinuousOn.exists_isMaxOn
    ⟨y₀, mem_closedBall_self (by linarith)⟩ (isCompact_closedBall y₀ (r - θ))
    (husc.mono hCΩ)
  have hy₁lt : u y₁ < m := hin y₁ (by rw [mem_closedBall] at hy₁C; linarith)
  set δ := m - u y₁ with hδ
  have hδ0 : 0 < δ := by linarith
  have hgapC : ∀ y ∈ closedBall y₀ (r - θ), u y ≤ m - δ := fun y hy => by
    have h' : u y ≤ u y₁ := hy₁max hy
    linarith
  -- ε
  set M₀ := 9 * κ ^ 2 * r ^ 4 with hM₀
  have hM₀0 : 0 ≤ M₀ := by positivity
  set ε := δ / (2 * (M₀ + 1)) with hεdef
  have hε0 : 0 < ε := by positivity
  have hεM : ε * M₀ ≤ δ / 2 := by
    rw [hεdef, div_mul_eq_mul_div, div_le_div_iff₀ (by positivity) (by norm_num)]
    have : 0 ≤ δ := hδ0.le
    linarith
  -- the barrier on the annulus and at z
  have hbar_le : ∀ y, r - θ ≤ dist y y₀ → dist y y₀ ≤ r → barrier y₀ B y ≤ M₀ := by
    intro y h1 h2
    unfold barrier
    rw [← dist_eq_norm]
    exact barrier_annulus_bound hr hκ0 hκ1 h1 h2
  have hbar_z : barrier y₀ B z = (κ * r ^ 2) ^ 2 := by
    unfold barrier
    rw [← dist_eq_norm, hzr, hB]
    ring
  -- the annulus
  set A := closedBall y₀ r ∩ {y | r - θ ≤ dist y y₀} with hAdef
  have hAc : IsCompact A :=
    (isCompact_closedBall y₀ r).inter_right
      (isClosed_le continuous_const (continuous_id.dist continuous_const))
  have hzA : z ∈ A := ⟨by rw [mem_closedBall, hzr], by
    change r - θ ≤ dist z y₀
    rw [hzr]; linarith⟩
  have hAΩ : A ⊆ Ω := fun y hy =>
    hball (hK (closedBall_subset_closedBall (by linarith) hy.1))
  -- the maximizer of g = u + ε φ
  set g : EuclSpace d → ℝ := fun y => u y + ε * barrier y₀ B y with hgdef
  have hgusc : UpperSemicontinuousOn g A := by
    have h1 := husc.mono hAΩ
    have h2 : Continuous (fun y => ε * barrier y₀ B y) := by
      unfold barrier; fun_prop
    exact h1.add (h2.upperSemicontinuous.upperSemicontinuousOn A)
  obtain ⟨w, hwA, hwmax⟩ := UpperSemicontinuousOn.exists_isMaxOn ⟨z, hzA⟩ hAc hgusc
  have hgz : g z = m + ε * (κ * r ^ 2) ^ 2 := by
    change u z + ε * barrier y₀ B z = _
    rw [huz, hbar_z]
  have hgw : g z ≤ g w := hwmax hzA
  have hwr : dist w y₀ ≤ r := by
    have := hwA.1
    rwa [mem_closedBall] at this
  -- w is not on the inner sphere
  have hwd : r - θ < dist w y₀ := by
    by_contra hcon
    push Not at hcon
    have hwC : w ∈ closedBall y₀ (r - θ) := by rw [mem_closedBall]; exact hcon
    have h1 := hgapC w hwC
    have h2 := hbar_le w hwA.2 hwr
    have h3 : g w ≤ m - δ + ε * M₀ := by
      change u w + ε * barrier y₀ B w ≤ _
      have := mul_le_mul_of_nonneg_left h2 hε0.le
      linarith
    have h4 : 0 ≤ ε * (κ * r ^ 2) ^ 2 := by positivity
    linarith
  -- w is a local maximum of g
  set ρ₀ := min (dist w y₀ - (r - θ)) (κ * r / 2) with hρ₀
  have hρ₀pos : 0 < ρ₀ := lt_min (by linarith) (by positivity)
  have hloc : ∀ᶠ y in 𝓝 w, u y + ε * barrier y₀ B y ≤ u w + ε * barrier y₀ B w := by
    filter_upwards [Metric.ball_mem_nhds w hρ₀pos] with y hy
    rw [mem_ball] at hy
    have hy1 : dist y w < dist w y₀ - (r - θ) := lt_of_lt_of_le hy (min_le_left _ _)
    have hy2 : dist y w < κ * r / 2 := lt_of_lt_of_le hy (min_le_right _ _)
    have hyd1 : r - θ < dist y y₀ := by
      have := dist_triangle w y y₀
      rw [dist_comm w y] at this
      linarith
    have hyd2 : dist y y₀ < r + κ * r / 2 := by
      have := dist_triangle y w y₀
      linarith
    by_cases hyr : dist y y₀ ≤ r
    · have hyA : y ∈ A := ⟨by rw [mem_closedBall]; exact hyr, hyd1.le⟩
      exact hwmax hyA
    · push Not at hyr
      have hyK : y ∈ closedBall y₀ (R / 2) := by
        rw [mem_closedBall]; linarith
      have huy : u y ≤ m := hmax y (hK hyK)
      have hby : barrier y₀ B y ≤ (κ * r ^ 2) ^ 2 := by
        unfold barrier
        rw [← dist_eq_norm]
        exact barrier_outside_bound hr hκ0 hκ1 hyr hyd2
      have h1 : u y + ε * barrier y₀ B y ≤ m + ε * (κ * r ^ 2) ^ 2 := by
        have := mul_le_mul_of_nonneg_left hby hε0.le
        linarith
      have h2 : g z ≤ u w + ε * barrier y₀ B w := hgw
      linarith
  -- the jet at w, and the contradiction
  have hwn : ‖w - y₀‖ = dist w y₀ := (dist_eq_norm w y₀).symm
  have hv0 : w - y₀ ≠ 0 := by
    intro h
    rw [h, norm_zero] at hwn
    linarith
  have hsr : ‖w - y₀‖ ^ 2 ≤ r ^ 2 := by
    rw [hwn, sq, sq]; exact mul_self_le_mul_self dist_nonneg hwr
  have hc : 0 < 4 * ε * (B - ‖w - y₀‖ ^ 2) := by
    have h1 : 0 < κ * r ^ 2 := mul_pos hκ0 (pow_pos hr 2)
    have : 0 < B - ‖w - y₀‖ ^ 2 := by rw [hB]; linarith
    positivity
  have hjet := superJet_barrier (u := u) (w := w) (y₀ := y₀) (B := B) hε0 hloc
  have hw : w ∈ Ω := hAΩ hwA
  have hq : (4 * ε * (B - ‖w - y₀‖ ^ 2)) • (w - y₀) ≠ 0 := smul_ne_zero hc.ne' hv0
  have hvisc := hjetc w hw _ _ hjet hq
  change _ ≤ (0 : ℝ) at hvisc
  rw [viscF_barrierJet hv0 hc] at hvisc
  -- the value is positive
  have hslo : (r - θ) ^ 2 ≤ ‖w - y₀‖ ^ 2 := by
    rw [hwn, sq, sq]; exact mul_self_le_mul_self (by linarith) hwd.le
  rw [hB] at hvisc
  set s := ‖w - y₀‖ ^ 2 with hs
  have hpos0 := smp_value_pos hp hdp hr hκ0 hκ1 hκ12 hslo
  have hpos := mul_pos hε0 hpos0
  have eq : -((4 * ε * (r ^ 2 + κ * r ^ 2 - s) * d - 8 * ε * s)
      + (p - 2) * (4 * ε * (r ^ 2 + κ * r ^ 2 - s) - 8 * ε * s))
      = ε * (8 * (p - 1) * s - 4 * (r ^ 2 + κ * r ^ 2 - s) * ((d : ℝ) + p - 2)) := by ring
  linarith
/-- **The strong maximum principle on a ball.** -/
theorem smp_ball (hd : 0 < d) {p : ℝ} (hp : 2 ≤ p) {Ω : Set (EuclSpace d)}
    {u : EuclSpace d → ℝ} (hsub : IsViscositySubsolution p Ω (fun _ => 0) u)
    {x : EuclSpace d} {R : ℝ} (hR : 0 < R) (hball : ball x R ⊆ Ω)
    (hmax : ∀ y ∈ ball x R, u y ≤ u x) :
    ∀ y ∈ ball x (R / 3), u y = u x :=
  smp_ball_jet hd hp hsub.usc (fun _ hw _ _ hj hq => superJet_regular hd hp hsub hw hj hq)
    hR hball hmax
/-- **The strong minimum principle on a ball.** -/
theorem smp_ball_min (hd : 0 < d) {p : ℝ} (hp : 2 ≤ p) {Ω : Set (EuclSpace d)}
    {V : EuclSpace d → ℝ} (hsup : IsViscositySupersolution p Ω (fun _ => 0) V)
    {x : EuclSpace d} {R : ℝ} (hR : 0 < R) (hball : ball x R ⊆ Ω)
    (hmin : ∀ y ∈ ball x R, V x ≤ V y) :
    ∀ y ∈ ball x (R / 3), V y = V x := by
  have key := smp_ball hd hp hsup.neg hR hball (fun y hy => neg_le_neg (hmin y hy))
  intro y hy
  exact neg_inj.1 (key y hy)
Proof sketch

Suppose $u(y_0) < m = u(x)$ near $x$, let $r$ be the distance from $y_0$ to the closed contact set $\{u = m\}$, and $z$ a nearest contact point. On a thin annulus about $y_0$ of outer radius $r$ the barrier $\varphi = (|\cdot - y_0|^2 - B)^2$, with $B$ slightly larger than $r^2$, has nonzero gradient, and a maximizer of $u + \eps\varphi$ over the annulus is a genuine local maximum. There the exact expansion of $\varphi$ turns the maximum into a superjet of $u$ (superJet_barrier), at which \[ F = \eps\bigl[\,8(p - 1)s - 4(B - s)(d + p - 2)\,\bigr] \ge \eps(p-1)r^2 > 0, \qquad s = |w - y_0|^2, \] (viscF_barrierJet), contradicting the hypothesis. The barrier is never differentiated, only the regular case of the predicates is used, and stating the hypothesis for jets lets the principle apply to sup-convolutions directly.

Theorem 6.2The change of values✓ formalized
Formal statementgenerated from the Lean declaration
peanoAt_cv

Let $d \in \mathbb{N}$, $V \colon \mathbb{R}^{d} \to \mathbb{R}$, $x, q \in \mathbb{R}^{d}$, $X \in \operatorname{Bilin}(d)$, $\eta \in \mathbb{R}$.

Assume

  • $\operatorname{PeanoAt}(V, x, q, X)$ h

Then $\operatorname{PeanoAt}(y \mapsto V(y) - \eta \cdot V(y) ^{2}, x, (1 - 2 \cdot \eta \cdot V(x)) \cdot q, (1 - 2 \cdot \eta \cdot V(x)) \cdot X - 2 \cdot \eta \cdot \operatorname{rankOne}(q))$.

normPLapOf_cv_strict

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $q \in \mathbb{R}^{d}$, $c, \eta \in \mathbb{R}$, $X \in \operatorname{Bilin}(d)$.

Assume

  • $2 \le p$ _hp
  • $q \ne 0$ hq
  • $0 < c$ hc
  • $0 \le \eta$ _hη
  • $\operatorname{normPLapOf}(p, q, X) \le 0$ hX

Then $\operatorname{normPLapOf}(p, c \cdot q, c \cdot X - 2 \cdot \eta \cdot \operatorname{rankOne}(q)) \le - (2 \cdot \eta \cdot (p - 1) \cdot \lVert q\rVert ^{2})$.

semiconcave_psiparts shown as Lean code

Let $d \in \mathbb{N}$, $V \colon \mathbb{R}^{d} \to \mathbb{R}$, $\mathrm{lam}, \eta, \mathrm{Cc} \in \mathbb{R}$.

Assume

  • $0 \le \mathrm{lam}$ hlam
  • $0 \le \eta$ hη
  • PLaplacian.SemiconvexWith lam fun y => -V y hV
  • $\forall y,\ 0 \le 1 - 2 \cdot \eta \cdot V(y)$ hc
  • $\forall y,\ 1 - 2 \cdot \eta \cdot V(y) \le \mathrm{Cc}$ hcC

Then PLaplacian.SemiconvexWith (Cc * lam) fun y => -(V y - η * V y ^ 2).

Informal statementfrom the blueprint

Let $\psi(s) = s - \eta s^2$ with $\eta > 0$. If $V$ has the Peano expansion $(q, X)$ at $x$, then $\psi \circ V$ has the expansion $(c q,\ cX - 2\eta\, q \otimes q)$, with $c = \psi'(V(x)) = 1 - 2\eta V(x)$; and if $\pnlap(q, X) \le 0$, $q \ne 0$ and $c > 0$, then \[ \pnlap\bigl(c q,\ cX - 2\eta\, q\otimes q\bigr) \le -2\eta(p - 1)\,|q|^2 . \] If $V$ is semiconcave and $0 \le \psi'(V) \le C_c$ everywhere, then $\psi \circ V$ is semiconcave.

Used byThm. 6.3
Lean 3
/-- **Composing an expansion with `ψ(s) = s - η s²`.** -/
theorem peanoAt_cv {V : EuclSpace d → ℝ} {x q : EuclSpace d} {X : Bilin d}
    (h : PeanoAt V x q X) (η : ℝ) :
    PeanoAt (fun y => V y - η * V y ^ 2) x ((1 - 2 * η * V x) • q)
      ((1 - 2 * η * V x) • X - (2 * η) • rankOne q) := by
  intro ε hε
  set c := 1 - 2 * η * V x with hc
  set K := ‖X‖ with hK
  set qn := ‖q‖ with hqn
  obtain ⟨δ₁, hδ₁, hb⟩ := h (min 1 (ε / (2 * (|c| + 1)))) (by positivity)
  refine ⟨min (min δ₁ 1) (ε / (2 * (|η| * ((K / 2 + 1) * (K / 2 + 1 + 2 * qn)) + 1))),
    by positivity, fun k hk => ?_⟩
  have hk1 : ‖k‖ < δ₁ := lt_of_lt_of_le hk (le_trans (min_le_left _ _) (min_le_left _ _))
  have hkle1 : ‖k‖ ≤ 1 := le_trans hk.le (le_trans (min_le_left _ _) (min_le_right _ _))
  have hk3 : ‖k‖ ≤ ε / (2 * (|η| * ((K / 2 + 1) * (K / 2 + 1 + 2 * qn)) + 1)) :=
    le_trans hk.le (min_le_right _ _)
  have he := hb k hk1
  -- the jet terms
  have hQ : inner ℝ (c • q) k = c * inner ℝ q k := real_inner_smul_left _ _ _
  have hR : ((c • X - (2 * η) • rankOne q) k) k
      = c * (X k) k - 2 * η * (inner ℝ q k * inner ℝ q k) := by
    rw [sub_apply, sub_apply, smul_apply, smul_apply, smul_apply, smul_apply, smul_eq_mul,
      smul_eq_mul, rankOne_apply]
  change |(V (x + k) - η * V (x + k) ^ 2) - (V x - η * V x ^ 2) - inner ℝ (c • q) k
    - 1 / 2 * ((c • X - (2 * η) • rankOne q) k) k| ≤ ε * ‖k‖ ^ 2
  rw [hQ, hR]
  have key : (V (x + k) - η * V (x + k) ^ 2) - (V x - η * V x ^ 2) - c * inner ℝ q k
      - 1 / 2 * (c * (X k) k - 2 * η * (inner ℝ q k * inner ℝ q k))
      = c * (V (x + k) - V x - inner ℝ q k - 1 / 2 * (X k) k)
        - η * ((V (x + k) - V x) ^ 2 - inner ℝ q k ^ 2) := by
    rw [hc]; ring
  rw [key]
  -- the bounds, in a small context
  have hQb : |1 / 2 * (X k) k| ≤ K / 2 * ‖k‖ ^ 2 := by
    have h1 : ‖(X k) k‖ ≤ ‖X‖ * ‖k‖ * ‖k‖ := X.le_opNorm₂ k k
    rw [Real.norm_eq_abs] at h1
    rw [abs_mul, abs_of_pos (by norm_num : (0 : ℝ) < 1 / 2), hK]
    nlinarith
  have hLb : |inner ℝ q k| ≤ qn * ‖k‖ := abs_real_inner_le_norm q k
  have e2 : V (x + k) - V x - inner ℝ q k - 1 / 2 * (X k) k
      = (V (x + k) - V x) - inner ℝ q k - 1 / 2 * (X k) k := rfl
  exact cv_arith hε (norm_nonneg k) hkle1 (norm_nonneg X) (norm_nonneg q) he hQb hLb hk3
PLaplacian.normPLapOf_cv_strictPlaplacian/CVJet.lean, lines 80–86
/-- **Strictness away from critical points.** -/
theorem normPLapOf_cv_strict {p : ℝ} (_hp : 2 ≤ p) {q : EuclSpace d} (hq : q ≠ 0)
    {c η : ℝ} (hc : 0 < c) (_hη : 0 ≤ η) {X : Bilin d} (hX : normPLapOf p q X ≤ 0) :
    normPLapOf p (c • q) (c • X - (2 * η) • rankOne q) ≤ -(2 * η * (p - 1) * ‖q‖ ^ 2) := by
  rw [normPLapOf_cv_sub hq hc]
  have : c * normPLapOf p q X ≤ 0 := mul_nonpos_of_nonneg_of_nonpos hc.le hX
  nlinarith
PLaplacian.semiconcave_psiPlaplacian/PsiSemi.lean, lines 68–90
/-- **`V - η V²` is semiconcave.** -/
theorem semiconcave_psi {V : EuclSpace d → ℝ} {lam η Cc : ℝ} (hlam : 0 ≤ lam) (hη : 0 ≤ η)
    (hV : SemiconvexWith lam (fun y => -V y))
    (hc : ∀ y, 0 ≤ 1 - 2 * η * V y) (hcC : ∀ y, 1 - 2 * η * V y ≤ Cc) :
    SemiconvexWith (Cc * lam) (fun y => -(V y - η * V y ^ 2)) := by
  apply semiconvex_of_supports
  intro x
  obtain ⟨P, hP⟩ := semiconvex_support hV x
  refine ⟨(1 - 2 * η * V x) • P, fun y => ?_⟩
  have h1 : -V x + inner ℝ P (y - x) - lam / 2 * ‖y - x‖ ^ 2 ≤ -V y := hP y
  have hc0 := hc x
  have hcx := hcC x
  -- ψ(V y) - ψ(V x) ≤ ψ'(V x)(V y - V x)
  have hψ : (V y - η * V y ^ 2) - (V x - η * V x ^ 2)
      = (1 - 2 * η * V x) * (V y - V x) - η * (V y - V x) ^ 2 := by ring
  have hsq : 0 ≤ η * (V y - V x) ^ 2 := by positivity
  have hcV : (1 - 2 * η * V x) * (V y - V x)
      ≤ (1 - 2 * η * V x) * (-inner ℝ P (y - x) + lam / 2 * ‖y - x‖ ^ 2) :=
    mul_le_mul_of_nonneg_left (by linarith) hc0
  have hlamC : (1 - 2 * η * V x) * (lam / 2 * ‖y - x‖ ^ 2) ≤ Cc * (lam / 2 * ‖y - x‖ ^ 2) :=
    mul_le_mul_of_nonneg_right hcx (by positivity)
  rw [real_inner_smul_left]
  nlinarith
Proof sketch

The strictness gained is proportional to $|q|^2$ and vanishes at critical points, exactly as anticipated; the next two steps deal with them. The composition is used only at points where $V$ is twice differentiable, so no viscosity chain rule is needed.

Theorem 6.3No maximum with a nonzero gradient✓ formalized
Formal statementgenerated from the Lean declaration
step2parts shown as Lean code

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $U, V \colon \mathbb{R}^{d} \to \mathbb{R}$, $\mathrm{lam}, \mu, \eta, \mathrm{Cc} \in \mathbb{R}$, $O \subseteq \mathbb{R}^{d}$, $x \in \mathbb{R}^{d}$, $\rho \in \mathbb{R}$, $q \in \mathbb{R}^{d}$.

Assume

  • $0 < d$ hd
  • $2 \le p$ hp
  • $0 \le \mathrm{lam}$ hlam
  • $0 \le \mu$ hμ
  • $0 < \eta$ hη
  • $\operatorname{SemiconvexWith}(\mathrm{lam}, U)$ hU
  • PLaplacian.SemiconvexWith lam fun y => -V y hV
  • PLaplacian.SemiconvexWith μ fun y => -(V y - η * V y ^ 2) hW
  • ∀ y ∈ O, ∀ (q : EuclSpace d) (X : PLaplacian.Bilin d), (q, X) ∈ PLaplacian.SuperJet U y → q ≠ 0 → PLaplacian.viscF p q X ≤ 0 hUjet
  • ∀ y ∈ O, ∀ (q : EuclSpace d) (X : PLaplacian.Bilin d), (q, X) ∈ PLaplacian.SubJet V y → q ≠ 0 → 0 ≤ PLaplacian.viscF p q X hVjet
  • $\forall y \in O,\ 0 < 1 - 2 \cdot \eta \cdot V(y)$ hc
  • $\forall y \in O,\ 1 - 2 \cdot \eta \cdot V(y) \le \mathrm{Cc}$ hCc
  • $0 < \rho$ hρ
  • $B(x, \rho) \subseteq O$ hball
  • $\forall y \in B(x, \rho),\ U(y) - (V(y) - \eta \cdot V(y) ^{2}) \le U(x) - (V(x) - \eta \cdot V(x) ^{2})$ hmax
  • $\forall y,\ U(x) + \operatorname{inner}(\mathbb{R}, q, y - x) - \mathrm{lam} / 2 \cdot \lVert y - x\rVert ^{2} \le U(y)$ hq

Then $q = 0$.

Informal statementfrom the blueprint

Let $U$ be semiconvex and $V$ and $W = \psi \circ V$ semiconcave. Suppose $U$ satisfies the jet subsolution inequality and $V$ the jet supersolution inequality on an open set $O \supseteq B(x, \rho)$, with $0 < \psi'(V) \le C_c$ there. If $x$ is a maximum of $U - W$ on $B(x, \rho)$, then every lower support $q$ of $U$ at $x$ vanishes.

Used byThm. 6.4
Lean 1
/-- **At a maximum of `U - ψ(V)`, the common gradient is zero.** -/
theorem step2 (hd : 0 < d) {p : ℝ} (hp : 2 ≤ p) {U V : EuclSpace d → ℝ} {lam μ η Cc : ℝ}
    (hlam : 0 ≤ lam) (hμ : 0 ≤ μ) (hη : 0 < η)
    (hU : SemiconvexWith lam U) (hV : SemiconvexWith lam (fun y => -V y))
    (hW : SemiconvexWith μ (fun y => -(V y - η * V y ^ 2)))
    {O : Set (EuclSpace d)}
    (hUjet : ∀ y ∈ O, ∀ (q : EuclSpace d) (X : Bilin d), (q, X) ∈ SuperJet U y →
      q ≠ 0 → viscF p q X ≤ 0)
    (hVjet : ∀ y ∈ O, ∀ (q : EuclSpace d) (X : Bilin d), (q, X) ∈ SubJet V y →
      q ≠ 0 → 0 ≤ viscF p q X)
    (hc : ∀ y ∈ O, 0 < 1 - 2 * η * V y) (hCc : ∀ y ∈ O, 1 - 2 * η * V y ≤ Cc)
    {x : EuclSpace d} {ρ : ℝ} (hρ : 0 < ρ) (hball : ball x ρ ⊆ O)
    (hmax : ∀ y ∈ ball x ρ, U y - (V y - η * V y ^ 2) ≤ U x - (V x - η * V x ^ 2))
    {q : EuclSpace d}
    (hq : ∀ y, U x + inner ℝ q (y - x) - lam / 2 * ‖y - x‖ ^ 2 ≤ U y) :
    q = 0 := by
  by_contra hq0
  have hQ : 0 < ‖q‖ := norm_pos_iff.2 hq0
  have hxO : x ∈ O := hball (mem_ball_self hρ)
  have hCc0 : 0 < Cc := lt_of_lt_of_le (hc x hxO) (hCc x hxO)
  have hp2 : 0 ≤ p - 2 := by linarith
  have hd1 : (1 : ℝ) ≤ d := by exact_mod_cast hd
  have hD0 : 0 < (d : ℝ) + p - 2 := by linarith
  have hL00 : 0 ≤ lam * (1 + Cc) + 1 := by positivity
  set κ := 2 * η * (p - 1) * (‖q‖ / (2 * Cc)) ^ 2 with hκ
  have hκ0 : 0 < κ := by
    have : 0 < p - 1 := by linarith
    positivity
  -- the parameters
  set r := min (ρ / 4) (min 1 (‖q‖ / (2 * (lam + 2 * μ + 3)))) with hr
  have hr0 : 0 < r := lt_min (by positivity) (lt_min one_pos (by positivity))
  have hrρ : r ≤ ρ / 4 := min_le_left _ _
  have hr1 : r ≤ 1 := le_trans (min_le_right _ _) (min_le_left _ _)
  have hrq : r ≤ ‖q‖ / (2 * (lam + 2 * μ + 3)) :=
    le_trans (min_le_right _ _) (min_le_right _ _)
  set δ := min (1 / 2) (min (κ / (6 * ((d : ℝ) + p - 2)))
    (κ * ‖q‖ / (72 * ((p - 2) * (lam * (1 + Cc) + 1) + 1)))) with hδ
  have hδ0 : 0 < δ := lt_min (by norm_num) (lt_min (by positivity) (by positivity))
  have hδ1 : δ ≤ 1 / 2 := min_le_left _ _
  have hδ2 : δ ≤ κ / (6 * ((d : ℝ) + p - 2)) := le_trans (min_le_right _ _) (min_le_left _ _)
  have hδ3 : δ ≤ κ * ‖q‖ / (72 * ((p - 2) * (lam * (1 + Cc) + 1) + 1)) :=
    le_trans (min_le_right _ _) (min_le_right _ _)
  set δJ := δ * r / 4 with hδJ
  have hδJ0 : 0 < δJ := by positivity
  have hδJr : 2 * δJ * r < δ * r ^ 2 := by
    rw [hδJ]
    have : 0 < δ * r ^ 2 := by positivity
    nlinarith
  -- the point
  obtain ⟨y₀, a, b, A, B, π, hy₀x, hπ, hPU, hPV, hAv, hBv, hgr, hquad⟩ :=
    step2_point hlam hμ hU hV hW hmax hr0 (by linarith) hδ0.le hδJ0 hδJr
  have hy₀O : y₀ ∈ O := hball (by rw [mem_ball, dist_eq_norm]; linarith)
  set c := 1 - 2 * η * V y₀ with hcdef
  have hc0 : 0 < c := hc y₀ hy₀O
  have hcC : c ≤ Cc := hCc y₀ hy₀O
  -- the gradient relation, in norm
  have hπn : ‖(2 * δ) • (y₀ - x) - π‖ ≤ 2 * δ * ‖y₀ - x‖ + δJ := by
    calc ‖(2 * δ) • (y₀ - x) - π‖ ≤ ‖(2 * δ) • (y₀ - x)‖ + ‖π‖ := norm_sub_le _ _
      _ = 2 * δ * ‖y₀ - x‖ + ‖π‖ := by
          rw [norm_smul, Real.norm_eq_abs, abs_of_pos (by positivity)]
      _ ≤ 2 * δ * ‖y₀ - x‖ + δJ := by linarith
  have hδy : 2 * δ * ‖y₀ - x‖ ≤ 2 * δ * r :=
    mul_le_mul_of_nonneg_left hy₀x.le (by positivity)
  have hδJδ : δJ ≤ δ := by rw [hδJ]; nlinarith
  have hδJr' : δJ ≤ r := by rw [hδJ]; nlinarith
  have h2δr : 2 * δ * r ≤ r := by nlinarith
  have h2δ : 2 * δ * r ≤ 2 * δ := by nlinarith
  have hab_n : ‖a - c • b‖ ≤ 3 * δ := by rw [hgr]; linarith
  have hab_r : ‖a - c • b‖ ≤ 2 * r := by rw [hgr]; linarith
  -- the gradient estimate
  have hsupp := semiconvex_subJet_support hU (twiceDiffAt_of_peanoAt hPU).2
  have hgest := grad_est (W := fun y => V y - η * V y ^ 2) hlam hμ hρ hW hmax hq
    (by linarith : ‖y₀ - x‖ < ρ / 3) hsupp
  have hgest' : ‖a - q‖ ≤ (lam + 2 * μ) * r :=
    hgest.trans (mul_le_mul_of_nonneg_left hy₀x.le (by positivity))
  have hrq' : (lam + 2 * μ + 2) * r ≤ ‖q‖ / 2 := by
    have := (le_div_iff₀ (by positivity : (0 : ℝ) < 2 * (lam + 2 * μ + 3))).1 hrq
    nlinarith
  -- the gradients are bounded below
  have hq_a : ‖q‖ ≤ ‖a - q‖ + ‖a‖ := by
    have := norm_sub_le a (a - q)
    rw [sub_sub_cancel] at this
    linarith
  have ha_cb : ‖a‖ ≤ ‖a - c • b‖ + ‖c • b‖ := by
    have := norm_sub_le (a - c • b) (-(c • b))
    rw [sub_neg_eq_add, sub_add_cancel, norm_neg] at this
    exact this
  have hcb : ‖q‖ / 2 ≤ ‖c • b‖ := by linarith
  have ha0 : a ≠ 0 := by
    intro h
    rw [h, zero_sub, norm_neg] at hgest'
    linarith
  have hcbn : ‖c • b‖ = c * ‖b‖ := by rw [norm_smul, Real.norm_eq_abs, abs_of_pos hc0]
  have hbq : ‖q‖ / (2 * Cc) ≤ ‖b‖ := by
    rw [div_le_iff₀ (by positivity)]
    have : c * ‖b‖ ≤ Cc * ‖b‖ := mul_le_mul_of_nonneg_right hcC (norm_nonneg _)
    linarith
  have hbκ : κ ≤ 2 * η * (p - 1) * ‖b‖ ^ 2 := by
    rw [hκ]
    have h1 : (‖q‖ / (2 * Cc)) ^ 2 ≤ ‖b‖ ^ 2 := by
      rw [sq, sq]; exact mul_self_le_mul_self (by positivity) hbq
    exact mul_le_mul_of_nonneg_left h1 (by have : 0 < p - 1 := (by linarith); positivity)
  -- the jet inequalities
  have hUi := hUjet y₀ hy₀O a A (twiceDiffAt_of_peanoAt hPU).1 ha0
  have hb0 : b ≠ 0 := by
    intro h; rw [h, smul_zero, norm_zero] at hcb; linarith
  have hVi := hVjet y₀ hy₀O b B (twiceDiffAt_of_peanoAt hPV).2 hb0
  rw [viscF_eq_neg] at hUi hVi
  -- the chain
  have hchain := step2_chain hp hη hc0 hcC hlam hδ0 hδ1 hQ (by linarith) (by linarith)
    hquad hAv hBv hab_n hcb ha0
  -- the right side is at most 2κ/3
  have hδD : 2 * δ * ((d : ℝ) + p - 2) ≤ κ / 3 := by
    have := (le_div_iff₀ (by positivity : (0 : ℝ) < 6 * ((d : ℝ) + p - 2))).1 hδ2
    linarith
  have hdir : (p - 2) * (2 * (lam * (1 + Cc) + 1) * (12 * δ / ‖q‖)) ≤ κ / 3 := by
    have h2 : (p - 2) * (2 * (lam * (1 + Cc) + 1) * (12 * δ / ‖q‖))
        = 24 * ((p - 2) * (lam * (1 + Cc) + 1) * δ) / ‖q‖ := by ring
    have h3 : δ * (72 * ((p - 2) * (lam * (1 + Cc) + 1) + 1)) ≤ κ * ‖q‖ :=
      (le_div_iff₀ (by positivity)).1 hδ3
    rw [h2, div_le_iff₀ hQ]
    have : 0 ≤ δ := hδ0.le
    linarith
  linarith
Proof sketch

Two quantitative ingredients replace the sequences of the textbook argument. First, a gradient estimate (grad_est): a lower support $a$ of $U$ at $y$ satisfies $|a - q| \le (\lambda + 2\mu)\,|y - x|$, by testing in the direction of $a - q$ against the upper support that the maximum provides. Second, a single point: suppose $q \ne 0$, and apply Jensen's lemma to $U - W - \delta|\cdot - x|^2$, which is globally semiconvex as $U - W - |\cdot - x|^4$ is not; the positive-measure set it yields meets the sets on which Alexandrov's theorem makes $U$ and $-V$ twice differentiable, at a point $y_0$ with tilt $\pi$. Reading off the conditions at the maximum there (max_peano) gives \[ a - c\,b = 2\delta(y_0 - x) - \pi, \qquad A \le cB - 2\eta\, b \otimes b + 2\delta I, \] and the operator estimates chain to $0 \le -\kappa + \kappa/3 + \kappa/3$, with $\kappa = 2\eta(p - 1)\bigl(|q|/(2C_c)\bigr)^2$ (step2_chain).

Theorem 6.4The translated maximum✓ formalized
Formal statementgenerated from the Lean declaration
step3parts shown as Lean code

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $U, V \colon \mathbb{R}^{d} \to \mathbb{R}$, $\mathrm{lam}, \mu, \eta, \mathrm{Cc} \in \mathbb{R}$, $O \subseteq \mathbb{R}^{d}$, $G \subseteq \mathbb{R}^{d}$, $R_{0} \in \mathbb{R}$, $x_{0} \in \mathbb{R}^{d}$.

Assume

  • $0 < d$ hd
  • $2 \le p$ hp
  • $0 \le \mathrm{lam}$ hlam
  • $0 \le \mu$ hμ
  • $0 < \eta$ hη
  • $\operatorname{SemiconvexWith}(\mathrm{lam}, U)$ hU
  • PLaplacian.SemiconvexWith lam fun y => -V y hV
  • PLaplacian.SemiconvexWith μ fun y => -(V y - η * V y ^ 2) hW
  • $U\text{ is continuous}$ hUc
  • $V\text{ is continuous}$ hVc
  • ∀ y ∈ O, ∀ (q : EuclSpace d) (X : PLaplacian.Bilin d), (q, X) ∈ PLaplacian.SuperJet U y → q ≠ 0 → PLaplacian.viscF p q X ≤ 0 hUjet
  • ∀ y ∈ O, ∀ (q : EuclSpace d) (X : PLaplacian.Bilin d), (q, X) ∈ PLaplacian.SuperJet (fun z => -V z) y → q ≠ 0 → PLaplacian.viscF p q X ≤ 0 hVneg
  • $\forall y \in O,\ 0 < 1 - 2 \cdot \eta \cdot V(y)$ hc
  • $\forall y \in O,\ 1 - 2 \cdot \eta \cdot V(y) \le \mathrm{Cc}$ hCc
  • $G\text{ is open}$ hGo
  • $G\text{ is bounded}$ hGb
  • $G\text{ is nonempty}$ hne
  • $\operatorname{IsPreconnected}(G)$ hGc
  • $0 < R_{0}$ hR₀
  • $\forall x \in \overline{G},\ B(x, R_{0}) \subseteq O$ hGO
  • $x_{0} \in G$ hx₀
  • $\forall z \in \partial G,\ U(z) - (V(z) - \eta \cdot V(z) ^{2}) < U(x_{0}) - (V(x_{0}) - \eta \cdot V(x_{0}) ^{2})$ hgap

Then $\mathrm{False}$.

Informal statementfrom the blueprint

Under the hypotheses of Theorem Theorem 6.3, let $G$ be bounded, open and connected, with $B(x, R_0) \subseteq O$ for $x \in \overline G$. Then $U - W$ cannot be strictly larger at a point of $G$ than everywhere on $\partial G$.

Used byThm. 6.5
Lean 1
/-- **The third step.** -/
theorem step3 (hd : 0 < d) {p : ℝ} (hp : 2 ≤ p) {U V : EuclSpace d → ℝ} {lam μ η Cc : ℝ}
    (hlam : 0 ≤ lam) (hμ : 0 ≤ μ) (hη : 0 < η)
    (hU : SemiconvexWith lam U) (hV : SemiconvexWith lam (fun y => -V y))
    (hW : SemiconvexWith μ (fun y => -(V y - η * V y ^ 2)))
    (hUc : Continuous U) (hVc : Continuous V)
    {O : Set (EuclSpace d)}
    (hUjet : ∀ y ∈ O, ∀ (q : EuclSpace d) (X : Bilin d), (q, X) ∈ SuperJet U y →
      q ≠ 0 → viscF p q X ≤ 0)
    (hVneg : ∀ y ∈ O, ∀ (q : EuclSpace d) (X : Bilin d),
      (q, X) ∈ SuperJet (fun z => -V z) y → q ≠ 0 → viscF p q X ≤ 0)
    (hc : ∀ y ∈ O, 0 < 1 - 2 * η * V y) (hCc : ∀ y ∈ O, 1 - 2 * η * V y ≤ Cc)
    {G : Set (EuclSpace d)} (hGo : IsOpen G) (hGb : Bornology.IsBounded G)
    (hne : G.Nonempty) (hGc : IsPreconnected G)
    {R₀ : ℝ} (hR₀ : 0 < R₀) (hGO : ∀ x ∈ closure G, ball x R₀ ⊆ O)
    {x₀ : EuclSpace d} (hx₀ : x₀ ∈ G)
    (hgap : ∀ z ∈ frontier G, U z - (V z - η * V z ^ 2) < U x₀ - (V x₀ - η * V x₀ ^ 2)) :
    False := by
  obtain ⟨h₁, hh₁, hconst, hint⟩ := Mfun_const hd hp hlam hμ hη hU hV hW hUc hVc hUjet hVneg
    hc hCc hGo hGb hne hR₀ hGO hx₀ hgap
  set M0 := Mfun U V η G 0 with hM0
  have hf0c : Continuous (fun z => U z - (V z - η * V z ^ 2)) := by fun_prop
  -- the bound by M(h), and its value
  have hleM : ∀ h, ‖h‖ < h₁ → ∀ x ∈ closure G, U (x + h) - (V x - η * V x ^ 2) ≤ M0 := by
    intro h hh x hx
    obtain ⟨_, _, _, hle⟩ := Mfun_attained (η := η) hUc hVc hGb hne h
    rw [← hconst h hh]
    exact hle x hx
  -- the contact set
  set K := {x | x ∈ G ∧ U x - (V x - η * V x ^ 2) = M0} with hKdef
  have hKne : (G ∩ K).Nonempty := by
    obtain ⟨xh, hxh, hxhM, _⟩ := Mfun_attained (η := η) hUc hVc hGb hne 0
    have hxhG : xh ∈ G := hint 0 (by rw [norm_zero]; exact hh₁) xh hxh hxhM
    rw [add_zero] at hxhM
    exact ⟨xh, hxhG, hxhG, hxhM⟩
  -- the semicontinuity needed by the strong principles
  have hUusc : UpperSemicontinuousOn U O := hUc.upperSemicontinuous.upperSemicontinuousOn O
  have hVusc : UpperSemicontinuousOn (fun z => -V z) O :=
    hVc.neg.upperSemicontinuous.upperSemicontinuousOn O
  -- K is open
  have hKo : IsOpen K := by
    rw [Metric.isOpen_iff]
    rintro x ⟨hxG, hxM⟩
    obtain ⟨ρ₁, hρ₁, hρ₁G⟩ := Metric.isOpen_iff.1 hGo x hxG
    set R := min h₁ (min ρ₁ R₀) with hR
    have hR0 : 0 < R := lt_min hh₁ (lt_min hρ₁ hR₀)
    have hRG : ball x R ⊆ G :=
      fun y hy => hρ₁G (ball_subset_ball (le_trans (min_le_right _ _) (min_le_left _ _)) hy)
    have hRO : ball x R ⊆ O := fun y hy =>
      hGO x (subset_closure hxG)
        (ball_subset_ball (le_trans (min_le_right _ _) (min_le_right _ _)) hy)
    have hRh : ∀ y ∈ ball x R, ‖y - x‖ < h₁ := by
      intro y hy
      rw [mem_ball, dist_eq_norm] at hy
      exact lt_of_lt_of_le hy (min_le_left _ _)
    -- U has a local maximum at x
    have hUmax : ∀ y ∈ ball x R, U y ≤ U x := by
      intro y hy
      have h1 := hleM (y - x) (hRh y hy) x (subset_closure hxG)
      have e : x + (y - x) = y := by abel
      rw [e] at h1
      linarith
    -- V has a local minimum at x
    have hVmin : ∀ y ∈ ball x R, -V y ≤ -V x := by
      intro y hy
      have hy' : ‖x - y‖ < h₁ := by rw [norm_sub_rev]; exact hRh y hy
      have h1 := hleM (x - y) hy' y (subset_closure (hRG hy))
      have e : y + (x - y) = x := by abel
      rw [e] at h1
      have hW : V x - η * V x ^ 2 ≤ V y - η * V y ^ 2 := by linarith
      have := psi_mono (hc x (hRO (mem_ball_self hR0))) (hc y (hRO hy)) hW
      linarith
    have hUconst := smp_ball_jet hd hp hUusc hUjet hR0 hRO hUmax
    have hVconst := smp_ball_jet hd hp hVusc hVneg hR0 hRO hVmin
    refine ⟨R / 3, by positivity, fun y hy => ⟨hRG (ball_subset_ball (by linarith) hy), ?_⟩⟩
    have h1 := hUconst y hy
    have h2 : V y = V x := by have := hVconst y hy; linarith
    rw [h1, h2]
    exact hxM
  -- the complement in G is open
  have hSo : IsOpen {x | U x - (V x - η * V x ^ 2) ≠ M0} :=
    isOpen_ne_fun hf0c continuous_const
  have hdisj : Disjoint K {x | U x - (V x - η * V x ^ 2) ≠ M0} :=
    Set.disjoint_left.2 fun x hxK hxS => hxS hxK.2
  have hcover : G ⊆ K ∪ {x | U x - (V x - η * V x ^ 2) ≠ M0} := by
    intro x hx
    by_cases h : U x - (V x - η * V x ^ 2) = M0
    · exact Or.inl ⟨hx, h⟩
    · exact Or.inr h
  -- connectedness
  have hGK : G ⊆ K :=
    IsPreconnected.subset_left_of_subset_union hKo hSo hdisj hcover hKne hGc
  have hclosed : closure G ⊆ {x | U x - (V x - η * V x ^ 2) = M0} := by
    apply closure_minimal _ (isClosed_eq hf0c continuous_const)
    intro x hx
    exact (hGK hx).2
  -- the contradiction at a frontier point
  obtain ⟨z, hz⟩ := frontier_nonempty hd hGo hGb hne
  have h1 : U z - (V z - η * V z ^ 2) = M0 := hclosed (frontier_subset_closure hz)
  have h2 := hleM 0 (by rw [norm_zero]; exact hh₁) x₀ (subset_closure hx₀)
  rw [add_zero] at h2
  have h3 := hgap z hz
  linarith
Proof sketch

Let $M(h) = \max_{\overline G}\bigl(U(\cdot + h) - W\bigr)$. For small $h$ the maximizers are interior, by uniform continuity and the gap; at each, Theorem Theorem 6.3 applies to the translate, so its lower support is zero and \[ M(h + k) \ge M(h) - \tfrac\lambda2 |k|^2 . \] Splitting a segment into $N$ equal steps loses at most $\lambda|k|^2/(2N)$, so $M$ is constant near $0$ (const_of_quad_lower); no Lipschitz bound or Rademacher's theorem is needed. On the contact set $K = \{x \in G : U - W = M(0)\}$, $U$ has a local maximum, $W$ a local minimum directly, and $V$ a local minimum because $\psi$ is increasing where $\psi' > 0$. The two strong principles make $U$ and $V$ constant near each point of $K$, so $K$ is open; it is relatively closed and nonempty, so connectedness gives $K = G$, and continuity carries $U - W = M(0)$ to a frontier point, contradicting the gap.

Theorem 6.5The comparison principle✓ formalized
Formal statementgenerated from the Lean declaration
visc_comparison

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $U, V \colon \mathbb{R}^{d} \to \mathbb{R}$, $x \in \mathbb{R}^{d}$.

Assume

  • $0 < d$ hd
  • $2 \le p$ hp
  • $\Omega\text{ is open}$ hΩo
  • $\Omega\text{ is bounded}$ hΩb
  • $U\text{ is upper semicontinuous}$ hU
  • $V\text{ is lower semicontinuous}$ hV
  • $U\text{ is bounded above}$ hUb
  • $U\text{ is bounded below}$ hUb'
  • $V\text{ is bounded below}$ hVb
  • $V\text{ is bounded above}$ hVb'
  • $U\text{ is a viscosity subsolution of }-\Delta_{p}^{\mathrm N} u = 0\text{ in }\Omega$ hsub
  • $V\text{ is a viscosity supersolution of }-\Delta_{p}^{\mathrm N} u = 0\text{ in }\Omega$ hsup
  • $\forall x \in \partial \Omega,\ U(x) \le V(x)$ hbd
  • $x \in \Omega$ a._@._internal._hyg.0

Then $U(x) \le V(x)$.

Informal statementfrom the blueprint

Let $\Omega \subseteq \R^d$ be bounded and open, $d \ge 1$ and $2 \le p$. Let $U$ be bounded, upper semicontinuous, and a viscosity subsolution of $-\pnlap u = 0$ in $\Omega$; let $V$ be bounded, lower semicontinuous, and a viscosity supersolution. If $U \le V$ on $\partial\Omega$, then $U \le V$ in $\Omega$.

Lean 1
/-- **The comparison principle** for the homogeneous normalized `p`-Laplacian. -/
theorem visc_comparison (hd : 0 < d) {p : ℝ} (hp : 2 ≤ p) {Ω : Set (EuclSpace d)}
    (hΩo : IsOpen Ω) (hΩb : Bornology.IsBounded Ω) {U V : EuclSpace d → ℝ}
    (hU : UpperSemicontinuous U) (hV : LowerSemicontinuous V)
    (hUb : BddAbove (range U)) (hUb' : BddBelow (range U))
    (hVb : BddBelow (range V)) (hVb' : BddAbove (range V))
    (hsub : IsViscositySubsolution p Ω (fun _ => 0) U)
    (hsup : IsViscositySupersolution p Ω (fun _ => 0) V)
    (hbd : ∀ x ∈ frontier Ω, U x ≤ V x) :
    ∀ x ∈ Ω, U x ≤ V x := by
  intro xb hxb
  by_contra hlt
  push Not at hlt
  set θ := U xb - V xb with hθdef
  have hθ : 0 < θ := by linarith
  -- the bounds
  obtain ⟨SU, hSU'⟩ := hUb
  obtain ⟨SL, hSL'⟩ := hUb'
  obtain ⟨TL, hTL'⟩ := hVb
  obtain ⟨TU, hTU'⟩ := hVb'
  have hSU : ∀ x, U x ≤ SU := fun x => hSU' ⟨x, rfl⟩
  have hSL : ∀ x, SL ≤ U x := fun x => hSL' ⟨x, rfl⟩
  have hTL : ∀ x, TL ≤ V x := fun x => hTL' ⟨x, rfl⟩
  have hTU : ∀ x, V x ≤ TU := fun x => hTU' ⟨x, rfl⟩
  have hUbA : BddAbove (range U) := ⟨SU, hSU'⟩
  have hVbB : BddBelow (range V) := ⟨TL, hTL'⟩
  have hCU : 0 ≤ SU - SL := by linarith [hSU 0, hSL 0]
  have hCV : 0 ≤ TU - TL := by linarith [hTU 0, hTL 0]
  -- the complement, and the distance of x̄ to it
  have hΩc := compl_nonempty hd hΩb
  have hxbd : 0 < infDist xb Ωᶜ :=
    (hΩo.isClosed_compl.notMem_iff_infDist_pos hΩc).1 (fun h => h hxb)
  -- δ from the band estimate
  obtain ⟨δ₀, hδ₀, Λ, hΛ, hband⟩ := band_est hΩb hΩc hU hV hUbA hVbB hSU hSL hTU hTL hbd
    (θ := θ / 4) (by positivity)
  set δ := min δ₀ (infDist xb Ωᶜ / 2) with hδdef
  have hδ : 0 < δ := lt_min hδ₀ (by positivity)
  have hδδ₀ : δ ≤ δ₀ := min_le_left _ _
  have hδxb : δ < infDist xb Ωᶜ := by
    have : δ ≤ infDist xb Ωᶜ / 2 := min_le_right _ _
    linarith
  -- λ
  set C := (SU - SL) + (TU - TL) + 1 with hC
  have hC0 : 0 < C := by linarith
  set lam := Λ + 8 * C / δ ^ 2 + 1 with hlamdef
  have hlamC : 8 * C / δ ^ 2 ≤ lam := by
    have : 0 < Λ := hΛ
    linarith
  have hlam0 : 0 < lam := lt_of_lt_of_le (by positivity) hlamC
  have hlamΛ : Λ ≤ lam := by
    have : 0 ≤ 8 * C / δ ^ 2 := by positivity
    linarith
  have hρ2 : 2 * C < (δ / 2) ^ 2 * lam + 1 := by
    have h1 : (δ / 2) ^ 2 * (8 * C / δ ^ 2) = 2 * C := by field_simp; ring
    have h2 := mul_le_mul_of_nonneg_left hlamC (by positivity : (0 : ℝ) ≤ (δ / 2) ^ 2)
    linarith
  have hρU : 2 * (SU - SL) / lam < (δ / 2) ^ 2 := by
    rw [div_lt_iff₀ hlam0]
    have h1 : (δ / 2) ^ 2 * (8 * C / δ ^ 2) = 2 * C := by field_simp; ring
    have h2 := mul_le_mul_of_nonneg_left hlamC (by positivity : (0 : ℝ) ≤ (δ / 2) ^ 2)
    nlinarith
  have hρV : 2 * (TU - TL) / lam < (δ / 2) ^ 2 := by
    rw [div_lt_iff₀ hlam0]
    have h1 : (δ / 2) ^ 2 * (8 * C / δ ^ 2) = 2 * C := by field_simp; ring
    have h2 := mul_le_mul_of_nonneg_left hlamC (by positivity : (0 : ℝ) ≤ (δ / 2) ^ 2)
    nlinarith
  -- the bounds on V_λ, and η
  have hVlam := regV_bounds hlam0.le hVbB hTU hTL
  set B := |TL| + |TU| + 1 with hB
  have hB0 : 0 < B := by positivity
  have hVB : ∀ y, |regV lam V y| ≤ B := by
    intro y
    obtain ⟨_, h1, h2⟩ := hVlam y
    rw [abs_le]
    constructor
    · have := neg_abs_le TL; linarith [abs_nonneg TU]
    · have := le_abs_self TU; linarith [abs_nonneg TL]
  set η := min (1 / (4 * B)) (θ / (8 * B ^ 2)) with hηdef
  have hη : 0 < η := lt_min (by positivity) (by positivity)
  have hηB : η * B ≤ 1 / 4 := by
    have := mul_le_mul_of_nonneg_right (min_le_left (1 / (4 * B)) (θ / (8 * B ^ 2))) hB0.le
    have e : 1 / (4 * B) * B = 1 / 4 := by field_simp
    linarith
  have hηB2 : η * B ^ 2 ≤ θ / 8 := by
    have := mul_le_mul_of_nonneg_right (min_le_right (1 / (4 * B)) (θ / (8 * B ^ 2)))
      (by positivity : (0 : ℝ) ≤ B ^ 2)
    have e : θ / (8 * B ^ 2) * B ^ 2 = θ / 8 := by field_simp
    linarith
  have hcb : ∀ y, 1 / 2 ≤ 1 - 2 * η * regV lam V y ∧ 1 - 2 * η * regV lam V y ≤ 3 / 2 := by
    intro y
    obtain ⟨a1, a2⟩ := abs_le.1 (hVB y)
    have k1 : η * regV lam V y ≤ η * B := mul_le_mul_of_nonneg_left a2 hη.le
    have k2 : η * (-B) ≤ η * regV lam V y := mul_le_mul_of_nonneg_left a1 hη.le
    constructor <;> nlinarith
  have hsq : ∀ y, η * regV lam V y ^ 2 ≤ θ / 8 := by
    intro y
    have h1 : regV lam V y ^ 2 ≤ B ^ 2 := by
      have := hVB y
      rw [← sq_abs]
      exact pow_le_pow_left₀ (abs_nonneg _) this 2
    have := mul_le_mul_of_nonneg_left h1 hη.le
    linarith
  -- the function f, at x̄ and on the band
  have hUc := regU_continuous hlam0.le hUbA
  have hVc := regV_continuous hlam0.le hVbB
  have hfc : Continuous (fun z => regU lam U z - (regV lam V z - η * regV lam V z ^ 2)) := by
    fun_prop
  have hfx : θ ≤ regU lam U xb - (regV lam V xb - η * regV lam V xb ^ 2) := by
    have h1 := (regU_bounds hlam0.le hUbA hSU hSL xb).1
    have h2 := (hVlam xb).1
    have h3 : 0 ≤ η * regV lam V xb ^ 2 := by positivity
    linarith
  have hfband : ∀ x ∈ closure Ω, infDist x Ωᶜ ≤ 2 * δ →
      regU lam U x - (regV lam V x - η * regV lam V x ^ 2) < θ / 2 := by
    intro x hx hxd
    have h1 := hband lam hlamΛ x hx (le_trans hxd (by linarith))
    have h2 := hsq x
    linarith
  -- the set S and the component G
  set S := {x | δ < infDist x Ωᶜ} ∩
    {x | θ / 2 < regU lam U x - (regV lam V x - η * regV lam V x ^ 2)} with hSdef
  have hSo : IsOpen S :=
    (isOpen_lt continuous_const (continuous_infDist_pt _)).inter
      (isOpen_lt continuous_const hfc)
  have hxbS : xb ∈ S := ⟨hδxb, by change θ / 2 < _; linarith⟩
  have hSΩ : S ⊆ Ω := by
    intro x hx
    by_contra hxΩ
    have : infDist x Ωᶜ = 0 := infDist_zero_of_mem hxΩ
    have h1 : δ < infDist x Ωᶜ := hx.1
    linarith
  set G := connectedComponentIn S xb with hGdef
  have hGo : IsOpen G := hSo.connectedComponentIn
  have hGc : IsPreconnected G := isPreconnected_connectedComponentIn
  have hxbG : xb ∈ G := mem_connectedComponentIn hxbS
  have hGne : G.Nonempty := ⟨xb, hxbG⟩
  have hGS : G ⊆ S := connectedComponentIn_subset S xb
  have hGb : Bornology.IsBounded G := hΩb.subset (hGS.trans hSΩ)
  have hclG : closure G ⊆ {x | δ ≤ infDist x Ωᶜ} := by
    apply closure_minimal _ (isClosed_le continuous_const (continuous_infDist_pt _))
    intro x hx
    have h : δ < infDist x Ωᶜ := (hGS hx).1
    exact h.le
  have hclGΩ : closure G ⊆ closure Ω := closure_mono (hGS.trans hSΩ)
  -- the frontier of G lies where f ≤ θ/2
  have hfr : ∀ z ∈ frontier G,
      regU lam U z - (regV lam V z - η * regV lam V z ^ 2) ≤ θ / 2 := by
    intro z hz
    by_contra hgt
    push Not at hgt
    have hzcl : z ∈ closure G := frontier_subset_closure hz
    rcases lt_or_ge δ (infDist z Ωᶜ) with hzd | hzd
    · -- z ∈ S would put z inside G
      have hzS : z ∈ S := ⟨hzd, hgt⟩
      obtain ⟨r, hr, hrS⟩ := Metric.isOpen_iff.1 hSo z hzS
      obtain ⟨w, hwG, hwz⟩ := Metric.mem_closure_iff.1 hzcl r hr
      have hwball : w ∈ ball z r := by rw [mem_ball, dist_comm]; exact hwz
      have hGw : G = connectedComponentIn S w := connectedComponentIn_eq hwG
      have hball : ball z r ⊆ connectedComponentIn S w :=
        (convex_ball z r).isPreconnected.subset_connectedComponentIn hwball hrS
      have hzG : z ∈ G := by rw [hGw]; exact hball (mem_ball_self hr)
      have hzint : z ∉ interior G := hz.2
      rw [hGo.interior_eq] at hzint
      exact hzint hzG
    · -- z lies in the band
      have h1 := hfband z (hclGΩ hzcl) (by linarith)
      linarith
  have hgap : ∀ z ∈ frontier G,
      regU lam U z - (regV lam V z - η * regV lam V z ^ 2)
        < regU lam U xb - (regV lam V xb - η * regV lam V xb ^ 2) := by
    intro z hz
    have := hfr z hz
    linarith
  -- the region O where the jet inequalities hold
  set O := {x | δ / 2 < infDist x Ωᶜ} with hOdef
  have hOball : ∀ y ∈ O, ball y (δ / 2) ⊆ Ω := by
    intro y hy w hw
    by_contra hwΩ
    have h1 := infDist_le_dist_of_mem (x := y) (show w ∈ Ωᶜ from hwΩ)
    have h2 : δ / 2 < infDist y Ωᶜ := hy
    rw [mem_ball, dist_comm] at hw
    linarith
  have hUjet : ∀ y ∈ O, ∀ (q : EuclSpace d) (X : Bilin d),
      (q, X) ∈ SuperJet (regU lam U) y → q ≠ 0 → viscF p q X ≤ 0 :=
    fun y hy q X hj hq => regU_jet hd hp hsub hlam0 hU hUbA hSU hSL hρU (by positivity)
      (hOball y hy) hj hq
  have hVneg : ∀ y ∈ O, ∀ (q : EuclSpace d) (X : Bilin d),
      (q, X) ∈ SuperJet (fun z => -regV lam V z) y → q ≠ 0 → viscF p q X ≤ 0 :=
    fun y hy q X hj hq => regV_jet hd hp hsup hlam0 hV hVbB hTU hTL hρV (by positivity)
      (hOball y hy) hj hq
  have hGO : ∀ x ∈ closure G, ball x (δ / 2) ⊆ O := by
    intro x hx y hy
    have h1 : δ ≤ infDist x Ωᶜ := hclG hx
    have h2 := infDist_le_infDist_add_dist (s := Ωᶜ) (x := x) (y := y)
    rw [mem_ball, dist_comm] at hy
    change δ / 2 < infDist y Ωᶜ
    linarith
  -- semiconvexity
  have hUs := regU_semiconvex hlam0.le hUbA
  have hVs := regV_semiconcave hlam0.le hVbB
  have hWs := semiconcave_psi (Cc := 3 / 2) hlam0.le hη.le hVs
    (fun y => by linarith [(hcb y).1]) (fun y => (hcb y).2)
  -- the third step
  exact step3 hd hp hlam0.le (by positivity) hη hUs hVs hWs hUc hVc hUjet hVneg
    (fun y _ => by linarith [(hcb y).1]) (fun y _ => (hcb y).2)
    hGo hGb hGne hGc (by positivity : (0 : ℝ) < δ / 2) hGO hxbG hgap
Proof sketch

The proof runs through a strong maximum principle, the change of values, and three steps: no maximum of the regularized difference has a nonzero gradient; translated maxima are constant, and the contact set is everything; and the regularization produces a set on which the regularized difference exceeds its boundary values. The theorem depends only on Lean's standard axioms.

Theorem 6.6Uniqueness of viscosity solutions✓ formalized
Formal statementgenerated from the Lean declaration
visc_unique

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $u_{1}, u_{2} \colon \mathbb{R}^{d} \to \mathbb{R}$, $x \in \mathbb{R}^{d}$.

Assume

  • $0 < d$ hd
  • $2 \le p$ hp
  • $\Omega\text{ is open}$ hΩo
  • $\Omega\text{ is bounded}$ hΩb
  • $u_{1}\text{ is continuous}$ h₁c
  • $u_{2}\text{ is continuous}$ h₂c
  • $u_{1}\text{ is bounded above}$ h₁a
  • $u_{1}\text{ is bounded below}$ h₁b
  • $u_{2}\text{ is bounded above}$ h₂a
  • $u_{2}\text{ is bounded below}$ h₂b
  • $u_{1}\text{ is a viscosity subsolution of }-\Delta_{p}^{\mathrm N} u = 0\text{ in }\Omega$ h₁sub
  • $u_{1}\text{ is a viscosity supersolution of }-\Delta_{p}^{\mathrm N} u = 0\text{ in }\Omega$ h₁sup
  • $u_{2}\text{ is a viscosity subsolution of }-\Delta_{p}^{\mathrm N} u = 0\text{ in }\Omega$ h₂sub
  • $u_{2}\text{ is a viscosity supersolution of }-\Delta_{p}^{\mathrm N} u = 0\text{ in }\Omega$ h₂sup
  • $\forall x \in \partial \Omega,\ u_{1}(x) = u_{2}(x)$ hbd
  • $x \in \Omega$ a._@._internal._hyg.0

Then $u_{1}(x) = u_{2}(x)$.

Informal statementfrom the blueprint

Two bounded continuous viscosity solutions of $-\pnlap u = 0$ in a bounded open set $\Omega$ that agree on $\partial\Omega$ agree in $\Omega$.

Lean 1
/-- **Uniqueness of viscosity solutions.** Two bounded continuous viscosity
solutions of the homogeneous normalized `p`-Laplace equation in a bounded open
set `Ω`, equal on `frontier Ω`, are equal in `Ω`. -/
theorem visc_unique (hd : 0 < d) {p : ℝ} (hp : 2 ≤ p)
    {Ω : Set (EuclSpace d)} (hΩo : IsOpen Ω) (hΩb : Bornology.IsBounded Ω)
    {u₁ u₂ : EuclSpace d → ℝ}
    (h₁c : Continuous u₁) (h₂c : Continuous u₂)
    (h₁a : BddAbove (range u₁)) (h₁b : BddBelow (range u₁))
    (h₂a : BddAbove (range u₂)) (h₂b : BddBelow (range u₂))
    (h₁sub : IsViscositySubsolution p Ω (fun _ => 0) u₁)
    (h₁sup : IsViscositySupersolution p Ω (fun _ => 0) u₁)
    (h₂sub : IsViscositySubsolution p Ω (fun _ => 0) u₂)
    (h₂sup : IsViscositySupersolution p Ω (fun _ => 0) u₂)
    (hbd : ∀ x ∈ frontier Ω, u₁ x = u₂ x) :
    ∀ x ∈ Ω, u₁ x = u₂ x := by
  intro x hx
  apply le_antisymm
  · exact visc_comparison hd hp hΩo hΩb h₁c.upperSemicontinuous
      h₂c.lowerSemicontinuous h₁a h₁b h₂b h₂a h₁sub h₂sup
      (fun y hy => (hbd y hy).le) x hx
  · exact visc_comparison hd hp hΩo hΩb h₂c.upperSemicontinuous
      h₁c.lowerSemicontinuous h₂a h₂b h₁b h₁a h₂sub h₁sup
      (fun y hy => (hbd y hy).ge) x hx
Proof sketch

A viscosity solution is both a sub- and a supersolution, and a continuous function is both upper and lower semicontinuous, so Theorem Theorem 6.5 applies in each direction and gives $u_1 \le u_2$ and $u_2 \le u_1$ in $\Omega$.

7. Boundary behaviour, existence, uniqueness and convergence

Theorem 7.1Discrete comparison against a strict supersolution✓ formalized
Formal statementgenerated from the Lean declaration
disc_comparison

Let $d \in \mathbb{N}$, $p, \varepsilon \in \mathbb{R}$, $D \subseteq \mathbb{R}^{d}$, $u, v \colon \mathbb{R}^{d} \to \mathbb{R}$, $\kappa \in \mathbb{R}$, $x \in \mathbb{R}^{d}$.

Assume

  • $2 \le p$ hp
  • $0 < p + d$ hpd
  • $0 < \varepsilon$ hε
  • $u\text{ is admissible (bounded and Borel measurable)}$ hu
  • $v\text{ is admissible (bounded and Borel measurable)}$ hv
  • $\forall x \in D,\ u(x) = T_{\varepsilon} u(x)$ hU
  • $0 < \kappa$ hκ
  • $\forall x \in D,\ T_{\varepsilon} v(x) \le v(x) - \kappa$ hV
  • $\forall w \notin D,\ (\exists y \in D,\ \operatorname{dist}(w, y) < \varepsilon) \to u(w) \le v(w)$ hstrip
  • $x \in D$ a._@._internal._hyg.0

Then $u(x) \le v(x)$.

Informal statementfrom the blueprint

Let $u$ and $v$ be admissible, with $u = \Op u$ and $\Op v \le v - \kappa$ on a set $D$ for some $\kappa > 0$, and $u \le v$ at the points outside $D$ within $\eps$ of it. Then $u \le v$ on $D$.

Used byThm. 7.3
Lean 1
/-- **Discrete comparison against a strict supersolution.** -/
theorem disc_comparison {p ε : ℝ} (hp : 2 ≤ p) (hpd : 0 < p + (d : ℝ)) (hε : 0 < ε)
    {D : Set (EuclSpace d)} {u v : EuclSpace d → ℝ} (hu : BddMeas u) (hv : BddMeas v)
    (hU : ∀ x ∈ D, u x = tugOfWarOp p ε u x)
    {κ : ℝ} (hκ : 0 < κ) (hV : ∀ x ∈ D, tugOfWarOp p ε v x ≤ v x - κ)
    (hstrip : ∀ w, w ∉ D → (∃ y ∈ D, dist w y < ε) → u w ≤ v w) :
    ∀ x ∈ D, u x ≤ v x := by
  by_contra hcon
  push Not at hcon
  obtain ⟨x₀, hx₀D, hx₀⟩ := hcon
  obtain ⟨Cu, hCu⟩ := hu.bound
  obtain ⟨Cv, hCv⟩ := hv.bound
  -- the ε-neighbourhood of D, and the supremum of u - v over it
  set A := {w | ∃ y ∈ D, dist w y < ε} with hAdef
  have hx₀A : x₀ ∈ A := ⟨x₀, hx₀D, by rw [dist_self]; exact hε⟩
  have hbdd : BddAbove ((fun w => u w - v w) '' A) := by
    refine ⟨Cu + Cv, ?_⟩
    rintro _ ⟨w, _, rfl⟩
    have h1 := (abs_le.1 (hCu w)).2
    have h2 := (abs_le.1 (hCv w)).1
    change u w - v w ≤ Cu + Cv
    linarith
  set M := sSup ((fun w => u w - v w) '' A) with hM
  have hleM : ∀ w ∈ A, u w - v w ≤ M := fun w hw => le_csSup hbdd ⟨w, hw, rfl⟩
  have hMpos : 0 < M := by
    have := hleM x₀ hx₀A
    linarith
  -- every value is at most max (M - κ) 0
  have hbound : ∀ w ∈ A, u w - v w ≤ max (M - κ) 0 := by
    rintro w ⟨y, hyD, hwy⟩
    by_cases hwD : w ∈ D
    · -- on D: the difference drops by κ
      have hball : ∀ z ∈ ball w ε, u z - v z ≤ M := by
        intro z hz
        exact hleM z ⟨w, hwD, hz⟩
      have h1 := tugOfWarOp_diff_le hp hpd hε hu hv w hball
      have h2 := hU w hwD
      have h3 := hV w hwD
      have : u w - v w ≤ M - κ := by linarith
      exact le_trans this (le_max_left _ _)
    · -- outside D: u ≤ v
      have := hstrip w hwD ⟨y, hyD, hwy⟩
      exact le_trans (by linarith) (le_max_right _ _)
  have hMle : M ≤ max (M - κ) 0 := by
    refine csSup_le ⟨_, ⟨x₀, hx₀A, rfl⟩⟩ ?_
    rintro _ ⟨w, hw, rfl⟩
    exact hbound w hw
  rcases le_total (M - κ) 0 with h | h
  · rw [max_eq_right h] at hMle; linarith
  · rw [max_eq_left h] at hMle; linarith
Proof sketch

Each of the three terms of $\Op$ moves by at most $\sup_{B_\eps(x)}(u - v)$, so $\Op u - \Op v$ does (tugOfWarOp_diff_le); hence $u - v \le M - \kappa$ on $D$, with $M$ the supremum over the $\eps$-neighbourhood, and $u - v \le 0$ outside $D$. Unlike Theorem Theorem 1.15, which compares two solutions, this needs no attained maximum.

Theorem 7.2The barrier✓ formalized
Formal statementgenerated from the Lean declaration
bpsi_op

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\delta \in \mathbb{R}$, $z, w \in \mathbb{R}^{d}$.

Assume

  • $0 < d$ hd
  • $2 \le p$ hp
  • $0 < \delta$ hδ
  • $\delta ^{2} \le \lVert w - z\rVert ^{2}$ h1
  • $\lVert w - z\rVert ^{2} \le \delta ^{2} + 1 / 4 \cdot \operatorname{bM}(p, \delta, d)$ h2

Then all of the following hold:

  • $\operatorname{gradient}(\operatorname{bpsi}(z, \delta, \operatorname{bM}(p, \delta, d)), w) \ne 0$
  • $\operatorname{normPLapOf}(p, \operatorname{gradient}(\operatorname{bpsi}(z, \delta, \operatorname{bM}(p, \delta, d)), w), \operatorname{hess}(\operatorname{bpsi}(z, \delta, \operatorname{bM}(p, \delta, d)), w)) \le - 1$
barrier_super

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\delta \in \mathbb{R}$, $z \in \mathbb{R}^{d}$, $c, A \in \mathbb{R}$.

Assume

  • $\mathbb{R}^{d}\text{ is nontrivial}$
  • $0 < d$ hd
  • $2 \le p$ hp
  • $0 < p + d$ hpd
  • $0 < \delta$ hδ
  • $0 < A$ hA

Then there exists $\varepsilon_{0} > 0$ such that:

  • $\forall y \in \operatorname{bShell}(z, \delta, \operatorname{bM}(p, \delta, d)),\ \forall \varepsilon,\ 0 < \varepsilon \to \varepsilon \le \varepsilon_{0} \to T_{\varepsilon} x \mapsto c + A \cdot \operatorname{bpsi}(z, \delta, \operatorname{bM}(p, \delta, d), x)(y) \le c + A \cdot \operatorname{bpsi}(z, \delta, \operatorname{bM}(p, \delta, d), y) - A \cdot \varepsilon ^{2} / (4 \cdot (p + d))$
Informal statementfrom the blueprint

For a ball $B(z, \delta)$ let $s = |x - z|^2$, $t = s - \delta^2$ and $\psi = t - M t^2$, with $M = (2(d + p - 2) + 1)/(8(p - 1)\delta^2)$. On the shell $\delta^2 \le s \le \delta^2 + 1/(4M)$ the gradient of $\psi$ does not vanish and $\pnlap \psi \le -1$; consequently, for $c \in \R$, $A > 0$ and $\eps$ small, \[ \Op(c + A\psi) \le c + A\psi - \frac{A\eps^2}{4(p + d)} \] on the shell.

Used byThm. 7.3
Lean 2
/-- **On the shell, the barrier has nonzero gradient and `Δᴺₚψ ≤ -1`.** -/
theorem bpsi_op (hd : 0 < d) {p : ℝ} (hp : 2 ≤ p) {δ : ℝ} (hδ : 0 < δ) (z : EuclSpace d)
    {w : EuclSpace d} (h1 : δ ^ 2 ≤ ‖w - z‖ ^ 2)
    (h2 : ‖w - z‖ ^ 2 ≤ δ ^ 2 + 1 / (4 * bM p δ d)) :
    gradient (bpsi z δ (bM p δ d)) w ≠ 0 ∧
      normPLapOf p (gradient (bpsi z δ (bM p δ d)) w) (hess (bpsi z δ (bM p δ d)) w)
        ≤ -1 := by
  have hp1 : 0 < p - 1 := by linarith
  have hd1 : (1 : ℝ) ≤ d := by exact_mod_cast hd
  have hD : 0 < (d : ℝ) + p - 2 := by linarith
  set M := bM p δ d with hMdef
  have hM : 0 < M := by rw [hMdef]; unfold bM; positivity
  set v := w - z with hv
  set t := ‖v‖ ^ 2 - δ ^ 2 with ht
  have ht0 : 0 ≤ t := by linarith
  have hMt : M * t ≤ 1 / 4 := by
    have : t ≤ 1 / (4 * M) := by linarith
    have h := mul_le_mul_of_nonneg_left this hM.le
    have e : M * (1 / (4 * M)) = 1 / 4 := by field_simp
    linarith
  set c := 2 * (1 - 2 * M * t) with hc
  have hc1 : 1 ≤ c := by rw [hc]; nlinarith
  have hc2 : c ≤ 2 := by rw [hc]; nlinarith [mul_nonneg hM.le ht0]
  have hv0 : v ≠ 0 := by
    intro h
    rw [h, norm_zero] at ht
    have : t = -δ ^ 2 := by rw [ht]; ring
    nlinarith [pow_pos hδ 2]
  -- the operator value, from the explicit expansion
  obtain ⟨hgrad, hval⟩ := normPLapOf_of_peano (p := p) (bpsi_contDiff z δ M)
    (bpsi_peano hM.le z δ w)
  rw [← hv, ← ht, ← hc] at hgrad hval
  have hcpos : 0 < c := by linarith
  refine ⟨?_, ?_⟩
  · rw [hgrad]; exact smul_ne_zero hcpos.ne' hv0
  · rw [hval, normPLapOf_cv_sub hv0 hcpos, normPLapOf_idForm hv0]
    -- c(d + p - 2) - 8M(p - 1)‖v‖² ≤ 2(d + p - 2) - 8M(p - 1)δ² = -1
    have hMδ : 8 * M * (p - 1) * δ ^ 2 = 2 * ((d : ℝ) + p - 2) + 1 := by
      rw [hMdef]; unfold bM; field_simp
    have k1 : c * ((d : ℝ) + p - 2) ≤ 2 * ((d : ℝ) + p - 2) :=
      mul_le_mul_of_nonneg_right hc2 hD.le
    have k2 : 8 * M * (p - 1) * δ ^ 2 ≤ (p - 1) * (8 * M) * ‖v‖ ^ 2 := by
      have := mul_le_mul_of_nonneg_left h1 (by positivity : (0 : ℝ) ≤ 8 * M * (p - 1))
      nlinarith
    linarith
/-- **The barrier is a strict discrete supersolution on the shell.** -/
theorem barrier_super [Nontrivial (EuclSpace d)] (hd : 0 < d) {p : ℝ} (hp : 2 ≤ p)
    (hpd : 0 < p + (d : ℝ)) {δ : ℝ} (hδ : 0 < δ) (z : EuclSpace d) (c : ℝ) {A : ℝ}
    (hA : 0 < A) :
    ∃ ε₀ > 0, ∀ y ∈ bShell z δ (bM p δ d), ∀ ε : ℝ, 0 < ε → ε ≤ ε₀ →
      tugOfWarOp p ε (fun x => c + A * bpsi z δ (bM p δ d) x) y
        ≤ (c + A * bpsi z δ (bM p δ d) y) - A * ε ^ 2 / (4 * (p + (d : ℝ))) := by
  set M := bM p δ d with hMdef
  have hp1 : 0 < p - 1 := by linarith
  have hd1 : (1 : ℝ) ≤ d := by exact_mod_cast hd
  have hM : 0 < M := by
    rw [hMdef]; unfold bM
    have hD : 0 < (d : ℝ) + p - 2 := by linarith
    exact div_pos (by linarith) (mul_pos (mul_pos (by norm_num) hp1) (pow_pos hδ 2))
  set v : EuclSpace d → ℝ := fun x => c + A * bpsi z δ M x with hvdef
  have hvC : ContDiff ℝ 3 v := contDiff_const.add (contDiff_const.mul (bpsi_contDiff z δ M))
  have hvC2 : ContDiff ℝ 2 v := contDiff_const.add (contDiff_const.mul (bpsi_contDiff z δ M))
  -- the gradient and the operator value of v on the shell
  have hval : ∀ y ∈ bShell z δ M, gradient v y ≠ 0 ∧
      normPLapOf p (gradient v y) (fderiv ℝ (fderiv ℝ v) y) ≤ -A := by
    intro y hy
    obtain ⟨hψg, hψN⟩ := bpsi_op hd hp hδ z hy.1 hy.2
    obtain ⟨hgψ, hNψ⟩ := normPLapOf_of_peano (p := p) (bpsi_contDiff z δ M)
      (bpsi_peano hM.le z δ y)
    obtain ⟨hgv, hNv⟩ := normPLapOf_of_peano (p := p) hvC2
      (peanoAt_affine (bpsi_peano hM.le z δ y) c A)
    set q := (2 * (1 - 2 * M * (‖y - z‖ ^ 2 - δ ^ 2))) • (y - z) with hq
    have hq0 : q ≠ 0 := by rw [← hgψ]; exact hψg
    refine ⟨by rw [hgv]; exact smul_ne_zero hA.ne' hq0, ?_⟩
    change normPLapOf p (gradient v y) (hess v y) ≤ -A
    rw [hNv, normPLapOf_smul_pos hA hq0, ← hNψ]
    have := mul_le_mul_of_nonneg_left hψN hA.le
    linarith
  -- the uniform expansion
  obtain ⟨ε₀, hε₀, hexp⟩ := expansion_compact hd hp hpd hvC (isCompact_bShell z δ M)
    (fun y hy => (hval y hy).1) (η := A / (4 * (p + (d : ℝ)))) (by positivity)
  refine ⟨ε₀, hε₀, fun y hy ε hε hεle => ?_⟩
  have h1 := hexp y hy ε hε hεle
  have h2 := (hval y hy).2
  have h3 : ε ^ 2 / (2 * (p + (d : ℝ))) * normPLapOf p (gradient v y) (fderiv ℝ (fderiv ℝ v) y)
      ≤ ε ^ 2 / (2 * (p + (d : ℝ))) * (-A) :=
    mul_le_mul_of_nonneg_left h2 (by positivity)
  have e : ε ^ 2 / (2 * (p + (d : ℝ))) * (-A) + A / (4 * (p + (d : ℝ))) * ε ^ 2
      = -(A * ε ^ 2 / (4 * (p + (d : ℝ)))) := by field_simp; ring
  change tugOfWarOp p ε v y ≤ v y - A * ε ^ 2 / (4 * (p + (d : ℝ)))
  linarith
Proof sketch

The barrier is a polynomial, hence globally smooth, which the expansion of Layer 3 requires. Its expansion at a point is exact algebra, and the value of $\pnlap$ at $(\nabla\psi, D^2\psi)$ is read off it through the uniqueness of Peano expansions (peano_unique, normPLapOf_of_peano), so no Hessian is computed. The expansion of Theorem Theorem 4.5 becomes uniform on the compact shell by a finite cover (expansion_compact).

Theorem 7.3The boundary estimate✓ formalized
Formal statementgenerated from the Lean declaration
ubar_le_bdry

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $F \colon \mathbb{R}^{d} \to \mathbb{R}$, $u \colon \mathbb{R} \to \mathbb{R}^{d} \to \mathbb{R}$, $C \in \mathbb{R}$, $y_{0} \in \mathbb{R}^{d}$, $z_{0} \in \mathbb{R}^{d}$, $\delta_{0} \in \mathbb{R}$.

Assume

  • $\mathbb{R}^{d}\text{ is nontrivial}$
  • $0 < d$ hd
  • $2 \le p$ hp
  • $0 < p + d$ hpd
  • $\forall \varepsilon, y,\ \lvert u_{\varepsilon}(y)\rvert \le C$ hC
  • $\forall \varepsilon > 0,\ u_{\varepsilon}\text{ is }p\text{-harmonious in }\Omega\text{ with step }\varepsilon\text{ and data }F$ hu
  • $\forall \varepsilon > 0,\ \forall x \notin \Omega,\ u_{\varepsilon}(x) = F(x)$ hout
  • $\operatorname{ContinuousAt}(F, y_{0})$ hFc
  • $0 < \delta_{0}$ hδ₀
  • $\lVert y_{0} - z_{0}\rVert = \delta_{0}$ hy₀z
  • $\forall x \in \Omega,\ \delta_{0} \le \lVert x - z_{0}\rVert$ hext

Then $\overline{u}(y_{0}) \le F(y_{0})$.

Informal statementfrom the blueprint

Let $|u_\eps| \le C$, with each $u_\eps$ $p$-harmonious in $\Omega$ with data $F$ and equal to $F$ outside $\Omega$. Let $y_0$ have an exterior ball $B(z_0, \delta_0)$ disjoint from $\Omega$, with $|y_0 - z_0| = \delta_0$, and let $F$ be continuous at $y_0$. Then $\overline u(y_0) \le F(y_0)$.

Used byThm. 7.4
Lean 1
/-- **`ubar u ≤ F` at a boundary point with an exterior sphere.** -/
theorem ubar_le_bdry [Nontrivial (EuclSpace d)] (hd : 0 < d) {p : ℝ} (hp : 2 ≤ p)
    (hpd : 0 < p + (d : ℝ)) {Ω : Set (EuclSpace d)} {F : EuclSpace d → ℝ}
    {u : ℝ → EuclSpace d → ℝ} {C : ℝ} (hC : ∀ ε y, |u ε y| ≤ C)
    (hu : ∀ ε > 0, IsPHarmonious p ε Ω F (u ε))
    (hout : ∀ ε > 0, ∀ x, x ∉ Ω → u ε x = F x)
    {y₀ : EuclSpace d} (hFc : ContinuousAt F y₀)
    {z₀ : EuclSpace d} {δ₀ : ℝ} (hδ₀ : 0 < δ₀) (hy₀z : ‖y₀ - z₀‖ = δ₀)
    (hext : ∀ x ∈ Ω, δ₀ ≤ ‖x - z₀‖) :
    ubar u y₀ ≤ F y₀ := by
  apply le_of_forall_pos_le_add
  intro η hη
  obtain ⟨ε₁, hε₁, r₁, hr₁, hb⟩ := bdry_step hd hp hpd hC hu hout hFc hδ₀ hy₀z hext
    (η₁ := η / 3) (by positivity)
  have h := ubar_le_of_bound u hC (S := Ioo 0 ε₁) (Ioo_mem_nhdsGT hε₁)
    (V := ball y₀ r₁) (b := F y₀ + 3 * (η / 3))
    (fun ε hε x hx => hb ε hε.1 hε.2 x hx) (ball_mem_nhds y₀ hr₁)
  linarith
Proof sketch

Halve the exterior ball, centring it at the midpoint $z$ of $y_0$ and $z_0$. By Apollonius's identity, $|x - z|^2 \ge \delta^2 + \tfrac12|x - y_0|^2$ for $x$ outside $B(z_0, \delta_0)$, so the contact is unique and the region $D = \Omega \cap \{|x - z|^2 < \delta^2 + \tau\}$ lies close to $y_0$. The barrier $F(y_0) + \eta + A\psi$, clamped to make it admissible and unchanged on the balls the operator reads (tugOfWarOp_congr_ball), dominates $u_\eps$ on the $\eps$-neighbourhood of $D$ for $A$ large and $\eps$ small, and Theorem Theorem 7.1 gives $u_\eps \le F(y_0) + 2\eta$ near $y_0$. The lower estimate $F \le \underline u$ follows by applying the theorem to $-u_\eps$, which is $p$-harmonious with data $-F$ because $\Op$ is odd. The hypothesis $u_\eps = F$ outside $\Omega$ is essential.

Theorem 7.4Convergence✓ formalized
Formal statementgenerated from the Lean declaration
pharmonious_converge

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $F \colon \mathbb{R}^{d} \to \mathbb{R}$, $u \colon \mathbb{R} \to \mathbb{R}^{d} \to \mathbb{R}$, $C \in \mathbb{R}$.

Assume

  • $\mathbb{R}^{d}\text{ is nontrivial}$
  • $0 < d$ hd
  • $2 \le p$ hp
  • $0 < p + d$ hpd
  • $\Omega\text{ is open}$ hΩo
  • $\Omega\text{ is bounded}$ hΩb
  • $F\text{ is continuous}$ hFc
  • $\forall y \in \partial \Omega,\ \exists z, \delta,\ 0 < \delta \wedge \lVert y - z\rVert = \delta \wedge \forall x \in \Omega,\ \delta \le \lVert x - z\rVert$ hext
  • $\forall \varepsilon, y,\ \lvert u_{\varepsilon}(y)\rvert \le C$ hC
  • $\forall \varepsilon > 0,\ u_{\varepsilon}\text{ is }p\text{-harmonious in }\Omega\text{ with step }\varepsilon\text{ and data }F$ hu
  • $\forall \varepsilon > 0,\ \forall x \notin \Omega,\ u_{\varepsilon}(x) = F(x)$ hout

Then all of the following hold:

  • $\forall x \in \overline{\Omega},\ \overline{u}(x) = \underline{u}(x)$
  • $\forall x \in \partial \Omega,\ \overline{u}(x) = F(x)$
  • $\forall \eta > 0,\ \exists \varepsilon_{0} > 0,\ \forall \varepsilon,\ 0 < \varepsilon \to \varepsilon < \varepsilon_{0} \to \forall x \in \overline{\Omega},\ \lvert u_{\varepsilon}(x) - \overline{u}(x)\rvert \le \eta$
Informal statementfrom the blueprint

Let $2 \le p$ and $d \ge 1$, let $\Omega \subseteq \R^d$ be bounded and open with an exterior sphere at every boundary point, and let $F$ be continuous. Let $(u_\eps)_{\eps > 0}$ be uniformly bounded, each $u_\eps$ $p$-harmonious in $\Omega$ with data $F$ and equal to $F$ outside $\Omega$. Then $\overline u = \underline u$ on $\overline\Omega$, $\overline u = F$ on $\partial\Omega$, and $u_\eps \to \overline u$ uniformly on $\overline\Omega$.

Used byThm. 7.7
Lean 1
PLaplacian.pharmonious_convergePlaplacian/MainConv.lean, lines 39–144
/-- **Convergence of `p`-harmonious functions to the viscosity solution.** -/
theorem pharmonious_converge [Nontrivial (EuclSpace d)] (hd : 0 < d) {p : ℝ} (hp : 2 ≤ p)
    (hpd : 0 < p + (d : ℝ)) {Ω : Set (EuclSpace d)} (hΩo : IsOpen Ω)
    (hΩb : Bornology.IsBounded Ω) {F : EuclSpace d → ℝ} (hFc : Continuous F)
    (hext : ∀ y ∈ frontier Ω, ∃ (z : EuclSpace d) (δ : ℝ), 0 < δ ∧ ‖y - z‖ = δ ∧
      ∀ x ∈ Ω, δ ≤ ‖x - z‖)
    {u : ℝ → EuclSpace d → ℝ} {C : ℝ} (hC : ∀ ε y, |u ε y| ≤ C)
    (hu : ∀ ε > 0, IsPHarmonious p ε Ω F (u ε))
    (hout : ∀ ε > 0, ∀ x, x ∉ Ω → u ε x = F x) :
    (∀ x ∈ closure Ω, ubar u x = lbar u x) ∧
    (∀ x ∈ frontier Ω, ubar u x = F x) ∧
    (∀ η > 0, ∃ ε₀ > 0, ∀ ε, 0 < ε → ε < ε₀ → ∀ x ∈ closure Ω,
      |u ε x - ubar u x| ≤ η) := by
  -- the negated family
  have hC' : ∀ ε y, |(fun ε y => -u ε y) ε y| ≤ C := fun ε y => by
    simp only [abs_neg]; exact hC ε y
  have hu' : ∀ ε > 0, IsPHarmonious p ε Ω (fun y => -F y) ((fun ε y => -u ε y) ε) :=
    fun ε hε => isPHarmonious_neg (hu ε hε)
  have hout' : ∀ ε > 0, ∀ x, x ∉ Ω → (fun ε y => -u ε y) ε x = (fun y => -F y) x := by
    intro ε hε x hx
    change -u ε x = -F x
    rw [hout ε hε x hx]
  -- the bounds on the relaxed limits
  have hubC : ∀ x, ubar u x ≤ C := fun x =>
    ubar_le_of_bound u hC (S := Ioi 0) self_mem_nhdsWithin (V := univ) (b := C)
      (fun ε _ y _ => (abs_le.1 (hC ε y)).2) univ_mem
  have hlbC : ∀ x, -C ≤ lbar u x := by
    intro x
    have h : ubar (fun ε y => -u ε y) x ≤ C :=
      ubar_le_of_bound _ hC' (S := Ioi 0) self_mem_nhdsWithin (V := univ) (b := C)
        (fun ε _ y _ => (abs_le.1 (hC' ε y)).2) univ_mem
    rw [lbar_eq_neg_ubar_neg]
    linarith
  have hord : ∀ x, lbar u x ≤ ubar u x := lbar_le_ubar u hC
  -- the boundary estimates
  have hupper : ∀ y ∈ frontier Ω, ubar u y ≤ F y := by
    intro y hy
    obtain ⟨z, δ, hδ, hyz, hext'⟩ := hext y hy
    exact ubar_le_bdry hd hp hpd hC hu hout hFc.continuousAt hδ hyz hext'
  have hlower : ∀ y ∈ frontier Ω, F y ≤ lbar u y := by
    intro y hy
    obtain ⟨z, δ, hδ, hyz, hext'⟩ := hext y hy
    have h : ubar (fun ε y => -u ε y) y ≤ -F y :=
      ubar_le_bdry hd hp hpd hC' hu' hout' hFc.neg.continuousAt hδ hyz hext'
    rw [lbar_eq_neg_ubar_neg]
    linarith
  -- comparison in Ω
  have hcomp := visc_comparison hd hp hΩo hΩb (upperSemicontinuous_ubar u hC)
    (lowerSemicontinuous_lbar u hC)
    ⟨C, by rintro _ ⟨x, rfl⟩; exact hubC x⟩
    ⟨-C, by rintro _ ⟨x, rfl⟩; exact le_trans (hlbC x) (hord x)⟩
    ⟨-C, by rintro _ ⟨x, rfl⟩; exact hlbC x⟩
    ⟨C, by rintro _ ⟨x, rfl⟩; exact le_trans (hord x) (hubC x)⟩
    (ubar_isViscositySubsolution hd hp hpd hΩo hC hu)
    (lbar_isViscositySupersolution hd hp hpd hΩo hC hu)
    (fun x hx => le_trans (hupper x hx) (hlower x hx))
  -- the relaxed limits agree on the closure
  have heq : ∀ x ∈ closure Ω, ubar u x = lbar u x := by
    intro x hx
    rw [closure_eq_self_union_frontier] at hx
    rcases hx with hx | hx
    · exact le_antisymm (hcomp x hx) (hord x)
    · exact le_antisymm (le_trans (hupper x hx) (hlower x hx)) (hord x)
  have heqF : ∀ x ∈ frontier Ω, ubar u x = F x := fun x hx =>
    le_antisymm (hupper x hx) (le_trans (hlower x hx) (hord x))
  refine ⟨heq, heqF, ?_⟩
  -- uniform convergence, by contradiction
  intro η hη
  by_contra hcon
  push Not at hcon
  have hseq : ∀ n : ℕ, ∃ ε x, 0 < ε ∧ ε < 1 / ((n : ℝ) + 1) ∧ x ∈ closure Ω ∧
      η < |u ε x - ubar u x| := by
    intro n
    obtain ⟨ε, hε0, hε1, x, hx, hbad⟩ := hcon (1 / ((n : ℝ) + 1)) (by positivity)
    exact ⟨ε, x, hε0, hε1, hx, hbad⟩
  choose εs xs hεs0 hεs1 hxs hbad using hseq
  -- a convergent subsequence
  obtain ⟨xstar, hxstar, φ, hφ, hxT⟩ := tendsto_subseq_of_bounded hΩb.closure hxs
  rw [closure_closure] at hxstar
  have hεT : Tendsto (fun n => εs (φ n)) atTop (𝓝[>] 0) := by
    rw [tendsto_nhdsWithin_iff]
    refine ⟨?_, Eventually.of_forall fun n => hεs0 (φ n)⟩
    have h1 : Tendsto (fun n => 1 / ((φ n : ℝ) + 1)) atTop (𝓝 0) :=
      tendsto_one_div_add_atTop_nhds_zero_nat.comp hφ.tendsto_atTop
    exact squeeze_zero (fun n => (hεs0 (φ n)).le) (fun n => (hεs1 (φ n)).le) h1
  have hqT : Tendsto (fun n => (εs (φ n), xs (φ n))) atTop (relaxFilter xstar) :=
    hεT.prodMk hxT
  -- four eventual bounds at x*
  have hb : 0 < η / 3 := by positivity
  have e1 : ∀ᶠ n in atTop, u (εs (φ n)) (xs (φ n)) < ubar u xstar + η / 3 :=
    hqT.eventually (eventually_lt_of_ubar_lt u hC xstar (by linarith))
  have e2 : ∀ᶠ n in atTop, -u (εs (φ n)) (xs (φ n)) < -lbar u xstar + η / 3 := by
    have h : ubar (fun ε y => -u ε y) xstar < -lbar u xstar + η / 3 := by
      rw [lbar_eq_neg_ubar_neg]; linarith
    exact hqT.eventually (eventually_lt_of_ubar_lt _ hC' xstar h)
  have e3 : ∀ᶠ n in atTop, ubar u (xs (φ n)) < ubar u xstar + η / 3 :=
    hxT.eventually (upperSemicontinuous_ubar u hC xstar _ (by linarith))
  have e4 : ∀ᶠ n in atTop, lbar u xstar - η / 3 < lbar u (xs (φ n)) :=
    hxT.eventually (lowerSemicontinuous_lbar u hC xstar _ (by linarith))
  obtain ⟨n, h1, h2, h3, h4⟩ := (e1.and (e2.and (e3.and e4))).exists
  have h5 := heq (xs (φ n)) (hxs (φ n))
  have h6 := heq xstar hxstar
  have h7 := hbad (φ n)
  have : |u (εs (φ n)) (xs (φ n)) - ubar u (xs (φ n))| < η := by
    rw [abs_lt]; constructor <;> linarith
  linarith
Proof sketch

By Theorem Theorem 4.14, $\overline u$ is a subsolution and $\underline u$ a supersolution; by Theorem Theorem 7.3 and its negation, $\overline u \le F \le \underline u$ on $\partial\Omega$; so Theorem Theorem 6.5 gives $\overline u \le \underline u$ in $\Omega$, and with Theorem Theorem 4.1 the two agree on $\overline\Omega$. Their common value is then continuous on $\overline\Omega$, and a sequence of points at which $|u_\eps - \overline u|$ stayed above some $\eta > 0$ would have a convergent subsequence contradicting the semicontinuity of the relaxed limits at its limit. This completes the argument of Barles and Souganidis . The theorem depends only on Lean's standard axioms.

Theorem 7.5Uniform convergence of the restricted iteration✓ formalized
Formal statementgenerated from the Lean declaration
dirIter_unif

Let $d \in \mathbb{N}$, $p, \varepsilon \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $u_{0} \colon \mathbb{R}^{d} \to \mathbb{R}$, $C \in \mathbb{R}$, $\eta \in \mathbb{R}$.

Assume

  • $2 \le p$ hp
  • $0 < \varepsilon$ hε
  • $0 < d$ hd
  • $0 < p + d$ hpd
  • $\Omega\text{ is measurable}$ hΩm
  • $\Omega\text{ is nonempty}$ hΩn
  • $\Omega\text{ is bounded}$ hΩb
  • $u_{0}\text{ is admissible (bounded and Borel measurable)}$ hu₀
  • $\forall y,\ \lvert u_{0}(y)\rvert \le C$ hC
  • $\forall x,\ u_{0}(x) \le \widetilde{T}_{\varepsilon} u_{0}(x)$ hstep
  • $\eta > 0$ a._@._internal._hyg.0

Then there exists $N$ such that:

  • $\forall j \ge N,\ \forall x,\ \lvert \operatorname{dirLimit}(p, \varepsilon, \Omega, u_{0}, x) - \operatorname{dirIter}(p, \varepsilon, \Omega, u_{0}, j, x)\rvert \le \eta$
Informal statementfrom the blueprint

Let $\Omega$ be bounded, measurable and nonempty, and let $u_0$ be admissible, with $\abs{u_0} \le C$ and $u_0 \le \widetilde T u_0$. Then $u_j \to u$ uniformly on $\R^d$.

Used byThm. 7.6
Lean 1
/-- **Uniform convergence of the iteration of `dppOp`, on all of `ℝᵈ`.** -/
theorem dirIter_unif (p ε : ℝ) (hp : 2 ≤ p) (hε : 0 < ε) (hd : 0 < d)
    (hpd : 0 < p + (d : ℝ)) {Ω : Set (EuclSpace d)} (hΩm : MeasurableSet Ω)
    (hΩn : Ω.Nonempty) (hΩb : Bornology.IsBounded Ω)
    {u₀ : EuclSpace d → ℝ} (hu₀ : BddMeas u₀) {C : ℝ}
    (hC : ∀ y, |u₀ y| ≤ C)
    (hstep : ∀ x, u₀ x ≤ dppOp p ε Ω u₀ x) :
    ∀ η > 0, ∃ N, ∀ j ≥ N, ∀ x,
      |dirLimit p ε Ω u₀ x - dirIter p ε Ω u₀ j x| ≤ η := by
  set u := dirLimit p ε Ω u₀ with hu
  set w := dirIter p ε Ω u₀ with hw
  have hBMu : BddMeas u := bddMeas_dirLimit p ε hp hε hd hpd hΩm hu₀ hC hstep
  have hBM : ∀ j, BddMeas (w j) := fun j => bddMeas_dirIter p ε hp hε hpd hΩm hu₀ j
  have hle : ∀ j y, w j y ≤ u y := fun j y =>
    dirIter_le_dirLimit p ε hp hε hpd hΩm hu₀ hC j y
  have hnn : ∀ j y, 0 ≤ u y - w j y := fun j y => by linarith [hle j y]
  have hCd : ∀ j y, |u y - w j y| ≤ 2 * C := fun j y => by
    have h1 := abs_le.1 (abs_dirLimit_le p ε hp hε hpd hΩm hu₀ hC y)
    have h2 := abs_le.1 (abs_dirIter_le p ε hp hε hpd hΩm hu₀ hC j y)
    rw [abs_le]; constructor <;> linarith
  have hmono : ∀ j y, w j y ≤ w (j + 1) y := fun j y =>
    dirIter_mono p ε hp hε hd hpd hΩm hu₀ hstep j y
  have hconv : ∀ x, Tendsto (fun j => w j x) atTop (𝓝 (u x)) := fun x =>
    tendsto_dirIter p ε hp hε hd hpd hΩm hu₀ hC hstep x
  have hoff : ∀ j x, x ∉ Ω → u x - w j x = 0 := fun j x hx => by
    rw [hu, hw, dirLimit_eq_of_notMem p ε hx, dirIter_eq_of_notMem p ε hx]
    ring
  -- the set over which the deficit is measured
  set S := closureEps Ω ε
  have hS : S.Nonempty := closureEps_nonempty hΩn ε
  have hSfin : volume S ≠ ⊤ :=
    (isBounded_closureEps hΩn hΩb hε.le).measure_lt_top.ne
  obtain ⟨M, hlim⟩ := exists_deficitLimit hS hCd hnn hmono
  -- the three inputs of the estimate
  have hint : ∀ k, MeasureTheory.IntegrableOn (fun y => u y - w k y) S :=
    fun k => integrableOn_of_bddMeas (hBMu.sub (hBM k)) hSfin
  have hintlim : Tendsto (fun j => ∫ y in S, (u y - w j y)) atTop (𝓝 0) :=
    tendsto_setIntegral_deficit hSfin (fun j => (hBMu.sub (hBM j)).meas)
      hCd hconv
  have hglob : ∀ η > 0, ∀ δ' > 0, ∃ k, (∫ y in S, (u y - w k y)) ≤ η
      ∧ deficitSup S u (w k) ≤ M + δ' := fun η hη δ' hδ' =>
    exists_index_both hintlim hlim hη hδ'
  have hsel : ∀ (δ : ℝ), 0 < δ → ∀ k : ℕ, ∃ x₀ ∈ Ω, ∃ l : ℕ,
      M - 2 * δ ≤ tugOfWarOp p ε (w l) x₀ - tugOfWarOp p ε (w k) x₀ := by
    intro δ hδ k
    have hMk : ∀ k, M ≤ deficitSup Ω u (w (k + 1)) := fun k =>
      le_trans (le_deficitSup_of_antitone hS hCd hmono hlim (k + 1))
        (deficitSup_le_of_vanish hΩn hS (hCd (k + 1)) (hnn (k + 1))
          (hoff (k + 1)))
    obtain ⟨x₀, hx₀, l, hl⟩ := exists_sel hΩn hδ hMk hconv k
    refine ⟨x₀, hx₀, l, ?_⟩
    have e1 : w (l + 1) x₀ = tugOfWarOp p ε (w l) x₀ := by
      rw [hw, dirIter_succ, dppOp_of_mem p ε hx₀]
    have e2 : w (k + 1) x₀ = tugOfWarOp p ε (w k) x₀ := by
      rw [hw, dirIter_succ, dppOp_of_mem p ε hx₀]
    rw [e1, e2] at hl
    exact hl
  have hM : M ≤ 0 :=
    deficit_le_zero_gen p ε hp hε hpd (Ω := Ω) hBMu hBM hle hCd hnn hglob hint hsel
  have hzero := tendsto_deficitSup_zero hS hCd hnn hlim hM
  -- from the deficit suprema to a uniform bound
  intro η hη
  obtain ⟨N, hN⟩ := Filter.eventually_atTop.1
    (hzero.eventually (eventually_le_nhds hη))
  refine ⟨N, fun j hj x => ?_⟩
  rw [abs_of_nonneg (hnn j x)]
  by_cases hx : x ∈ S
  · exact le_trans (le_csSup (bddAbove_deficit (hCd j)) ⟨x, hx, rfl⟩) (hN j hj)
  · have hxΩ : x ∉ Ω := fun h => hx (subset_closureEps Ω ε h)
    rw [hoff j x hxΩ]
    exact hη.le
Proof sketch

The proof is the estimate of Theorem Theorem 1.12, restated for a general increasing sequence below its limit (deficit_le_zero_gen), with its inputs now discharged. The integrals of the deficit over $\Omega_\eps$ tend to zero by dominated convergence, $\Omega_\eps$ being bounded; the deficit suprema decrease to their limit $M$; and since the deficit vanishes off $\Omega$, its supremum over $\Omega_\eps$ is at most its supremum over $\Omega$, so the point $x_0$ of the argument can be chosen in $\Omega$, where $u_{j+1}(x_0) = \Op u_j(x_0)$. Hence $M \le 0$, the suprema tend to zero, and the convergence is uniform on $\Omega_\eps$, hence on $\R^d$.

Theorem 7.6Existence with exterior data✓ formalized
Formal statementgenerated from the Lean declaration
dirLimit_fixed

Let $d \in \mathbb{N}$, $p, \varepsilon \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $u_{0} \colon \mathbb{R}^{d} \to \mathbb{R}$, $C \in \mathbb{R}$, $x \in \mathbb{R}^{d}$.

Assume

  • $2 \le p$ hp
  • $0 < \varepsilon$ hε
  • $0 < d$ hd
  • $0 < p + d$ hpd
  • $\Omega\text{ is measurable}$ hΩm
  • $\Omega\text{ is bounded}$ hΩb
  • $u_{0}\text{ is admissible (bounded and Borel measurable)}$ hu₀
  • $\forall y,\ \lvert u_{0}(y)\rvert \le C$ hC
  • $\forall x,\ u_{0}(x) \le \widetilde{T}_{\varepsilon} u_{0}(x)$ hstep

Then $\widetilde{T}_{\varepsilon} \operatorname{dirLimit}(p, \varepsilon, \Omega, u_{0})(x) = \operatorname{dirLimit}(p, \varepsilon, \Omega, u_{0}, x)$.

exists_pharmonious

Let $d \in \mathbb{N}$, $p, \varepsilon \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $F \colon \mathbb{R}^{d} \to \mathbb{R}$, $C \in \mathbb{R}$.

Assume

  • $2 \le p$ hp
  • $0 < \varepsilon$ hε
  • $0 < d$ hd
  • $0 < p + d$ hpd
  • $\Omega\text{ is measurable}$ hΩm
  • $\Omega\text{ is bounded}$ hΩb
  • $F\text{ is Borel measurable}$ hFm
  • $\forall y,\ \lvert F(y)\rvert \le C$ hFC

Then there exists $u$ such that:

  • $u\text{ is }p\text{-harmonious in }\Omega\text{ with step }\varepsilon\text{ and data }F$
  • $\forall x \notin \Omega,\ u(x) = F(x)$
  • $\forall y,\ \lvert u(y)\rvert \le C$
Informal statementfrom the blueprint

Let $\Omega$ be bounded and measurable, $\eps > 0$, and $F$ measurable with $\abs F \le C$. Then there is a $p$-harmonious function $u$ in $\Omega$ with data $F$, equal to $F$ outside $\Omega$, with $\abs u \le C$.

Used byThm. 7.7
Lean 2
/-- **The limit is a fixed point of the restricted operator.** -/
theorem dirLimit_fixed (p ε : ℝ) (hp : 2 ≤ p) (hε : 0 < ε) (hd : 0 < d)
    (hpd : 0 < p + (d : ℝ)) {Ω : Set (EuclSpace d)} (hΩm : MeasurableSet Ω)
    (hΩb : Bornology.IsBounded Ω)
    {u₀ : EuclSpace d → ℝ} (hu₀ : BddMeas u₀) {C : ℝ}
    (hC : ∀ y, |u₀ y| ≤ C)
    (hstep : ∀ x, u₀ x ≤ dppOp p ε Ω u₀ x) (x : EuclSpace d) :
    dppOp p ε Ω (dirLimit p ε Ω u₀) x = dirLimit p ε Ω u₀ x := by
  by_cases hx : x ∈ Ω
  swap
  · exact dppOp_of_notMem p ε hx _
  rw [dppOp_of_mem p ε hx]
  have hBMu := bddMeas_dirLimit p ε hp hε hd hpd hΩm hu₀ hC hstep
  have hunif := dirIter_unif p ε hp hε hd hpd hΩm ⟨x, hx⟩ hΩb hu₀ hC hstep
  set D := tugOfWarOp p ε (dirLimit p ε Ω u₀) x - dirLimit p ε Ω u₀ x
    with hD
  have key : ∀ η > 0, |D| ≤ 2 * η := by
    intro η hη
    obtain ⟨N, hN⟩ := hunif η hη
    have h1 : |tugOfWarOp p ε (dirLimit p ε Ω u₀) x
        - tugOfWarOp p ε (dirIter p ε Ω u₀ N) x| ≤ η :=
      tugOfWarOp_nonexpansive p ε hp hd hε hpd hBMu
        (bddMeas_dirIter p ε hp hε hpd hΩm hu₀ N)
        (fun y => hN N le_rfl y) x
    have h2 : |dirLimit p ε Ω u₀ x - dirIter p ε Ω u₀ (N + 1) x| ≤ η :=
      hN (N + 1) (Nat.le_succ N) x
    have h3 : dirIter p ε Ω u₀ (N + 1) x
        = tugOfWarOp p ε (dirIter p ε Ω u₀ N) x := by
      rw [dirIter_succ, dppOp_of_mem p ε hx]
    rw [h3] at h2
    have h4 := abs_le.1 h1
    have h5 := abs_le.1 h2
    rw [hD, abs_le]
    constructor <;> linarith
  have hDzero : D = 0 := by
    by_contra hcon
    have hpos : 0 < |D| := abs_pos.2 hcon
    have := key (|D| / 4) (by positivity)
    linarith
  linarith [hDzero, hD]
/-- **Existence for the `ε`-problem with exterior data.** For bounded measurable
data `F` with `|F| ≤ C`, there is a `p`-harmonious function in `Ω` with data `F`
that equals `F` outside `Ω` and is bounded by `C`. -/
theorem exists_pharmonious (p ε : ℝ) (hp : 2 ≤ p) (hε : 0 < ε) (hd : 0 < d)
    (hpd : 0 < p + (d : ℝ)) {Ω : Set (EuclSpace d)} (hΩm : MeasurableSet Ω)
    (hΩb : Bornology.IsBounded Ω)
    {F : EuclSpace d → ℝ} (hFm : Measurable F) {C : ℝ}
    (hFC : ∀ y, |F y| ≤ C) :
    ∃ u : EuclSpace d → ℝ, IsPHarmonious p ε Ω F u
      ∧ (∀ x, x ∉ Ω → u x = F x) ∧ ∀ y, |u y| ≤ C := by
  have hC0 : 0 ≤ C := le_trans (abs_nonneg _) (hFC 0)
  have hbd : ∀ y, |dirStart Ω F C y| ≤ C := by
    intro y
    by_cases hy : y ∈ Ω
    · rw [dirStart_of_mem hy, abs_neg, abs_of_nonneg hC0]
    · rw [dirStart_of_notMem hy]; exact hFC y
  have hmeas : Measurable (dirStart Ω F C) := by
    unfold dirStart
    exact Measurable.ite hΩm measurable_const hFm
  have hu₀ : BddMeas (dirStart Ω F C) := ⟨hmeas, ⟨C, hbd⟩⟩
  have hstep : ∀ x, dirStart Ω F C x ≤ dppOp p ε Ω (dirStart Ω F C) x := by
    intro x
    by_cases hx : x ∈ Ω
    · rw [dirStart_of_mem hx, dppOp_of_mem p ε hx]
      exact (abs_le.1 (abs_tugOfWarOp_le p ε hp hε hpd hu₀ hbd x)).1
    · exact (dppOp_of_notMem p ε hx _).symm.le
  refine ⟨dirLimit p ε Ω (dirStart Ω F C), ⟨?_, ?_, ?_⟩, ?_, ?_⟩
  · exact bddMeas_dirLimit p ε hp hε hd hpd hΩm hu₀ hbd hstep
  · intro x hx
    have h := dirLimit_fixed p ε hp hε hd hpd hΩm hΩb hu₀ hbd hstep x
    rw [dppOp_of_mem p ε hx] at h
    exact h.symm
  · intro x hx
    rw [dirLimit_eq_of_notMem p ε hx.1, dirStart_of_notMem hx.1]
  · intro x hx
    rw [dirLimit_eq_of_notMem p ε hx, dirStart_of_notMem hx]
  · exact abs_dirLimit_le p ε hp hε hpd hΩm hu₀ hbd
Proof sketch

Start from $u_0 = -C$ on $\Omega$ and $u_0 = F$ elsewhere (dirStart). It is admissible, and $u_0 \le \widetilde T u_0$ because $\abs{\Op u_0} \le C$ on $\Omega$. By Theorem Theorem 7.5 and nonexpansiveness, the limit satisfies $u = \widetilde T u$, that is, $u = \Op u$ on $\Omega$ and $u = F$ outside.

Theorem 7.7Existence and convergence✓ formalized
Formal statementgenerated from the Lean declaration
pharmonious_exists_converge

Let $d \in \mathbb{N}$, $p \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $F \colon \mathbb{R}^{d} \to \mathbb{R}$, $C \in \mathbb{R}$.

Assume

  • $\mathbb{R}^{d}\text{ is nontrivial}$
  • $0 < d$ hd
  • $2 \le p$ hp
  • $0 < p + d$ hpd
  • $\Omega\text{ is open}$ hΩo
  • $\Omega\text{ is bounded}$ hΩb
  • $F\text{ is continuous}$ hFc
  • $\forall y,\ \lvert F(y)\rvert \le C$ hFC
  • $\forall y \in \partial \Omega,\ \exists z, \delta,\ 0 < \delta \wedge \lVert y - z\rVert = \delta \wedge \forall x \in \Omega,\ \delta \le \lVert x - z\rVert$ hext

Then there exists $u$ such that:

  • $\forall \varepsilon > 0,\ u_{\varepsilon}\text{ is }p\text{-harmonious in }\Omega\text{ with step }\varepsilon\text{ and data }F$
  • $\forall \varepsilon > 0,\ \forall x \notin \Omega,\ u_{\varepsilon}(x) = F(x)$
  • $\forall \varepsilon, y,\ \lvert u_{\varepsilon}(y)\rvert \le C$
  • $\forall x \in \overline{\Omega},\ \overline{u}(x) = \underline{u}(x)$
  • $\forall x \in \partial \Omega,\ \overline{u}(x) = F(x)$
  • $\forall \eta > 0,\ \exists \varepsilon_{0} > 0,\ \forall \varepsilon,\ 0 < \varepsilon \to \varepsilon < \varepsilon_{0} \to \forall x \in \overline{\Omega},\ \lvert u_{\varepsilon}(x) - \overline{u}(x)\rvert \le \eta$
Informal statementfrom the blueprint

Let $\Omega$ be bounded and open with an exterior sphere at every boundary point, and $F$ bounded and continuous. Then for every $\eps > 0$ the $\eps$-problem has a $p$-harmonious solution $u_\eps$ with data $F$, equal to $F$ outside $\Omega$, and these solutions converge uniformly on $\overline\Omega$ to the common value of the relaxed limits, which equals $F$ on $\partial\Omega$.

Lean 1
PLaplacian.pharmonious_exists_convergePlaplacian/DirichletExistence.lean, lines 459–497
/-- **Existence and convergence.** Let `Ω` be bounded and open with an exterior
sphere at every boundary point, and `F` bounded and continuous. Then for every
`ε > 0` the `ε`-problem has a `p`-harmonious solution with data `F`, equal to
`F` outside `Ω`, and these solutions converge uniformly on `closure Ω` to the
common value of the relaxed limits, which equals `F` on `frontier Ω`. -/
theorem pharmonious_exists_converge [Nontrivial (EuclSpace d)] (hd : 0 < d)
    {p : ℝ} (hp : 2 ≤ p) (hpd : 0 < p + (d : ℝ)) {Ω : Set (EuclSpace d)}
    (hΩo : IsOpen Ω) (hΩb : Bornology.IsBounded Ω) {F : EuclSpace d → ℝ}
    (hFc : Continuous F) {C : ℝ} (hFC : ∀ y, |F y| ≤ C)
    (hext : ∀ y ∈ frontier Ω, ∃ (z : EuclSpace d) (δ : ℝ), 0 < δ ∧
      ‖y - z‖ = δ ∧ ∀ x ∈ Ω, δ ≤ ‖x - z‖) :
    ∃ u : ℝ → EuclSpace d → ℝ,
      (∀ ε > 0, IsPHarmonious p ε Ω F (u ε)) ∧
      (∀ ε > 0, ∀ x, x ∉ Ω → u ε x = F x) ∧
      (∀ ε y, |u ε y| ≤ C) ∧
      (∀ x ∈ closure Ω, ubar u x = lbar u x) ∧
      (∀ x ∈ frontier Ω, ubar u x = F x) ∧
      (∀ η > 0, ∃ ε₀ > 0, ∀ ε, 0 < ε → ε < ε₀ → ∀ x ∈ closure Ω,
        |u ε x - ubar u x| ≤ η) := by
  have hex : ∀ ε : ℝ, 0 < ε → ∃ v : EuclSpace d → ℝ,
      IsPHarmonious p ε Ω F v ∧ (∀ x, x ∉ Ω → v x = F x) ∧ ∀ y, |v y| ≤ C :=
    fun ε hε => exists_pharmonious p ε hp hε hd hpd hΩo.measurableSet hΩb
      hFc.measurable hFC
  choose! U hU using hex
  set u : ℝ → EuclSpace d → ℝ := fun ε => if 0 < ε then U ε else F with hudef
  have hUeq : ∀ ε, 0 < ε → u ε = U ε := fun ε hε => by
    rw [hudef]; simp [hε]
  have hu : ∀ ε > 0, IsPHarmonious p ε Ω F (u ε) := fun ε hε => by
    rw [hUeq ε hε]; exact (hU ε hε).1
  have hout : ∀ ε > 0, ∀ x, x ∉ Ω → u ε x = F x := fun ε hε x hx => by
    rw [hUeq ε hε]; exact (hU ε hε).2.1 x hx
  have hC : ∀ ε y, |u ε y| ≤ C := fun ε y => by
    by_cases hε : 0 < ε
    · rw [hUeq ε hε]; exact (hU ε hε).2.2 y
    · have h : u ε = F := by rw [hudef]; simp [hε]
      rw [h]; exact hFC y
  obtain ⟨h1, h2, h3⟩ :=
    pharmonious_converge hd hp hpd hΩo hΩb hFc hext hC hu hout
  exact ⟨u, hu, hout, hC, h1, h2, h3⟩
Proof sketch

The family is chosen by Theorem Theorem 7.6 and fed to Theorem Theorem 7.4. The boundedness of $F$ is the one hypothesis added, and it is unavoidable, since $u_\eps = F$ outside $\Omega$ and $u_\eps$ must be bounded. Both theorems depend only on Lean's standard axioms.

Lemma 7.8The one-step estimate✓ formalized
Formal statementgenerated from the Lean declaration
disc_step

Let $d \in \mathbb{N}$, $p, \varepsilon \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $u, v \colon \mathbb{R}^{d} \to \mathbb{R}$, $M \in \mathbb{R}$, $x \in \mathbb{R}^{d}$, $\delta \in \mathbb{R}$, $e \in \mathbb{R}^{d}$.

Assume

  • $2 \le p$ hp
  • $0 < \varepsilon$ hε
  • $0 < p + d$ hpd
  • $u\text{ is admissible (bounded and Borel measurable)}$ hu
  • $v\text{ is admissible (bounded and Borel measurable)}$ hv
  • $\forall x \in \Omega,\ u(x) = T_{\varepsilon} u(x)$ hTu
  • $\forall x \in \Omega,\ v(x) = T_{\varepsilon} v(x)$ hTv
  • $\forall y,\ v(y) - u(y) \le M$ hM
  • $x \in \Omega$ hx
  • $0 < \delta$ hδ
  • $M - \delta < v(x) - u(x)$ hwx
  • $\lVert e\rVert = 1$ he

Then there exists $y$ such that:

  • $M - \operatorname{stepConst}(p, \varepsilon) \cdot \delta < v(y) - u(y)$
  • $\operatorname{inner}(\mathbb{R}, x, e) + \varepsilon / 2 \le \operatorname{inner}(\mathbb{R}, y, e)$
Informal statementfrom the blueprint

Let $u$ and $v$ satisfy the dynamic programming principle in $\Omega$, let $w = v - u \le M$ on $\R^d$, and let $e$ be a unit vector. If $x \in \Omega$ and $w(x) > M - \delta$ with $\delta > 0$, then $w(y) > M - C\delta$ at some point $y$ with $\langle y, e\rangle \ge \langle x, e\rangle + \eps/2$, where $C = 2\abs{B_\eps}/(\beta\abs{B_{\eps/4}})$ depends only on $d$, $p$ and $\eps$.

Used byThm. 7.9
Lean 1
/-- **The one-step estimate.** If `v - u ≤ M` everywhere and `v x - u x > M - δ`
at a point `x ∈ Ω`, then `v - u > M - Cδ` at some point `y` with
`⟪y, e⟫ ≥ ⟪x, e⟫ + ε / 2`. -/
theorem disc_step (p ε : ℝ) (hp : 2 ≤ p) (hε : 0 < ε)
    (hpd : 0 < p + (d : ℝ)) {Ω : Set (EuclSpace d)}
    {u v : EuclSpace d → ℝ} (hu : BddMeas u) (hv : BddMeas v)
    (hTu : ∀ x ∈ Ω, u x = tugOfWarOp p ε u x)
    (hTv : ∀ x ∈ Ω, v x = tugOfWarOp p ε v x)
    {M : ℝ} (hM : ∀ y, v y - u y ≤ M)
    {x : EuclSpace d} (hx : x ∈ Ω) {δ : ℝ} (hδ : 0 < δ)
    (hwx : M - δ < v x - u x) {e : EuclSpace d} (he : ‖e‖ = 1) :
    ∃ y, M - stepConst (d := d) p ε * δ < v y - u y
      ∧ ⟪x, e⟫ + ε / 2 ≤ ⟪y, e⟫ := by
  have hβ : 0 < ((d : ℝ) + 2) / (p + (d : ℝ)) := by positivity
  have hα : 0 ≤ (p - 2) / (p + (d : ℝ)) := div_nonneg (by linarith) hpd.le
  have hab := alpha_add_beta p hpd
  have hV : 0 < volume.real (ball (0 : EuclSpace d) ε) := volumeReal_ball_pos hε
  have hs : 0 < volume.real (ball (0 : EuclSpace d) (ε / 4)) :=
    volumeReal_ball_pos (by linarith)
  have hw : BddMeas (fun y => v y - u y) := hv.sub hu
  -- the equation at x
  have hkey := key_estimate p ε hp hε hpd hu hv x
  have hsup : sSup ((fun y => v y - u y) '' ball x ε) ≤ M := by
    refine csSup_le ((nonempty_ball x hε).image _) ?_
    rintro _ ⟨y, -, rfl⟩
    exact hM y
  have hwx' : v x - u x ≤ (p - 2) / (p + (d : ℝ)) * M
      + ((d : ℝ) + 2) / (p + (d : ℝ)) * ⨍ y in ball x ε, (v y - u y) := by
    have h1 : v x - u x = tugOfWarOp p ε v x - tugOfWarOp p ε u x := by
      rw [← hTv x hx, ← hTu x hx]
    have h2 := mul_le_mul_of_nonneg_left hsup hα
    rw [h1]
    linarith [hkey]
  -- the small ball near the edge of B_ε(x), in the direction e
  set c := x + (3 * ε / 4) • e with hcdef
  have hcx : ‖c - x‖ = 3 * ε / 4 := by
    rw [hcdef, add_sub_cancel_left, norm_smul, he, mul_one, Real.norm_eq_abs,
      abs_of_pos (by linarith)]
  have hSB : ball c (ε / 4) ⊆ ball x ε := by
    intro y hy
    rw [mem_ball] at hy ⊢
    calc dist y x ≤ dist y c + dist c x := dist_triangle _ _ _
      _ < ε / 4 + 3 * ε / 4 := by
          rw [dist_eq_norm c x, hcx]; linarith
      _ = ε := by ring
  -- every point of the small ball lies far enough in the direction e
  have hfar : ∀ y ∈ ball c (ε / 4), ⟪x, e⟫ + ε / 2 ≤ ⟪y, e⟫ := by
    intro y hy
    have hyc : ‖y - c‖ < ε / 4 := by rw [← dist_eq_norm]; exact mem_ball.1 hy
    have h5 : -(ε / 4) ≤ ⟪y - c, e⟫ := by
      have := abs_real_inner_le_norm (y - c) e
      rw [he, mul_one] at this
      linarith [neg_abs_le ⟪y - c, e⟫]
    have h6 : ⟪c, e⟫ = ⟪x, e⟫ + 3 * ε / 4 := by
      rw [hcdef, inner_add_left, real_inner_smul_left, real_inner_self_eq_norm_sq, he]
      ring
    have h7 : ⟪y, e⟫ = ⟪y - c, e⟫ + ⟪c, e⟫ := by
      rw [← inner_add_left, sub_add_cancel]
    linarith
  -- by contradiction: no point of the small ball has v - u > M - Cδ
  by_contra hcon
  push Not at hcon
  have hlow : ∀ y ∈ ball c (ε / 4),
      stepConst (d := d) p ε * δ ≤ M - (v y - u y) := by
    intro y hy
    by_contra hlt
    push Not at hlt
    have := hcon y (by linarith)
    linarith [hfar y hy]
  -- integrate over the small ball and over B_ε(x)
  have hintB : IntegrableOn (fun y => M - (v y - u y)) (ball x ε) :=
    Integrable.sub (integrableOn_const_ball M x ε) (hw.integrableOn_ball x ε)
  have hintS : IntegrableOn (fun y => M - (v y - u y)) (ball c (ε / 4)) :=
    hintB.mono_set hSB
  have hnn : ∀ y, 0 ≤ M - (v y - u y) := fun y => by linarith [hM y]
  have hI1 : (∫ y in ball c (ε / 4), (M - (v y - u y)))
      ≤ ∫ y in ball x ε, (M - (v y - u y)) :=
    MeasureTheory.setIntegral_mono_set hintB
      (Filter.Eventually.of_forall hnn) (LE.le.eventuallyLE hSB)
  have hI2 : (∫ y in ball c (ε / 4), (stepConst (d := d) p ε * δ))
      ≤ ∫ y in ball c (ε / 4), (M - (v y - u y)) :=
    MeasureTheory.setIntegral_mono_on (integrableOn_const_ball _ c _) hintS
      measurableSet_ball hlow
  have hI3 : (∫ y in ball c (ε / 4), (stepConst (d := d) p ε * δ))
      = stepConst (d := d) p ε * δ
          * volume.real (ball (0 : EuclSpace d) (ε / 4)) := by
    rw [MeasureTheory.setIntegral_const, smul_eq_mul,
      volumeReal_ball_center c (ε / 4)]
    ring
  have hI4 : (∫ y in ball x ε, (M - (v y - u y)))
      = volume.real (ball (0 : EuclSpace d) ε)
          * (M - ⨍ y in ball x ε, (v y - u y)) := by
    rw [MeasureTheory.integral_sub (integrableOn_const_ball M x ε)
        (hw.integrableOn_ball x ε),
      MeasureTheory.setIntegral_const, smul_eq_mul,
      MeasureTheory.setAverage_eq, smul_eq_mul, volumeReal_ball_center x ε,
      mul_sub, ← mul_assoc, mul_inv_cancel₀ hV.ne', one_mul]
  have hint : stepConst (d := d) p ε * δ
        * volume.real (ball (0 : EuclSpace d) (ε / 4))
      ≤ volume.real (ball (0 : EuclSpace d) ε)
          * (M - ⨍ y in ball x ε, (v y - u y)) := by
    rw [← hI3, ← hI4]; exact le_trans hI2 hI1
  have hK : stepConst (d := d) p ε * δ
        * volume.real (ball (0 : EuclSpace d) (ε / 4))
      = 2 * volume.real (ball (0 : EuclSpace d) ε) * δ
          / (((d : ℝ) + 2) / (p + (d : ℝ))) := by
    have hsne := hs.ne'
    have hβne := hβ.ne'
    have hpdne : p + (d : ℝ) ≠ 0 := hpd.ne'
    have hd2 : (d : ℝ) + 2 ≠ 0 := by positivity
    unfold stepConst
    field_simp
  exact step_arith hβ hV hδ hab (lt_of_lt_of_le hwx hwx') hK hint
Proof sketch

By the key estimate, $w(x) \le \alpha M + \beta \avgint_{B_\eps(x)} w$, so $\avgint_{B_\eps(x)} w > M - \delta/\beta$. The ball $S = B(x + \frac34\eps e, \frac14\eps)$ lies in $B_\eps(x)$, and each of its points lies at least $\eps/2$ further in the direction $e$. If $w \le M - C\delta$ on all of $S$, then $\int_{B_\eps(x)}(M - w) \ge \int_S (M - w) \ge C\delta\abs{B_{\eps/4}}$, while $\int_{B_\eps(x)}(M - w) = \abs{B_\eps}(M - \avgint_{B_\eps(x)} w) < \abs{B_\eps}\delta/\beta$; with the stated $C$ these are incompatible.

Theorem 7.9The difference of two solutions is nonpositive✓ formalized
Formal statementgenerated from the Lean declaration
sup_diff_nonpos

Let $d \in \mathbb{N}$, $p, \varepsilon \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $u, v \colon \mathbb{R}^{d} \to \mathbb{R}$, $x \in \mathbb{R}^{d}$.

Assume

  • $\mathbb{R}^{d}\text{ is nontrivial}$
  • $2 \le p$ hp
  • $0 < \varepsilon$ hε
  • $0 < p + d$ hpd
  • $\Omega\text{ is bounded}$ hΩb
  • $u\text{ is admissible (bounded and Borel measurable)}$ hu
  • $v\text{ is admissible (bounded and Borel measurable)}$ hv
  • $\forall x \in \Omega,\ u(x) = T_{\varepsilon} u(x)$ hTu
  • $\forall x \in \Omega,\ v(x) = T_{\varepsilon} v(x)$ hTv
  • $\forall x \notin \Omega,\ u(x) = v(x)$ hout

Then $v(x) \le u(x)$.

Informal statementfrom the blueprint

Let $\Omega$ be bounded, and let $u$ and $v$ satisfy the dynamic programming principle in $\Omega$ and agree outside $\Omega$. Then $v \le u$.

Used byThm. 7.10
Lean 1
/-- **The difference of two solutions is nonpositive.** If `u` and `v` satisfy
the dynamic programming principle in a bounded set `Ω` and agree outside `Ω`,
then `v ≤ u`. -/
theorem sup_diff_nonpos [Nontrivial (EuclSpace d)] (p ε : ℝ) (hp : 2 ≤ p)
    (hε : 0 < ε) (hpd : 0 < p + (d : ℝ)) {Ω : Set (EuclSpace d)}
    (hΩb : Bornology.IsBounded Ω)
    {u v : EuclSpace d → ℝ} (hu : BddMeas u) (hv : BddMeas v)
    (hTu : ∀ x ∈ Ω, u x = tugOfWarOp p ε u x)
    (hTv : ∀ x ∈ Ω, v x = tugOfWarOp p ε v x)
    (hout : ∀ x, x ∉ Ω → u x = v x) :
    ∀ x, v x ≤ u x := by
  have hw : BddMeas (fun y => v y - u y) := hv.sub hu
  obtain ⟨B, hB⟩ := hw.bound
  have hbdd : BddAbove (range fun y => v y - u y) :=
    ⟨B, by rintro _ ⟨y, rfl⟩; exact (abs_le.1 (hB y)).2⟩
  set M := ⨆ y, (v y - u y)
  have hM : ∀ y, v y - u y ≤ M := fun y => le_ciSup hbdd y
  -- it suffices to show M ≤ 0
  suffices hM0 : M ≤ 0 by
    intro x
    linarith [hM x]
  by_contra hMpos
  push Not at hMpos
  -- a point where v - u > 0 lies in Ω
  have hmem : ∀ y, 0 < v y - u y → y ∈ Ω := by
    intro y hy
    by_contra hyΩ
    rw [hout y hyΩ, sub_self] at hy
    exact lt_irrefl _ hy
  -- a unit direction, and a bound for Ω in that direction
  obtain ⟨e, he⟩ := exists_norm_eq (EuclSpace d) zero_le_one
  obtain ⟨R, hR⟩ := hΩb.exists_norm_le
  have hproj : ∀ y ∈ Ω, |⟪y, e⟫| ≤ R := by
    intro y hy
    have := abs_real_inner_le_norm y e
    rw [he, mul_one] at this
    exact le_trans this (hR y hy)
  -- the number of steps and the constants
  set C := max (stepConst (d := d) p ε) 1
  have hC1 : 1 ≤ C := le_max_right _ _
  have hCpos : 0 < C := by linarith
  set N : ℕ := ⌈4 * |R| / ε⌉₊ + 1 with hNdef
  have hCN : 0 < C ^ N := pow_pos hCpos N
  set δ₀ := M / (2 * C ^ N) with hδ₀def
  have hδ₀ : 0 < δ₀ := by rw [hδ₀def]; positivity
  have hsmall : ∀ k ≤ N, C ^ k * δ₀ ≤ M / 2 := by
    intro k hk
    have h1 : C ^ k ≤ C ^ N := pow_le_pow_right₀ hC1 hk
    have hCNne : C ^ N ≠ 0 := hCN.ne'
    have h2 : C ^ N * δ₀ = M / 2 := by
      rw [hδ₀def]
      field_simp
    calc C ^ k * δ₀ ≤ C ^ N * δ₀ := mul_le_mul_of_nonneg_right h1 hδ₀.le
      _ = M / 2 := h2
  -- the starting point
  obtain ⟨x₀, hx₀⟩ : ∃ x₀, M - δ₀ < v x₀ - u x₀ :=
    exists_lt_of_lt_ciSup (by linarith : M - δ₀ < M)
  -- the walk
  have hwalk : ∀ k ≤ N, ∃ x, M - C ^ k * δ₀ < v x - u x
      ∧ ⟪x₀, e⟫ + (k : ℝ) * (ε / 2) ≤ ⟪x, e⟫ := by
    intro k
    induction k with
    | zero =>
        intro _
        refine ⟨x₀, ?_, ?_⟩
        · simpa using hx₀
        · simp
    | succ k ih =>
        intro hk
        obtain ⟨x, hxw, hxe⟩ := ih (Nat.le_of_succ_le hk)
        have hk' := hsmall k (Nat.le_of_succ_le hk)
        have hxΩ : x ∈ Ω := hmem x (by linarith)
        have hδk : 0 < C ^ k * δ₀ := by positivity
        obtain ⟨y, hyw, hye⟩ :=
          disc_step p ε hp hε hpd hu hv hTu hTv hM hxΩ hδk hxw he
        refine ⟨y, ?_, ?_⟩
        · have h1 : stepConst (d := d) p ε ≤ C := le_max_left _ _
          have h2 : stepConst (d := d) p ε * (C ^ k * δ₀) ≤ C * (C ^ k * δ₀) :=
            mul_le_mul_of_nonneg_right h1 hδk.le
          have h3 : C ^ (k + 1) * δ₀ = C * (C ^ k * δ₀) := by rw [pow_succ]; ring
          rw [h3]
          linarith
        · push_cast
          linarith
  -- after N steps the walk has left Ω, but v - u is still positive there
  obtain ⟨x, hxw, hxe⟩ := hwalk N le_rfl
  have hxΩ : x ∈ Ω := hmem x (by linarith [hsmall N le_rfl])
  have hx₀Ω : x₀ ∈ Ω := hmem x₀ (by
    have := hsmall 0 (Nat.zero_le N)
    simp only [pow_zero, one_mul] at this
    linarith)
  obtain ⟨h1a, h1b⟩ := abs_le.1 (hproj x hxΩ)
  obtain ⟨h2a, h2b⟩ := abs_le.1 (hproj x₀ hx₀Ω)
  have hN : 4 * |R| / ε < (N : ℝ) := by
    rw [hNdef]; push_cast
    linarith [Nat.le_ceil (4 * |R| / ε)]
  have hNε : 2 * |R| < (N : ℝ) * (ε / 2) := by
    have := (div_lt_iff₀ hε).1 hN
    linarith
  have hRabs : R ≤ |R| := le_abs_self R
  linarith
Proof sketch

The strategy is that of Luiro, Parviainen and Saksman (Theorem 2.2 of their paper on $p$-harmonious functions): near-maxima propagate in a fixed direction until they leave the bounded domain. Let $M = \sup(v - u)$ and suppose $M > 0$; since $v - u = 0$ outside $\Omega$, near-maxima lie in $\Omega$. Starting from $w(x_0) > M - \delta_0$ and applying Lemma Lemma 7.8 $N$ times, with $N\eps/2$ larger than the width of $\Omega$, gives a point outside $\Omega$ where $w > M - C^N\delta_0$. With $\delta_0 = M/(2C^N)$ this is positive, a contradiction. Unlike the original argument, the formal proof propagates near-maxima with geometrically growing errors, so no compactness argument is needed to produce an exact maximal set.

Theorem 7.10Uniqueness for the $\eps$-problem✓ formalized
Formal statementgenerated from the Lean declaration
pharmonious_unique

Let $d \in \mathbb{N}$, $p, \varepsilon \in \mathbb{R}$, $\Omega \subseteq \mathbb{R}^{d}$, $F, u, v \colon \mathbb{R}^{d} \to \mathbb{R}$.

Assume

  • $\mathbb{R}^{d}\text{ is nontrivial}$
  • $2 \le p$ hp
  • $0 < \varepsilon$ hε
  • $0 < p + d$ hpd
  • $\Omega\text{ is bounded}$ hΩb
  • $u\text{ is }p\text{-harmonious in }\Omega\text{ with step }\varepsilon\text{ and data }F$ hu
  • $v\text{ is }p\text{-harmonious in }\Omega\text{ with step }\varepsilon\text{ and data }F$ hv
  • $\forall x \notin \Omega,\ u(x) = F(x)$ huF
  • $\forall x \notin \Omega,\ v(x) = F(x)$ hvF

Then $u = v$.

Informal statementfrom the blueprint

Let $\Omega$ be bounded. Two $p$-harmonious functions in $\Omega$ with data $F$ that both equal $F$ outside $\Omega$ are equal.

Lean 1
PLaplacian.pharmonious_uniquePlaplacian/DiscUnique.lean, lines 300–314
/-- **Uniqueness for the `ε`-problem.** Two `p`-harmonious functions in a bounded
set `Ω` with data `F` that both equal `F` outside `Ω` are equal. -/
theorem pharmonious_unique [Nontrivial (EuclSpace d)] (p ε : ℝ) (hp : 2 ≤ p)
    (hε : 0 < ε) (hpd : 0 < p + (d : ℝ)) {Ω : Set (EuclSpace d)}
    (hΩb : Bornology.IsBounded Ω) {F u v : EuclSpace d → ℝ}
    (hu : IsPHarmonious p ε Ω F u) (hv : IsPHarmonious p ε Ω F v)
    (huF : ∀ x, x ∉ Ω → u x = F x) (hvF : ∀ x, x ∉ Ω → v x = F x) :
    u = v := by
  have hout : ∀ x, x ∉ Ω → u x = v x := fun x hx => by rw [huF x hx, hvF x hx]
  have h1 := sup_diff_nonpos p ε hp hε hpd hΩb hu.bddMeas hv.bddMeas
    hu.interior hv.interior hout
  have h2 := sup_diff_nonpos p ε hp hε hpd hΩb hv.bddMeas hu.bddMeas
    hv.interior hu.interior (fun x hx => (hout x hx).symm)
  funext x
  exact le_antisymm (h2 x) (h1 x)
Proof sketch

Both functions satisfy the dynamic programming principle in $\Omega$ and agree outside $\Omega$, so Theorem Theorem 7.9 applies in each direction.