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.Geometry.RicciFlow.Soliton.TwoDimensional.Compact.Gradient |
| 2 | import PoincareLib.Geometry.Riemannian.Connection.AlongCurve.Coefficients |
| 3 | |
| 4 | /-! |
| 5 | # Smoothness from a smooth pure-trace Hessian in Euclidean coordinates |
| 6 | |
| 7 | The coordinate derivative of the differential satisfies a first-order linear |
| 8 | equation with smooth coefficients. Induction on the differentiability order |
| 9 | therefore improves an initially `C2` potential to a smooth one. |
| 10 | -/ |
| 11 | |
| 12 | set_option autoImplicit false |
| 13 | set_option backward.isDefEq.respectTransparency false |
| 14 | set_option maxSynthPendingDepth 8 |
| 15 | |
| 16 | open scoped Manifold ContDiff Bundle Topology |
| 17 | open Bundle Set |
| 18 | |
| 19 | namespace PoincareMT.LeviCivitaData |
| 20 | |
| 21 | variable {n : ℕ} {g : RiemannianMetric n (EuclideanSpace ℝ (Fin n))} |
| 22 | |
| 23 | theorem hessian_eq_fderiv_sub_connectionCoefficient_of_C2 (D : LeviCivitaData g) |
| 24 | {f : EuclideanSpace ℝ (Fin n) → ℝ} {x : EuclideanSpace ℝ (Fin n)} |
| 25 | (hf : ContDiffAt ℝ 2 f x) (v w : EuclideanSpace ℝ (Fin n)) : |
| 26 | D.hessian f x v w = fderiv ℝ (fderiv ℝ f) x v w - |
| 27 | fderiv ℝ f x (D.connectionCoefficient x v w) := by |
| 28 | have hfm : ContMDiffAt (𝓡 n) 𝓘(ℝ, ℝ) 2 f x := hf.contMDiffAt |
| 29 | have hw : MDifferentiableAt (𝓡 n) ((𝓡 n).prod (𝓡 n)) |
| 30 | (fun y : EuclideanSpace ℝ (Fin n) ↦ TotalSpace.mk' |
| 31 | (EuclideanSpace ℝ (Fin n)) y (E := TangentSpace (𝓡 n)) w) x := by |
| 32 | apply ContMDiffAt.mdifferentiableAt (n := 1) _ (by norm_num) |
| 33 | rw [contMDiffAt_totalSpace] |
| 34 | exact ⟨contMDiffAt_id, by simpa using (contMDiffAt_const |
| 35 | (I := 𝓡 n) (I' := 𝓡 n) (c := w) (x := x) (n := 1))⟩ |
| 36 | let : Bundle.RiemannianBundle |
| 37 | (TangentSpace (𝓡 n) : EuclideanSpace ℝ (Fin n) → Type _) := |
| 38 | ⟨g.toRiemannianMetric⟩ |
| 39 | have h := D.metricCompatible.mvfderiv_inner_eq (fun _ => v) |
| 40 | ((D.contMDiffAt_one_gradient_of_C2 hfm).mdifferentiableAt (by norm_num)) hw |
| 41 | change mvfderiv (𝓡 n) (fun y => g.inner y (D.gradient f y) w) x v = |
| 42 | g.inner x (D.connection (D.gradient f) x v) w + |
| 43 | g.inner x (D.gradient f x) (D.connection (fun _ => w) x v) at h |
| 44 | simp only [D.inner_gradient] at h |
| 45 | have hess := D.hessian_eq_inner_connection_gradient_of_C2 hfm v w |
| 46 | have hd := ((hf.fderiv_right (m := 1) (by norm_num)).differentiableAt |
| 47 | (by norm_num)).hasFDerivAt |
| 48 | have heval := hd.clm_apply (hasFDerivAt_const w x) |
| 49 | simp +instances only [mvfderiv, mfderiv_eq_fderiv, NormedSpace.fromTangentSpace] at h |
| 50 | change fderiv ℝ (fun y => fderiv ℝ f y w) x v = |
| 51 | g.inner x (D.connection (D.gradient f) x v) w + |
| 52 | fderiv ℝ f x (D.connectionCoefficient x v w) at h |
| 53 | rw [heval.fderiv] at h |
| 54 | simp only [add_apply, ContinuousLinearMap.comp_apply, zero_apply, |
| 55 | map_zero, zero_add, ContinuousLinearMap.flip_apply] at h |
| 56 | linarith |
| 57 | |
| 58 | /-- Smooth pure-trace Hessian coefficients bootstrap the original C2 function. -/ |
| 59 | theorem contDiffOn_of_C2_hessian_eq_smooth_mul_metric (D : LeviCivitaData g) |
| 60 | {U : Set (EuclideanSpace ℝ (Fin n))} (hU : IsOpen U) |
| 61 | {f a : EuclideanSpace ℝ (Fin n) → ℝ} |
| 62 | (hf : ContDiffOn ℝ 2 f U) (ha : ContDiffOn ℝ ∞ a U) |
| 63 | (hess : ∀ x ∈ U, ∀ v w, |
| 64 | D.hessian f x v w = a x * g.inner x v w) : |
| 65 | ContDiffOn ℝ ∞ f U := by |
| 66 | have hfd : ContDiffOn ℝ ∞ (fderiv ℝ f) U := by |
| 67 | rw [contDiffOn_infty] |
| 68 | intro k |
| 69 | induction k with |
| 70 | | zero => |
| 71 | exact (hf.fderiv_of_isOpen hU (m := 1) (by norm_num)).of_le (by norm_num) |
| 72 | | succ k ih => |
| 73 | rw [show ((k + 1 : ℕ) : ℕ∞ω) = (k : ℕ∞ω) + 1 by simp, |
| 74 | contDiffOn_succ_iff_fderiv_of_isOpen hU] |
| 75 | refine ⟨?_, by simp, ?_⟩ |
| 76 | · exact (hf.fderiv_of_isOpen hU (m := 1) (by norm_num)).differentiableOn |
| 77 | (by norm_num) |
| 78 | · apply contDiffOn_clm_apply.mpr |
| 79 | intro v |
| 80 | apply contDiffOn_clm_apply.mpr |
| 81 | intro w |
| 82 | have ha' := ha.of_le (ENat.natCast_le_of_coe_top_le_withTop le_rfl k) |
| 83 | have hg' := (contDiff_iff_contDiffAt.mpr g.contDiffAt_euclideanCoefficients).of_le |
| 84 | (ENat.natCast_le_of_coe_top_le_withTop le_rfl k) |
| 85 | have hΓ' := D.contDiff_connectionCoefficient.of_le |
| 86 | (ENat.natCast_le_of_coe_top_le_withTop le_rfl k) |
| 87 | have hright : ContDiffOn ℝ (k : ℕ∞ω) |
| 88 | (fun x => a x * g.euclideanCoefficients x v w + |
| 89 | fderiv ℝ f x (D.connectionCoefficient x v w)) U := |
| 90 | (ha'.mul ((hg'.contDiffOn.clm_apply contDiffOn_const).clm_apply |
| 91 | contDiffOn_const)).add (ih.clm_apply |
| 92 | ((hΓ'.contDiffOn.clm_apply contDiffOn_const).clm_apply contDiffOn_const)) |
| 93 | apply hright.congr |
| 94 | intro x hx |
| 95 | have h := D.hessian_eq_fderiv_sub_connectionCoefficient_of_C2 |
| 96 | (hf.contDiffAt (hU.mem_nhds hx)) v w |
| 97 | rw [hess x hx v w] at h |
| 98 | change fderiv ℝ (fderiv ℝ f) x v w = _ |
| 99 | dsimp only [RiemannianMetric.euclideanCoefficients] |
| 100 | exact sub_eq_iff_eq_add.mp h.symm |
| 101 | rw [contDiffOn_infty_iff_fderiv_of_isOpen hU] |
| 102 | exact ⟨hf.differentiableOn (by norm_num), hfd⟩ |
| 103 | |
| 104 | end PoincareMT.LeviCivitaData |