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.ContDiff.Comp |
| 2 | import Mathlib.Analysis.Calculus.Deriv.Comp |
| 3 | import Mathlib.Analysis.Calculus.Deriv.Prod |
| 4 | import Mathlib.Analysis.Calculus.TangentCone.Prod |
| 5 | |
| 6 | /-! |
| 7 | # Actual spatial derivatives on a closed parameter domain |
| 8 | |
| 9 | Unique differentiation in the parameter set gives regularity of the |
| 10 | actual spatial derivative on the entire product. MT2007 Claim 19.1, |
| 11 | p. 437; `2026-09-22-ambient-label-velocity.md`, statement 1. |
| 12 | -/ |
| 13 | |
| 14 | set_option autoImplicit false |
| 15 | |
| 16 | open Set Filter |
| 17 | open scoped ContDiff Topology |
| 18 | |
| 19 | universe u v |
| 20 | |
| 21 | /-- The actual spatial derivative loses one order on a uniquely |
| 22 | differentiable parameter domain, without an endpoint extension. |
| 23 | MT2007 Claim 19.1, p. 437; ambient label-velocity derivation. -/ |
| 24 | theorem contDiffOn_spatial_deriv_of_uniqueDiffOn |
| 25 | {P : Type u} [NormedAddCommGroup P] [NormedSpace ℝ P] |
| 26 | {E : Type v} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 27 | {S : Set P} (hS : UniqueDiffOn ℝ S) {q : P → ℝ → E} |
| 28 | {m n : ℕ∞ω} (hmn : m + 1 ≤ n) |
| 29 | (hq : ContDiffOn ℝ n (Function.uncurry q) (S ×ˢ univ)) : |
| 30 | ContDiffOn ℝ m (fun z : P × ℝ => deriv (q z.1) z.2) (S ×ˢ univ) := by |
| 31 | have hone : (1 : ℕ∞ω) ≤ n := |
| 32 | (le_add_of_nonneg_left (show (0 : ℕ∞ω) ≤ m from bot_le)).trans hmn |
| 33 | have hn : n ≠ 0 := ne_of_gt ((show (0 : ℕ∞ω) < 1 by decide).trans_le hone) |
| 34 | have hd := (hq.fderivWithin (hS.prod uniqueDiffOn_univ) hmn).clm_apply |
| 35 | (contDiffOn_const (c := (0, (1 : ℝ)))) |
| 36 | apply hd.congr |
| 37 | intro z hz |
| 38 | have hline : HasDerivAt (fun y : ℝ => (z.1, y)) (0, 1) z.2 := |
| 39 | (hasDerivAt_const z.2 z.1).prodMk (hasDerivAt_id z.2) |
| 40 | have hmaps : ∀ᶠ y in 𝓝 z.2, (z.1, y) ∈ S ×ˢ (univ : Set ℝ) := |
| 41 | Eventually.of_forall fun _ => ⟨hz.1, mem_univ _⟩ |
| 42 | exact (((hq.differentiableOn hn) z hz).hasFDerivWithinAt.comp_hasDerivAt |
| 43 | z.2 hline hmaps).deriv |