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.ReducedGeometry.ReducedLength.Tensor.LocalMinimumHessian |
| 2 | import Mathlib.Analysis.Calculus.ContDiff.Deriv |
| 3 | |
| 4 | /-! |
| 5 | # The actual second derivative of scalar composition |
| 6 | |
| 7 | The first derivative is identified on a neighborhood before differentiating |
| 8 | the varying differential and varying velocity. |
| 9 | -/ |
| 10 | |
| 11 | set_option autoImplicit false |
| 12 | |
| 13 | open scoped ContDiff Topology |
| 14 | open Filter |
| 15 | |
| 16 | namespace PoincareMT.ReducedLength |
| 17 | |
| 18 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 19 | |
| 20 | theorem secondDeriv_comp (f : E → ℝ) (y : ℝ → E) (s : ℝ) |
| 21 | (hf : ContDiffAt ℝ ∞ f (y s)) (hy : ContDiffAt ℝ ∞ y s) : |
| 22 | deriv (deriv (fun t ↦ f (y t))) s = |
| 23 | fderiv ℝ (fderiv ℝ f) (y s) (deriv y s) (deriv y s) + |
| 24 | fderiv ℝ f (y s) (deriv (deriv y) s) := by |
| 25 | have hfy : ∀ᶠ x in 𝓝 (y s), DifferentiableAt ℝ f x := |
| 26 | ((hf.of_le (show (1 : ℕ∞ω) ≤ ∞ by simp)).eventually (by simp)).mono |
| 27 | (fun x hx ↦ hx.differentiableAt (by simp)) |
| 28 | have hyt : ∀ᶠ t in 𝓝 s, DifferentiableAt ℝ y t := |
| 29 | ((hy.of_le (show (1 : ℕ∞ω) ≤ ∞ by simp)).eventually (by simp)).mono |
| 30 | (fun t ht ↦ ht.differentiableAt (by simp)) |
| 31 | have hfirst : deriv (fun t ↦ f (y t)) =ᶠ[𝓝 s] |
| 32 | (fun t ↦ fderiv ℝ f (y t) (deriv y t)) := by |
| 33 | filter_upwards [hy.continuousAt.tendsto.eventually hfy, hyt] with t hft hyt' |
| 34 | exact (hft.hasFDerivAt.comp_hasDerivAt t hyt'.hasDerivAt).deriv |
| 35 | have hd := (hy.differentiableAt (by simp)).hasDerivAt |
| 36 | have hdf := ((hf.fderiv_right (m := ∞) (by simp)).differentiableAt (by simp)).hasFDerivAt |
| 37 | have hdy := ((hy.derivWithin (m := ∞) (by simp)).differentiableAt (by simp)).hasDerivAt |
| 38 | have hsecond := (hdf.comp_hasDerivAt s hd).clm_apply hdy |
| 39 | rw [hfirst.deriv_eq] |
| 40 | exact hsecond.deriv |
| 41 | |
| 42 | end PoincareMT.ReducedLength |