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 Mathlib.Analysis.Calculus.FDeriv.Symmetric |
| 2 | import Mathlib.Analysis.Calculus.ContDiff.Deriv |
| 3 | import Mathlib.Analysis.Calculus.Deriv.Prod |
| 4 | import Mathlib.Analysis.Calculus.Deriv.Mul |
| 5 | |
| 6 | /-! # Interchanging a time derivative and a spatial derivative -/ |
| 7 | |
| 8 | set_option autoImplicit false |
| 9 | set_option backward.isDefEq.respectTransparency false |
| 10 | |
| 11 | open scoped ContDiff Topology |
| 12 | open Filter |
| 13 | |
| 14 | namespace Poincare.Analysis |
| 15 | |
| 16 | variable {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 17 | [NormedAddCommGroup F] [NormedSpace ℝ F] |
| 18 | |
| 19 | /-- Smooth families commute time and spatial differentiation using a time |
| 20 | derivative identity on a neighborhood of the spatial parameter. -/ |
| 21 | lemma hasDerivAt_fderiv_time_of_eventually |
| 22 | {f : ℝ × E → F} {df : E → F} {t : ℝ} {x : E} |
| 23 | (hf : ContDiffAt ℝ ∞ f (t, x)) |
| 24 | (hdf : ∀ᶠ y in 𝓝 x, HasDerivAt (fun s => f (s, y)) (df y) t) (v : E) : |
| 25 | HasDerivAt (fun s => fderiv ℝ (fun y => f (s, y)) x v) |
| 26 | (fderiv ℝ df x v) t := by |
| 27 | have hd := (hf.fderiv_right (m := 1) |
| 28 | (WithTop.coe_le_coe.mpr le_top)).differentiableAt one_ne_zero |
| 29 | have hn : ∀ᶠ p in 𝓝 (t, x), DifferentiableAt ℝ f p := |
| 30 | ((hf.of_le (show (1 : WithTop ℕ∞) ≤ ∞ from WithTop.coe_le_coe.mpr le_top)).eventually |
| 31 | (by decide)).mono |
| 32 | fun p hp => hp.differentiableAt one_ne_zero |
| 33 | have hs := hd.hasFDerivAt.comp_hasDerivAt t |
| 34 | ((hasDerivAt_id t).prodMk (hasDerivAt_const t x)) |
| 35 | have hl := hs.clm_apply (hasDerivAt_const t (0, v)) |
| 36 | simp only [ContinuousLinearMap.map_zero, add_zero] at hl |
| 37 | have he : (fun s => fderiv ℝ (fun y => f (s, y)) x v) =ᶠ[𝓝 t] |
| 38 | (fun s => fderiv ℝ f (s, x) (0, v)) := by |
| 39 | have ht : Tendsto (fun s : ℝ => (s, x)) (𝓝 t) (𝓝 (t, x)) := |
| 40 | continuousAt_id.prodMk continuousAt_const |
| 41 | filter_upwards [ht.eventually hn] with s hs |
| 42 | have h := hs.hasFDerivAt.comp x |
| 43 | ((hasFDerivAt_const (c := s) x).prodMk (hasFDerivAt_id x)) |
| 44 | simpa [Function.comp_def] using congrArg (fun A : E →L[ℝ] F => A v) h.fderiv |
| 45 | have hspace := hd.hasFDerivAt.comp x |
| 46 | ((hasFDerivAt_const (c := t) x).prodMk (hasFDerivAt_id x)) |
| 47 | have hr := hspace.clm_apply (hasFDerivAt_const (c := (1, (0 : E))) x) |
| 48 | have he' : df =ᶠ[𝓝 x] (fun y => fderiv ℝ f (t, y) (1, 0)) := by |
| 49 | have hx : Tendsto (fun y : E => (t, y)) (𝓝 x) (𝓝 (t, x)) := |
| 50 | continuousAt_const.prodMk continuousAt_id |
| 51 | filter_upwards [hx.eventually hn, hdf] with y hy hdy |
| 52 | have h := hy.hasFDerivAt.comp_hasDerivAt t |
| 53 | ((hasDerivAt_id t).prodMk (hasDerivAt_const t y)) |
| 54 | exact hdy.unique h |
| 55 | have hr' := congrArg (fun A : E →L[ℝ] F => A v) |
| 56 | (hr.congr_of_eventuallyEq he').fderiv |
| 57 | simp only [add_apply, ContinuousLinearMap.comp_apply, |
| 58 | ContinuousLinearMap.flip_apply, zero_apply, |
| 59 | ContinuousLinearMap.map_zero, zero_add, |
| 60 | ContinuousLinearMap.prod_apply, ContinuousLinearMap.id_apply] at hr' |
| 61 | have hsym := hf.isSymmSndFDerivAt |
| 62 | (by rw [minSmoothness_of_isRCLikeNormedField]; exact WithTop.coe_le_coe.mpr le_top) |
| 63 | (1, 0) (0, v) |
| 64 | apply (hl.congr_of_eventuallyEq he).congr_deriv |
| 65 | simpa only [Function.comp_def] using hsym.trans hr'.symm |
| 66 | |
| 67 | /-- A smooth real-valued family commutes time differentiation with a fixed |
| 68 | spatial directional derivative. -/ |
| 69 | lemma hasDerivAt_fderiv_time |
| 70 | {f : ℝ × E → ℝ} {df : E → ℝ} {t : ℝ} {x : E} |
| 71 | (hf : ContDiffAt ℝ ∞ f (t, x)) |
| 72 | (hdf : ∀ y, HasDerivAt (fun s => f (s, y)) (df y) t) (v : E) : |
| 73 | HasDerivAt (fun s => fderiv ℝ (fun y => f (s, y)) x v) |
| 74 | (fderiv ℝ df x v) t := |
| 75 | hasDerivAt_fderiv_time_of_eventually hf (Filter.Eventually.of_forall hdf) v |
| 76 | |
| 77 | end Poincare.Analysis |