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.Calculus.MixedPartials |
| 2 | import Mathlib.Analysis.Calculus.Deriv.Comp |
| 3 | |
| 4 | /-! |
| 5 | # Linearizing a smooth family of coordinate solutions |
| 6 | |
| 7 | The equation is needed only at the tested time. This also applies at |
| 8 | an endpoint of the closed interval on which the solutions are given. |
| 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 hasDerivAt_variation_of_ode (f : ℝ × ℝ → E) (B : ℝ × E → E) (s : ℝ) |
| 21 | (hf : ContDiffAt ℝ ∞ f (s, 0)) |
| 22 | (hB : DifferentiableAt ℝ B (s, f (s, 0))) |
| 23 | (hode : ∀ᶠ u in 𝓝 (0 : ℝ), |
| 24 | HasDerivAt (fun r ↦ f (r, u)) (B (s, f (s, u))) s) : |
| 25 | HasDerivAt (fun r ↦ deriv (fun u ↦ f (r, u)) 0) |
| 26 | (fderiv ℝ B (s, f (s, 0)) (0, deriv (fun u ↦ f (s, u)) 0)) s := by |
| 27 | let Y : ℝ → E := fun r ↦ deriv (fun u ↦ f (r, u)) 0 |
| 28 | let w := fderiv ℝ B (s, f (s, 0)) (0, Y s) |
| 29 | have hu : HasDerivAt (fun u ↦ f (s, u)) (Y s) 0 := |
| 30 | (hasDerivAt_slice_snd f s 0 (hf.differentiableAt (by simp))).differentiableAt.hasDerivAt |
| 31 | have hk : HasDerivAt (fun u ↦ B (s, f (s, u))) w 0 := |
| 32 | hB.hasFDerivAt.comp_hasDerivAt 0 ((hasDerivAt_const 0 s).prodMk hu) |
| 33 | have htrans : ContDiffAt ℝ ∞ (fun z : ℝ × ℝ ↦ (s + z.1, z.2)) (0, 0) := |
| 34 | (contDiff_const.add contDiff_fst).prodMk contDiff_snd |>.contDiffAt |
| 35 | have hF : ContDiffAt ℝ ∞ (fun z : ℝ × ℝ ↦ f (s + z.1, z.2)) (0, 0) := by |
| 36 | have hf' : ContDiffAt ℝ ∞ f (s + 0, 0) := by simpa only [add_zero] using hf |
| 37 | exact hf'.comp (0, 0) htrans |
| 38 | have hjet : ∀ᶠ u in 𝓝 (0 : ℝ), |
| 39 | HasDerivAt (fun r ↦ f (s + r, u)) (B (s, f (s, u))) 0 := by |
| 40 | filter_upwards [hode] with u hu |
| 41 | simpa only [Function.comp_def, id_eq, one_smul] using hu.scomp_of_eq 0 |
| 42 | ((hasDerivAt_id 0).const_add s) (add_zero s).symm |
| 43 | have hY : HasDerivAt (fun r ↦ Y (s + r)) w 0 := |
| 44 | hasDerivAt_partial_snd_of_initial_fst (fun z : ℝ × ℝ ↦ f (s + z.1, z.2)) |
| 45 | hF (fun u ↦ B (s, f (s, u))) w hk hjet |
| 46 | have hback := hY.scomp_of_eq s ((hasDerivAt_id s).sub_const s) (sub_self s).symm |
| 47 | have hcancel (r : ℝ) : s + (r - s) = r := by ring |
| 48 | simpa only [Function.comp_def, id_eq, one_smul, hcancel, Y, w] using hback |
| 49 | |
| 50 | end PoincareMT.ReducedLength |