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.Iteration.DifferentiatedEquation |
| 2 | import PoincareLib.Analysis.Elliptic.Regularity.EnergyEstimate.Coefficients |
| 3 | |
| 4 | /-! |
| 5 | # Classical elliptic operators and their weak equations |
| 6 | |
| 7 | The nondivergence operator is written with its original first-order term. |
| 8 | The coefficient derivative correction identifies the scalar source in the |
| 9 | divergence equation used by the interior estimates. |
| 10 | -/ |
| 11 | |
| 12 | noncomputable section |
| 13 | |
| 14 | open Set MeasureTheory Filter Topology |
| 15 | open scoped ContDiff |
| 16 | open Poincare.Analysis.Elliptic.Iteration |
| 17 | open Poincare.Analysis.Sobolev.Weak |
| 18 | open Poincare.Analysis.Sobolev.NirenbergEuclidean |
| 19 | |
| 20 | namespace Poincare.Analysis.Elliptic.InteriorEstimates |
| 21 | |
| 22 | variable {d : ℕ} |
| 23 | local notation "E" => EuclideanSpace ℝ (Fin d) |
| 24 | |
| 25 | /-- A real second-order nondivergence operator, with no zeroth-order term. -/ |
| 26 | def secondOrderOperator (a : E → Matrix (Fin d) (Fin d) ℝ) |
| 27 | (b : Fin d → E → ℝ) (u : E → ℝ) : E → ℝ := fun x => |
| 28 | (∑ i, ∑ j, a x i j * partialDeriv i (partialDeriv j u) x) + |
| 29 | ∑ i, b i x * partialDeriv i u x |
| 30 | |
| 31 | /-- The negative divergence of the principal flux. -/ |
| 32 | def principalSource (a : E → Matrix (Fin d) (Fin d) ℝ) (u : E → ℝ) : E → ℝ := |
| 33 | fun x => -(∑ i, partialDeriv i (matrixFlux a (fun j => partialDeriv j u) i) x) |
| 34 | |
| 35 | /-- A differential operator depends only on the germ of its input. -/ |
| 36 | theorem secondOrderOperator_eq_of_eventuallyEq |
| 37 | (a : E → Matrix (Fin d) (Fin d) ℝ) (b : Fin d → E → ℝ) |
| 38 | {u v : E → ℝ} {x : E} (h : u =ᶠ[𝓝 x] v) : |
| 39 | secondOrderOperator a b u x = secondOrderOperator a b v x := by |
| 40 | have hp (i : Fin d) : partialDeriv i u =ᶠ[𝓝 x] partialDeriv i v := by |
| 41 | filter_upwards [h.fderiv (𝕜 := ℝ)] with y hy |
| 42 | exact congrArg (fun A : E →L[ℝ] ℝ => A (EuclideanSpace.single i 1)) hy |
| 43 | have hp₂ (i j : Fin d) : partialDeriv i (partialDeriv j u) x = |
| 44 | partialDeriv i (partialDeriv j v) x := |
| 45 | congrArg (fun A : E →L[ℝ] ℝ => A (EuclideanSpace.single i 1)) (hp j).fderiv_eq |
| 46 | simp only [secondOrderOperator, hp₂, (hp _).self_of_nhds] |
| 47 | |
| 48 | theorem secondOrderOperator_eqOn {V : Set E} (hV : IsOpen V) |
| 49 | {a a' : E → Matrix (Fin d) (Fin d) ℝ} {b b' : Fin d → E → ℝ} |
| 50 | (ha : EqOn a a' V) (hb : ∀ i, EqOn (b i) (b' i) V) |
| 51 | {u v : E → ℝ} (hu : EqOn u v V) : |
| 52 | EqOn (secondOrderOperator a b u) (secondOrderOperator a' b' v) V := by |
| 53 | intro x hx |
| 54 | have hg : u =ᶠ[𝓝 x] v := by |
| 55 | filter_upwards [hV.mem_nhds hx] with y hy |
| 56 | exact hu hy |
| 57 | rw [secondOrderOperator_eq_of_eventuallyEq a b hg] |
| 58 | simp only [secondOrderOperator, ha hx, hb _ hx] |
| 59 | |
| 60 | theorem iterate_secondOrderOperator_eqOn {V : Set E} (hV : IsOpen V) |
| 61 | {a a' : E → Matrix (Fin d) (Fin d) ℝ} {b b' : Fin d → E → ℝ} |
| 62 | (ha : EqOn a a' V) (hb : ∀ i, EqOn (b i) (b' i) V) |
| 63 | {u v : E → ℝ} (hu : EqOn u v V) (j : ℕ) : |
| 64 | EqOn ((secondOrderOperator a b)^[j] u) ((secondOrderOperator a' b')^[j] v) V := by |
| 65 | induction j with |
| 66 | | zero => exact hu |
| 67 | | succ j ih => |
| 68 | simpa only [Function.iterate_succ_apply'] using secondOrderOperator_eqOn hV ha hb ih |
| 69 | |
| 70 | theorem contDiff_secondOrderOperator |
| 71 | {a : E → Matrix (Fin d) (Fin d) ℝ} {b : Fin d → E → ℝ} |
| 72 | (ha : ∀ i j, ContDiff ℝ ∞ (fun x => a x i j)) |
| 73 | (hb : ∀ i, ContDiff ℝ ∞ (b i)) {u : E → ℝ} (hu : ContDiff ℝ ∞ u) : |
| 74 | ContDiff ℝ ∞ (secondOrderOperator a b u) := by |
| 75 | apply ContDiff.add |
| 76 | · exact ContDiff.sum fun i _ => ContDiff.sum fun j _ => |
| 77 | (ha i j).mul (contDiff_partial (contDiff_partial hu j) i) |
| 78 | · exact ContDiff.sum fun i _ => (hb i).mul (contDiff_partial hu i) |
| 79 | |
| 80 | theorem weakEquation_principalSource {V : Set E} (hV : IsOpen V) |
| 81 | {a : E → Matrix (Fin d) (Fin d) ℝ} |
| 82 | (ha : ∀ i j, ContDiff ℝ ∞ (fun x => a x i j)) |
| 83 | {u : E → ℝ} (hu : ContDiff ℝ ∞ u) : |
| 84 | WeakEquation V (matrixFlux a (fun j => partialDeriv j u)) (principalSource a u) := by |
| 85 | let F := matrixFlux a (fun j => partialDeriv j u) |
| 86 | have hF (i) : ContDiff ℝ ∞ (F i) := |
| 87 | ContDiff.sum fun j _ => (ha i j).mul (contDiff_partial hu j) |
| 88 | intro φ hφ hφc hφV |
| 89 | have hi (i) := HasWeakPartialDeriv.of_contDiff (i := i) hV |
| 90 | ((hF i).of_le (by simp)) φ hφ hφc hφV |
| 91 | have hFi (i) : LocallyIntegrable (F i) (volume.restrict V) := |
| 92 | (hF i).continuous.locallyIntegrable.mono_measure Measure.restrict_le_self |
| 93 | have hDi (i) : LocallyIntegrable (partialDeriv i (F i)) (volume.restrict V) := |
| 94 | (contDiff_partial (hF i) i).continuous.locallyIntegrable.mono_measure |
| 95 | Measure.restrict_le_self |
| 96 | change (∫ x in V, ∑ i, F i x * partialDeriv i φ x) = |
| 97 | ∫ x in V, (-(∑ i, partialDeriv i (F i) x)) * φ x |
| 98 | rw [integral_finsetSum _ (fun i _ => integrable_mul_partial_test (hFi i) hφ hφc i)] |
| 99 | simp_rw [neg_mul, Finset.sum_mul] |
| 100 | rw [integral_neg, integral_finsetSum _ (fun i _ => integrable_mul_test (hDi i) hφ hφc), |
| 101 | ← Finset.sum_neg_distrib] |
| 102 | exact Finset.sum_congr rfl (fun i _ => hi i) |
| 103 | |
| 104 | /-- Classical smooth functions satisfy the weak principal equation with their |
| 105 | computed divergence source. -/ |
| 106 | theorem principal_equation_of_smooth [NeZero d] {Ω V : Set E} |
| 107 | (B : SmoothEllipticBilinearForm d Ω) (hV : IsOpen V) |
| 108 | {u : E → ℝ} (hu : ContDiff ℝ ∞ u) : |
| 109 | ∀ φ : E → ℝ, ContDiff ℝ ∞ φ → HasCompactSupport φ → tsupport φ ⊆ V → |
| 110 | (∫ x in V, B.principalIntegrand u φ x) = |
| 111 | ∫ x in V, principalSource B.a u x * φ x := by |
| 112 | intro φ hφ hφc hφV |
| 113 | have h := weakEquation_principalSource hV B.smooth_a hu φ hφ hφc hφV |
| 114 | convert h using 1 |
| 115 | apply integral_congr_ae |
| 116 | filter_upwards [] with x |
| 117 | simp only [SmoothEllipticBilinearForm.principalIntegrand, matrixFlux, |
| 118 | partialDeriv, Finset.sum_mul] |
| 119 | rw [Finset.sum_comm] |
| 120 | simp only [B.symm] |
| 121 | |
| 122 | theorem principalSource_eq_secondOrderOperator |
| 123 | {a : E → Matrix (Fin d) (Fin d) ℝ} (b : Fin d → E → ℝ) |
| 124 | (ha : ∀ i j, ContDiff ℝ ∞ (fun x => a x i j)) |
| 125 | {u : E → ℝ} (hu : ContDiff ℝ ∞ u) (x : E) : |
| 126 | principalSource a u x = -secondOrderOperator a b u x + |
| 127 | ∑ j, (b j x - ∑ i, partialDeriv i (fun y => a y i j) x) * partialDeriv j u x := by |
| 128 | have hd (i j) : DifferentiableAt ℝ (fun y => a y i j * partialDeriv j u y) x := |
| 129 | ((ha i j).mul (contDiff_partial hu j)).differentiable (by simp) x |
| 130 | have hprod (i j) : partialDeriv i (fun y => a y i j * partialDeriv j u y) x = |
| 131 | a x i j * partialDeriv i (partialDeriv j u) x + |
| 132 | partialDeriv i (fun y => a y i j) x * partialDeriv j u x := by |
| 133 | change (fderiv ℝ (fun y => a y i j * partialDeriv j u y) x) |
| 134 | (EuclideanSpace.single i 1) = _ |
| 135 | rw [fderiv_fun_mul ((ha i j).differentiable (by simp) x) |
| 136 | ((contDiff_partial hu j).differentiable (by simp) x)] |
| 137 | simp only [add_apply, smul_apply, smul_eq_mul, partialDeriv] |
| 138 | ring |
| 139 | have hflux (i) : partialDeriv i (matrixFlux a (fun j => partialDeriv j u) i) x = |
| 140 | ∑ j, (a x i j * partialDeriv i (partialDeriv j u) x + |
| 141 | partialDeriv i (fun y => a y i j) x * partialDeriv j u x) := by |
| 142 | change (fderiv ℝ (fun y => ∑ j, a y i j * partialDeriv j u y) x) |
| 143 | (EuclideanSpace.single i 1) = _ |
| 144 | rw [fderiv_fun_sum (fun j _ => hd i j)] |
| 145 | simp only [sum_apply] |
| 146 | exact Finset.sum_congr rfl (fun j _ => hprod i j) |
| 147 | unfold principalSource secondOrderOperator |
| 148 | simp_rw [hflux, Finset.sum_add_distrib, sub_mul, Finset.sum_sub_distrib, |
| 149 | Finset.sum_mul] |
| 150 | rw [Finset.sum_comm (f := fun j i => |
| 151 | partialDeriv i (fun y => a y i j) x * partialDeriv j u x)] |
| 152 | ring |
| 153 | |
| 154 | end Poincare.Analysis.Elliptic.InteriorEstimates |