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 Mathlib.Topology.Bases |
| 2 | import Mathlib.Topology.Separation.Hausdorff |
| 3 | |
| 4 | /-! |
| 5 | # Final topology for two overlapping spacetime charts |
| 6 | |
| 7 | The old spacetime and a terminal cylinder may be mapped into a prescribed |
| 8 | carrier. Openness of the two overlap maps makes their inclusions open |
| 9 | embeddings in the final topology. A continuous time map separates pairs which |
| 10 | do not lie in a common chart. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | |
| 15 | open Set Function TopologicalSpace Topology |
| 16 | |
| 17 | universe u v w z |
| 18 | |
| 19 | namespace PoincareMT.SingularRegularLimit.TwoChart |
| 20 | |
| 21 | variable {X : Type u} {Y : Type v} {Z : Type w} |
| 22 | [TopologicalSpace X] [TopologicalSpace Y] |
| 23 | (f : X → Z) (g : Y → Z) |
| 24 | |
| 25 | /-- The final topology of the two chart maps into a prescribed carrier. -/ |
| 26 | @[instance_reducible] def topology : TopologicalSpace Z := |
| 27 | TopologicalSpace.coinduced (Sum.elim f g) inferInstance |
| 28 | |
| 29 | /-- Openness is tested in both charts. -/ |
| 30 | theorem isOpen_iff (U : Set Z) : |
| 31 | @IsOpen Z (topology f g) U ↔ IsOpen (f ⁻¹' U) ∧ IsOpen (g ⁻¹' U) := Iff.rfl |
| 32 | |
| 33 | theorem continuous_left : @Continuous X Z _ (topology f g) f := |
| 34 | continuous_def.mpr fun U hU => ((isOpen_iff f g U).mp hU).1 |
| 35 | |
| 36 | theorem continuous_right : @Continuous Y Z _ (topology f g) g := |
| 37 | continuous_def.mpr fun U hU => ((isOpen_iff f g U).mp hU).2 |
| 38 | |
| 39 | /-- The left map is an open embedding when its images are open in the right chart. -/ |
| 40 | theorem isOpenEmbedding_left (hf : Injective f) |
| 41 | (hgf : ∀ U : Set X, IsOpen U → IsOpen (g ⁻¹' (f '' U))) : |
| 42 | @IsOpenEmbedding X Z _ (topology f g) f := by |
| 43 | let _ := topology f g |
| 44 | apply IsOpenEmbedding.of_continuous_injective_isOpenMap (continuous_left f g) hf |
| 45 | intro U hU |
| 46 | apply (isOpen_iff f g (f '' U)).mpr |
| 47 | exact ⟨by simpa only [preimage_image_eq U hf] using hU, hgf U hU⟩ |
| 48 | |
| 49 | /-- The right map is an open embedding when its images are open in the left chart. -/ |
| 50 | theorem isOpenEmbedding_right (hg : Injective g) |
| 51 | (hfg : ∀ V : Set Y, IsOpen V → IsOpen (f ⁻¹' (g '' V))) : |
| 52 | @IsOpenEmbedding Y Z _ (topology f g) g := by |
| 53 | let _ := topology f g |
| 54 | apply IsOpenEmbedding.of_continuous_injective_isOpenMap (continuous_right f g) hg |
| 55 | intro V hV |
| 56 | apply (isOpen_iff f g (g '' V)).mpr |
| 57 | exact ⟨hfg V hV, by simpa only [preimage_image_eq V hg] using hV⟩ |
| 58 | |
| 59 | /-- A map from the glued carrier is continuous exactly when it is continuous in both charts. -/ |
| 60 | theorem continuous_iff {W : Type z} [TopologicalSpace W] (h : Z → W) : |
| 61 | @Continuous Z W (topology f g) _ h ↔ |
| 62 | Continuous (h ∘ f) ∧ Continuous (h ∘ g) := by |
| 63 | let _ := topology f g |
| 64 | constructor |
| 65 | · intro hh |
| 66 | exact ⟨hh.comp (continuous_left f g), hh.comp (continuous_right f g)⟩ |
| 67 | · rintro ⟨hf, hg⟩ |
| 68 | apply continuous_def.mpr |
| 69 | intro U hU |
| 70 | exact (isOpen_iff f g (h ⁻¹' U)).mpr ⟨hU.preimage hf, hU.preimage hg⟩ |
| 71 | |
| 72 | /-- An open final quotient of two second-countable charts is second countable. -/ |
| 73 | theorem secondCountableTopology [SecondCountableTopology X] [SecondCountableTopology Y] |
| 74 | (hf : Injective f) (hg : Injective g) |
| 75 | (hfg : ∀ V : Set Y, IsOpen V → IsOpen (f ⁻¹' (g '' V))) |
| 76 | (hgf : ∀ U : Set X, IsOpen U → IsOpen (g ⁻¹' (f '' U))) |
| 77 | (hcover : ∀ z : Z, z ∈ range f ∨ z ∈ range g) : |
| 78 | @SecondCountableTopology Z (topology f g) := by |
| 79 | let _ := topology f g |
| 80 | have hsurj : Surjective (Sum.elim f g) := by |
| 81 | intro z |
| 82 | rcases hcover z with ⟨x, rfl⟩ | ⟨y, rfl⟩ |
| 83 | · exact ⟨Sum.inl x, rfl⟩ |
| 84 | · exact ⟨Sum.inr y, rfl⟩ |
| 85 | have hquot : IsQuotientMap (Sum.elim f g) := ⟨⟨rfl⟩, hsurj⟩ |
| 86 | exact hquot.secondCountableTopology |
| 87 | ((isOpenEmbedding_left f g hf hgf).isOpenMap.sumElim |
| 88 | (isOpenEmbedding_right f g hg hfg).isOpenMap) |
| 89 | |
| 90 | /-- A Hausdorff-valued continuous map separates pairs outside every common chart. -/ |
| 91 | theorem t2Space [T2Space X] [T2Space Y] |
| 92 | (hf : Injective f) (hg : Injective g) |
| 93 | (hfg : ∀ V : Set Y, IsOpen V → IsOpen (f ⁻¹' (g '' V))) |
| 94 | (hgf : ∀ U : Set X, IsOpen U → IsOpen (g ⁻¹' (f '' U))) |
| 95 | {W : Type z} [TopologicalSpace W] [T2Space W] (τ : Z → W) |
| 96 | (hτf : Continuous (τ ∘ f)) (hτg : Continuous (τ ∘ g)) |
| 97 | (hsep : ∀ z w : Z, ¬ (z ∈ range f ∧ w ∈ range f) → |
| 98 | ¬ (z ∈ range g ∧ w ∈ range g) → τ z ≠ τ w) : |
| 99 | @T2Space Z (topology f g) := by |
| 100 | let _ := topology f g |
| 101 | have hfopen := isOpenEmbedding_left f g hf hgf |
| 102 | have hgopen := isOpenEmbedding_right f g hg hfg |
| 103 | have hτ : Continuous τ := (continuous_iff f g τ).mpr ⟨hτf, hτg⟩ |
| 104 | constructor |
| 105 | intro z w hne |
| 106 | by_cases hleft : z ∈ range f ∧ w ∈ range f |
| 107 | · rcases hleft with ⟨⟨x, rfl⟩, ⟨y, rfl⟩⟩ |
| 108 | obtain ⟨U, V, hU, hV, hx, hy, hdisj⟩ := t2_separation (fun hxy => hne (congrArg f hxy)) |
| 109 | exact ⟨f '' U, f '' V, hfopen.isOpenMap U hU, hfopen.isOpenMap V hV, |
| 110 | mem_image_of_mem f hx, mem_image_of_mem f hy, disjoint_image_of_injective hf hdisj⟩ |
| 111 | · by_cases hright : z ∈ range g ∧ w ∈ range g |
| 112 | · rcases hright with ⟨⟨x, rfl⟩, ⟨y, rfl⟩⟩ |
| 113 | obtain ⟨U, V, hU, hV, hx, hy, hdisj⟩ := t2_separation (fun hxy => hne (congrArg g hxy)) |
| 114 | exact ⟨g '' U, g '' V, hgopen.isOpenMap U hU, hgopen.isOpenMap V hV, |
| 115 | mem_image_of_mem g hx, mem_image_of_mem g hy, disjoint_image_of_injective hg hdisj⟩ |
| 116 | · obtain ⟨U, V, hU, hV, hz, hw, hdisj⟩ := t2_separation (hsep z w hleft hright) |
| 117 | exact ⟨τ ⁻¹' U, τ ⁻¹' V, hU.preimage hτ, hV.preimage hτ, hz, hw, |
| 118 | hdisj.preimage τ⟩ |
| 119 | |
| 120 | end PoincareMT.SingularRegularLimit.TwoChart |