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.CurveShortening.Comparison.IntrinsicComparison.Obstacle.Barriers |
| 2 | import PoincareLib.Geometry.CurveShortening.Comparison.IntrinsicComparison.Transverse.StripSeparation |
| 3 | |
| 4 | /-! |
| 5 | # Simultaneous obstacle avoidance for the actual finite strip chain |
| 6 | |
| 7 | Outer endpoint barriers come from the cap union. Every internal endpoint |
| 8 | lies outside that closed union. One positive width preserves all original |
| 9 | strip intersections and permits cap contact only on the two outer cuts. |
| 10 | |
| 11 | Morgan--Tian context: Proposition 19.35, printed pp. 467-481, including Claim 19.40, |
| 12 | pp. 470-471. These project constructions provide actual fitted boundary pieces and |
| 13 | contacts for the regional Gauss--Bonnet arguments. |
| 14 | -/ |
| 15 | |
| 16 | noncomputable section |
| 17 | set_option autoImplicit false |
| 18 | set_option backward.isDefEq.respectTransparency false |
| 19 | |
| 20 | open Set Filter |
| 21 | open scoped Topology ContDiff |
| 22 | open Poincare.Topology.Plane.Curves PoincareMT.Topology.Surface |
| 23 | |
| 24 | namespace PoincareMT |
| 25 | |
| 26 | private theorem exists_axis_height_avoiding |
| 27 | (F : OpenPartialHomeomorph (ℝ × ℝ) AnnulusCoordinates) {s : ℝ} |
| 28 | (hs : (s, (0 : ℝ)) ∈ F.source) {C : Set AnnulusCoordinates} (hC : IsClosed C) |
| 29 | (havoid : F (s, 0) ∉ C) : |
| 30 | ∃ delta > 0, ∀ z : ℝ, |z| < delta → F (s, z) ∉ C := by |
| 31 | have hc : ContinuousAt (fun z : ℝ => F (s, z)) 0 := |
| 32 | (F.continuousAt hs).comp ((continuous_const.prodMk continuous_id).continuousAt) |
| 33 | have hnear := hc.preimage_mem_nhds (hC.isOpen_compl.mem_nhds havoid) |
| 34 | obtain ⟨delta, hdelta, hball⟩ := Metric.mem_nhds_iff.mp hnear |
| 35 | refine ⟨delta, hdelta, fun z hz => hball ?_⟩ |
| 36 | simpa only [Metric.mem_ball, dist_zero_right, Real.norm_eq_abs] using hz |
| 37 | |
| 38 | /-- Construct an actual finite separated strip chain whose only possible obstacle contacts |
| 39 | are on its two outer endpoint cuts. Source: |
| 40 | `proof-work/tasks/M64/reports/2026-09-24-obstacle-strip-chain.md`. -/ |
| 41 | theorem m64Intrinsic_exists_obstacle_avoiding_strip_chain |
| 42 | {gamma : ℝ → AnnulusCoordinates} (hg : ContDiff ℝ ∞ gamma) |
| 43 | {a b : ℝ} (hab : a < b) (hinj : InjOn gamma (Icc a b)) |
| 44 | (hregular : ∀ t ∈ Icc a b, deriv gamma t ≠ 0) |
| 45 | (d : ℝ → AnnulusCoordinates) |
| 46 | (hd : ∀ t ∈ Icc a b, 0 < inner ℝ (quarterTurn (deriv gamma t)) (d t)) |
| 47 | {C : Set AnnulusCoordinates} (hC : IsClosed C) |
| 48 | (havoid : ∀ t ∈ Ioo a b, gamma t ∉ C) |
| 49 | (ellA ellB : AnnulusCoordinates →L[ℝ] ℝ) |
| 50 | (hcutA : ellA (d a) = 0) (hcutB : ellB (d b) = 0) |
| 51 | (htangentA : 0 < ellA (deriv gamma a)) (htangentB : ellB (deriv gamma b) < 0) |
| 52 | {WA WB : Set AnnulusCoordinates} (hWA : IsOpen WA) (hWB : IsOpen WB) |
| 53 | (haW : gamma a ∈ WA) (hbW : gamma b ∈ WB) |
| 54 | (hsepA : ∀ z ∈ C ∩ WA, ellA (z - gamma a) ≤ 0) |
| 55 | (hsepB : ∀ z ∈ C ∩ WB, ellB (z - gamma b) ≤ 0) : |
| 56 | ∃ (n : ℕ) (c : Fin (n + 1) → ℝ) |
| 57 | (L : Fin n → AnnulusCoordinates ≃L[ℝ] (ℝ × ℝ)) |
| 58 | (G : Fin n → OpenPartialHomeomorph ℝ ℝ) (f : Fin n → ℝ → ℝ) |
| 59 | (hf : ∀ i, ContDiffOn ℝ ∞ (f i) (G i).target) |
| 60 | (P : ∀ i, TransverseGraphCuts (f i) (G i (c i.castSucc)) (G i (c i.succ)) |
| 61 | (L i (d (c i.castSucc))).1 (L i (d (c i.castSucc))).2 |
| 62 | (L i (d (c i.succ))).1 (L i (d (c i.succ))).2), |
| 63 | let F (i : Fin n) := (P i).linearCoordinates (L i).symm (G i).open_target (hf i) |
| 64 | ∃ delta > 0, 0 < n ∧ StrictMono c ∧ c 0 = a ∧ c (Fin.last n) = b ∧ |
| 65 | (∀ i, Icc (c i.castSucc) (c i.succ) ⊆ (G i).source ∧ |
| 66 | StrictMonoOn (G i) (G i).source ∧ ContDiffOn ℝ ∞ (G i) (G i).source ∧ |
| 67 | (∀ t ∈ (G i).source, L i (gamma t) = (G i t, f i (G i t))) ∧ |
| 68 | G i '' Icc (c i.castSucc) (c i.succ) = |
| 69 | Icc (G i (c i.castSucc)) (G i (c i.succ)) ∧ |
| 70 | Icc (G i (c i.castSucc)) (G i (c i.succ)) ⊆ (G i).target) ∧ |
| 71 | (∀ i, delta ≤ (P i).radius ∧ |
| 72 | Icc (0 : ℝ) 1 ×ˢ Ioo (-delta) delta ⊆ (F i).source ∧ |
| 73 | (fun t => F i (t, 0)) '' Icc (0 : ℝ) 1 = |
| 74 | gamma '' Icc (c i.castSucc) (c i.succ)) ∧ |
| 75 | (∀ i j : Fin n, i.succ < j.castSucc → |
| 76 | Disjoint (F i '' (Icc (0 : ℝ) 1 ×ˢ Ioo (-delta) delta)) |
| 77 | (F j '' (Icc (0 : ℝ) 1 ×ˢ Ioo (-delta) delta))) ∧ |
| 78 | (∀ i j : Fin n, i.succ = j.castSucc → |
| 79 | ∀ t ∈ Icc (0 : ℝ) 1, ∀ s ∈ Icc (0 : ℝ) 1, |
| 80 | ∀ z w : ℝ, |z| < delta → |w| < delta → |
| 81 | F i (t, z) = F j (s, w) → t = 1 ∧ s = 0) ∧ |
| 82 | ∀ i, ∀ t ∈ Icc (0 : ℝ) 1, ∀ z : ℝ, |z| < delta → F i (t, z) ∈ C → |
| 83 | (c i.castSucc = a ∧ t = 0) ∨ (c i.succ = b ∧ t = 1) := by |
| 84 | classical |
| 85 | obtain ⟨n, c, L, G, f, hf, P, rho, hrho, hn, hc, hfirst, hlast, |
| 86 | hgraph, hstrip, hdisjoint, hadj⟩ := |
| 87 | m64Intrinsic_exists_separated_transverse_arc_strips hg hab hinj hregular d hd |
| 88 | let F (i : Fin n) := (P i).linearCoordinates (L i).symm (G i).open_target (hf i) |
| 89 | have hstep (i : Fin n) := hc (Fin.castSucc_lt_succ (i := i)) |
| 90 | have hcut (k : Fin (n + 1)) : c k ∈ Icc a b := by |
| 91 | constructor |
| 92 | · simpa only [hfirst] using hc.monotone (Fin.zero_le k) |
| 93 | · simpa only [hlast] using hc.monotone (Fin.le_last k) |
| 94 | have hleft (i : Fin n) : ∃ (ell : AnnulusCoordinates →L[ℝ] ℝ) (W : Set AnnulusCoordinates), |
| 95 | IsOpen W ∧ gamma (c i.castSucc) ∈ W ∧ ell (d (c i.castSucc)) = 0 ∧ |
| 96 | 0 < ell (deriv gamma (c i.castSucc)) ∧ |
| 97 | ∀ z ∈ C ∩ W, ell (z - gamma (c i.castSucc)) ≤ 0 := by |
| 98 | by_cases heq : c i.castSucc = a |
| 99 | · exact ⟨ellA, WA, hWA, heq ▸ haW, by simpa only [heq] using hcutA, |
| 100 | by simpa only [heq] using htangentA, by simpa only [heq] using hsepA⟩ |
| 101 | · have ht : c i.castSucc ∈ Ioo a b := |
| 102 | ⟨lt_of_le_of_ne (hcut i.castSucc).1 (Ne.symm heq), |
| 103 | (hstep i).trans_le (hcut i.succ).2⟩ |
| 104 | exact m64Intrinsic_exists_internal_obstacle_barrier hC (havoid _ ht) |
| 105 | (hd _ (hcut i.castSucc)) false |
| 106 | have hright (i : Fin n) : ∃ (ell : AnnulusCoordinates →L[ℝ] ℝ) (W : Set AnnulusCoordinates), |
| 107 | IsOpen W ∧ gamma (c i.succ) ∈ W ∧ ell (d (c i.succ)) = 0 ∧ |
| 108 | ell (deriv gamma (c i.succ)) < 0 ∧ |
| 109 | ∀ z ∈ C ∩ W, ell (z - gamma (c i.succ)) ≤ 0 := by |
| 110 | by_cases heq : c i.succ = b |
| 111 | · exact ⟨ellB, WB, hWB, heq ▸ hbW, by simpa only [heq] using hcutB, |
| 112 | by simpa only [heq] using htangentB, by simpa only [heq] using hsepB⟩ |
| 113 | · have ht : c i.succ ∈ Ioo a b := |
| 114 | ⟨(hcut i.castSucc).1.trans_lt (hstep i), lt_of_le_of_ne (hcut i.succ).2 heq⟩ |
| 115 | exact m64Intrinsic_exists_internal_obstacle_barrier hC (havoid _ ht) |
| 116 | (hd _ (hcut i.succ)) true |
| 117 | choose ellL WL hWL hpL hkL htL hsL using hleft |
| 118 | choose ellR WR hWR hpR hkR htR hsR using hright |
| 119 | have hwidth (i : Fin n) := m64Intrinsic_exists_obstacle_avoiding_graph_strip hg |
| 120 | (hstep i) (fun t ht => hregular t ⟨(hcut i.castSucc).1.trans ht.1, |
| 121 | ht.2.trans (hcut i.succ).2⟩) (L i) (G i) (hgraph i).2.2.1 (hf i) |
| 122 | (hgraph i).2.1 (hgraph i).1 (hgraph i).2.2.2.1 (hgraph i).2.2.2.2.1 hC |
| 123 | (fun t ht => havoid t ⟨(hcut i.castSucc).1.trans_lt ht.1, |
| 124 | ht.2.trans_le (hcut i.succ).2⟩) (d (c i.castSucc)) (d (c i.succ)) (P i) |
| 125 | (ellL i) (ellR i) (hkL i) (hkR i) (htL i) (htR i) |
| 126 | (hWL i) (hWR i) (hpL i) (hpR i) (hsL i) (hsR i) |
| 127 | choose width hwidth hwP hwsource hwavoid using hwidth |
| 128 | have hleftBase (i : Fin n) : F i (0, 0) = gamma (c i.castSucc) := by |
| 129 | rw [(P i).linearCoordinates_axis] |
| 130 | simp only [zero_mul, add_zero] |
| 131 | rw [← (hgraph i).2.2.2.1 _ ((hgraph i).1 (left_mem_Icc.mpr (hstep i).le)), |
| 132 | (L i).symm_apply_apply] |
| 133 | have hrightBase (i : Fin n) : F i (1, 0) = gamma (c i.succ) := by |
| 134 | rw [(P i).linearCoordinates_axis] |
| 135 | simp only [one_mul, add_sub_cancel] |
| 136 | rw [← (hgraph i).2.2.2.1 _ ((hgraph i).1 (right_mem_Icc.mpr (hstep i).le)), |
| 137 | (L i).symm_apply_apply] |
| 138 | have hleftTube (i : Fin n) : ∃ epsilon > 0, |
| 139 | c i.castSucc ≠ a → ∀ z : ℝ, |z| < epsilon → F i (0, z) ∉ C := by |
| 140 | by_cases heq : c i.castSucc = a |
| 141 | · exact ⟨1, zero_lt_one, fun hne => (hne heq).elim⟩ |
| 142 | · have ht : c i.castSucc ∈ Ioo a b := |
| 143 | ⟨lt_of_le_of_ne (hcut i.castSucc).1 (Ne.symm heq), |
| 144 | (hstep i).trans_le (hcut i.succ).2⟩ |
| 145 | obtain ⟨epsilon, hepsilon, havoid'⟩ := exists_axis_height_avoiding (F i) |
| 146 | (hwsource i 0 (by simp) 0 (by simpa only [abs_zero] using hwidth i)) hC |
| 147 | (hleftBase i ▸ havoid _ ht) |
| 148 | exact ⟨epsilon, hepsilon, fun _ => havoid'⟩ |
| 149 | have hrightTube (i : Fin n) : ∃ epsilon > 0, |
| 150 | c i.succ ≠ b → ∀ z : ℝ, |z| < epsilon → F i (1, z) ∉ C := by |
| 151 | by_cases heq : c i.succ = b |
| 152 | · exact ⟨1, zero_lt_one, fun hne => (hne heq).elim⟩ |
| 153 | · have ht : c i.succ ∈ Ioo a b := |
| 154 | ⟨(hcut i.castSucc).1.trans_lt (hstep i), lt_of_le_of_ne (hcut i.succ).2 heq⟩ |
| 155 | obtain ⟨epsilon, hepsilon, havoid'⟩ := exists_axis_height_avoiding (F i) |
| 156 | (hwsource i 1 (by simp) 0 (by simpa only [abs_zero] using hwidth i)) hC |
| 157 | (hrightBase i ▸ havoid _ ht) |
| 158 | exact ⟨epsilon, hepsilon, fun _ => havoid'⟩ |
| 159 | choose leftRadius hlRadius hlAvoid using hleftTube |
| 160 | choose rightRadius hrRadius hrAvoid using hrightTube |
| 161 | obtain ⟨eta, heta, hle⟩ := exists_pos_le_finite_family |
| 162 | (fun i => min (width i) (min (leftRadius i) (rightRadius i))) |
| 163 | (fun i => lt_min (hwidth i) (lt_min (hlRadius i) (hrRadius i))) |
| 164 | let delta := min rho eta |
| 165 | have hdelta : 0 < delta := lt_min hrho heta |
| 166 | have hdR : delta ≤ rho := min_le_left _ _ |
| 167 | have hdw (i : Fin n) : delta ≤ width i := |
| 168 | (min_le_right _ _).trans ((hle i).trans (min_le_left _ _)) |
| 169 | have hdl (i : Fin n) : delta ≤ leftRadius i := |
| 170 | (min_le_right _ _).trans ((hle i).trans ((min_le_right _ _).trans (min_le_left _ _))) |
| 171 | have hdr (i : Fin n) : delta ≤ rightRadius i := |
| 172 | (min_le_right _ _).trans ((hle i).trans ((min_le_right _ _).trans (min_le_right _ _))) |
| 173 | have hsub : Icc (0 : ℝ) 1 ×ˢ Ioo (-delta) delta ⊆ Icc (0 : ℝ) 1 ×ˢ Ioo (-rho) rho := |
| 174 | prod_mono Subset.rfl (Ioo_subset_Ioo (neg_le_neg hdR) hdR) |
| 175 | refine ⟨n, c, L, G, f, hf, P, delta, hdelta, hn, hc, hfirst, hlast, hgraph, |
| 176 | fun i => ⟨hdR.trans (hstrip i).1, hsub.trans (hstrip i).2.1, (hstrip i).2.2⟩, |
| 177 | fun i j hij => (hdisjoint i j hij).mono (image_mono hsub) (image_mono hsub), |
| 178 | fun i j hij t ht s hs z w hz hw => hadj i j hij t ht s hs z w |
| 179 | (hz.trans_le hdR) (hw.trans_le hdR), ?_⟩ |
| 180 | intro i t ht z hz hmem |
| 181 | by_cases ht0 : t = 0 |
| 182 | · subst t |
| 183 | refine Or.inl ⟨?_, rfl⟩ |
| 184 | by_contra hne |
| 185 | exact hlAvoid i hne z (hz.trans_le (hdl i)) hmem |
| 186 | · have htpos : 0 < t := lt_of_le_of_ne ht.1 (Ne.symm ht0) |
| 187 | have ht1 : t = 1 := by |
| 188 | by_contra hne |
| 189 | exact hwavoid i t ⟨htpos, lt_of_le_of_ne ht.2 hne⟩ z (hz.trans_le (hdw i)) hmem |
| 190 | subst t |
| 191 | refine Or.inr ⟨?_, rfl⟩ |
| 192 | by_contra hne |
| 193 | exact hrAvoid i hne z (hz.trans_le (hdr i)) hmem |
| 194 | |
| 195 | end PoincareMT |