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.Convex.Deriv |
| 2 | import Mathlib.Analysis.InnerProductSpace.Calculus |
| 3 | |
| 4 | /-! # Second derivative bounds from quadratic concavity -/ |
| 5 | |
| 6 | set_option autoImplicit false |
| 7 | |
| 8 | open Set Filter |
| 9 | open scoped Topology ContDiff |
| 10 | |
| 11 | namespace Poincare.Analysis |
| 12 | |
| 13 | variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] |
| 14 | |
| 15 | /-- A smooth semiconcave function has the corresponding actual Hessian bound |
| 16 | at every point of its open domain. -/ |
| 17 | theorem fderiv_fderiv_le_of_concaveOn_sub_norm_sq |
| 18 | {f : E → ℝ} {U : Set E} {C : ℝ} (hU : IsOpen U) |
| 19 | (hf : ContDiffOn ℝ ∞ f U) |
| 20 | (hconc : ConcaveOn ℝ U (fun y => f y - C * ‖y‖ ^ 2 / 2)) |
| 21 | {x : E} (hx : x ∈ U) (v : E) : |
| 22 | fderiv ℝ (fderiv ℝ f) x v v ≤ C * ‖v‖ ^ 2 := by |
| 23 | let A : ℝ → E := fun t => x + t • v |
| 24 | let q : ℝ → ℝ := fun t => f (A t) - C * ‖A t‖ ^ 2 / 2 |
| 25 | let q' : ℝ → ℝ := fun t => fderiv ℝ f (A t) v - C * inner ℝ (A t) v |
| 26 | have hA (t : ℝ) : HasDerivAt A v t := by |
| 27 | simpa [A] using ((hasDerivAt_id t).smul_const v).const_add x |
| 28 | have hAo : IsOpen (A ⁻¹' U) := hU.preimage (by fun_prop) |
| 29 | have hA0 : (0 : ℝ) ∈ A ⁻¹' U := by simpa [A] using hx |
| 30 | have hq : ConcaveOn ℝ (A ⁻¹' U) q := by |
| 31 | simpa [A, q, Function.comp_def, AffineMap.coe_lineMap, add_comm] using |
| 32 | hconc.comp_affineMap (AffineMap.lineMap x (x + v)) |
| 33 | have hd (t : ℝ) (ht : t ∈ A ⁻¹' U) : HasDerivAt q (q' t) t := by |
| 34 | have hft := (hf.contDiffAt (hU.mem_nhds ht)).differentiableAt (by simp) |
| 35 | change HasDerivAt (fun t => f (A t) - C * ‖A t‖ ^ 2 / 2) |
| 36 | (fderiv ℝ f (A t) v - C * inner ℝ (A t) v) t |
| 37 | convert (hft.hasFDerivAt.comp_hasDerivAt t (hA t)).sub |
| 38 | (((hA t).norm_sq.const_mul C).div_const 2) using 1 <;> first | rfl | ring |
| 39 | have hant : AntitoneOn (deriv q) (A ⁻¹' U) := |
| 40 | hq.antitoneOn_deriv (fun t ht => (hd t ht).differentiableAt) |
| 41 | have hn : deriv (deriv q) 0 ≤ 0 := by |
| 42 | rw [← derivWithin_of_mem_nhds (hAo.mem_nhds hA0)] |
| 43 | exact hant.derivWithin_nonpos |
| 44 | have hfd : DifferentiableAt ℝ (fderiv ℝ f) x := |
| 45 | ((hf.fderiv_of_isOpen hU (m := ∞) (by simp)).contDiffAt |
| 46 | (hU.mem_nhds hx)).differentiableAt (by simp) |
| 47 | have hlinear : HasDerivAt (fun t => fderiv ℝ f (A t) v) |
| 48 | (fderiv ℝ (fderiv ℝ f) x v v) 0 := by |
| 49 | have hfd' : HasFDerivAt (fderiv ℝ f) (fderiv ℝ (fderiv ℝ f) x) (A 0) := by |
| 50 | simpa [A] using hfd.hasFDerivAt |
| 51 | have h := (hfd'.comp_hasDerivAt 0 (hA 0)).clm_apply (hasDerivAt_const 0 v) |
| 52 | simpa [A] using h |
| 53 | have hinner : HasDerivAt (fun t => inner ℝ (A t) v) (‖v‖ ^ 2) 0 := by |
| 54 | simpa using (hA 0).inner ℝ (hasDerivAt_const 0 v) |
| 55 | have hsecond : HasDerivAt (deriv q) |
| 56 | (fderiv ℝ (fderiv ℝ f) x v v - C * ‖v‖ ^ 2) 0 := by |
| 57 | apply (hlinear.sub (hinner.const_mul C)).congr_of_eventuallyEq |
| 58 | filter_upwards [hAo.mem_nhds hA0] with t ht |
| 59 | exact (hd t ht).deriv |
| 60 | rw [hsecond.deriv] at hn |
| 61 | linarith |
| 62 | |
| 63 | end Poincare.Analysis |