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.ComparisonAngle |
| 2 | import Mathlib.Topology.MetricSpace.Pseudo.Constructions |
| 3 | import Mathlib.Tactic.FieldSimp |
| 4 | import Mathlib.Tactic.FunProp |
| 5 | import Mathlib.Tactic.LinearCombination |
| 6 | |
| 7 | /-! |
| 8 | # Comparison angles near a vertex |
| 9 | |
| 10 | For a short side adjacent to a fixed positive side, a small comparison angle |
| 11 | at the fixed vertex forces an almost opposite comparison angle at the nearby |
| 12 | vertex. A change-of-vertex cosine identity removes the singular short-side |
| 13 | denominator before applying continuity. |
| 14 | -/ |
| 15 | |
| 16 | noncomputable section |
| 17 | set_option autoImplicit false |
| 18 | |
| 19 | open Filter Topology |
| 20 | |
| 21 | namespace Poincare.Alexandrov |
| 22 | |
| 23 | /-- The hyperbolic cosine rule rewritten at the other endpoint of the side |
| 24 | of length `a`, with the short-side denominator canceled. -/ |
| 25 | theorem cos_comparisonAngle_change_vertex {a b c : ℝ} |
| 26 | (ha : 0 < a) (hb : 0 < b) (hc : 0 < c) |
| 27 | (hlow : |a - b| ≤ c) (hhigh : c ≤ a + b) : |
| 28 | Real.cos (comparisonAngle a c b) = |
| 29 | (Real.sinh a * Real.cosh b - Real.cosh a * Real.sinh b * |
| 30 | Real.cos (comparisonAngle a b c)) / Real.sinh c := by |
| 31 | have hlow' : |a - c| ≤ b := abs_le.mpr ⟨by linarith, by |
| 32 | have h := le_abs_self (a - b) |
| 33 | linarith⟩ |
| 34 | have hhigh' : b ≤ a + c := by |
| 35 | have h := neg_le_abs (a - b) |
| 36 | linarith |
| 37 | rw [cos_comparisonAngle ha hc hb.le hlow' hhigh', |
| 38 | cos_comparisonAngle ha hb hc.le hlow hhigh] |
| 39 | have hsa := (Real.sinh_pos_iff.mpr ha).ne' |
| 40 | have hsb := (Real.sinh_pos_iff.mpr hb).ne' |
| 41 | have hsc := (Real.sinh_pos_iff.mpr hc).ne' |
| 42 | field_simp |
| 43 | linear_combination (Real.cosh b) * (Real.cosh_sq_sub_sinh_sq a) |
| 44 | |
| 45 | /-- If one side tends to zero while an adjacent side stays fixed, a comparison |
| 46 | angle at most `α` forces the angle at the nearby vertex to exceed `pi - 2α`. |
| 47 | The third side need only satisfy the triangle inequalities. -/ |
| 48 | theorem exists_pos_comparisonAngle_near_vertex {b α : ℝ} |
| 49 | (hb : 0 < b) (hα : 0 < α) (hαpi : α < Real.pi / 2) : |
| 50 | ∃ ε : ℝ, 0 < ε ∧ ∀ a c : ℝ, 0 < a → a < ε → |
| 51 | |a - b| ≤ c → c ≤ a + b → comparisonAngle a b c ≤ α → |
| 52 | Real.pi - 2 * α < comparisonAngle a c b := by |
| 53 | let F : ℝ × ℝ → ℝ := fun v => |
| 54 | (Real.sinh v.1 * Real.cosh b - Real.cosh v.1 * Real.sinh b * Real.cos α) / |
| 55 | Real.sinh v.2 |
| 56 | have hF : ContinuousAt F (0, b) := by |
| 57 | apply ContinuousAt.div |
| 58 | · fun_prop |
| 59 | · fun_prop |
| 60 | · exact (Real.sinh_pos_iff.mpr hb).ne' |
| 61 | have hFzero : F (0, b) = -Real.cos α := by |
| 62 | dsimp [F] |
| 63 | simp only [Real.sinh_zero, Real.cosh_zero, zero_mul, one_mul, zero_sub] |
| 64 | field_simp |
| 65 | have hcos : Real.cos (2 * α) < Real.cos α := |
| 66 | Real.cos_lt_cos_of_nonneg_of_le_pi hα.le (by linarith) (by linarith) |
| 67 | have hgap : F (0, b) < Real.cos (Real.pi - 2 * α) := by |
| 68 | rw [hFzero, Real.cos_pi_sub] |
| 69 | linarith |
| 70 | have hev : ∀ᶠ v in 𝓝 (0, b), F v < Real.cos (Real.pi - 2 * α) := |
| 71 | hF.eventually_lt continuousAt_const hgap |
| 72 | obtain ⟨r, hr, hball⟩ := Metric.eventually_nhds_iff.mp hev |
| 73 | refine ⟨min r (b / 2), lt_min hr (by positivity), ?_⟩ |
| 74 | intro a c ha har hlow hhigh hangle |
| 75 | have har' : a < r := har.trans_le (min_le_left _ _) |
| 76 | have hab : a < b / 2 := har.trans_le (min_le_right _ _) |
| 77 | have hcb : |c - b| ≤ a := abs_le.mpr ⟨by |
| 78 | have h := neg_le_abs (a - b) |
| 79 | linarith, by linarith⟩ |
| 80 | have hc : 0 < c := by |
| 81 | have h := neg_le_abs (a - b) |
| 82 | linarith |
| 83 | have hFbound : F (a, c) < Real.cos (Real.pi - 2 * α) := by |
| 84 | apply hball |
| 85 | simp only [Prod.dist_eq, Real.dist_eq, sub_zero, abs_of_pos ha] |
| 86 | exact max_lt har' (hcb.trans_lt har') |
| 87 | have hcosangle : Real.cos α ≤ Real.cos (comparisonAngle a b c) := |
| 88 | Real.cos_le_cos_of_nonneg_of_le_pi (comparisonAngle_nonneg a b c) |
| 89 | (by linarith [Real.pi_pos]) hangle |
| 90 | have hupper : Real.cos (comparisonAngle a c b) ≤ F (a, c) := by |
| 91 | rw [cos_comparisonAngle_change_vertex ha hb hc hlow hhigh] |
| 92 | apply div_le_div_of_nonneg_right _ (Real.sinh_pos_iff.mpr hc).le |
| 93 | have hmul := mul_le_mul_of_nonneg_left hcosangle |
| 94 | (mul_nonneg (Real.cosh_pos a).le (Real.sinh_pos_iff.mpr hb).le) |
| 95 | dsimp [F] |
| 96 | linarith only [hmul] |
| 97 | have hstrict := hupper.trans_lt hFbound |
| 98 | by_contra! hle |
| 99 | have hreverse := Real.cos_le_cos_of_nonneg_of_le_pi |
| 100 | (comparisonAngle_nonneg a c b) (by linarith : Real.pi - 2 * α ≤ Real.pi) hle |
| 101 | exact (not_lt_of_ge hreverse) hstrict |
| 102 | |
| 103 | end Poincare.Alexandrov |