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.Surgery.Metric.Profile.SmoothProfile |
| 2 | import Mathlib.Analysis.Calculus.IteratedDeriv.Lemmas |
| 3 | import Mathlib.Analysis.Calculus.TangentCone.Real |
| 4 | |
| 5 | /-! |
| 6 | # Derivatives and flatness of the surgery profile |
| 7 | |
| 8 | The first two identities are the scalar terms in Morgan--Tian's |
| 9 | conformal-curvature calculation, pp. 334-336. Flatness includes the |
| 10 | central-sphere endpoint of the retained metric. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | |
| 15 | open scoped ContDiff |
| 16 | |
| 17 | namespace PoincareMT.MetricSurgery |
| 18 | |
| 19 | theorem smoothProfile_hasDerivAt {C q epsilon : ℝ} (hq : 0 < q) (s : ℝ) : |
| 20 | HasDerivAt (smoothProfile C q epsilon) |
| 21 | (q / s ^ 2 * smoothProfile C q epsilon s) s := by |
| 22 | have h := expNegInvGlue.hasDerivAt_polynomial_eval_inv_mul (1 : Polynomial ℝ) (s / q) |
| 23 | simp only [Polynomial.eval_one, one_mul, Polynomial.derivative_one, sub_zero, |
| 24 | mul_one, Polynomial.eval_pow, Polynomial.eval_X] at h |
| 25 | convert! (h.comp s ((hasDerivAt_id s).div_const q)).const_mul (C * epsilon) using 1 |
| 26 | simp only [smoothProfile, inv_div] |
| 27 | by_cases hs : s = 0 |
| 28 | · simp [hs] |
| 29 | · field_simp [hq.ne', hs] |
| 30 | |
| 31 | theorem smoothProfile_deriv {C q epsilon : ℝ} (hq : 0 < q) (s : ℝ) : |
| 32 | deriv (smoothProfile C q epsilon) s = q / s ^ 2 * smoothProfile C q epsilon s := |
| 33 | (smoothProfile_hasDerivAt hq s).deriv |
| 34 | |
| 35 | theorem smoothProfile_deriv_hasDerivAt {C q epsilon : ℝ} (hq : 0 < q) (s : ℝ) : |
| 36 | HasDerivAt (deriv (smoothProfile C q epsilon)) |
| 37 | ((q ^ 2 / s ^ 4 - 2 * q / s ^ 3) * smoothProfile C q epsilon s) s := by |
| 38 | have h := expNegInvGlue.hasDerivAt_polynomial_eval_inv_mul |
| 39 | (Polynomial.X ^ 2 : Polynomial ℝ) (s / q) |
| 40 | simp only [Polynomial.derivative_pow, Polynomial.derivative_X, mul_one, |
| 41 | Polynomial.eval_mul, Polynomial.eval_sub, Polynomial.eval_pow, |
| 42 | Polynomial.eval_X] at h |
| 43 | norm_num at h |
| 44 | have hcomp := (h.comp s ((hasDerivAt_id s).div_const q)).const_mul |
| 45 | (C * epsilon / q) |
| 46 | have heq : deriv (smoothProfile C q epsilon) = |
| 47 | fun x => C * epsilon / q * ((x / q)⁻¹ ^ 2 * expNegInvGlue (x / q)) := by |
| 48 | funext x |
| 49 | rw [smoothProfile_deriv hq] |
| 50 | dsimp [smoothProfile] |
| 51 | by_cases hx : x = 0 |
| 52 | · simp [hx] |
| 53 | · field_simp [hq.ne', hx] |
| 54 | rw [heq] |
| 55 | convert! hcomp using 1 |
| 56 | · simp only [Function.comp_apply, id_eq, inv_pow] |
| 57 | simp only [smoothProfile] |
| 58 | by_cases hs : s = 0 |
| 59 | · simp [hs] |
| 60 | · field_simp [hq.ne', hs] |
| 61 | |
| 62 | theorem smoothProfile_second_deriv {C q epsilon : ℝ} (hq : 0 < q) (s : ℝ) : |
| 63 | deriv (deriv (smoothProfile C q epsilon)) s = |
| 64 | (q ^ 2 / s ^ 4 - 2 * q / s ^ 3) * smoothProfile C q epsilon s := |
| 65 | (smoothProfile_deriv_hasDerivAt hq s).deriv |
| 66 | |
| 67 | /-- Every scalar jet agrees with the zero profile on the closed retained side. -/ |
| 68 | theorem smoothProfile_iteratedDeriv_eq_zero {C q epsilon s : ℝ} |
| 69 | (hq : 0 < q) (hs : s ≤ 0) (n : ℕ) : |
| 70 | iteratedDeriv n (smoothProfile C q epsilon) s = 0 := by |
| 71 | have heq : Set.EqOn (smoothProfile C q epsilon) (fun _ => 0) (Set.Iic 0) := |
| 72 | fun _ hx => smoothProfile_eq_zero hq hx |
| 73 | have h := iteratedDerivWithin_congr (n := n) heq hs |
| 74 | rw [iteratedDerivWithin_eq_iteratedDeriv (uniqueDiffOn_Iic 0) |
| 75 | ((smoothProfile_contDiff C q epsilon).of_le |
| 76 | (by exact_mod_cast (show (n : ℕ∞) ≤ ⊤ from le_top))).contDiffAt hs] at h |
| 77 | simpa using h |
| 78 | |
| 79 | end PoincareMT.MetricSurgery |