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.Basic |
| 2 | import PoincareLib.Geometry.Alexandrov.Comparison.Collinear |
| 3 | import Mathlib.Data.Fintype.EquivFin |
| 4 | import Mathlib.Order.Preorder.Finite |
| 5 | |
| 6 | /-! |
| 7 | # Finite comparison-angle covers |
| 8 | |
| 9 | A uniform finite packing bound gives a maximal finite family of separated |
| 10 | comparison directions. Every further point either belongs to that family or |
| 11 | makes a comparison angle at most the threshold with one of its members. |
| 12 | -/ |
| 13 | |
| 14 | noncomputable section |
| 15 | set_option autoImplicit false |
| 16 | |
| 17 | open Set |
| 18 | |
| 19 | namespace Poincare.Alexandrov |
| 20 | |
| 21 | variable {X : Type*} [MetricSpace X] {α : ℝ} {N : ℕ} |
| 22 | |
| 23 | theorem ComparisonAnglePackingBound.card_le |
| 24 | (h : ComparisonAnglePackingBound X α N) (p : X) (s : Finset X) |
| 25 | (hp : p ∉ s) |
| 26 | (hs : ∀ x ∈ s, ∀ y ∈ s, x ≠ y → |
| 27 | α < comparisonAngle (dist p x) (dist p y) (dist x y)) : s.card ≤ N := by |
| 28 | classical |
| 29 | let e := (Fintype.equivFin s).symm |
| 30 | have hcard := h (Fintype.card s) p (fun i => (e i : X)) |
| 31 | (fun i heq => hp (heq ▸ (e i).property)) (fun i j hij => |
| 32 | hs _ (e i).property _ (e j).property (fun heq => |
| 33 | hij (e.injective (Subtype.ext heq)))) |
| 34 | simpa only [Fintype.card_coe] using hcard |
| 35 | |
| 36 | /-- A maximal separated family covers every point away from the center, |
| 37 | with the family itself retained explicitly in the covering alternative. -/ |
| 38 | theorem ComparisonAnglePackingBound.exists_finite_cover |
| 39 | (h : ComparisonAnglePackingBound X α N) (p : X) : |
| 40 | ∃ s : Finset X, s.card ≤ N ∧ p ∉ s ∧ |
| 41 | (∀ x ∈ s, ∀ y ∈ s, x ≠ y → |
| 42 | α < comparisonAngle (dist p x) (dist p y) (dist x y)) ∧ |
| 43 | ∀ y : X, y ≠ p → y ∈ s ∨ |
| 44 | ∃ q ∈ s, comparisonAngle (dist p y) (dist p q) (dist y q) ≤ α := by |
| 45 | classical |
| 46 | let S : Set (Finset X) := {s | p ∉ s ∧ ∀ x ∈ s, ∀ y ∈ s, x ≠ y → |
| 47 | α < comparisonAngle (dist p x) (dist p y) (dist x y)} |
| 48 | have hfinite : (Finset.card '' S).Finite := by |
| 49 | apply (Finset.range (N + 1)).finite_toSet.subset |
| 50 | rintro _ ⟨s, hs, rfl⟩ |
| 51 | exact Finset.mem_range.mpr (Nat.lt_succ_of_le (h.card_le p s hs.1 hs.2)) |
| 52 | have hempty : (∅ : Finset X) ∈ S := by simp [S] |
| 53 | obtain ⟨s, hs, hmax⟩ := hfinite.exists_maximalFor' Finset.card S ⟨∅, hempty⟩ |
| 54 | refine ⟨s, h.card_le p s hs.1 hs.2, hs.1, hs.2, ?_⟩ |
| 55 | intro y hyp |
| 56 | by_cases hys : y ∈ s |
| 57 | · exact Or.inl hys |
| 58 | right |
| 59 | by_contra hnone |
| 60 | have hsep (q : X) (hq : q ∈ s) : |
| 61 | α < comparisonAngle (dist p y) (dist p q) (dist y q) := by |
| 62 | exact lt_of_not_ge (fun hle => hnone ⟨q, hq, hle⟩) |
| 63 | have hinsert : insert y s ∈ S := by |
| 64 | refine ⟨?_, ?_⟩ |
| 65 | · simpa only [Finset.mem_insert, not_or] using And.intro hyp.symm hs.1 |
| 66 | · intro a ha b hb hab |
| 67 | rcases Finset.mem_insert.mp ha with rfl | ha' |
| 68 | · rcases Finset.mem_insert.mp hb with rfl | hb' |
| 69 | · exact (hab rfl).elim |
| 70 | · exact hsep b hb' |
| 71 | · rcases Finset.mem_insert.mp hb with rfl | hb' |
| 72 | · simpa only [comparisonAngle_comm, dist_comm] using hsep a ha' |
| 73 | · exact hs.2 a ha' b hb' hab |
| 74 | have hle := hmax hinsert (Finset.card_le_card (Finset.subset_insert y s)) |
| 75 | rw [Finset.card_insert_of_notMem hys] at hle |
| 76 | omega |
| 77 | |
| 78 | /-- At a nonnegative threshold, the maximal family is an actual angular |
| 79 | cover, including its own points. -/ |
| 80 | theorem ComparisonAnglePackingBound.exists_angle_net |
| 81 | (h : ComparisonAnglePackingBound X α N) (hα : 0 ≤ α) (p : X) : |
| 82 | ∃ s : Finset X, s.card ≤ N ∧ p ∉ s ∧ |
| 83 | ∀ y : X, y ≠ p → |
| 84 | ∃ q ∈ s, comparisonAngle (dist p y) (dist p q) (dist y q) ≤ α := by |
| 85 | obtain ⟨s, hcard, hp, _, hcover⟩ := h.exists_finite_cover p |
| 86 | refine ⟨s, hcard, hp, ?_⟩ |
| 87 | intro y hyp |
| 88 | rcases hcover y hyp with hy | hy |
| 89 | · refine ⟨y, hy, ?_⟩ |
| 90 | simpa only [dist_self, comparisonAngle_self_zero (dist_pos.mpr hyp.symm)] using hα |
| 91 | · exact hy |
| 92 | |
| 93 | end Poincare.Alexandrov |