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.InnerProductSpace.Calculus |
| 2 | import Mathlib.Analysis.SpecialFunctions.Sqrt |
| 3 | |
| 4 | /-! |
| 5 | # Differentiating radial coefficients |
| 6 | |
| 7 | These elementary Cartesian formulas supply the connection computation for |
| 8 | Morgan-Tian Lemma 12.2, printed pp. 294-295. They apply to any real inner |
| 9 | product space and are used only away from the origin. See the M34 |
| 10 | radial-curvature derivation for the metric and curvature conventions. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | |
| 15 | namespace Poincare |
| 16 | |
| 17 | variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] |
| 18 | |
| 19 | /-- The differential of radius away from the origin, for the Cartesian |
| 20 | calculation in Morgan-Tian Lemma 12.2, pp. 294-295. -/ |
| 21 | theorem hasFDerivAt_radius {x : E} (hx : x ≠ 0) : |
| 22 | HasFDerivAt (fun y : E => ‖y‖) (‖x‖⁻¹ • innerSL ℝ x) x := by |
| 23 | have hn : ‖x‖ ≠ 0 := norm_ne_zero_iff.mpr hx |
| 24 | have h := (hasStrictFDerivAt_norm_sq x).hasFDerivAt.sqrt (pow_ne_zero 2 hn) |
| 25 | simp only [Real.sqrt_sq (norm_nonneg _)] at h |
| 26 | convert! h using 1 |
| 27 | ext v |
| 28 | simp only [smul_apply, smul_eq_mul, innerSL_apply_apply, two_smul] |
| 29 | change ‖x‖⁻¹ * inner ℝ x v = 1 / (2 * ‖x‖) * (inner ℝ x v + inner ℝ x v) |
| 30 | field_simp |
| 31 | ring |
| 32 | |
| 33 | /-- Chain rule for a scalar radial coefficient, retaining the radial |
| 34 | derivative rather than a totalized derivative at a singular point |
| 35 | (Lemma 12.2 connection calculation, pp. 294-295). -/ |
| 36 | theorem hasFDerivAt_radial {f : ℝ → ℝ} {f' : ℝ} {x : E} (hx : x ≠ 0) |
| 37 | (hf : HasDerivAt f f' ‖x‖) : |
| 38 | HasFDerivAt (fun y : E => f ‖y‖) ((f' / ‖x‖) • innerSL ℝ x) x := by |
| 39 | convert! hf.comp_hasFDerivAt x (hasFDerivAt_radius hx) using 1 |
| 40 | ext v |
| 41 | simp only [smul_apply, smul_eq_mul, innerSL_apply_apply] |
| 42 | ring |
| 43 | |
| 44 | /-- First derivative of a radial metric pairing in fixed Cartesian |
| 45 | directions (Lemma 12.2 connection calculation, pp. 294-295). -/ |
| 46 | theorem fderiv_radial_pairing {c b : ℝ → ℝ} {c' b' : ℝ} {x : E} |
| 47 | (hx : x ≠ 0) (hc : HasDerivAt c c' ‖x‖) (hb : HasDerivAt b b' ‖x‖) |
| 48 | (u v w : E) : |
| 49 | fderiv ℝ (fun y : E => c ‖y‖ * inner ℝ u v + |
| 50 | b ‖y‖ * (inner ℝ y u * inner ℝ y v)) x w = |
| 51 | c' / ‖x‖ * inner ℝ x w * inner ℝ u v + |
| 52 | b' / ‖x‖ * inner ℝ x w * (inner ℝ x u * inner ℝ x v) + |
| 53 | b ‖x‖ * (inner ℝ w u * inner ℝ x v + inner ℝ x u * inner ℝ w v) := by |
| 54 | have hu := (hasFDerivAt_id x).inner ℝ (hasFDerivAt_const u x) |
| 55 | have hv := (hasFDerivAt_id x).inner ℝ (hasFDerivAt_const v x) |
| 56 | have h := ((hasFDerivAt_radial hx hc).mul_const (inner ℝ u v)).add |
| 57 | ((hasFDerivAt_radial hx hb).mul (hu.mul hv)) |
| 58 | change HasFDerivAt (fun y : E => c ‖y‖ * inner ℝ u v + |
| 59 | b ‖y‖ * (inner ℝ y u * inner ℝ y v)) _ x at h |
| 60 | rw [h.fderiv] |
| 61 | simp only [add_apply, smul_apply, |
| 62 | ContinuousLinearMap.comp_apply, ContinuousLinearMap.prod_apply, |
| 63 | ContinuousLinearMap.id_apply, zero_apply, |
| 64 | fderivInnerCLM_apply, inner_zero_right, zero_add, innerSL_apply_apply, smul_eq_mul, |
| 65 | Pi.mul_apply, id_eq] |
| 66 | ring |
| 67 | |
| 68 | end Poincare |