Poincaré conjecture: the Lean proof, cleaned up together
The 2026 Lean proof of the Poincaré conjecture after Morgan and Tian, 3 million lines, cleaned up together: smaller, faster to build, more readable, the theorems unchanged

| 1 | import PoincareLib.Analysis.Elliptic.Regularity.EnergyEstimate.ComparisonTest |
| 2 | |
| 3 | /-! |
| 4 | # Energy comparison from two weak divergence inequalities |
| 5 | |
| 6 | Testing both inequalities with nonnegative cutoff differences controls the |
| 7 | pairing of the flux difference with the gradient difference. All integrability |
| 8 | conditions are derived from local Lipschitz regularity and square-integrable |
| 9 | fluxes; the test functions need not be smooth. |
| 10 | -/ |
| 11 | |
| 12 | noncomputable section |
| 13 | |
| 14 | open Set MeasureTheory Filter |
| 15 | open scoped Topology ENNReal NNReal BigOperators |
| 16 | open Poincare.Analysis.Sobolev.Weak |
| 17 | |
| 18 | namespace Poincare.Analysis.Elliptic |
| 19 | |
| 20 | variable {d : ℕ} |
| 21 | local notation "E" => EuclideanSpace ℝ (Fin d) |
| 22 | |
| 23 | private theorem memLp_top_difference_weight |
| 24 | {O : Set E} (hO : IsOpen O) {u v : E → ℝ} {A B ε : ℝ≥0} |
| 25 | (hu : LipschitzOnWith A u O) (hv : LipschitzOnWith B v O) |
| 26 | (herr : ∀ x ∈ O, |u x - v x| ≤ ε) : |
| 27 | MemLp (fun x => v x - u x + ε) ∞ (volume.restrict O) := by |
| 28 | apply memLp_top_of_bound |
| 29 | (((hv.continuousOn.sub hu.continuousOn).add continuousOn_const).aestronglyMeasurable |
| 30 | hO.measurableSet) (2 * (ε : ℝ)) |
| 31 | filter_upwards [ae_restrict_mem hO.measurableSet] with x hx |
| 32 | simp only [Pi.add_apply, Pi.sub_apply] |
| 33 | rw [Real.norm_eq_abs] |
| 34 | have h := abs_le.mp (herr x hx) |
| 35 | apply abs_le.mpr |
| 36 | constructor <;> linarith [ε.coe_nonneg] |
| 37 | |
| 38 | /-- The two opposite nonnegative difference tests give the flux energy |
| 39 | comparison, including the explicit cutoff and source terms. -/ |
| 40 | theorem weak_flux_comparison_energy_le |
| 41 | {O : Set E} (hO : IsOpen O) {F G : Fin d → E → ℝ} {f g u v φ : E → ℝ} |
| 42 | (hF : ∀ i, MemLp (F i) 2 (volume.restrict O)) |
| 43 | (hG : ∀ i, MemLp (G i) 2 (volume.restrict O)) |
| 44 | (hf : MemLp f 2 (volume.restrict O)) (hg : MemLp g 2 (volume.restrict O)) |
| 45 | (hleF : ∀ ψ : E → ℝ, ContDiff ℝ (⊤ : ℕ∞) ψ → HasCompactSupport ψ → |
| 46 | tsupport ψ ⊆ O → (∀ x, 0 ≤ ψ x) → |
| 47 | (∫ x in O, ∑ i, F i x * fderiv ℝ ψ x (EuclideanSpace.single i 1)) ≤ |
| 48 | ∫ x in O, f x * ψ x) |
| 49 | (hleG : ∀ ψ : E → ℝ, ContDiff ℝ (⊤ : ℕ∞) ψ → HasCompactSupport ψ → |
| 50 | tsupport ψ ⊆ O → (∀ x, 0 ≤ ψ x) → |
| 51 | (∫ x in O, ∑ i, G i x * fderiv ℝ ψ x (EuclideanSpace.single i 1)) ≤ |
| 52 | ∫ x in O, g x * ψ x) |
| 53 | {A B ε : ℝ≥0} (hu : LipschitzOnWith A u O) (hv : LipschitzOnWith B v O) |
| 54 | (herr : ∀ x ∈ O, |u x - v x| ≤ ε) |
| 55 | (hφ : ContDiff ℝ (⊤ : ℕ∞) φ) (hφc : HasCompactSupport φ) |
| 56 | (hφO : tsupport φ ⊆ O) (hφ0 : ∀ x, 0 ≤ φ x) (hφ1 : ∀ x, φ x ≤ 1) : |
| 57 | (∫ x in O, φ x * ∑ i, (G i x - F i x) * |
| 58 | (fderiv ℝ u x (EuclideanSpace.single i 1) - fderiv ℝ v x (EuclideanSpace.single i 1))) ≤ |
| 59 | (∫ x in O, f x * (φ x * (v x - u x + ε))) + |
| 60 | (∫ x in O, g x * (φ x * (u x - v x + ε))) - |
| 61 | ∫ x in O, ∑ i, ((v x - u x + ε) * F i x + (u x - v x + ε) * G i x) * |
| 62 | fderiv ℝ φ x (EuclideanSpace.single i 1) := by |
| 63 | let du := fun i x => fderiv ℝ u x (EuclideanSpace.single i 1) |
| 64 | let dv := fun i x => fderiv ℝ v x (EuclideanSpace.single i 1) |
| 65 | let dφ := fun i x => fderiv ℝ φ x (EuclideanSpace.single i 1) |
| 66 | let w := fun x => v x - u x + (ε : ℝ) |
| 67 | let z := fun x => u x - v x + (ε : ℝ) |
| 68 | have herr' : ∀ x ∈ O, |v x - u x| ≤ ε := by simpa only [abs_sub_comm] using herr |
| 69 | have hw := memLp_top_difference_weight hO hu hv herr |
| 70 | have hz := memLp_top_difference_weight hO hv hu herr' |
| 71 | have hdu (i) : MemLp (du i) ∞ (volume.restrict O) := |
| 72 | memLp_top_fderiv_apply_of_lipschitzOn hO hu _ |
| 73 | have hdv (i) : MemLp (dv i) ∞ (volume.restrict O) := |
| 74 | memLp_top_fderiv_apply_of_lipschitzOn hO hv _ |
| 75 | have hp : MemLp φ 2 (volume.restrict O) := |
| 76 | (hφ.continuous.memLp_of_hasCompactSupport hφc).restrict O |
| 77 | have hdp (i) : MemLp (dφ i) 2 (volume.restrict O) := by |
| 78 | have h := (hφ.fderiv_right (m := (⊤ : ℕ∞)) (by norm_cast)).clm_apply |
| 79 | (contDiff_const (c := EuclideanSpace.single i (1 : ℝ))) |
| 80 | exact (h.continuous.memLp_of_hasCompactSupport (hφc.fderiv_apply (𝕜 := ℝ) _)).restrict O |
| 81 | let L₁ := fun x => ∑ i, F i x * (φ x * (dv i x - du i x) + w x * dφ i x) |
| 82 | let L₂ := fun x => ∑ i, G i x * (φ x * (du i x - dv i x) + z x * dφ i x) |
| 83 | let energy := fun x => φ x * ∑ i, (G i x - F i x) * (du i x - dv i x) |
| 84 | let boundary := fun x => ∑ i, (w x * F i x + z x * G i x) * dφ i x |
| 85 | have hproduct {a b : E → ℝ} (ha : MemLp a ∞ (volume.restrict O)) |
| 86 | (hb : MemLp b 2 (volume.restrict O)) : |
| 87 | MemLp (fun x => b x * a x) 2 (volume.restrict O) := ha.mul' hb |
| 88 | have hproduct' {a b : E → ℝ} (ha : MemLp a ∞ (volume.restrict O)) |
| 89 | (hb : MemLp b 2 (volume.restrict O)) : |
| 90 | MemLp (fun x => a x * b x) 2 (volume.restrict O) := hb.mul' ha |
| 91 | have hL₁ : IntegrableOn L₁ O := by |
| 92 | apply integrable_finsetSum |
| 93 | intro i _ |
| 94 | exact (hF i).integrable_mul |
| 95 | ((hproduct ((hdv i).sub (hdu i)) hp).add (hproduct' hw (hdp i))) |
| 96 | have hL₂ : IntegrableOn L₂ O := by |
| 97 | apply integrable_finsetSum |
| 98 | intro i _ |
| 99 | exact (hG i).integrable_mul |
| 100 | ((hproduct ((hdu i).sub (hdv i)) hp).add (hproduct' hz (hdp i))) |
| 101 | have he : IntegrableOn energy O := by |
| 102 | have hsum : IntegrableOn |
| 103 | (fun x => ∑ i, (G i x - F i x) * (φ x * (du i x - dv i x))) O := by |
| 104 | apply integrable_finsetSum |
| 105 | intro i _ |
| 106 | exact ((hG i).sub (hF i)).integrable_mul (hproduct ((hdu i).sub (hdv i)) hp) |
| 107 | convert hsum using 1 |
| 108 | funext x |
| 109 | dsimp only [energy] |
| 110 | rw [Finset.mul_sum] |
| 111 | apply Finset.sum_congr rfl |
| 112 | intro i _ |
| 113 | ring |
| 114 | have hb : IntegrableOn boundary O := by |
| 115 | apply integrable_finsetSum |
| 116 | intro i _ |
| 117 | have h := ((hF i).integrable_mul (hproduct' hw (hdp i))).add |
| 118 | ((hG i).integrable_mul (hproduct' hz (hdp i))) |
| 119 | convert h using 1 |
| 120 | funext x |
| 121 | dsimp only [Pi.add_apply, Pi.mul_apply, w, z] |
| 122 | ring |
| 123 | have hidentity : (∫ x in O, energy x) + (∫ x in O, boundary x) = |
| 124 | (∫ x in O, L₁ x) + ∫ x in O, L₂ x := by |
| 125 | rw [← integral_add he hb, ← integral_add hL₁ hL₂] |
| 126 | apply integral_congr_ae |
| 127 | filter_upwards with x |
| 128 | dsimp only [energy, boundary, L₁, L₂] |
| 129 | simp only [Finset.mul_sum, ← Finset.sum_add_distrib] |
| 130 | apply Finset.sum_congr rfl |
| 131 | intro i _ |
| 132 | ring |
| 133 | have hfirst := weakInequality_comparison_test hO hF hf hleF hu hv herr hφ hφc hφO hφ0 hφ1 |
| 134 | have hsecond := weakInequality_comparison_test hO hG hg hleG hv hu herr' hφ hφc hφO hφ0 hφ1 |
| 135 | change (∫ x in O, energy x) ≤ _ - ∫ x in O, boundary x |
| 136 | change (∫ x in O, L₁ x) ≤ _ at hfirst |
| 137 | change (∫ x in O, L₂ x) ≤ _ at hsecond |
| 138 | linarith |
| 139 | |
| 140 | end Poincare.Analysis.Elliptic |