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.Inward.RaySign |
| 2 | import PoincareLib.Topology.Plane.Triangles.CapTransversality |
| 3 | |
| 4 | /-! |
| 5 | # The actual fitted cap supplies positive endpoint chord directions |
| 6 | |
| 7 | Cap transversality gives nonzero physical cross products. The chord belongs |
| 8 | to the closed Jordan region, so the proved inward-side criterion fixes |
| 9 | their signs in the original loop orientation. |
| 10 | |
| 11 | Morgan--Tian context: Proposition 19.35, printed pp. 467-481. These project |
| 12 | Jordan-region constructions supply the actual domains, boundary charts and finite |
| 13 | faces used in its 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 Matrix |
| 22 | open Poincare.Topology.Plane.Curves Poincare.Topology.Plane.Triangles |
| 23 | |
| 24 | namespace PoincareMT |
| 25 | |
| 26 | private theorem transverse_inner_ne_zero {u w : AnnulusCoordinates} |
| 27 | (hind : LinearIndependent ℝ (![u, w] : Fin 2 → AnnulusCoordinates)) : |
| 28 | inner ℝ (quarterTurn u) w ≠ 0 := by |
| 29 | let B := basisOfLinearIndependentOfCardEqFinrank hind (by simp) |
| 30 | have horth : inner ℝ (quarterTurn u) u = 0 := by |
| 31 | rw [real_inner_comm] |
| 32 | exact inner_quarterTurn_self _ |
| 33 | intro hw |
| 34 | have hzero : (innerSL ℝ (quarterTurn u)).toLinearMap = 0 := by |
| 35 | apply B.ext |
| 36 | intro i |
| 37 | fin_cases i <;> |
| 38 | simp [B, coe_basisOfLinearIndependentOfCardEqFinrank, horth, hw] |
| 39 | have hself : inner ℝ (quarterTurn u) (quarterTurn u) = 0 := |
| 40 | congrArg (fun f : AnnulusCoordinates →ₗ[ℝ] ℝ => f (quarterTurn u)) hzero |
| 41 | have hu : u = 0 := quarterTurn.injective (by simpa only [map_zero] using |
| 42 | (inner_self_eq_zero.mp hself)) |
| 43 | exact (hind.ne_zero (0 : Fin 2)) (by simpa using hu) |
| 44 | |
| 45 | /-- A fitted cap with the two original endpoint arcs supplies strictly inward chord |
| 46 | directions at both ends. The signs are consequences of its actual placement and smooth cap |
| 47 | transversality. Source: `proof-work/tasks/M64/reports/2026-09-24-signed-corner-chords.md`, |
| 48 | Signed corner cap coordinates and external chord signs. -/ |
| 49 | theorem m64Intrinsic_fitted_cap_chord_signs |
| 50 | {gamma : ℝ → AnnulusCoordinates} (hg : ContDiff ℝ ∞ gamma) {T r : ℝ} |
| 51 | (hend : gamma 0 = gamma T) (hinj : InjOn gamma (Ico 0 T)) |
| 52 | (hregular : ∀ t ∈ Ioo (0 : ℝ) T, deriv gamma t ≠ 0) |
| 53 | {U V : Set AnnulusCoordinates} (hU : IsOpen U) (hV : IsOpen V) |
| 54 | (hdisj : Disjoint U V) (hfU : frontier U = gamma '' Icc 0 T) |
| 55 | (hfV : frontier V = gamma '' Icc 0 T) |
| 56 | (hray : ∀ t ∈ Ioo (0 : ℝ) T, ∀ᶠ z in 𝓝[>] (0 : ℝ), |
| 57 | gamma t + z • quarterTurn (deriv gamma t) ∈ U) |
| 58 | (hr : 0 < r) (hrT : r < T) |
| 59 | (F : OpenPartialHomeomorph (ℝ × ℝ) AnnulusCoordinates) |
| 60 | (hsource : {q : ℝ × ℝ | 0 ≤ q.1 ∧ 0 ≤ q.2 ∧ q.1 + q.2 ≤ r} ⊆ F.source) |
| 61 | (hF : ContDiffOn ℝ ∞ F F.source) (hFi : ContDiffOn ℝ ∞ F.symm F.target) |
| 62 | (hfirst : ∀ s ∈ Icc (0 : ℝ) r, F (s, 0) = gamma s) |
| 63 | (hsecond : ∀ s ∈ Icc (0 : ℝ) r, F (0, s) = gamma (T - s)) |
| 64 | (hchord : ∀ t : ℝ, F ((1 - t) * r, t * r) = |
| 65 | (1 - t) • gamma r + t • gamma (T - r)) |
| 66 | (hsub : F '' {q : ℝ × ℝ | 0 ≤ q.1 ∧ 0 ≤ q.2 ∧ q.1 + q.2 ≤ r} ⊆ closure U) : |
| 67 | 0 < inner ℝ (quarterTurn (deriv gamma r)) (gamma (T - r) - gamma r) ∧ |
| 68 | 0 < inner ℝ (quarterTurn (deriv gamma (T - r))) (gamma r - gamma (T - r)) := by |
| 69 | have hrI : r ∈ Icc (0 : ℝ) r := ⟨hr.le, le_rfl⟩ |
| 70 | have hchordF : ∀ t ∈ Icc (0 : ℝ) 1, F ((1 - t) * r, t * r) = |
| 71 | (1 - t) • F (r, 0) + t • F (0, r) := by |
| 72 | intro t _ |
| 73 | rw [hfirst r hrI, hsecond r hrI] |
| 74 | exact hchord t |
| 75 | have hrev : ContDiff ℝ ∞ (fun s => gamma (T - s)) := |
| 76 | hg.comp (contDiff_const.sub contDiff_id) |
| 77 | obtain ⟨hleft, hright, _, _⟩ := cap_endpoint_transversality_of_axis_maps |
| 78 | F hF hFi hr hsource hchordF ((hg.differentiable (by simp)) r) |
| 79 | ((hrev.differentiable (by simp)) r) hfirst hsecond |
| 80 | have hleftne := transverse_inner_ne_zero hleft |
| 81 | have hrightne : inner ℝ (quarterTurn (deriv gamma (T - r))) |
| 82 | (gamma r - gamma (T - r)) ≠ 0 := by |
| 83 | have h := transverse_inner_ne_zero hright |
| 84 | simpa only [deriv_comp_const_sub, map_neg, inner_neg_left, neg_ne_zero] using h |
| 85 | have hleftRay : ∀ᶠ t in 𝓝[>] (0 : ℝ), |
| 86 | gamma r + t • (gamma (T - r) - gamma r) ∈ closure U := by |
| 87 | filter_upwards [Ioo_mem_nhdsGT (show (0 : ℝ) < 1 by norm_num)] with t ht |
| 88 | apply hsub |
| 89 | refine ⟨((1 - t) * r, t * r), ⟨mul_nonneg (sub_nonneg.mpr ht.2.le) hr.le, |
| 90 | mul_nonneg ht.1.le hr.le, by dsimp; nlinarith⟩, ?_⟩ |
| 91 | rw [hchord] |
| 92 | module |
| 93 | have hrightRay : ∀ᶠ t in 𝓝[>] (0 : ℝ), |
| 94 | gamma (T - r) + t • (gamma r - gamma (T - r)) ∈ closure U := by |
| 95 | filter_upwards [Ioo_mem_nhdsGT (show (0 : ℝ) < 1 by norm_num)] with t ht |
| 96 | apply hsub |
| 97 | refine ⟨((1 - (1 - t)) * r, (1 - t) * r), |
| 98 | ⟨by nlinarith [mul_nonneg ht.1.le hr.le], |
| 99 | mul_nonneg (sub_nonneg.mpr ht.2.le) hr.le, by dsimp; nlinarith⟩, ?_⟩ |
| 100 | rw [hchord] |
| 101 | module |
| 102 | have hrT' : T - r ∈ Ioo (0 : ℝ) T := ⟨sub_pos.mpr hrT, sub_lt_self T hr⟩ |
| 103 | exact ⟨m64Intrinsic_inward_ray_transverse_pos hg hend hinj ⟨hr, hrT⟩ |
| 104 | (hregular r ⟨hr, hrT⟩) hU hV hdisj hfU hfV (hray r ⟨hr, hrT⟩) hleftne hleftRay, |
| 105 | m64Intrinsic_inward_ray_transverse_pos hg hend hinj hrT' |
| 106 | (hregular (T - r) hrT') hU hV hdisj hfU hfV (hray (T - r) hrT') hrightne hrightRay⟩ |
| 107 | |
| 108 | /-- Either axis of a signed-sector cap gives a strictly inward chord when that axis is the |
| 109 | actual outgoing or reversed incoming loop arc. This also applies to the two external caps at |
| 110 | a reflex corner. Source: `proof-work/tasks/M64/reports/2026-09-24-signed-corner-chords.md`, |
| 111 | Signed corner cap coordinates and external chord signs. -/ |
| 112 | theorem m64Intrinsic_cap_endpoint_chord_sign |
| 113 | {gamma : ℝ → AnnulusCoordinates} (hg : ContDiff ℝ ∞ gamma) {T r : ℝ} |
| 114 | (hend : gamma 0 = gamma T) (hinj : InjOn gamma (Ico 0 T)) |
| 115 | (hregular : ∀ t ∈ Ioo (0 : ℝ) T, deriv gamma t ≠ 0) |
| 116 | {U V : Set AnnulusCoordinates} (hU : IsOpen U) (hV : IsOpen V) |
| 117 | (hdisj : Disjoint U V) (hfU : frontier U = gamma '' Icc 0 T) |
| 118 | (hfV : frontier V = gamma '' Icc 0 T) |
| 119 | (hray : ∀ t ∈ Ioo (0 : ℝ) T, ∀ᶠ z in 𝓝[>] (0 : ℝ), |
| 120 | gamma t + z • quarterTurn (deriv gamma t) ∈ U) |
| 121 | (hr : 0 < r) (hrT : r < T) |
| 122 | (F : OpenPartialHomeomorph (ℝ × ℝ) AnnulusCoordinates) |
| 123 | (hsource : {q : ℝ × ℝ | 0 ≤ q.1 ∧ 0 ≤ q.2 ∧ q.1 + q.2 ≤ r} ⊆ F.source) |
| 124 | (hF : ContDiffOn ℝ ∞ F F.source) (hFi : ContDiffOn ℝ ∞ F.symm F.target) |
| 125 | (hchord : ∀ t : ℝ, F ((1 - t) * r, t * r) = |
| 126 | (1 - t) • F (r, 0) + t • F (0, r)) |
| 127 | (hsub : F '' {q : ℝ × ℝ | 0 ≤ q.1 ∧ 0 ≤ q.2 ∧ q.1 + q.2 ≤ r} ⊆ closure U) |
| 128 | (terminal vertical : Bool) |
| 129 | (haxis : ∀ s ∈ Icc (0 : ℝ) r, |
| 130 | F (if vertical then (0, s) else (s, 0)) = gamma (if terminal then T - s else s)) : |
| 131 | 0 < inner ℝ (quarterTurn (deriv gamma (if terminal then T - r else r))) |
| 132 | (if vertical then F (r, 0) - F (0, r) else F (0, r) - F (r, 0)) := by |
| 133 | let b : ℝ → AnnulusCoordinates := fun s => F (if vertical then (0, s) else (s, 0)) |
| 134 | let beta : ℝ → AnnulusCoordinates := fun s => gamma (if terminal then T - s else s) |
| 135 | let p := if terminal then T - r else r |
| 136 | let d := if vertical then F (r, 0) - F (0, r) else F (0, r) - F (r, 0) |
| 137 | have hp : p ∈ Ioo (0 : ℝ) T := by |
| 138 | cases terminal |
| 139 | · exact ⟨hr, hrT⟩ |
| 140 | · exact ⟨sub_pos.mpr hrT, sub_lt_self T hr⟩ |
| 141 | have hrI : r ∈ Icc (0 : ℝ) r := ⟨hr.le, le_rfl⟩ |
| 142 | have hbs : (if vertical then ((0 : ℝ), r) else (r, 0)) ∈ F.source := by |
| 143 | apply hsource |
| 144 | cases vertical <;> simp [hr.le] |
| 145 | have hb : DifferentiableAt ℝ b r := by |
| 146 | have hdF := (hF.contDiffAt (F.open_source.mem_nhds hbs)).differentiableAt (by simp) |
| 147 | cases vertical |
| 148 | · exact hdF.comp r (differentiableAt_id.prodMk (differentiableAt_const (0 : ℝ))) |
| 149 | · exact hdF.comp r ((differentiableAt_const (0 : ℝ)).prodMk differentiableAt_id) |
| 150 | have hbeta : ContDiff ℝ ∞ beta := by |
| 151 | cases terminal |
| 152 | · exact hg |
| 153 | · exact hg.comp (contDiff_const.sub contDiff_id) |
| 154 | have hderiv : deriv b r = deriv beta r := by |
| 155 | rw [← hb.derivWithin (uniqueDiffOn_Icc hr r hrI), |
| 156 | ← ((hbeta.differentiable (by simp)) r).derivWithin (uniqueDiffOn_Icc hr r hrI)] |
| 157 | exact derivWithin_congr haxis (haxis r hrI) |
| 158 | have hind : LinearIndependent ℝ (![deriv b r, d] : Fin 2 → AnnulusCoordinates) := by |
| 159 | obtain ⟨hl, hr', _⟩ := cap_endpoint_transversality F hF hFi hr hsource (fun t _ => hchord t) |
| 160 | cases vertical |
| 161 | · exact hl |
| 162 | · exact hr' |
| 163 | have hnonzero : inner ℝ (quarterTurn (deriv gamma p)) d ≠ 0 := by |
| 164 | have h := transverse_inner_ne_zero hind |
| 165 | rw [hderiv] at h |
| 166 | cases terminal |
| 167 | · exact h |
| 168 | · simpa only [beta, p, Bool.true_eq, ite_true, deriv_comp_const_sub, |
| 169 | map_neg, inner_neg_left, neg_ne_zero] using h |
| 170 | have hbase : (if vertical then F (0, r) else F (r, 0)) = gamma p := by |
| 171 | cases vertical <;> exact haxis r hrI |
| 172 | have hwray : ∀ᶠ t in 𝓝[>] (0 : ℝ), gamma p + t • d ∈ closure U := by |
| 173 | filter_upwards [Ioo_mem_nhdsGT (show (0 : ℝ) < 1 by norm_num)] with t ht |
| 174 | cases vertical |
| 175 | · apply hsub |
| 176 | refine ⟨((1 - t) * r, t * r), |
| 177 | ⟨mul_nonneg (sub_nonneg.mpr ht.2.le) hr.le, |
| 178 | mul_nonneg ht.1.le hr.le, by dsimp; nlinarith⟩, ?_⟩ |
| 179 | rw [hchord, ← hbase] |
| 180 | dsimp [d] |
| 181 | module |
| 182 | · apply hsub |
| 183 | refine ⟨((1 - (1 - t)) * r, (1 - t) * r), |
| 184 | ⟨by nlinarith [mul_nonneg ht.1.le hr.le], |
| 185 | mul_nonneg (sub_nonneg.mpr ht.2.le) hr.le, by dsimp; nlinarith⟩, ?_⟩ |
| 186 | rw [hchord, ← hbase] |
| 187 | dsimp [d] |
| 188 | module |
| 189 | exact m64Intrinsic_inward_ray_transverse_pos hg hend hinj hp (hregular p hp) |
| 190 | hU hV hdisj hfU hfV (hray p hp) hnonzero hwray |
| 191 | |
| 192 | end PoincareMT |