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 PoincareLib.Topology.Manifold.Separation.Collar |
| 3 | import Mathlib.Topology.Connected.LocallyConnected |
| 4 | import Mathlib.Topology.Connected.Clopen |
| 5 | |
| 6 | /-! |
| 7 | # Opposite components along a compact collar |
| 8 | |
| 9 | Two distinct complementary components whose frontiers contain a compact |
| 10 | connected collar slice fill one ambient connected component. No global |
| 11 | connectedness or simple connectedness is required. This is the OPP step |
| 12 | in the reviewed opposite-choice derivation for MT Claim A.24, pp. 512-513. |
| 13 | -/ |
| 14 | |
| 15 | set_option autoImplicit false |
| 16 | |
| 17 | open Set Topology |
| 18 | |
| 19 | namespace Poincare.Topology |
| 20 | |
| 21 | variable {X : Type*} [TopologicalSpace X] [LocallyConnectedSpace X] |
| 22 | |
| 23 | /-- A component of the complement of a closed set has no new closure |
| 24 | points outside that set. This is the component-boundary step used in |
| 25 | MT Claim A.24, pp. 512-513. -/ |
| 26 | theorem closure_connectedComponentIn_compl_subset {S : Set X} (hS : IsClosed S) |
| 27 | (a : X) : |
| 28 | closure (connectedComponentIn Sᶜ a) ⊆ connectedComponentIn Sᶜ a ∪ S := by |
| 29 | intro x hx |
| 30 | by_cases hxS : x ∈ S |
| 31 | · exact Or.inr hxS |
| 32 | · left |
| 33 | obtain ⟨y, hyC, hyA⟩ := mem_closure_iff.mp hx |
| 34 | (connectedComponentIn Sᶜ x) hS.isOpen_compl.connectedComponentIn |
| 35 | (mem_connectedComponentIn hxS) |
| 36 | rw [connectedComponentIn_eq hyA, ← connectedComponentIn_eq hyC] |
| 37 | exact mem_connectedComponentIn hxS |
| 38 | |
| 39 | /-- Opposite actual complementary components along a compact connected |
| 40 | collar, together with its middle slice, form one clopen ambient component. |
| 41 | This is the topological OPP argument in MT Claim A.24, pp. 512-513; the |
| 42 | ambient space is allowed to be disconnected. -/ |
| 43 | theorem opposite_collar_components |
| 44 | {Y : Type*} [TopologicalSpace Y] [CompactSpace Y] [ConnectedSpace Y] |
| 45 | [T2Space X] {r : ℝ} (hr : 0 < r) {U : Set X} (hU : IsOpen U) |
| 46 | (e : (Y × Ioo (-r) r) ≃ₜ U) {a b : X} |
| 47 | (ha : a ∉ range (fun y : Y => (e (y, ⟨0, neg_lt_zero.mpr hr, hr⟩) : X))) |
| 48 | (hb : b ∉ range (fun y : Y => (e (y, ⟨0, neg_lt_zero.mpr hr, hr⟩) : X))) |
| 49 | (hne : connectedComponentIn |
| 50 | (range (fun y : Y => (e (y, ⟨0, neg_lt_zero.mpr hr, hr⟩) : X)))ᶜ a ≠ |
| 51 | connectedComponentIn |
| 52 | (range (fun y : Y => (e (y, ⟨0, neg_lt_zero.mpr hr, hr⟩) : X)))ᶜ b) |
| 53 | (hfront : range (fun y : Y => (e (y, ⟨0, neg_lt_zero.mpr hr, hr⟩) : X)) ⊆ |
| 54 | frontier (connectedComponentIn |
| 55 | (range (fun y : Y => (e (y, ⟨0, neg_lt_zero.mpr hr, hr⟩) : X)))ᶜ a) ∩ |
| 56 | frontier (connectedComponentIn |
| 57 | (range (fun y : Y => (e (y, ⟨0, neg_lt_zero.mpr hr, hr⟩) : X)))ᶜ b)) : |
| 58 | let S := range (fun y : Y => (e (y, ⟨0, neg_lt_zero.mpr hr, hr⟩) : X)) |
| 59 | let A := connectedComponentIn Sᶜ a |
| 60 | let B := connectedComponentIn Sᶜ b |
| 61 | frontier A = S ∧ frontier B = S ∧ IsClopen (A ∪ S ∪ B) ∧ |
| 62 | IsConnected (A ∪ S ∪ B) ∧ A ∪ S ∪ B = connectedComponent a := by |
| 63 | let S := range (fun y : Y => (e (y, ⟨0, neg_lt_zero.mpr hr, hr⟩) : X)) |
| 64 | let A := connectedComponentIn Sᶜ a |
| 65 | let B := connectedComponentIn Sᶜ b |
| 66 | let L := (fun z => (e z : X)) '' {z | (z.2 : ℝ) < 0} |
| 67 | let R := (fun z => (e z : X)) '' {z | 0 < (z.2 : ℝ)} |
| 68 | change a ∉ S at ha |
| 69 | change b ∉ S at hb |
| 70 | change A ≠ B at hne |
| 71 | change S ⊆ frontier A ∩ frontier B at hfront |
| 72 | change frontier A = S ∧ frontier B = S ∧ IsClopen (A ∪ S ∪ B) ∧ |
| 73 | IsConnected (A ∪ S ∪ B) ∧ A ∪ S ∪ B = connectedComponent a |
| 74 | have hS : IsClosed S := (isCompact_range |
| 75 | (continuous_subtype_val.comp (e.continuous.comp |
| 76 | (continuous_id.prodMk continuous_const)))).isClosed |
| 77 | have hA : IsOpen A := hS.isOpen_compl.connectedComponentIn |
| 78 | have hB : IsOpen B := hS.isOpen_compl.connectedComponentIn |
| 79 | have hAc : IsConnected A := isConnected_connectedComponentIn_iff.mpr ha |
| 80 | have hBc : IsConnected B := isConnected_connectedComponentIn_iff.mpr hb |
| 81 | have hAS : A ⊆ Sᶜ := connectedComponentIn_subset _ _ |
| 82 | have hBS : B ⊆ Sᶜ := connectedComponentIn_subset _ _ |
| 83 | have hdis : Disjoint A B := by |
| 84 | apply Set.disjoint_left.mpr |
| 85 | intro x hxA hxB |
| 86 | exact hne ((connectedComponentIn_eq hxA).trans (connectedComponentIn_eq hxB).symm) |
| 87 | have hLc : IsConnected L := isConnected_collar_negative hr e |
| 88 | have hRc : IsConnected R := isConnected_collar_positive hr e |
| 89 | have hLS : L ⊆ Sᶜ := by |
| 90 | rintro x ⟨z, hz, rfl⟩ ⟨y, hy⟩ |
| 91 | have he := e.injective (Subtype.ext hy) |
| 92 | have ht := congrArg (fun w : Y × Ioo (-r) r => (w.2 : ℝ)) he |
| 93 | exact (ne_of_lt hz) ht.symm |
| 94 | have hRS : R ⊆ Sᶜ := by |
| 95 | rintro x ⟨z, hz, rfl⟩ ⟨y, hy⟩ |
| 96 | have he := e.injective (Subtype.ext hy) |
| 97 | have ht := congrArg (fun w : Y × Ioo (-r) r => (w.2 : ℝ)) he |
| 98 | exact (ne_of_gt hz) ht.symm |
| 99 | have hSU : S ⊆ U := by rintro x ⟨y, rfl⟩; exact (e _).property |
| 100 | have hUcover : U ⊆ L ∪ S ∪ R := by |
| 101 | intro x hx |
| 102 | obtain ⟨z, hz⟩ := e.surjective ⟨x, hx⟩ |
| 103 | have hzx := congrArg Subtype.val hz |
| 104 | rcases lt_trichotomy (z.2 : ℝ) 0 with ht | ht | ht |
| 105 | · exact Or.inl (Or.inl ⟨z, ht, hzx⟩) |
| 106 | · left; right |
| 107 | refine ⟨z.1, ?_⟩ |
| 108 | have he : (z.1, (⟨0, neg_lt_zero.mpr hr, hr⟩ : Ioo (-r) r)) = z := |
| 109 | Prod.ext rfl (Subtype.ext ht.symm) |
| 110 | simpa only [he] using hzx |
| 111 | · exact Or.inr ⟨z, ht, hzx⟩ |
| 112 | have hmeet (c : X) (hSc : S ⊆ frontier (connectedComponentIn Sᶜ c)) : |
| 113 | (L ∩ connectedComponentIn Sᶜ c).Nonempty ∨ |
| 114 | (R ∩ connectedComponentIn Sᶜ c).Nonempty := by |
| 115 | obtain ⟨y⟩ := (inferInstance : Nonempty Y) |
| 116 | let x : X := e (y, ⟨0, neg_lt_zero.mpr hr, hr⟩) |
| 117 | have hxS : x ∈ S := ⟨y, rfl⟩ |
| 118 | obtain ⟨z, hzU, hzC⟩ := mem_closure_iff.mp (hSc hxS).1 U hU (hSU hxS) |
| 119 | rcases hUcover hzU with (hzL | hzS) | hzR |
| 120 | · exact Or.inl ⟨z, hzL, hzC⟩ |
| 121 | · exact False.elim ((connectedComponentIn_subset Sᶜ c hzC) hzS) |
| 122 | · exact Or.inr ⟨z, hzR, hzC⟩ |
| 123 | have hside (c : X) {V : Set X} (hc : IsPreconnected V) (hs : V ⊆ Sᶜ) |
| 124 | (hi : (V ∩ connectedComponentIn Sᶜ c).Nonempty) : |
| 125 | V ⊆ connectedComponentIn Sᶜ c := by |
| 126 | obtain ⟨x, hxV, hxC⟩ := hi |
| 127 | rw [connectedComponentIn_eq hxC] |
| 128 | exact hc.subset_connectedComponentIn hxV hs |
| 129 | have hchooseA : L ⊆ A ∨ R ⊆ A := |
| 130 | (hmeet a (fun x hx => (hfront hx).1)).imp |
| 131 | (hside a hLc.isPreconnected hLS) (hside a hRc.isPreconnected hRS) |
| 132 | have hchooseB : L ⊆ B ∨ R ⊆ B := |
| 133 | (hmeet b (fun x hx => (hfront hx).2)).imp |
| 134 | (hside b hLc.isPreconnected hLS) (hside b hRc.isPreconnected hRS) |
| 135 | have hUW : U ⊆ A ∪ S ∪ B := by |
| 136 | rcases hchooseA with hLA | hRA <;> rcases hchooseB with hLB | hRB |
| 137 | · obtain ⟨x, hx⟩ := hLc.nonempty |
| 138 | exact False.elim (Set.disjoint_left.mp hdis (hLA hx) (hLB hx)) |
| 139 | · intro x hx |
| 140 | rcases hUcover hx with (h | h) | h |
| 141 | · exact Or.inl (Or.inl (hLA h)) |
| 142 | · exact Or.inl (Or.inr h) |
| 143 | · exact Or.inr (hRB h) |
| 144 | · intro x hx |
| 145 | rcases hUcover hx with (h | h) | h |
| 146 | · exact Or.inr (hLB h) |
| 147 | · exact Or.inl (Or.inr h) |
| 148 | · exact Or.inl (Or.inl (hRA h)) |
| 149 | · obtain ⟨x, hx⟩ := hRc.nonempty |
| 150 | exact False.elim (Set.disjoint_left.mp hdis (hRA hx) (hRB hx)) |
| 151 | have hclA : closure A = A ∪ S := by |
| 152 | apply Subset.antisymm (closure_connectedComponentIn_compl_subset hS a) |
| 153 | exact union_subset subset_closure (fun x hx => (hfront hx).1.1) |
| 154 | have hclB : closure B = B ∪ S := by |
| 155 | apply Subset.antisymm (closure_connectedComponentIn_compl_subset hS b) |
| 156 | exact union_subset subset_closure (fun x hx => (hfront hx).2.1) |
| 157 | have hfrontA : frontier A = S := by |
| 158 | apply Subset.antisymm ?_ (fun x hx => (hfront hx).1) |
| 159 | intro x hx |
| 160 | rcases hclA ▸ hx.1 with hxA | hxS |
| 161 | · exact False.elim (hx.2 (hA.interior_eq.symm ▸ hxA)) |
| 162 | · exact hxS |
| 163 | have hfrontB : frontier B = S := by |
| 164 | apply Subset.antisymm ?_ (fun x hx => (hfront hx).2) |
| 165 | intro x hx |
| 166 | rcases hclB ▸ hx.1 with hxB | hxS |
| 167 | · exact False.elim (hx.2 (hB.interior_eq.symm ▸ hxB)) |
| 168 | · exact hxS |
| 169 | have hWcl : A ∪ S ∪ B = closure A ∪ closure B := by |
| 170 | rw [hclA, hclB] |
| 171 | ext x; simp only [mem_union]; tauto |
| 172 | have hWop : IsOpen (A ∪ S ∪ B) := by |
| 173 | have heq : A ∪ S ∪ B = A ∪ U ∪ B := by |
| 174 | apply Subset.antisymm |
| 175 | · exact union_subset (union_subset |
| 176 | (fun _ h => Or.inl (Or.inl h)) (fun _ h => Or.inl (Or.inr (hSU h)))) |
| 177 | (fun _ h => Or.inr h) |
| 178 | · exact union_subset (union_subset |
| 179 | (fun _ h => Or.inl (Or.inl h)) hUW) (fun _ h => Or.inr h) |
| 180 | rw [heq] |
| 181 | exact (hA.union hU).union hB |
| 182 | have hW : IsClopen (A ∪ S ∪ B) := |
| 183 | ⟨hWcl ▸ isClosed_closure.union isClosed_closure, hWop⟩ |
| 184 | have hWc : IsConnected (A ∪ S ∪ B) := by |
| 185 | rw [hWcl] |
| 186 | apply hAc.closure.union ?_ hBc.closure |
| 187 | obtain ⟨y⟩ := (inferInstance : Nonempty Y) |
| 188 | exact ⟨e (y, ⟨0, neg_lt_zero.mpr hr, hr⟩), |
| 189 | (hfront ⟨y, rfl⟩).1.1, (hfront ⟨y, rfl⟩).2.1⟩ |
| 190 | have haW : a ∈ A ∪ S ∪ B := Or.inl (Or.inl (mem_connectedComponentIn ha)) |
| 191 | exact ⟨hfrontA, hfrontB, hW, hWc, |
| 192 | Subset.antisymm (hWc.subset_connectedComponent haW) |
| 193 | (hW.connectedComponent_subset haW)⟩ |
| 194 | |
| 195 | end Poincare.Topology |