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.Deriv.Prod |
| 3 | import Mathlib.Analysis.Calculus.Deriv.Mul |
| 4 | |
| 5 | /-! |
| 6 | # Mixed derivatives at finite regularity |
| 7 | |
| 8 | Local C2 regularity supplies genuine witnesses for both mixed coordinate |
| 9 | derivatives with the same value. This is the scalar calculus used in |
| 10 | MT2007 Lemma 19.6, pp. 441-442, and correction Lemma 0.1, p. 3. |
| 11 | See `references/ricci-flow/mapher/curve-evolution/derivations/2026-09-19-scalar-commutator.md`. |
| 12 | -/ |
| 13 | |
| 14 | set_option autoImplicit false |
| 15 | set_option maxSynthPendingDepth 3 |
| 16 | |
| 17 | open Filter Topology |
| 18 | open scoped ContDiff |
| 19 | |
| 20 | set_option backward.isDefEq.respectTransparency false in |
| 21 | /-- Local C2 regularity gives equal mixed coordinate derivative witnesses. |
| 22 | The scalar bridge for MT2007 Lemma 19.6, pp. 441-442, in normed-space generality. -/ |
| 23 | theorem ContDiffAt.exists_hasDerivAt_mixed |
| 24 | {K E : Type*} [NontriviallyNormedField K] [IsRCLikeNormedField K] |
| 25 | [NormedAddCommGroup E] [NormedSpace K E] |
| 26 | {f : K × K → E} {p : K × K} (hf : ContDiffAt K 2 f p) : |
| 27 | ∃ k : E, |
| 28 | HasDerivAt (fun u ↦ deriv (fun s ↦ f (s, u)) p.1) k p.2 ∧ |
| 29 | HasDerivAt (fun s ↦ deriv (fun u ↦ f (s, u)) p.2) k p.1 := by |
| 30 | have hfd : DifferentiableAt K (fderiv K f) p := |
| 31 | (hf.fderiv_right (m := 1) (by norm_num)).differentiableAt one_ne_zero |
| 32 | have hnear := hf.eventually (by norm_num) |
| 33 | let k := fderiv K (fderiv K f) p (0, 1) (1, 0) |
| 34 | refine ⟨k, ?_, ?_⟩ |
| 35 | · have h := (hfd.hasFDerivAt.comp_hasDerivAt (f := fun u : K ↦ (p.1, u)) p.2 |
| 36 | ((hasDerivAt_const p.2 p.1).prodMk (hasDerivAt_id p.2))).clm_apply |
| 37 | (hasDerivAt_const p.2 ((1 : K), (0 : K))) |
| 38 | have hd : HasDerivAt (fun u ↦ fderiv K f (p.1, u) (1, 0)) k p.2 := by |
| 39 | simpa only [Function.comp_def, id_eq, k, map_zero, add_zero] using h |
| 40 | apply hd.congr_of_eventuallyEq |
| 41 | have hgerm : ∀ᶠ u in 𝓝 p.2, ContDiffAt K 2 f (p.1, u) := |
| 42 | (continuous_const.prodMk continuous_id).continuousAt.tendsto.eventually hnear |
| 43 | filter_upwards [hgerm] with u hu |
| 44 | exact ((hu.differentiableAt two_ne_zero).hasFDerivAt.comp_hasDerivAt |
| 45 | (f := fun s : K ↦ (s, u)) p.1 |
| 46 | ((hasDerivAt_id p.1).prodMk (hasDerivAt_const p.1 u))).deriv |
| 47 | · have h := (hfd.hasFDerivAt.comp_hasDerivAt (f := fun s : K ↦ (s, p.2)) p.1 |
| 48 | ((hasDerivAt_id p.1).prodMk (hasDerivAt_const p.1 p.2))).clm_apply |
| 49 | (hasDerivAt_const p.1 ((0 : K), (1 : K))) |
| 50 | have hsym := (hf.isSymmSndFDerivAt (by |
| 51 | rw [minSmoothness_of_isRCLikeNormedField])) (1, 0) (0, 1) |
| 52 | have hd : HasDerivAt (fun s ↦ fderiv K f (s, p.2) (0, 1)) k p.1 := by |
| 53 | simpa only [Function.comp_def, id_eq, k, map_zero, add_zero, hsym] using h |
| 54 | apply hd.congr_of_eventuallyEq |
| 55 | have hgerm : ∀ᶠ s in 𝓝 p.1, ContDiffAt K 2 f (s, p.2) := |
| 56 | (continuous_id.prodMk continuous_const).continuousAt.tendsto.eventually hnear |
| 57 | filter_upwards [hgerm] with s hs |
| 58 | exact ((hs.differentiableAt two_ne_zero).hasFDerivAt.comp_hasDerivAt |
| 59 | (f := fun u : K ↦ (s, u)) p.2 |
| 60 | ((hasDerivAt_const p.2 s).prodMk (hasDerivAt_id p.2))).deriv |