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.Packing.Net |
| 2 | import PoincareLib.Geometry.Alexandrov.Comparison.NearVertex |
| 3 | import Mathlib.Data.Finset.Lattice.Fold |
| 4 | |
| 5 | /-! |
| 6 | # Nearly opposite comparison directions near a point |
| 7 | |
| 8 | A finite angular cover at a fixed center provides comparison directions |
| 9 | with nearly opposite angles throughout a punctured neighborhood. The |
| 10 | positive neighborhood radius is the minimum of finitely many radii from |
| 11 | the hyperbolic cosine law. |
| 12 | -/ |
| 13 | |
| 14 | noncomputable section |
| 15 | set_option autoImplicit false |
| 16 | |
| 17 | namespace Poincare.Alexandrov |
| 18 | |
| 19 | theorem ComparisonAnglePackingBound.exists_pos_near_opposite |
| 20 | {X : Type*} [MetricSpace X] {α : ℝ} {N : ℕ} |
| 21 | (h : ComparisonAnglePackingBound X α N) |
| 22 | (hα : 0 < α) (hαpi : α < Real.pi / 2) (p : X) : |
| 23 | ∃ r : ℝ, 0 < r ∧ ∀ y : X, 0 < dist p y → dist p y < r → |
| 24 | ∃ q : X, q ≠ y ∧ Real.pi - 2 * α < |
| 25 | comparisonAngle (dist y p) (dist y q) (dist p q) := by |
| 26 | classical |
| 27 | obtain ⟨s, _, hp, hcover⟩ := h.exists_angle_net hα.le p |
| 28 | have hqpos (q : s) : 0 < dist p q := |
| 29 | dist_pos.mpr (fun heq => hp (heq.symm ▸ q.property)) |
| 30 | have hlocal (q : s) := exists_pos_comparisonAngle_near_vertex (hqpos q) hα hαpi |
| 31 | choose ε hε hεangle using hlocal |
| 32 | let ρ : s → ℝ := fun q => min (ε q) (dist p q / 2) |
| 33 | have hρ (q : s) : 0 < ρ q := lt_min (hε q) (half_pos (hqpos q)) |
| 34 | by_cases hs : s.Nonempty |
| 35 | · let : Nonempty s := ⟨⟨hs.choose, hs.choose_spec⟩⟩ |
| 36 | let r := Finset.univ.inf' Finset.univ_nonempty ρ |
| 37 | have hr : 0 < r := by simpa only [r, Finset.lt_inf'_iff] using (fun q _ => hρ q) |
| 38 | refine ⟨r, hr, ?_⟩ |
| 39 | intro y hpy hyr |
| 40 | obtain ⟨q, hqs, hangle⟩ := hcover y (dist_pos.mp hpy).symm |
| 41 | let q' : s := ⟨q, hqs⟩ |
| 42 | have hle : r ≤ ρ q' := Finset.inf'_le _ (Finset.mem_univ q') |
| 43 | have hye : dist p y < ε q' := hyr.trans_le (hle.trans (min_le_left _ _)) |
| 44 | have hyq : dist p y < dist p q / 2 := hyr.trans_le (hle.trans (min_le_right _ _)) |
| 45 | have hqy : q ≠ y := by |
| 46 | intro heq |
| 47 | subst q |
| 48 | linarith |
| 49 | refine ⟨q, hqy, ?_⟩ |
| 50 | have hlow : |dist p y - dist p q| ≤ dist y q := by |
| 51 | simpa only [dist_comm y p, dist_comm q p] using abs_dist_sub_le y q p |
| 52 | have hupp : dist y q ≤ dist p y + dist p q := by |
| 53 | simpa only [dist_comm y p] using dist_triangle y p q |
| 54 | simpa only [dist_comm y p] using |
| 55 | hεangle q' (dist p y) (dist y q) hpy hye hlow hupp hangle |
| 56 | · refine ⟨1, zero_lt_one, ?_⟩ |
| 57 | intro y hpy _ |
| 58 | obtain ⟨q, hq, _⟩ := hcover y (dist_pos.mp hpy).symm |
| 59 | exact (hs ⟨q, hq⟩).elim |
| 60 | |
| 61 | end Poincare.Alexandrov |