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.ReducedGeometry.ReducedVolume.Regularity.Semiconcavity.ScalarUpperContacts |
| 2 | import Mathlib.Analysis.Calculus.ContDiff.Deriv |
| 3 | import Mathlib.Analysis.Calculus.FDeriv.CompCLM |
| 4 | |
| 5 | /-! |
| 6 | # Second derivatives on affine lines |
| 7 | |
| 8 | The genuine twice differentiable germ supplies both chain rules. At a |
| 9 | local minimum a negative directional second derivative contradicts the |
| 10 | strict upper-contact minimum principle. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | |
| 15 | open Set Filter |
| 16 | open scoped Topology |
| 17 | |
| 18 | namespace PoincareMT.ReducedVolume |
| 19 | |
| 20 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 21 | |
| 22 | /-- The scalar second derivative on a line is the actual diagonal second Frechet derivative. -/ |
| 23 | theorem second_deriv_affine_line {f : E → ℝ} {x : E} |
| 24 | (hf : ContDiffAt ℝ 2 f x) (v : E) : |
| 25 | deriv (deriv (fun t : ℝ ↦ f (x + t • v))) 0 = |
| 26 | fderiv ℝ (fderiv ℝ f) x v v := by |
| 27 | let L := fun t : ℝ ↦ x + t • v |
| 28 | have hL (t : ℝ) : HasDerivAt L v t := by |
| 29 | simpa only [L, id_eq, one_smul] using ((hasDerivAt_id t).smul_const v).const_add x |
| 30 | have hL0 : L 0 = x := by simp [L] |
| 31 | have hnear : ∀ᶠ t in 𝓝 (0 : ℝ), DifferentiableAt ℝ f (L t) := by |
| 32 | have he := (hf.eventually (by norm_num)).mono (fun y hy ↦ hy.differentiableAt two_ne_zero) |
| 33 | have ht : Tendsto L (𝓝 0) (𝓝 x) := by |
| 34 | simpa only [hL0] using (hL 0).continuousAt.tendsto |
| 35 | exact ht he |
| 36 | have hderiv : deriv (fun t ↦ f (L t)) =ᶠ[𝓝 (0 : ℝ)] |
| 37 | (fun t ↦ fderiv ℝ f (L t) v) := by |
| 38 | filter_upwards [hnear] with t ht |
| 39 | exact (ht.hasFDerivAt.comp_hasDerivAt t (hL t)).deriv |
| 40 | rw [hderiv.deriv_eq] |
| 41 | have hD := (hf.fderiv_right (m := 1) (by norm_num)).differentiableAt one_ne_zero |
| 42 | have hD' : DifferentiableAt ℝ (fderiv ℝ f) (L 0) := by rwa [hL0] |
| 43 | have hd := (hD'.hasFDerivAt.comp_hasDerivAt 0 (hL 0)).clm_apply (hasDerivAt_const 0 v) |
| 44 | simpa only [hL0, map_zero, add_zero, Function.comp_def] using hd.deriv |
| 45 | |
| 46 | /-- Diagonal second derivatives are nonnegative at a twice differentiable local minimum. -/ |
| 47 | theorem second_fderiv_nonneg_of_isLocalMin {f : E → ℝ} {x : E} |
| 48 | (hf : ContDiffAt ℝ 2 f x) (hmin : IsLocalMin f x) (v : E) : |
| 49 | 0 ≤ fderiv ℝ (fderiv ℝ f) x v v := by |
| 50 | let L := fun t : ℝ ↦ x + t • v |
| 51 | have hL : ContinuousAt L 0 := by dsimp [L]; fun_prop |
| 52 | have hzero : L 0 = x := by simp [L] |
| 53 | have hmin' : IsLocalMin f (L 0) := by rwa [hzero] |
| 54 | have hcont : ContinuousAt (fun t ↦ f (L t)) 0 := by |
| 55 | have hf' : ContinuousAt f (L 0) := by simpa only [hzero] using hf.continuousAt |
| 56 | exact hf'.comp hL |
| 57 | by_contra! hneg |
| 58 | rw [← second_deriv_affine_line hf v] at hneg |
| 59 | exact not_isLocalMin_of_strict_upper_contact rfl (Filter.Eventually.of_forall (fun _ ↦ le_rfl)) |
| 60 | hcont hneg (hmin'.comp_continuous hL) |
| 61 | |
| 62 | end PoincareMT.ReducedVolume |