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.Arc.NormalNeighborhood |
| 2 | import PoincareLib.Geometry.CurveShortening.Comparison.IntrinsicComparison.Inward.RaySign |
| 3 | |
| 4 | /-! |
| 5 | # Physical signs of transverse rays along a boundary arc |
| 6 | |
| 7 | An actual inward normal ray fixes the Jordan side of the normal chart. |
| 8 | Every transverse ray lying in the closed region then has positive normal |
| 9 | component, even when the other boundary pieces have corners. |
| 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 |
| 22 | open Poincare.Topology.Plane.Curves |
| 23 | |
| 24 | namespace PoincareMT |
| 25 | |
| 26 | private theorem arc_positive_normal_germ |
| 27 | {gamma : ℝ → AnnulusCoordinates} {p : ℝ} |
| 28 | {U V : Set AnnulusCoordinates} (hU : IsOpen U) (hV : IsOpen V) |
| 29 | (hdisj : Disjoint U V) (hf : frontier U = frontier V) |
| 30 | (H : OpenPartialHomeomorph (ℝ × ℝ) AnnulusCoordinates) |
| 31 | (hps : (p, (0 : ℝ)) ∈ H.source) (hmap : ∀ q, H q = normalStrip gamma q) |
| 32 | (hline : ∀ q ∈ H.source, H q ∈ frontier U ↔ q.2 = 0) |
| 33 | (hray : ∀ᶠ r in 𝓝[>] (0 : ℝ), gamma p + r • quarterTurn (deriv gamma p) ∈ U) : |
| 34 | ∀ᶠ q in 𝓝 (p, (0 : ℝ)), H q ∈ closure U ↔ 0 ≤ q.2 := by |
| 35 | have hfront : H (p, 0) ∈ frontier U := (hline _ hps).mpr rfl |
| 36 | have hline' : ∀ᶠ q in 𝓝 (p, (0 : ℝ)), H q ∈ frontier U ↔ q.2 = 0 := by |
| 37 | filter_upwards [H.open_source.mem_nhds hps] with q hq using hline q hq |
| 38 | rcases m64Intrinsic_jordan_product_line_germ hU hV hdisj hf H hps hfront hline' |
| 39 | with hpos | hneg |
| 40 | · exact hpos |
| 41 | · have hpath : Tendsto (fun r : ℝ => (p, r)) (𝓝 0) (𝓝 (p, (0 : ℝ))) := |
| 42 | continuous_const.prodMk continuous_id |>.tendsto 0 |
| 43 | have hneg' : ∀ᶠ r in 𝓝[>] (0 : ℝ), H (p, r) ∈ closure U ↔ r ≤ 0 := |
| 44 | (hpath.eventually hneg).filter_mono nhdsWithin_le_nhds |
| 45 | have hfalse : ∀ᶠ r in 𝓝[>] (0 : ℝ), False := by |
| 46 | filter_upwards [hray, hneg', self_mem_nhdsWithin] with r hrU hrside hrpos |
| 47 | have hcl : H (p, r) ∈ closure U := by |
| 48 | simpa only [hmap, normalStrip] using subset_closure hrU |
| 49 | exact (show 0 < r from hrpos).not_ge (hrside.mp hcl) |
| 50 | obtain ⟨_, h⟩ := hfalse.exists |
| 51 | exact False.elim h |
| 52 | |
| 53 | /-- Actual closed-region placement gives the positive physical normal sign of every |
| 54 | transverse ray at a regular point of either boundary arc. Source: |
| 55 | `proof-work/tasks/M64/derivations/2026-09-27-joined-orientation-and-attachments.md`, Section |
| 56 | 1. -/ |
| 57 | theorem m64Intrinsic_arc_inward_ray_transverse_pos |
| 58 | {gamma : ℝ → AnnulusCoordinates} (hg : ContDiff ℝ ∞ gamma) {A B p : ℝ} |
| 59 | (hinj : InjOn gamma (Icc A B)) (hp : p ∈ Ioo A B) |
| 60 | (hregular : ∀ t ∈ Ioo A B, deriv gamma t ≠ 0) |
| 61 | {K U V : Set AnnulusCoordinates} (hK : IsCompact K) (hpK : gamma p ∉ K) |
| 62 | (hU : IsOpen U) (hV : IsOpen V) (hdisj : Disjoint U V) |
| 63 | (hfU : frontier U = gamma '' Icc A B ∪ K) (hfV : frontier V = frontier U) |
| 64 | (hray : ∀ᶠ r in 𝓝[>] (0 : ℝ), gamma p + r • quarterTurn (deriv gamma p) ∈ U) |
| 65 | {w : AnnulusCoordinates} (hw : inner ℝ (quarterTurn (deriv gamma p)) w ≠ 0) |
| 66 | (hwray : ∀ᶠ r in 𝓝[>] (0 : ℝ), gamma p + r • w ∈ closure U) : |
| 67 | 0 < inner ℝ (quarterTurn (deriv gamma p)) w := by |
| 68 | obtain ⟨delta, hdelta, H, hsource, hmap, _, _, hboundary⟩ := |
| 69 | m64Intrinsic_exists_arc_normal_neighborhood hg hinj le_rfl hp.1 hp.2 hregular hK |
| 70 | (fun t ht => by have he : t = p := le_antisymm ht.2 ht.1; simpa only [he] using hpK) |
| 71 | have hline : ∀ q ∈ H.source, H q ∈ frontier U ↔ q.2 = 0 := by |
| 72 | simpa only [hfU] using hboundary |
| 73 | have hps : (p, (0 : ℝ)) ∈ H.source := hsource ⟨by simp, ⟨by linarith, hdelta⟩⟩ |
| 74 | have hbase : H (p, 0) = gamma p := by rw [hmap, normalStrip_axis] |
| 75 | have hpt : gamma p ∈ H.target := hbase ▸ H.map_source hps |
| 76 | have hinverse : H.symm (gamma p) = (p, 0) := by rw [← hbase, H.left_inv hps] |
| 77 | have hside := arc_positive_normal_germ hU hV hdisj hfV.symm H hps hmap hline hray |
| 78 | obtain ⟨L, hL, hd⟩ := exists_strictFDerivAt_normalStrip_axis hg (hregular p hp) |
| 79 | have hHfun : (H : (ℝ × ℝ) → AnnulusCoordinates) = normalStrip gamma := funext hmap |
| 80 | have hHd : HasFDerivAt H (L : (ℝ × ℝ) →L[ℝ] AnnulusCoordinates) (p, 0) := by |
| 81 | rw [hHfun] |
| 82 | exact hd.hasFDerivAt |
| 83 | have hdi : HasFDerivAt H.symm (L.symm : AnnulusCoordinates →L[ℝ] (ℝ × ℝ)) |
| 84 | (gamma p) := H.hasFDerivAt_symm hpt (hinverse ▸ hHd) |
| 85 | have hrayderiv : HasDerivAt (fun r : ℝ => gamma p + r • w) w 0 := by |
| 86 | convert! (hasDerivAt_const (0 : ℝ) (gamma p)).add |
| 87 | ((hasDerivAt_id (0 : ℝ)).smul_const w) using 1 |
| 88 | simp |
| 89 | have hdi' : HasFDerivAt H.symm (L.symm : AnnulusCoordinates →L[ℝ] (ℝ × ℝ)) |
| 90 | (gamma p + (0 : ℝ) • w) := by simpa only [zero_smul, add_zero] using hdi |
| 91 | have hpath : HasDerivAt (fun r : ℝ => H.symm (gamma p + r • w)) (L.symm w) 0 := by |
| 92 | convert! hdi'.comp_hasDerivAt 0 hrayderiv using 1 |
| 93 | have hheightderiv : HasDerivAt (fun r : ℝ => (H.symm (gamma p + r • w)).2) |
| 94 | (L.symm w).2 0 := by |
| 95 | convert! hasFDerivAt_snd.comp_hasDerivAt 0 hpath using 1 |
| 96 | have hlim : Tendsto (fun r : ℝ => H.symm (gamma p + r • w)) (𝓝 0) (𝓝 (p, 0)) := by |
| 97 | simpa only [zero_smul, add_zero, hinverse] using hpath.continuousAt.tendsto |
| 98 | have htarget : ∀ᶠ r in 𝓝 (0 : ℝ), gamma p + r • w ∈ H.target := |
| 99 | hrayderiv.continuousAt.preimage_mem_nhds (by |
| 100 | simpa only [zero_smul, add_zero] using H.open_target.mem_nhds hpt) |
| 101 | have hheightnonneg : ∀ᶠ r in 𝓝[>] (0 : ℝ), 0 ≤ (H.symm (gamma p + r • w)).2 := by |
| 102 | filter_upwards [hwray, (hlim.eventually hside).filter_mono nhdsWithin_le_nhds, |
| 103 | htarget.filter_mono nhdsWithin_le_nhds] with r hr hrside hrtarget |
| 104 | apply hrside.mp |
| 105 | rwa [H.right_inv hrtarget] |
| 106 | have hnonneg : 0 ≤ (L.symm w).2 := by |
| 107 | apply ge_of_tendsto hheightderiv.tendsto_slope_zero_right |
| 108 | filter_upwards [hheightnonneg, self_mem_nhdsWithin] with r hr hrpos |
| 109 | have hrpos' : 0 < r := hrpos |
| 110 | simpa only [zero_add, zero_smul, add_zero, hinverse, sub_zero, smul_eq_mul] using |
| 111 | mul_nonneg (inv_nonneg.mpr hrpos'.le) hr |
| 112 | have horth : inner ℝ (quarterTurn (deriv gamma p)) (deriv gamma p) = 0 := by |
| 113 | rw [real_inner_comm] |
| 114 | exact inner_quarterTurn_self _ |
| 115 | have heq := congrArg (fun z => inner ℝ (quarterTurn (deriv gamma p)) z) (hL (L.symm w)) |
| 116 | rw [L.apply_symm_apply, inner_add_right, real_inner_smul_right, real_inner_smul_right, |
| 117 | horth, mul_zero, zero_add] at heq |
| 118 | have hnonneg' : 0 ≤ inner ℝ (quarterTurn (deriv gamma p)) w := by |
| 119 | rw [heq] |
| 120 | exact mul_nonneg hnonneg real_inner_self_nonneg |
| 121 | exact lt_of_le_of_ne hnonneg' (Ne.symm hw) |
| 122 | |
| 123 | /-- Every positive transverse ray enters the actual Jordan region at a regular point of an |
| 124 | embedded boundary arc. Corners may lie elsewhere. Source: |
| 125 | `proof-work/tasks/M64/derivations/2026-09-27-joined-orientation-and-attachments.md`, Section |
| 126 | 1. -/ |
| 127 | theorem m64Intrinsic_arc_transverse_ray_enters_region |
| 128 | {gamma : ℝ → AnnulusCoordinates} (hg : ContDiff ℝ ∞ gamma) {A B p : ℝ} |
| 129 | (hinj : InjOn gamma (Icc A B)) (hp : p ∈ Ioo A B) |
| 130 | (hregular : ∀ t ∈ Ioo A B, deriv gamma t ≠ 0) |
| 131 | {K U V : Set AnnulusCoordinates} (hK : IsCompact K) (hpK : gamma p ∉ K) |
| 132 | (hU : IsOpen U) (hV : IsOpen V) (hdisj : Disjoint U V) |
| 133 | (hfU : frontier U = gamma '' Icc A B ∪ K) (hfV : frontier V = frontier U) |
| 134 | (hray : ∀ᶠ r in 𝓝[>] (0 : ℝ), gamma p + r • quarterTurn (deriv gamma p) ∈ U) |
| 135 | {w : AnnulusCoordinates} (hw : 0 < inner ℝ (quarterTurn (deriv gamma p)) w) : |
| 136 | ∀ᶠ r in 𝓝[>] (0 : ℝ), gamma p + r • w ∈ U := by |
| 137 | obtain ⟨delta, hdelta, H, hsource, hmap, _, _, hboundary⟩ := |
| 138 | m64Intrinsic_exists_arc_normal_neighborhood hg hinj le_rfl hp.1 hp.2 hregular hK |
| 139 | (fun t ht => by have he : t = p := le_antisymm ht.2 ht.1; simpa only [he] using hpK) |
| 140 | have hline : ∀ q ∈ H.source, H q ∈ frontier U ↔ q.2 = 0 := by |
| 141 | simpa only [hfU] using hboundary |
| 142 | have hps : (p, (0 : ℝ)) ∈ H.source := hsource ⟨by simp, ⟨by linarith, hdelta⟩⟩ |
| 143 | have hbase : H (p, 0) = gamma p := by rw [hmap, normalStrip_axis] |
| 144 | have hpt : gamma p ∈ H.target := hbase ▸ H.map_source hps |
| 145 | have hinverse : H.symm (gamma p) = (p, 0) := by rw [← hbase, H.left_inv hps] |
| 146 | have hside := arc_positive_normal_germ hU hV hdisj hfV.symm H hps hmap hline hray |
| 147 | obtain ⟨L, hL, hd⟩ := exists_strictFDerivAt_normalStrip_axis hg (hregular p hp) |
| 148 | have hHfun : (H : (ℝ × ℝ) → AnnulusCoordinates) = normalStrip gamma := funext hmap |
| 149 | have hHd : HasFDerivAt H (L : (ℝ × ℝ) →L[ℝ] AnnulusCoordinates) (p, 0) := by |
| 150 | rw [hHfun] |
| 151 | exact hd.hasFDerivAt |
| 152 | have hdi : HasFDerivAt H.symm (L.symm : AnnulusCoordinates →L[ℝ] (ℝ × ℝ)) |
| 153 | (gamma p) := H.hasFDerivAt_symm hpt (hinverse ▸ hHd) |
| 154 | have hrayderiv : HasDerivAt (fun r : ℝ => gamma p + r • w) w 0 := by |
| 155 | convert! (hasDerivAt_const (0 : ℝ) (gamma p)).add |
| 156 | ((hasDerivAt_id (0 : ℝ)).smul_const w) using 1 |
| 157 | simp |
| 158 | have hdi' : HasFDerivAt H.symm (L.symm : AnnulusCoordinates →L[ℝ] (ℝ × ℝ)) |
| 159 | (gamma p + (0 : ℝ) • w) := by simpa only [zero_smul, add_zero] using hdi |
| 160 | have hpath : HasDerivAt (fun r : ℝ => H.symm (gamma p + r • w)) (L.symm w) 0 := by |
| 161 | convert! hdi'.comp_hasDerivAt 0 hrayderiv using 1 |
| 162 | have hnormal : quarterTurn (deriv gamma p) ≠ 0 := by |
| 163 | intro hn |
| 164 | simp only [hn, inner_zero_left] at hw |
| 165 | exact (lt_irrefl 0) hw |
| 166 | have hheight : 0 < (L.symm w).2 := by |
| 167 | have horth : inner ℝ (quarterTurn (deriv gamma p)) (deriv gamma p) = 0 := by |
| 168 | rw [real_inner_comm] |
| 169 | exact inner_quarterTurn_self _ |
| 170 | have heq := congrArg (fun z => inner ℝ (quarterTurn (deriv gamma p)) z) |
| 171 | (hL (L.symm w)) |
| 172 | rw [L.apply_symm_apply, inner_add_right, real_inner_smul_right, |
| 173 | real_inner_smul_right, horth, mul_zero, zero_add] at heq |
| 174 | exact (mul_pos_iff_of_pos_right (real_inner_self_pos.mpr hnormal)).mp (heq ▸ hw) |
| 175 | have hheightderiv : HasDerivAt (fun r : ℝ => (H.symm (gamma p + r • w)).2) |
| 176 | (L.symm w).2 0 := by |
| 177 | convert! hasFDerivAt_snd.comp_hasDerivAt 0 hpath using 1 |
| 178 | have hpos : ∀ᶠ r in 𝓝[>] (0 : ℝ), 0 < (H.symm (gamma p + r • w)).2 := by |
| 179 | have hs := hheightderiv.tendsto_slope_zero_right.eventually_const_lt hheight |
| 180 | filter_upwards [hs, self_mem_nhdsWithin] with r hr hrpos |
| 181 | have hrpos' : 0 < r := hrpos |
| 182 | simp only [zero_add, zero_smul, add_zero, hinverse, sub_zero, smul_eq_mul] at hr |
| 183 | exact (mul_pos_iff_of_pos_left (inv_pos.mpr hrpos')).mp hr |
| 184 | have hlim : Tendsto (fun r : ℝ => H.symm (gamma p + r • w)) (𝓝 0) (𝓝 (p, 0)) := by |
| 185 | simpa only [zero_smul, add_zero, hinverse] using hpath.continuousAt.tendsto |
| 186 | have htarget : ∀ᶠ r in 𝓝 (0 : ℝ), gamma p + r • w ∈ H.target := |
| 187 | hrayderiv.continuousAt.preimage_mem_nhds (by |
| 188 | simpa only [zero_smul, add_zero] using H.open_target.mem_nhds hpt) |
| 189 | filter_upwards [hpos, (hlim.eventually hside).filter_mono nhdsWithin_le_nhds, |
| 190 | htarget.filter_mono nhdsWithin_le_nhds] with r hrpos hrside hrtarget |
| 191 | have hcl : gamma p + r • w ∈ closure U := by |
| 192 | have h := hrside.mpr hrpos.le |
| 193 | rwa [H.right_inv hrtarget] at h |
| 194 | by_contra hn |
| 195 | have hfront : gamma p + r • w ∈ frontier U := |
| 196 | ⟨hcl, by simpa only [hU.interior_eq] using hn⟩ |
| 197 | have hzero := (hline _ (H.map_target hrtarget)).mp |
| 198 | (by simpa only [H.right_inv hrtarget] using hfront) |
| 199 | exact hrpos.ne' hzero |
| 200 | |
| 201 | end PoincareMT |