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.Topology.Connected.BoundaryIncidence |
| 2 | import Mathlib.Topology.Compactness.SigmaCompact |
| 3 | import Mathlib.Topology.Connected.LocallyConnected |
| 4 | |
| 5 | /-! |
| 6 | # Finitely many complementary components outside a larger compact set |
| 7 | |
| 8 | For two nested compact sets, only finitely many components outside the |
| 9 | smaller set reach beyond the larger one. They meet the compact frontier of |
| 10 | the larger set, which is covered by their open components. This supplies |
| 11 | the finite choice needed to extract an end from a noncompact remainder. |
| 12 | -/ |
| 13 | |
| 14 | set_option autoImplicit false |
| 15 | |
| 16 | open Set |
| 17 | open scoped Topology |
| 18 | |
| 19 | namespace Poincare.Topology |
| 20 | |
| 21 | variable {X : Type*} [TopologicalSpace X] [T2Space X] |
| 22 | [LocallyConnectedSpace X] [PreconnectedSpace X] |
| 23 | |
| 24 | omit [T2Space X] [PreconnectedSpace X] in |
| 25 | private theorem frontier_component_compl_subset {K : Set X} (hK : IsClosed K) |
| 26 | {x : X} (hx : x ∈ Kᶜ) : frontier (connectedComponentIn Kᶜ x) ⊆ K := by |
| 27 | intro y hy |
| 28 | by_contra hyK |
| 29 | have hmem : (⟨y, hyK⟩ : ↥(Kᶜ)) ∈ connectedComponent (⟨x, hx⟩ : ↥(Kᶜ)) := by |
| 30 | rw [← (isClosed_connectedComponent (x := (⟨x, hx⟩ : ↥(Kᶜ)))).closure_eq] |
| 31 | apply closure_subtype.mpr |
| 32 | rw [← connectedComponentIn_eq_image hx] |
| 33 | exact hy.1 |
| 34 | have hyC : y ∈ connectedComponentIn Kᶜ x := by |
| 35 | rw [connectedComponentIn_eq_image hx] |
| 36 | exact ⟨⟨y, hyK⟩, hmem, rfl⟩ |
| 37 | exact hy.2 (hK.isOpen_compl.connectedComponentIn.interior_eq.symm ▸ hyC) |
| 38 | |
| 39 | omit [T2Space X] in |
| 40 | /-- Every component reaching outside the larger compact set meets its frontier. -/ |
| 41 | theorem component_compl_meets_frontier {K L : Set X} |
| 42 | (hK : IsClosed K) (hKne : K.Nonempty) |
| 43 | (hKL : K ⊆ interior L) {x : X} (hx : x ∉ L) : |
| 44 | (connectedComponentIn Kᶜ x ∩ frontier L).Nonempty := by |
| 45 | have hxK : x ∈ Kᶜ := fun h => hx (interior_subset (hKL h)) |
| 46 | let C := connectedComponentIn Kᶜ x |
| 47 | have hCne : C.Nonempty := ⟨x, mem_connectedComponentIn hxK⟩ |
| 48 | have hCnot : C ≠ univ := by |
| 49 | intro heq |
| 50 | obtain ⟨p, hp⟩ := hKne |
| 51 | exact connectedComponentIn_subset Kᶜ x (show p ∈ C from heq.symm ▸ mem_univ p) hp |
| 52 | obtain ⟨p, hp⟩ := nonempty_frontier_iff.mpr ⟨hCne, hCnot⟩ |
| 53 | have hpL : p ∈ interior L := hKL (frontier_component_compl_subset hK hxK hp) |
| 54 | obtain ⟨q, hqL, hqC⟩ := mem_closure_iff.mp hp.1 (interior L) isOpen_interior hpL |
| 55 | by_contra h |
| 56 | have hdis : Disjoint C (frontier L) := disjoint_iff_inter_eq_empty.mpr |
| 57 | (not_nonempty_iff_eq_empty.mp h) |
| 58 | have hsub := preconnected_subset_interior_of_disjoint_frontier |
| 59 | isPreconnected_connectedComponentIn hdis ⟨q, hqC, hqL⟩ |
| 60 | exact hx (interior_subset (hsub (mem_connectedComponentIn hxK))) |
| 61 | |
| 62 | /-- Outside a larger compact neighborhood, finitely many components of the |
| 63 | complement of the original compact set suffice. -/ |
| 64 | theorem exists_finite_component_cover_outside_compact {K L : Set X} |
| 65 | (hK : IsCompact K) (hL : IsCompact L) (hKL : K ⊆ interior L) : |
| 66 | ∃ s : Finset X, (∀ p ∈ s, p ∈ Kᶜ) ∧ |
| 67 | ∀ x, x ∉ L → ∃ p ∈ s, x ∈ connectedComponentIn Kᶜ p := by |
| 68 | classical |
| 69 | rcases K.eq_empty_or_nonempty with hKe | hKne |
| 70 | · rw [hKe] |
| 71 | by_cases hX : Nonempty X |
| 72 | · let p := Classical.choice hX |
| 73 | refine ⟨{p}, by simp, ?_⟩ |
| 74 | intro x hx |
| 75 | exact ⟨p, by simp, by simp [connectedComponentIn_univ, |
| 76 | PreconnectedSpace.connectedComponent_eq_univ]⟩ |
| 77 | · let : IsEmpty X := not_nonempty_iff.mp hX |
| 78 | exact ⟨∅, by simp, fun x => isEmptyElim x⟩ |
| 79 | have hfront : IsCompact (frontier L) := |
| 80 | hL.of_isClosed_subset isClosed_frontier hL.isClosed.frontier_subset |
| 81 | have hfrontK : frontier L ⊆ Kᶜ := fun p hp hpK => hp.2 (hKL hpK) |
| 82 | obtain ⟨s, hs⟩ := hfront.elim_finite_subcover |
| 83 | (fun p : frontier L => connectedComponentIn Kᶜ p.val) |
| 84 | (fun _ => hK.isClosed.isOpen_compl.connectedComponentIn) (by |
| 85 | intro x hx |
| 86 | exact mem_iUnion.mpr ⟨⟨x, hx⟩, mem_connectedComponentIn (hfrontK hx)⟩) |
| 87 | refine ⟨s.image Subtype.val, ?_, ?_⟩ |
| 88 | · intro p hp |
| 89 | obtain ⟨q, _, rfl⟩ := Finset.mem_image.mp hp |
| 90 | exact hfrontK q.property |
| 91 | · intro x hx |
| 92 | obtain ⟨y, hyC, hyL⟩ := component_compl_meets_frontier hK.isClosed hKne hKL hx |
| 93 | obtain ⟨p, hp, hyp⟩ := mem_iUnion₂.mp (hs hyL) |
| 94 | refine ⟨p.val, Finset.mem_image.mpr ⟨p, hp, rfl⟩, ?_⟩ |
| 95 | have heq := (connectedComponentIn_eq hyC).trans (connectedComponentIn_eq hyp).symm |
| 96 | rw [← heq] |
| 97 | exact mem_connectedComponentIn (fun hxK => hx (interior_subset (hKL hxK))) |
| 98 | |
| 99 | /-- A set escaping every compact set has a noncompact trace in some component |
| 100 | outside any compact set. No finiteness of all complementary components is needed. -/ |
| 101 | theorem exists_unbounded_component_trace (K : CompactExhaustion X) |
| 102 | {A : Set X} (hA : ∀ L : Set X, IsCompact L → ¬ A ⊆ L) (n : ℕ) : |
| 103 | ∃ p : X, p ∈ (K n)ᶜ ∧ |
| 104 | ∀ L : Set X, IsCompact L → ¬ A ∩ connectedComponentIn (K n)ᶜ p ⊆ L := by |
| 105 | classical |
| 106 | obtain ⟨s, hs, hcover⟩ := exists_finite_component_cover_outside_compact |
| 107 | (K.isCompact n) (K.isCompact (n + 1)) (K.subset_interior_succ n) |
| 108 | by_contra h |
| 109 | push Not at h |
| 110 | choose L hL hsub using fun p : s => h p.val (hs p.val p.property) |
| 111 | let B := K (n + 1) ∪ ⋃ p : s, L p |
| 112 | have hB : IsCompact B := (K.isCompact (n + 1)).union (isCompact_iUnion hL) |
| 113 | apply hA B hB |
| 114 | intro x hxA |
| 115 | by_cases hxK : x ∈ K (n + 1) |
| 116 | · exact Or.inl hxK |
| 117 | · obtain ⟨p, hp, hxp⟩ := hcover x hxK |
| 118 | exact Or.inr (mem_iUnion.mpr ⟨⟨p, hp⟩, hsub ⟨p, hp⟩ ⟨hxA, hxp⟩⟩) |
| 119 | |
| 120 | end Poincare.Topology |