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.Clopen |
| 3 | import Mathlib.Topology.Instances.Real.Lemmas |
| 4 | import Mathlib.Topology.OpenPartialHomeomorph.Basic |
| 5 | import Mathlib.Tactic.FieldSimp |
| 6 | import Mathlib.Tactic.Linarith |
| 7 | import Mathlib.Tactic.Ring |
| 8 | |
| 9 | /-! |
| 10 | # Connected complements of fiberwise graphs |
| 11 | |
| 12 | A graph inside one actual product chart has connected complement when |
| 13 | the base arc has a closed connected complement and the projection is |
| 14 | coinducing with connected fibers. The chart must cover the full preimage |
| 15 | of the outer arc. This is the topological core of the nonseparating |
| 16 | labels in Morgan--Tian A.20, p. 508; see |
| 17 | `tasks/M25/case-fibration/plan-cyclic-labels.md`, section 5. |
| 18 | -/ |
| 19 | |
| 20 | set_option autoImplicit false |
| 21 | |
| 22 | open Set |
| 23 | |
| 24 | /-- The open region between two ordered continuous graphs over a |
| 25 | connected space is connected. The positive fiber width supplies an |
| 26 | explicit parametrization by the unit interval. Used in MT A.20, p. 508. -/ |
| 27 | theorem isConnected_between_continuous_graphs |
| 28 | {K : Type*} [TopologicalSpace K] [ConnectedSpace K] |
| 29 | {f g : K → ℝ} (hf : Continuous f) (hg : Continuous g) (hlt : ∀ q, f q < g q) : |
| 30 | IsConnected {z : K × ℝ | f z.1 < z.2 ∧ z.2 < g z.1} := by |
| 31 | let F : K × ℝ → K × ℝ := fun z => (z.1, f z.1 + z.2 * (g z.1 - f z.1)) |
| 32 | have hF : Continuous F := |
| 33 | continuous_fst.prodMk ((hf.comp continuous_fst).add |
| 34 | (continuous_snd.mul ((hg.comp continuous_fst).sub (hf.comp continuous_fst)))) |
| 35 | have himage : F '' (univ ×ˢ Ioo (0 : ℝ) 1) = |
| 36 | {z : K × ℝ | f z.1 < z.2 ∧ z.2 < g z.1} := by |
| 37 | apply Subset.antisymm |
| 38 | · rintro _ ⟨⟨q, t⟩, ⟨_, ht⟩, rfl⟩ |
| 39 | change f q < f q + t * (g q - f q) ∧ f q + t * (g q - f q) < g q |
| 40 | have hwidth : 0 < g q - f q := sub_pos.mpr (hlt q) |
| 41 | constructor |
| 42 | · linarith [mul_pos ht.1 hwidth] |
| 43 | · nlinarith [mul_pos (sub_pos.mpr ht.2) hwidth] |
| 44 | · rintro ⟨q, s⟩ ⟨hlo, hhi⟩ |
| 45 | have hwidth : 0 < g q - f q := sub_pos.mpr (hlt q) |
| 46 | refine ⟨(q, (s - f q) / (g q - f q)), ⟨mem_univ _, ?_⟩, ?_⟩ |
| 47 | · exact ⟨div_pos (sub_pos.mpr hlo) hwidth, |
| 48 | (div_lt_one hwidth).mpr (by linarith)⟩ |
| 49 | · apply Prod.ext |
| 50 | · rfl |
| 51 | · change f q + (s - f q) / (g q - f q) * (g q - f q) = s |
| 52 | rw [div_mul_cancel₀ _ hwidth.ne'] |
| 53 | ring |
| 54 | rw [← himage] |
| 55 | exact ((isConnected_univ : IsConnected (univ : Set K)).prod |
| 56 | (isConnected_Ioo (show (0 : ℝ) < 1 by norm_num))).image F hF.continuousOn |
| 57 | |
| 58 | namespace OpenPartialHomeomorph |
| 59 | |
| 60 | /-- The entire complement of a graph in a full fiberwise product chart |
| 61 | is connected when the base arc has connected closed complement. Neither |
| 62 | a global trivialization over the complementary arc nor an ambient |
| 63 | isotopy-extension theorem is assumed. This is the label core of |
| 64 | MT A.20, p. 508. -/ |
| 65 | theorem isConnected_compl_range_graph_of_fiberwise |
| 66 | {K E B : Type*} [TopologicalSpace K] [ConnectedSpace K] |
| 67 | [TopologicalSpace E] [TopologicalSpace B] |
| 68 | (j : OpenPartialHomeomorph ℝ B) (T : OpenPartialHomeomorph (K × ℝ) E) |
| 69 | (π : E → B) {a α β b : ℝ} |
| 70 | (ha : a < α) (hαβ : α < β) (hb : β < b) |
| 71 | (hj : j.source = Ioo a b) (hT : T.source = univ ×ˢ Ioo a b) |
| 72 | (htarget : T.target = π ⁻¹' j.target) |
| 73 | (hfiber : ∀ z ∈ T.source, π (T z) = j z.2) |
| 74 | (hπ : Topology.IsCoinducing π) |
| 75 | (hfibers : ∀ c : B, IsConnected (π ⁻¹' {c})) |
| 76 | (hC : IsConnected ((j '' Ioo α β)ᶜ)) |
| 77 | (h : K → ℝ) (hh : Continuous h) (hrange : ∀ q, h q ∈ Ioo α β) : |
| 78 | IsConnected ((range fun q => T (q, h q))ᶜ) := by |
| 79 | have hjinner : Ioo α β ⊆ j.source := by |
| 80 | rw [hj] |
| 81 | exact fun _ hs => ⟨ha.trans hs.1, hs.2.trans hb⟩ |
| 82 | have hjα : α ∈ j.source := by rw [hj]; exact ⟨ha, hαβ.trans hb⟩ |
| 83 | have hjβ : β ∈ j.source := by rw [hj]; exact ⟨ha.trans hαβ, hb⟩ |
| 84 | have hαC : j α ∈ (j '' Ioo α β)ᶜ := by |
| 85 | rintro ⟨s, hs, heq⟩ |
| 86 | exact (ne_of_gt hs.1) (j.injOn (hjinner hs) hjα heq) |
| 87 | have hβC : j β ∈ (j '' Ioo α β)ᶜ := by |
| 88 | rintro ⟨s, hs, heq⟩ |
| 89 | exact (ne_of_lt hs.2) (j.injOn (hjinner hs) hjβ heq) |
| 90 | have hgraph (q : K) : (q, h q) ∈ T.source := by |
| 91 | rw [hT] |
| 92 | exact ⟨mem_univ _, ha.trans (hrange q).1, (hrange q).2.trans hb⟩ |
| 93 | let Dminus : Set (K × ℝ) := {z | a < z.2 ∧ z.2 < h z.1} |
| 94 | let Dplus : Set (K × ℝ) := {z | h z.1 < z.2 ∧ z.2 < b} |
| 95 | have hminusSub : Dminus ⊆ T.source := by |
| 96 | intro z hz |
| 97 | rw [hT] |
| 98 | exact ⟨mem_univ _, hz.1, hz.2.trans ((hrange z.1).2.trans hb)⟩ |
| 99 | have hplusSub : Dplus ⊆ T.source := by |
| 100 | intro z hz |
| 101 | rw [hT] |
| 102 | exact ⟨mem_univ _, (ha.trans (hrange z.1).1).trans hz.1, hz.2⟩ |
| 103 | have hminus : IsConnected (T '' Dminus) := |
| 104 | (isConnected_between_continuous_graphs continuous_const hh |
| 105 | (fun q => ha.trans (hrange q).1)).image T (T.continuousOn.mono hminusSub) |
| 106 | have hplus : IsConnected (T '' Dplus) := |
| 107 | (isConnected_between_continuous_graphs hh continuous_const |
| 108 | (fun q => (hrange q).2.trans hb)).image T (T.continuousOn.mono hplusSub) |
| 109 | have hclosed : IsClosed ((j '' Ioo α β)ᶜ) := |
| 110 | (j.isOpen_image_of_subset_source isOpen_Ioo hjinner).isClosed_compl |
| 111 | have hzero : IsConnected (π ⁻¹' ((j '' Ioo α β)ᶜ)) := |
| 112 | Topology.IsCoinducing.isConnected_preimage_of_isClosed hfibers hπ hclosed hC |
| 113 | obtain ⟨q₀⟩ := (inferInstance : Nonempty K) |
| 114 | have hTα : (q₀, α) ∈ T.source := by |
| 115 | rw [hT] |
| 116 | exact ⟨mem_univ _, ha, hαβ.trans hb⟩ |
| 117 | have hTβ : (q₀, β) ∈ T.source := by |
| 118 | rw [hT] |
| 119 | exact ⟨mem_univ _, ha.trans hαβ, hb⟩ |
| 120 | have hmeetMinus : ((π ⁻¹' ((j '' Ioo α β)ᶜ)) ∩ T '' Dminus).Nonempty := by |
| 121 | refine ⟨T (q₀, α), ?_, ⟨(q₀, α), ⟨ha, (hrange q₀).1⟩, rfl⟩⟩ |
| 122 | change π (T (q₀, α)) ∈ (j '' Ioo α β)ᶜ |
| 123 | rw [hfiber _ hTα] |
| 124 | exact hαC |
| 125 | have hmeetPlus : (((π ⁻¹' ((j '' Ioo α β)ᶜ)) ∪ T '' Dminus) ∩ |
| 126 | T '' Dplus).Nonempty := by |
| 127 | refine ⟨T (q₀, β), Or.inl ?_, ⟨(q₀, β), ⟨(hrange q₀).2, hb⟩, rfl⟩⟩ |
| 128 | change π (T (q₀, β)) ∈ (j '' Ioo α β)ᶜ |
| 129 | rw [hfiber _ hTβ] |
| 130 | exact hβC |
| 131 | have heq : (range fun q => T (q, h q))ᶜ = |
| 132 | ((π ⁻¹' ((j '' Ioo α β)ᶜ)) ∪ T '' Dminus) ∪ T '' Dplus := by |
| 133 | ext x |
| 134 | constructor |
| 135 | · intro hx |
| 136 | by_cases hxc : π x ∈ (j '' Ioo α β)ᶜ |
| 137 | · exact Or.inl (Or.inl hxc) |
| 138 | · have hxJ : π x ∈ j '' Ioo α β := not_not.mp hxc |
| 139 | have hxTarget : x ∈ T.target := by |
| 140 | rw [htarget] |
| 141 | obtain ⟨s, hs, hsx⟩ := hxJ |
| 142 | rw [mem_preimage, ← hsx] |
| 143 | exact j.map_source (hjinner hs) |
| 144 | have hz : T.symm x ∈ univ ×ˢ Ioo a b := hT ▸ T.map_target hxTarget |
| 145 | rcases lt_trichotomy (T.symm x).2 (h (T.symm x).1) with hlo | he | hhi |
| 146 | · exact Or.inl (Or.inr ⟨T.symm x, ⟨hz.2.1, hlo⟩, T.right_inv hxTarget⟩) |
| 147 | · apply False.elim |
| 148 | apply hx |
| 149 | refine ⟨(T.symm x).1, ?_⟩ |
| 150 | change T ((T.symm x).1, h (T.symm x).1) = x |
| 151 | rw [← he, Prod.mk.eta, T.right_inv hxTarget] |
| 152 | · exact Or.inr ⟨T.symm x, ⟨hhi, hz.2.2⟩, T.right_inv hxTarget⟩ |
| 153 | · rintro ((hx | ⟨z, hz, rfl⟩) | ⟨z, hz, rfl⟩) |
| 154 | · rintro ⟨q, rfl⟩ |
| 155 | exact hx ⟨h q, hrange q, (hfiber _ (hgraph q)).symm⟩ |
| 156 | · rintro ⟨q, hq⟩ |
| 157 | have he : (q, h q) = z := T.injOn (hgraph q) (hminusSub hz) hq |
| 158 | have hs : z.2 = h z.1 := by rw [← he] |
| 159 | exact (ne_of_lt hz.2) hs |
| 160 | · rintro ⟨q, hq⟩ |
| 161 | have he : (q, h q) = z := T.injOn (hgraph q) (hplusSub hz) hq |
| 162 | have hs : z.2 = h z.1 := by rw [← he] |
| 163 | exact (ne_of_gt hz.1) hs |
| 164 | rw [heq] |
| 165 | exact IsConnected.union hmeetPlus (IsConnected.union hmeetMinus hzero hminus) hplus |
| 166 | |
| 167 | end OpenPartialHomeomorph |