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.RicciFlow.Generalized.BoundedDistance.GeometryImports |
| 2 | import Mathlib.Topology.Connected.LocallyConnected |
| 3 | import Mathlib.Topology.Connected.Clopen |
| 4 | |
| 5 | /-! |
| 6 | # Complementary components determined by a two-half collar |
| 7 | |
| 8 | Every component of the complement of a nonempty closed set meets any open |
| 9 | neighborhood of that set in a connected locally connected space. Two |
| 10 | connected collar halves therefore account for all complementary components. |
| 11 | This is the topology of Morgan--Tian Proposition 10.7, pp. 253-254; |
| 12 | M28 derivation 114. |
| 13 | -/ |
| 14 | |
| 15 | set_option autoImplicit false |
| 16 | |
| 17 | open Set Topology |
| 18 | |
| 19 | /-- An ambient closure adds to a relative component only points outside |
| 20 | its defining set. No local connectedness, openness or separation assumption |
| 21 | is needed. Source: M28 derivation 114. -/ |
| 22 | theorem closure_connectedComponentIn_subset_union_compl |
| 23 | {X : Type*} [TopologicalSpace X] (U : Set X) (x : X) : |
| 24 | closure (connectedComponentIn U x) ⊆ connectedComponentIn U x ∪ Uᶜ := by |
| 25 | by_cases hx : x ∈ U |
| 26 | · intro y hy |
| 27 | by_cases hyU : y ∈ U |
| 28 | · left |
| 29 | rw [connectedComponentIn_eq_image hx] at hy ⊢ |
| 30 | have hsub : (⟨y, hyU⟩ : U) ∈ closure (connectedComponent (⟨x, hx⟩ : U)) := by |
| 31 | rw [IsEmbedding.subtypeVal.closure_eq_preimage_closure_image] |
| 32 | exact hy |
| 33 | exact ⟨⟨y, hyU⟩, |
| 34 | (isClosed_connectedComponent (x := (⟨x, hx⟩ : U))).closure_eq ▸ hsub, rfl⟩ |
| 35 | · exact Or.inr hyU |
| 36 | · simp only [connectedComponentIn_eq_empty hx, closure_empty, empty_subset] |
| 37 | |
| 38 | /-- Every complementary component meets an open neighborhood of the |
| 39 | nonempty removed set. Otherwise the component would be nonempty clopen |
| 40 | in the connected ambient space. Source: M28 derivation 114. -/ |
| 41 | theorem connectedComponentIn_compl_inter_neighborhood_nonempty |
| 42 | {X : Type*} [TopologicalSpace X] [ConnectedSpace X] [LocallyConnectedSpace X] |
| 43 | {S V : Set X} (hS : IsClosed S) (hne : S.Nonempty) (hV : IsOpen V) |
| 44 | (hSV : S ⊆ V) {x : X} (hx : x ∈ Sᶜ) : |
| 45 | (connectedComponentIn Sᶜ x ∩ V).Nonempty := by |
| 46 | by_contra hn |
| 47 | have hdis : connectedComponentIn Sᶜ x ⊆ Vᶜ := by |
| 48 | intro y hy hyV |
| 49 | exact hn ⟨y, hy, hyV⟩ |
| 50 | have hclosure : closure (connectedComponentIn Sᶜ x) ⊆ Vᶜ := |
| 51 | closure_minimal hdis hV.isClosed_compl |
| 52 | have hclosed : IsClosed (connectedComponentIn Sᶜ x) := by |
| 53 | apply isClosed_of_closure_subset |
| 54 | intro y hy |
| 55 | rcases closure_connectedComponentIn_subset_union_compl Sᶜ x hy with h | h |
| 56 | · exact h |
| 57 | · exact False.elim (hclosure hy (hSV (by simpa only [compl_compl] using h))) |
| 58 | have hall : connectedComponentIn Sᶜ x = univ := |
| 59 | (show IsClopen (connectedComponentIn Sᶜ x) from |
| 60 | ⟨hclosed, hS.isOpen_compl.connectedComponentIn⟩).eq_univ |
| 61 | ⟨x, mem_connectedComponentIn hx⟩ |
| 62 | obtain ⟨s, hs⟩ := hne |
| 63 | exact connectedComponentIn_subset Sᶜ x (hall.symm ▸ mem_univ s) hs |
| 64 | |
| 65 | /-- A collar with two preconnected halves leaves at most two complementary |
| 66 | components. The two components are allowed to coincide; a separate |
| 67 | separation argument establishes their distinctness. Source: derivation 114. -/ |
| 68 | theorem compl_eq_union_connectedComponentIn_of_two_half_collar |
| 69 | {X : Type*} [TopologicalSpace X] [ConnectedSpace X] [LocallyConnectedSpace X] |
| 70 | {S V B₀ B₁ : Set X} (hS : IsClosed S) (hne : S.Nonempty) (hV : IsOpen V) |
| 71 | (hSV : S ⊆ V) (hpartition : V \ S = B₀ ∪ B₁) |
| 72 | (hB₀ : IsPreconnected B₀) (hB₁ : IsPreconnected B₁) |
| 73 | {x₀ x₁ : X} (hx₀ : x₀ ∈ B₀) (hx₁ : x₁ ∈ B₁) : |
| 74 | Sᶜ = connectedComponentIn Sᶜ x₀ ∪ connectedComponentIn Sᶜ x₁ := by |
| 75 | have hsub : B₀ ∪ B₁ ⊆ Sᶜ := by |
| 76 | rw [← hpartition] |
| 77 | exact sdiff_subset_compl V S |
| 78 | apply Subset.antisymm |
| 79 | · intro x hx |
| 80 | obtain ⟨y, hy, hyV⟩ := |
| 81 | connectedComponentIn_compl_inter_neighborhood_nonempty hS hne hV hSV hx |
| 82 | have hyB : y ∈ B₀ ∪ B₁ := |
| 83 | hpartition ▸ ⟨hyV, connectedComponentIn_subset Sᶜ x hy⟩ |
| 84 | rcases hyB with hy₀ | hy₁ |
| 85 | · have heq := (connectedComponentIn_eq hy).trans (connectedComponentIn_eq |
| 86 | (hB₀.subset_connectedComponentIn hx₀ (subset_union_left.trans hsub) hy₀)).symm |
| 87 | exact Or.inl (heq ▸ mem_connectedComponentIn hx) |
| 88 | · have heq := (connectedComponentIn_eq hy).trans (connectedComponentIn_eq |
| 89 | (hB₁.subset_connectedComponentIn hx₁ (subset_union_right.trans hsub) hy₁)).symm |
| 90 | exact Or.inr (heq ▸ mem_connectedComponentIn hx) |
| 91 | · exact union_subset (connectedComponentIn_subset _ _) (connectedComponentIn_subset _ _) |
| 92 | |
| 93 | /-- A complementary component has exactly the removed set as its frontier |
| 94 | when a subset of that component approaches every removed point. Source: |
| 95 | Proposition 10.7, pp. 253-254; M28 derivation 114. -/ |
| 96 | theorem frontier_connectedComponentIn_compl_eq_of_closure_subset |
| 97 | {X : Type*} [TopologicalSpace X] [LocallyConnectedSpace X] |
| 98 | {S B : Set X} (hS : IsClosed S) {x : X} |
| 99 | (hB : B ⊆ connectedComponentIn Sᶜ x) (hSB : S ⊆ closure B) : |
| 100 | frontier (connectedComponentIn Sᶜ x) = S := by |
| 101 | rw [hS.isOpen_compl.connectedComponentIn.frontier_eq] |
| 102 | apply Subset.antisymm |
| 103 | · rintro y ⟨hycl, hy⟩ |
| 104 | have h := (closure_connectedComponentIn_subset_union_compl Sᶜ x hycl).resolve_left hy |
| 105 | simpa only [compl_compl] using h |
| 106 | · intro y hy |
| 107 | exact ⟨closure_mono hB (hSB hy), fun h => connectedComponentIn_subset Sᶜ x h hy⟩ |