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.InwardRaySign |
| 2 | import PoincareLib.Geometry.CurveShortening.Comparison.IntrinsicComparison.Cap.ChordSigns |
| 3 | |
| 4 | /-! |
| 5 | # Actual inward chord directions at either end of a boundary arc |
| 6 | |
| 7 | The cap's smooth transversality gives a nonzero normal component. Its |
| 8 | placement in the Jordan closure and the actual inward ray fix the sign. |
| 9 | Either cap axis can parametrize an outgoing or incoming incident arc. |
| 10 | |
| 11 | Morgan--Tian context: Proposition 19.35, printed pp. 467-481, including Claim 19.40, |
| 12 | pp. 470-471. These project constructions supply actual occupied boundary collars |
| 13 | and attachment coverage for the regional Gauss--Bonnet argument. |
| 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 arc_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 | /-- The actual cap supplies a strictly inward chord at either endpoint of a trimmed boundary |
| 46 | arc of a piecewise smooth Jordan region. Source: |
| 47 | `proof-work/tasks/M64/reviews/2026-09-27-intrinsic-boundary-coverage-review.md`, round_1, |
| 48 | semantic check 12. -/ |
| 49 | theorem m64Intrinsic_arc_cap_endpoint_chord_sign |
| 50 | {gamma : ℝ → AnnulusCoordinates} (hg : ContDiff ℝ ∞ gamma) {T r : ℝ} |
| 51 | (hinj : InjOn gamma (Icc 0 T)) |
| 52 | (hregular : ∀ t ∈ Ioo (0 : ℝ) T, deriv gamma t ≠ 0) |
| 53 | {K U V : Set AnnulusCoordinates} (hK : IsCompact K) |
| 54 | (havoid : ∀ t ∈ Ioo (0 : ℝ) T, gamma t ∉ K) |
| 55 | (hU : IsOpen U) (hV : IsOpen V) (hdisj : Disjoint U V) |
| 56 | (hfU : frontier U = gamma '' Icc 0 T ∪ K) (hfV : frontier V = frontier U) |
| 57 | (hray : ∀ t ∈ Ioo (0 : ℝ) T, ∀ᶠ z in 𝓝[>] (0 : ℝ), |
| 58 | gamma t + z • quarterTurn (deriv gamma t) ∈ U) |
| 59 | (hr : 0 < r) (hrT : r < T) |
| 60 | (F : OpenPartialHomeomorph (ℝ × ℝ) AnnulusCoordinates) |
| 61 | (hsource : {q : ℝ × ℝ | 0 ≤ q.1 ∧ 0 ≤ q.2 ∧ q.1 + q.2 ≤ r} ⊆ F.source) |
| 62 | (hF : ContDiffOn ℝ ∞ F F.source) (hFi : ContDiffOn ℝ ∞ F.symm F.target) |
| 63 | (hchord : ∀ t : ℝ, F ((1 - t) * r, t * r) = |
| 64 | (1 - t) • F (r, 0) + t • F (0, r)) |
| 65 | (hsub : F '' {q : ℝ × ℝ | 0 ≤ q.1 ∧ 0 ≤ q.2 ∧ q.1 + q.2 ≤ r} ⊆ closure U) |
| 66 | (terminal vertical : Bool) |
| 67 | (haxis : ∀ s ∈ Icc (0 : ℝ) r, |
| 68 | F (if vertical then (0, s) else (s, 0)) = gamma (if terminal then T - s else s)) : |
| 69 | 0 < inner ℝ (quarterTurn (deriv gamma (if terminal then T - r else r))) |
| 70 | (if vertical then F (r, 0) - F (0, r) else F (0, r) - F (r, 0)) := by |
| 71 | let b : ℝ → AnnulusCoordinates := fun s => F (if vertical then (0, s) else (s, 0)) |
| 72 | let beta : ℝ → AnnulusCoordinates := fun s => gamma (if terminal then T - s else s) |
| 73 | let p := if terminal then T - r else r |
| 74 | let d := if vertical then F (r, 0) - F (0, r) else F (0, r) - F (r, 0) |
| 75 | have hp : p ∈ Ioo (0 : ℝ) T := by |
| 76 | cases terminal |
| 77 | · exact ⟨hr, hrT⟩ |
| 78 | · exact ⟨sub_pos.mpr hrT, sub_lt_self T hr⟩ |
| 79 | have hrI : r ∈ Icc (0 : ℝ) r := ⟨hr.le, le_rfl⟩ |
| 80 | have hbs : (if vertical then ((0 : ℝ), r) else (r, 0)) ∈ F.source := by |
| 81 | apply hsource |
| 82 | cases vertical <;> simp [hr.le] |
| 83 | have hb : DifferentiableAt ℝ b r := by |
| 84 | have hdF := (hF.contDiffAt (F.open_source.mem_nhds hbs)).differentiableAt (by simp) |
| 85 | cases vertical |
| 86 | · exact hdF.comp r (differentiableAt_id.prodMk (differentiableAt_const (0 : ℝ))) |
| 87 | · exact hdF.comp r ((differentiableAt_const (0 : ℝ)).prodMk differentiableAt_id) |
| 88 | have hbeta : ContDiff ℝ ∞ beta := by |
| 89 | cases terminal |
| 90 | · exact hg |
| 91 | · exact hg.comp (contDiff_const.sub contDiff_id) |
| 92 | have hderiv : deriv b r = deriv beta r := by |
| 93 | rw [← hb.derivWithin (uniqueDiffOn_Icc hr r hrI), |
| 94 | ← ((hbeta.differentiable (by simp)) r).derivWithin (uniqueDiffOn_Icc hr r hrI)] |
| 95 | exact derivWithin_congr haxis (haxis r hrI) |
| 96 | have hind : LinearIndependent ℝ (![deriv b r, d] : Fin 2 → AnnulusCoordinates) := by |
| 97 | obtain ⟨hl, hr', _⟩ := cap_endpoint_transversality F hF hFi hr hsource (fun t _ => hchord t) |
| 98 | cases vertical |
| 99 | · exact hl |
| 100 | · exact hr' |
| 101 | have hnonzero : inner ℝ (quarterTurn (deriv gamma p)) d ≠ 0 := by |
| 102 | have h := arc_transverse_inner_ne_zero hind |
| 103 | rw [hderiv] at h |
| 104 | cases terminal |
| 105 | · exact h |
| 106 | · simpa only [beta, p, Bool.true_eq, ite_true, deriv_comp_const_sub, |
| 107 | map_neg, inner_neg_left, neg_ne_zero] using h |
| 108 | have hbase : (if vertical then F (0, r) else F (r, 0)) = gamma p := by |
| 109 | cases vertical <;> exact haxis r hrI |
| 110 | have hwray : ∀ᶠ t in 𝓝[>] (0 : ℝ), gamma p + t • d ∈ closure U := by |
| 111 | filter_upwards [Ioo_mem_nhdsGT (show (0 : ℝ) < 1 by norm_num)] with t ht |
| 112 | cases vertical |
| 113 | · apply hsub |
| 114 | refine ⟨((1 - t) * r, t * r), |
| 115 | ⟨mul_nonneg (sub_nonneg.mpr ht.2.le) hr.le, |
| 116 | mul_nonneg ht.1.le hr.le, by dsimp; nlinarith⟩, ?_⟩ |
| 117 | rw [hchord, ← hbase] |
| 118 | dsimp [d] |
| 119 | module |
| 120 | · apply hsub |
| 121 | refine ⟨((1 - (1 - t)) * r, (1 - t) * r), |
| 122 | ⟨by nlinarith [mul_nonneg ht.1.le hr.le], |
| 123 | mul_nonneg (sub_nonneg.mpr ht.2.le) hr.le, by dsimp; nlinarith⟩, ?_⟩ |
| 124 | rw [hchord, ← hbase] |
| 125 | dsimp [d] |
| 126 | module |
| 127 | exact m64Intrinsic_arc_inward_ray_transverse_pos hg hinj hp hregular hK (havoid p hp) |
| 128 | hU hV hdisj hfU hfV (hray p hp) hnonzero hwray |
| 129 | |
| 130 | end PoincareMT |