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.ReducedLength.Variation.Differential.SecondDerivativeComposition |
| 2 | |
| 3 | /-! |
| 4 | # Second derivatives of smooth scalar contact differences |
| 5 | -/ |
| 6 | |
| 7 | set_option autoImplicit false |
| 8 | |
| 9 | open scoped ContDiff Topology |
| 10 | open Filter |
| 11 | |
| 12 | namespace PoincareMT.ReducedLength |
| 13 | |
| 14 | theorem localMin_secondDeriv_scaled_comparison (f g : ℝ → ℝ) (c x : ℝ) |
| 15 | (hf : ContDiffAt ℝ ∞ f x) (hg : ContDiffAt ℝ ∞ g x) |
| 16 | (hmin : IsLocalMin (fun t ↦ f t - c * g t) x) : |
| 17 | c * deriv (deriv g) x ≤ deriv (deriv f) x := by |
| 18 | have hfn : ∀ᶠ t in 𝓝 x, DifferentiableAt ℝ f t := |
| 19 | ((hf.of_le (show (1 : ℕ∞ω) ≤ ∞ by simp)).eventually (by simp)).mono |
| 20 | (fun t ht ↦ ht.differentiableAt (by simp)) |
| 21 | have hgn : ∀ᶠ t in 𝓝 x, DifferentiableAt ℝ g t := |
| 22 | ((hg.of_le (show (1 : ℕ∞ω) ≤ ∞ by simp)).eventually (by simp)).mono |
| 23 | (fun t ht ↦ ht.differentiableAt (by simp)) |
| 24 | have hfirst : deriv (fun t ↦ f t - c * g t) =ᶠ[𝓝 x] |
| 25 | (fun t ↦ deriv f t - c * deriv g t) := by |
| 26 | filter_upwards [hfn, hgn] with t hft hgt |
| 27 | exact (hft.hasDerivAt.sub (hgt.hasDerivAt.const_mul c)).deriv |
| 28 | have hdf := ((hf.derivWithin (m := ∞) (by simp)).differentiableAt (by simp)).hasDerivAt |
| 29 | have hdg := ((hg.derivWithin (m := ∞) (by simp)).differentiableAt (by simp)).hasDerivAt |
| 30 | have hsecond : deriv (fun t ↦ deriv f t - c * deriv g t) x = |
| 31 | deriv (deriv f) x - c * deriv (deriv g) x := (hdf.sub (hdg.const_mul c)).deriv |
| 32 | have hpos := localMin_secondDeriv_nonneg (fun t ↦ f t - c * g t) x |
| 33 | (hf.continuousAt.sub (continuousAt_const.mul hg.continuousAt)) hmin |
| 34 | rw [hfirst.deriv_eq, hsecond] at hpos |
| 35 | exact sub_nonneg.mp hpos |
| 36 | |
| 37 | end PoincareMT.ReducedLength |