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.Exact.CornerRegion |
| 2 | |
| 3 | /-! |
| 4 | # Actual occupied corner caps with exact return-loop contacts |
| 5 | |
| 6 | Morgan--Tian context: Proposition 19.35, printed pp. 467-481. These project |
| 7 | Jordan-region constructions supply the actual domains, boundary charts and finite |
| 8 | faces used in its regional Gauss--Bonnet arguments. |
| 9 | -/ |
| 10 | |
| 11 | noncomputable section |
| 12 | set_option autoImplicit false |
| 13 | set_option backward.isDefEq.respectTransparency false |
| 14 | |
| 15 | open Set Filter Metric |
| 16 | open scoped Topology ContDiff Manifold Matrix |
| 17 | open PoincareMT.Topology.Surface ChartCircleArrangementVertexPatch |
| 18 | |
| 19 | namespace PoincareMT |
| 20 | |
| 21 | /-- Construct the occupied convex or reflex cap union from the loop and its Jordan pair. Its |
| 22 | intersection with the full loop consists exactly of the two retained endpoint arcs. Source: |
| 23 | `proof-work/tasks/M64/reports/2026-09-24-loop-caps-transverse-bands.md`, Actual loop cap |
| 24 | contacts and occupied transverse bands. -/ |
| 25 | theorem m64Intrinsic_exists_loop_caps_with_exact_contacts |
| 26 | {gamma : ℝ → AnnulusCoordinates} (hg : ContDiff ℝ ∞ gamma) {T : ℝ} (hT : 0 < T) |
| 27 | (hend : gamma 0 = gamma T) (hinj : InjOn gamma (Ico 0 T)) |
| 28 | (hind : LinearIndependent ℝ |
| 29 | (![deriv gamma 0, -deriv gamma T] : Fin 2 → AnnulusCoordinates)) |
| 30 | {U V : Set AnnulusCoordinates} (hU : IsOpen U) (hV : IsOpen V) |
| 31 | (hdisj : Disjoint U V) (hfU : frontier U = gamma '' Icc 0 T) |
| 32 | (hfV : frontier V = gamma '' Icc 0 T) : |
| 33 | ∃ (H : OpenPartialHomeomorph (ℝ × ℝ) AnnulusCoordinates) (r : ℝ) |
| 34 | (F : Bool × Bool → OpenPartialHomeomorph (ℝ × ℝ) AnnulusCoordinates) |
| 35 | (W : Set AnnulusCoordinates) (positive : Bool), |
| 36 | let C (i : Bool × Bool) := |
| 37 | F i '' {q : ℝ × ℝ | 0 ≤ q.1 ∧ 0 ≤ q.2 ∧ q.1 + q.2 ≤ r} |
| 38 | let occupied (i : Bool × Bool) := if positive then i = (true, true) else i ≠ (true, true) |
| 39 | let A := ⋃ i, ⋃ (_ : occupied i), C i |
| 40 | 0 < r ∧ r ≤ T / 3 ∧ H 0 = gamma 0 ∧ |
| 41 | (∀ s : ℝ, H (s, 0) = gamma s) ∧ |
| 42 | (∀ s : ℝ, H (0, s) = gamma (T - s)) ∧ |
| 43 | (∀ i, |
| 44 | {q : ℝ × ℝ | 0 ≤ q.1 ∧ 0 ≤ q.2 ∧ q.1 + q.2 ≤ r} ⊆ (F i).source ∧ |
| 45 | (F i).target ⊆ H.target ∧ |
| 46 | ContDiffOn ℝ ∞ (F i) (F i).source ∧ |
| 47 | ContDiffOn ℝ ∞ (F i).symm (F i).target ∧ |
| 48 | (∀ s ∈ Icc (0 : ℝ) r, F i (s, 0) = H (sectorParameterEquiv 0 i (s, 0))) ∧ |
| 49 | (∀ s ∈ Icc (0 : ℝ) r, F i (0, s) = H (sectorParameterEquiv 0 i (0, s))) ∧ |
| 50 | (∀ t : ℝ, F i ((1 - t) * r, t * r) = |
| 51 | (1 - t) • F i (r, 0) + t • F i (0, r)) ∧ |
| 52 | C i ⊆ H '' (H.source ∩ (sectorParameterEquiv 0 i) '' |
| 53 | {q : ℝ × ℝ | 0 ≤ q.1 ∧ 0 ≤ q.2})) ∧ |
| 54 | IsOpen W ∧ gamma 0 ∈ W ∧ A ⊆ closure U ∧ W ∩ closure U ⊆ A ∧ |
| 55 | A ∩ gamma '' Icc 0 T = gamma '' Icc 0 r ∪ gamma '' Icc (T - r) T := by |
| 56 | classical |
| 57 | obtain ⟨H, h0, hbase, hH, hHi, haxis, haxis', hloop, hside⟩ := |
| 58 | m64Intrinsic_exists_exact_loop_corner_region hg hT hend hinj hind hU hV hdisj hfU hfV |
| 59 | obtain ⟨eta, heta, hball⟩ := Metric.mem_nhds_iff.mp (H.open_source.mem_nhds h0) |
| 60 | obtain ⟨r, F, W, hr, hrbound, hW, hpW, hWt, hF⟩ := |
| 61 | m64Intrinsic_exists_four_axis_fitted_caps H h0 hH hHi |
| 62 | (lt_min (show (0 : ℝ) < T / 3 by positivity) (half_pos heta)) |
| 63 | have hrT : r ≤ T / 3 := hrbound.trans (min_le_left _ _) |
| 64 | have hre : r < eta := (hrbound.trans (min_le_right _ _)).trans_lt (half_lt_self heta) |
| 65 | have hsmall (i : Bool × Bool) {s : ℝ} (hs : s ∈ Icc (0 : ℝ) r) (vertical : Bool) : |
| 66 | sectorParameterEquiv 0 i (if vertical then (0, s) else (s, 0)) ∈ H.source := by |
| 67 | apply hball |
| 68 | rcases i with ⟨i, j⟩ |
| 69 | cases i <;> cases j <;> cases vertical <;> |
| 70 | simp [sectorParameterEquiv_apply, Metric.mem_ball, |
| 71 | abs_of_nonneg hs.1, hs.2.trans_lt hre, heta] |
| 72 | obtain ⟨positive, hside'⟩ : ∃ positive : Bool, ∀ q ∈ H.source, |
| 73 | H q ∈ closure U ↔ if positive then 0 ≤ q.1 ∧ 0 ≤ q.2 else q.1 ≤ 0 ∨ q.2 ≤ 0 := by |
| 74 | rcases hside with hpos | hneg |
| 75 | · exact ⟨true, hpos⟩ |
| 76 | · exact ⟨false, hneg⟩ |
| 77 | let C (i : Bool × Bool) := |
| 78 | F i '' {q : ℝ × ℝ | 0 ≤ q.1 ∧ 0 ≤ q.2 ∧ q.1 + q.2 ≤ r} |
| 79 | let occupied (i : Bool × Bool) := if positive then i = (true, true) else i ≠ (true, true) |
| 80 | let A := ⋃ i, ⋃ (_ : occupied i), C i |
| 81 | have hcap (i : Bool × Bool) := (hF i).2.2.2.2.2.2.2.1 |
| 82 | have hcontacts (i : Bool × Bool) := (hF i).2.2.2.2.2.2.2.2.1 |
| 83 | have hcover (i : Bool × Bool) := (hF i).2.2.2.2.2.2.2.2.2 |
| 84 | have hcontact (i : Bool × Bool) : C i ∩ gamma '' Icc 0 T ⊆ |
| 85 | gamma '' Icc 0 r ∪ gamma '' Icc (T - r) T := by |
| 86 | intro z hz |
| 87 | have hzt : z ∈ H.target := by |
| 88 | obtain ⟨q, hq, rfl⟩ := hz.1 |
| 89 | exact (hF i).2.1 ((F i).map_source ((hF i).1 hq)) |
| 90 | have hq := H.map_target hzt |
| 91 | have hqloop := (hloop (H.symm z) hq).mp (by simpa only [H.right_inv hzt] using hz.2) |
| 92 | have hzaxes : z ∈ H '' (H.source ∩ {q : ℝ × ℝ | q.1 = 0 ∨ q.2 = 0}) := by |
| 93 | refine ⟨H.symm z, ⟨hq, ?_⟩, H.right_inv hzt⟩ |
| 94 | exact hqloop.elim (fun h => Or.inl h.1) (fun h => Or.inr h.2) |
| 95 | have hzsmall := (hcontacts i).subset ⟨hz.1, hzaxes⟩ |
| 96 | obtain ⟨_, ⟨p, hp, rfl⟩, hpz⟩ := hzsmall |
| 97 | rcases hp with ⟨hp1, hp2⟩ | ⟨hp1, hp2⟩ |
| 98 | · have hp : p = (p.1, 0) := Prod.ext rfl hp2 |
| 99 | rw [hp] at hpz |
| 100 | have hsloop := (hloop _ (hsmall i hp1 false)).mp (hpz.symm ▸ hz.2) |
| 101 | rcases i with ⟨i, j⟩ |
| 102 | cases i |
| 103 | · have hs0 : p.1 = 0 := by |
| 104 | simp only [sectorParameterEquiv_apply] at hsloop |
| 105 | rcases hsloop with hs | hs <;> dsimp at hs <;> linarith [hp1.1] |
| 106 | apply Or.inl |
| 107 | refine ⟨0, ⟨le_rfl, hr.le⟩, ?_⟩ |
| 108 | simpa [sectorParameterEquiv_apply, hs0, haxis] using hpz |
| 109 | · apply Or.inl |
| 110 | exact ⟨p.1, hp1, by simpa [sectorParameterEquiv_apply, haxis] using hpz⟩ |
| 111 | · have hp : p = (0, p.2) := Prod.ext hp1 rfl |
| 112 | rw [hp] at hpz |
| 113 | have hsloop := (hloop _ (hsmall i hp2 true)).mp (hpz.symm ▸ hz.2) |
| 114 | rcases i with ⟨i, j⟩ |
| 115 | cases j |
| 116 | · have hs0 : p.2 = 0 := by |
| 117 | simp only [sectorParameterEquiv_apply] at hsloop |
| 118 | rcases hsloop with hs | hs <;> dsimp at hs <;> linarith [hp2.1] |
| 119 | apply Or.inl |
| 120 | refine ⟨0, ⟨le_rfl, hr.le⟩, ?_⟩ |
| 121 | simpa [sectorParameterEquiv_apply, hs0, haxis] using hpz |
| 122 | · apply Or.inr |
| 123 | exact ⟨T - p.2, ⟨by linarith [hp2.2], by linarith [hp2.1]⟩, |
| 124 | by simpa [sectorParameterEquiv_apply, haxis'] using hpz⟩ |
| 125 | have hsub : A ⊆ closure U := by |
| 126 | intro z hz |
| 127 | obtain ⟨i, hi⟩ := mem_iUnion.mp hz |
| 128 | obtain ⟨hoccupied, hz⟩ := mem_iUnion.mp hi |
| 129 | obtain ⟨_, ⟨hq, p, hp, rfl⟩, rfl⟩ := hcap i hz |
| 130 | apply (hside' _ hq).mpr |
| 131 | cases positive |
| 132 | · rcases i with ⟨i, j⟩ |
| 133 | cases i <;> cases j <;> simp_all [occupied, sectorParameterEquiv_apply] |
| 134 | · have hi' : i = (true, true) := hoccupied |
| 135 | simp [hi', sectorParameterEquiv_apply, hp.1, hp.2] |
| 136 | have hcovered : W ∩ closure U ⊆ A := by |
| 137 | intro z hz |
| 138 | have hzt := hWt hz.1 |
| 139 | let q := H.symm z |
| 140 | have hq : q ∈ H.source := H.map_target hzt |
| 141 | have hqz : H q = z := H.right_inv hzt |
| 142 | have hqside := (hside' q hq).mp (hqz.symm ▸ hz.2) |
| 143 | have hmember (i : Bool × Bool) (hi : occupied i) (p : ℝ × ℝ) |
| 144 | (hp : 0 ≤ p.1 ∧ 0 ≤ p.2) (heq : sectorParameterEquiv 0 i p = q) : z ∈ A := |
| 145 | mem_iUnion.mpr ⟨i, mem_iUnion.mpr ⟨hi, |
| 146 | hcover i ⟨hz.1, q, ⟨hq, p, hp, heq⟩, hqz⟩⟩⟩ |
| 147 | cases positive |
| 148 | · by_cases hq1 : q.1 ≤ 0 |
| 149 | · by_cases hq2 : q.2 ≤ 0 |
| 150 | · exact hmember (false, false) (by simp [occupied]) (-q.1, -q.2) |
| 151 | ⟨neg_nonneg.mpr hq1, neg_nonneg.mpr hq2⟩ (by simp [sectorParameterEquiv_apply]) |
| 152 | · exact hmember (false, true) (by simp [occupied]) (-q.1, q.2) |
| 153 | ⟨neg_nonneg.mpr hq1, (lt_of_not_ge hq2).le⟩ (by simp [sectorParameterEquiv_apply]) |
| 154 | · have hq2 : q.2 ≤ 0 := hqside.resolve_left hq1 |
| 155 | exact hmember (true, false) (by simp [occupied]) (q.1, -q.2) |
| 156 | ⟨(lt_of_not_ge hq1).le, neg_nonneg.mpr hq2⟩ (by simp [sectorParameterEquiv_apply]) |
| 157 | · exact hmember (true, true) (by simp [occupied]) q hqside |
| 158 | (by simp [sectorParameterEquiv_apply]) |
| 159 | refine ⟨H, r, F, W, positive, hr, hrT, hbase, haxis, haxis', ?_, hW, |
| 160 | hbase ▸ hpW, hsub, hcovered, ?_⟩ |
| 161 | · intro i |
| 162 | exact ⟨(hF i).1, (hF i).2.1, (hF i).2.2.1, (hF i).2.2.2.1, |
| 163 | (hF i).2.2.2.2.1, (hF i).2.2.2.2.2.1, (hF i).2.2.2.2.2.2.1, hcap i⟩ |
| 164 | · ext z |
| 165 | constructor |
| 166 | · rintro ⟨hz, hzloop⟩ |
| 167 | obtain ⟨i, hi⟩ := mem_iUnion.mp hz |
| 168 | obtain ⟨_, hz⟩ := mem_iUnion.mp hi |
| 169 | exact hcontact i ⟨hz, hzloop⟩ |
| 170 | · intro hz |
| 171 | constructor |
| 172 | · rcases hz with ⟨s, hs, rfl⟩ | ⟨s, hs, rfl⟩ |
| 173 | · apply mem_iUnion.mpr |
| 174 | refine ⟨(true, positive), mem_iUnion.mpr ⟨?_, ?_⟩⟩ |
| 175 | · cases positive <;> simp |
| 176 | · refine ⟨(s, 0), ⟨hs.1, le_rfl, by simpa using hs.2⟩, ?_⟩ |
| 177 | simpa [sectorParameterEquiv_apply, haxis] using (hF (true, positive)).2.2.2.2.1 s hs |
| 178 | · have hs' : T - s ∈ Icc (0 : ℝ) r := ⟨by linarith [hs.2], by linarith [hs.1]⟩ |
| 179 | apply mem_iUnion.mpr |
| 180 | refine ⟨(positive, true), mem_iUnion.mpr ⟨?_, ?_⟩⟩ |
| 181 | · cases positive <;> simp |
| 182 | · refine ⟨(0, T - s), ⟨le_rfl, hs'.1, by simpa using hs'.2⟩, ?_⟩ |
| 183 | simpa [sectorParameterEquiv_apply, haxis'] using |
| 184 | (hF (positive, true)).2.2.2.2.2.1 (T - s) hs' |
| 185 | · rcases hz with ⟨s, hs, rfl⟩ | ⟨s, hs, rfl⟩ |
| 186 | · exact ⟨s, ⟨hs.1, by linarith [hs.2]⟩, rfl⟩ |
| 187 | · exact ⟨s, ⟨by linarith [hs.1], hs.2⟩, rfl⟩ |
| 188 | |
| 189 | end PoincareMT |