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.Alexandrov.Comparison.DistanceChord |
| 2 | import Mathlib.Analysis.Calculus.Deriv.Slope |
| 3 | |
| 4 | /-! |
| 5 | # Local ascent of distance from an obtuse comparison angle |
| 6 | |
| 7 | Hyperbolic distance-chord comparison supplies ascending points arbitrarily |
| 8 | near the initial point of a minimizing segment. The proof differentiates |
| 9 | only the explicit hyperbolic model chord, not the metric distance function. |
| 10 | |
| 11 | This is the metric local-ascent implication used in Petrunin (2009), |
| 12 | Section 3.4, author manuscript p. 6. |
| 13 | -/ |
| 14 | |
| 15 | noncomputable section |
| 16 | set_option autoImplicit false |
| 17 | |
| 18 | open Set Filter Topology |
| 19 | |
| 20 | namespace Poincare.Alexandrov |
| 21 | |
| 22 | private theorem eventually_pos_of_hasDerivAt_pos |
| 23 | {f : ℝ → ℝ} {a : ℝ} (hf : HasDerivAt f a 0) (ha : 0 < a) (h0 : f 0 = 0) : |
| 24 | ∀ᶠ t in 𝓝[>] (0 : ℝ), 0 < f t := by |
| 25 | have hslope := hf.tendsto_slope_zero_right.eventually_const_lt ha |
| 26 | filter_upwards [hslope, self_mem_nhdsWithin] with t ht htpos |
| 27 | have hmul : 0 < t⁻¹ * f t := by simpa only [zero_add, h0, sub_zero, smul_eq_mul] using ht |
| 28 | exact (mul_pos_iff_of_pos_left (inv_pos.mpr htpos)).mp hmul |
| 29 | |
| 30 | /-- A sufficiently obtuse comparison angle gives strict distance ascent at |
| 31 | arbitrarily small scales along the given minimizing segment. -/ |
| 32 | theorem CurvatureGEnegOne.exists_local_distance_ascent_of_comparisonAngle |
| 33 | {X : Type*} [MetricSpace X] (hX : CurvatureGEnegOne X) |
| 34 | {p y q : X} (hpy : p ≠ y) (hqy : q ≠ y) |
| 35 | (γ : ℝ → X) (hγ0 : γ 0 = y) (hγ1 : γ 1 = q) |
| 36 | (hγdist : ∀ s ∈ Icc (0 : ℝ) 1, ∀ t ∈ Icc (0 : ℝ) 1, |
| 37 | dist (γ s) (γ t) = |s - t| * dist y q) |
| 38 | {c : ℝ} (hc : 0 ≤ c) |
| 39 | (hangle : c < -Real.cos (comparisonAngle (dist y p) (dist y q) (dist p q))) : |
| 40 | ∀ s : ℝ, 0 < s → ∃ z : X, |
| 41 | dist y z < s ∧ c * dist y z < dist p z - dist p y := by |
| 42 | let a := dist p y |
| 43 | let ell := dist y q |
| 44 | let d := dist p q |
| 45 | have ha : 0 < a := dist_pos.mpr hpy |
| 46 | have hell : 0 < ell := dist_pos.mpr hqy.symm |
| 47 | have hsinha : 0 < Real.sinh a := Real.sinh_pos_iff.mpr ha |
| 48 | have hsinhell : 0 < Real.sinh ell := Real.sinh_pos_iff.mpr hell |
| 49 | have hden : 0 < Real.sinh a * Real.sinh ell := mul_pos hsinha hsinhell |
| 50 | rw [dist_comm y p] at hangle |
| 51 | change c < -Real.cos (comparisonAngle a ell d) at hangle |
| 52 | have htriangle : |a - ell| ≤ d := by |
| 53 | simpa only [a, ell, d, dist_comm q y] using abs_dist_sub_le p q y |
| 54 | rw [cos_comparisonAngle ha hell dist_nonneg htriangle (dist_triangle p y q), |
| 55 | ← neg_div, lt_div_iff₀ hden] at hangle |
| 56 | have hderivpos : 0 < ell * (Real.cosh d - Real.cosh a * Real.cosh ell - |
| 57 | c * Real.sinh a * Real.sinh ell) := by |
| 58 | apply mul_pos hell |
| 59 | nlinarith only [hangle] |
| 60 | let F : ℝ → ℝ := fun t => |
| 61 | Real.cosh a * Real.sinh ((1 - t) * ell) + Real.cosh d * Real.sinh (t * ell) - |
| 62 | Real.cosh (a + c * t * ell) * Real.sinh ell |
| 63 | have hF0 : F 0 = 0 := by simp [F] |
| 64 | have hFderiv : HasDerivAt F |
| 65 | (ell * (Real.cosh d - Real.cosh a * Real.cosh ell - |
| 66 | c * Real.sinh a * Real.sinh ell)) 0 := by |
| 67 | have h1 := (((hasDerivAt_id (0 : ℝ)).const_sub 1).mul_const ell).sinh.const_mul |
| 68 | (Real.cosh a) |
| 69 | have h2 := ((hasDerivAt_id (0 : ℝ)).mul_const ell).sinh.const_mul (Real.cosh d) |
| 70 | have h3 := ((((hasDerivAt_id (0 : ℝ)).const_mul c).mul_const ell).const_add a).cosh.mul_const |
| 71 | (Real.sinh ell) |
| 72 | convert! (h1.add h2).sub h3 using 1 |
| 73 | simp only [id_eq, sub_zero, one_mul, neg_one_mul, zero_mul, mul_zero, Real.cosh_zero, |
| 74 | mul_one, add_zero] |
| 75 | ring |
| 76 | have hFpos := eventually_pos_of_hasDerivAt_pos hFderiv hderivpos hF0 |
| 77 | intro s hs |
| 78 | have hsmall : ∀ᶠ t in 𝓝[>] (0 : ℝ), t < min 1 (s / ell) := |
| 79 | (eventually_lt_nhds (lt_min zero_lt_one (div_pos hs hell))).filter_mono |
| 80 | nhdsWithin_le_nhds |
| 81 | have hpositive : ∀ᶠ t in 𝓝[>] (0 : ℝ), 0 < t := self_mem_nhdsWithin |
| 82 | obtain ⟨t, htF, ht0, htsmall⟩ := |
| 83 | (hFpos.and (hpositive.and hsmall)).exists |
| 84 | have ht1 : t < 1 := lt_of_lt_of_le htsmall (min_le_left _ _) |
| 85 | have hts : t * ell < s := |
| 86 | (lt_div_iff₀ hell).mp (lt_of_lt_of_le htsmall (min_le_right _ _)) |
| 87 | have htI : t ∈ Icc (0 : ℝ) 1 := ⟨ht0.le, ht1.le⟩ |
| 88 | have hyz : dist y (γ t) = t * ell := by |
| 89 | have h := hγdist 0 ⟨le_rfl, zero_le_one⟩ t htI |
| 90 | simpa only [hγ0, zero_sub, abs_neg, abs_of_pos ht0] using h |
| 91 | have hzq : dist (γ t) q = (1 - t) * ell := by |
| 92 | have h := hγdist t htI 1 ⟨zero_le_one, le_rfl⟩ |
| 93 | simpa only [hγ1, abs_of_neg (sub_neg.mpr ht1), neg_sub] using h |
| 94 | have hyzpos : 0 < dist y (γ t) := by rw [hyz]; positivity |
| 95 | have hzqpos : 0 < dist (γ t) q := by rw [hzq]; positivity |
| 96 | have hbetween : dist y q = dist y (γ t) + dist (γ t) q := by |
| 97 | rw [hyz, hzq] |
| 98 | change ell = t * ell + (1 - t) * ell |
| 99 | ring |
| 100 | have hchord := hX.cosh_distance_chord_lower_bound (p := p) hyzpos hzqpos hbetween |
| 101 | rw [hyz, hzq] at hchord |
| 102 | have hcoshlt : Real.cosh (a + c * t * ell) < Real.cosh (dist p (γ t)) := by |
| 103 | apply (mul_lt_mul_iff_left₀ hsinhell).mp |
| 104 | dsimp [F] at htF |
| 105 | nlinarith only [htF, hchord] |
| 106 | have hincrement : a + c * t * ell < dist p (γ t) := by |
| 107 | have h := Real.cosh_lt_cosh.mp hcoshlt |
| 108 | simpa only [abs_of_nonneg (show 0 ≤ a + c * t * ell by positivity), |
| 109 | abs_of_nonneg dist_nonneg] using h |
| 110 | refine ⟨γ t, ?_, ?_⟩ |
| 111 | · rw [hyz] |
| 112 | exact hts |
| 113 | · rw [hyz] |
| 114 | dsimp [a] at hincrement |
| 115 | linarith |
| 116 | |
| 117 | end Poincare.Alexandrov |