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.Boundary.Geometry |
| 2 | import PoincareLib.Geometry.CurveShortening.Comparison.IntrinsicComparison.Jordan.Region |
| 3 | import Mathlib.Analysis.Calculus.InverseFunctionTheorem.Deriv |
| 4 | import Mathlib.Analysis.Calculus.ContDiff.RCLike |
| 5 | import Mathlib.Topology.MetricSpace.Pseudo.Lemmas |
| 6 | |
| 7 | /-! |
| 8 | # Simple return loops in a regular smooth curve |
| 9 | |
| 10 | A nonzero velocity gives local injectivity by a scalar coordinate inverse. |
| 11 | Compactness makes the separation of distinct return times positive. The |
| 12 | first return therefore has an embedded half-open preceding parameter |
| 13 | interval, giving the actual simple loop needed for Jordan separation. |
| 14 | |
| 15 | Morgan--Tian context: Proposition 19.35, printed pp. 467-481. These project |
| 16 | Jordan-region constructions supply the actual domains, boundary charts and finite |
| 17 | faces used in its regional Gauss--Bonnet arguments. |
| 18 | -/ |
| 19 | |
| 20 | noncomputable section |
| 21 | set_option autoImplicit false |
| 22 | |
| 23 | open Set Filter Metric |
| 24 | open scoped Topology ContDiff |
| 25 | |
| 26 | namespace PoincareMT |
| 27 | |
| 28 | /-- A nonzero velocity of a smooth coordinate curve gives an actual open parameter |
| 29 | neighborhood on which the original curve is injective. Source: |
| 30 | `proof-work/tasks/M64/reports/2026-09-24-intrinsic-radial-scalar.md`, Endpoint length and |
| 31 | actual normal return regions. -/ |
| 32 | theorem m64Intrinsic_regular_curve_locally_injective |
| 33 | {gamma : ℝ → AnnulusCoordinates} {s : ℝ} |
| 34 | (hg : ContDiffAt ℝ ∞ gamma s) (hregular : deriv gamma s ≠ 0) : |
| 35 | ∃ U : Set ℝ, IsOpen U ∧ s ∈ U ∧ InjOn gamma U := by |
| 36 | have hcoord : ∃ i : Fin 2, deriv gamma s i ≠ 0 := by |
| 37 | by_contra hn |
| 38 | push Not at hn |
| 39 | apply hregular |
| 40 | ext i |
| 41 | exact hn i |
| 42 | obtain ⟨i, hi⟩ := hcoord |
| 43 | let f : ℝ → ℝ := fun t => gamma t i |
| 44 | have hproj : ContDiff ℝ ∞ (fun z : AnnulusCoordinates => z i) := by fun_prop |
| 45 | have hf : ContDiffAt ℝ ∞ f s := hproj.contDiffAt.comp s hg |
| 46 | have hdf : HasDerivAt f (deriv gamma s i) s := |
| 47 | (PiLp.hasFDerivAt_apply (𝕜 := ℝ) 2 (gamma s) i).comp_hasDerivAt s |
| 48 | (hg.differentiableAt (by simp)).hasDerivAt |
| 49 | have hstrict := hf.hasStrictDerivAt' hdf (by simp) |
| 50 | have hinv := hstrict.eventually_left_inverse hi |
| 51 | obtain ⟨r, hr, hball⟩ := Metric.mem_nhds_iff.mp hinv |
| 52 | refine ⟨ball s r, isOpen_ball, mem_ball_self hr, ?_⟩ |
| 53 | intro x hx y hy heq |
| 54 | calc |
| 55 | x = hstrict.localInverse f _ s hi (f x) := (hball hx).symm |
| 56 | _ = hstrict.localInverse f _ s hi (f y) := by |
| 57 | rw [show f x = f y from congrArg (fun z => z i) heq] |
| 58 | _ = y := hball hy |
| 59 | |
| 60 | /-- Local injectivity over a compact parameter interval gives a uniform positive separation |
| 61 | between distinct return times. Source: |
| 62 | `proof-work/tasks/M64/reports/2026-09-24-intrinsic-radial-scalar.md`, Endpoint length and |
| 63 | actual normal return regions. -/ |
| 64 | theorem m64Intrinsic_regular_return_separation |
| 65 | {gamma : ℝ → AnnulusCoordinates} {a b : ℝ} |
| 66 | (hlocal : ∀ s ∈ Icc a b, ∃ U : Set ℝ, IsOpen U ∧ s ∈ U ∧ InjOn gamma U) : |
| 67 | ∃ epsilon : ℝ, 0 < epsilon ∧ ∀ s ∈ Icc a b, ∀ t ∈ Icc a b, |
| 68 | s < t → gamma s = gamma t → epsilon ≤ t - s := by |
| 69 | choose U hU hsU hi using hlocal |
| 70 | have hcover : Icc a b ⊆ ⋃ s : Icc a b, U s.val s.property := by |
| 71 | intro s hs |
| 72 | exact mem_iUnion.mpr ⟨⟨s, hs⟩, hsU s hs⟩ |
| 73 | obtain ⟨epsilon, hepsilon, hsmall⟩ := lebesgue_number_lemma_of_metric isCompact_Icc |
| 74 | (fun s : Icc a b => hU s.val s.property) hcover |
| 75 | refine ⟨epsilon, hepsilon, ?_⟩ |
| 76 | intro s hs t _ hst heq |
| 77 | obtain ⟨p, hp⟩ := hsmall s hs |
| 78 | by_contra hn |
| 79 | have htball : t ∈ ball s epsilon := by |
| 80 | rw [mem_ball, Real.dist_eq, abs_of_pos (sub_pos.mpr hst)] |
| 81 | exact lt_of_not_ge hn |
| 82 | exact hst.ne ((hi p.val p.property) (hp (mem_ball_self hepsilon)) (hp htball) heq) |
| 83 | |
| 84 | /-- The first self-intersection of a continuous locally injective interval curve leaves its |
| 85 | entire preceding half-open parameter interval embedded. Source: |
| 86 | `proof-work/tasks/M64/reports/2026-09-24-intrinsic-radial-scalar.md`, Endpoint length and |
| 87 | actual normal return regions. -/ |
| 88 | theorem m64Intrinsic_exists_first_return_interval |
| 89 | {gamma : ℝ → AnnulusCoordinates} (hg : Continuous gamma) {a b : ℝ} |
| 90 | (hlocal : ∀ s ∈ Icc a b, ∃ U : Set ℝ, IsOpen U ∧ s ∈ U ∧ InjOn gamma U) |
| 91 | (hnot : ¬ InjOn gamma (Icc a b)) : |
| 92 | ∃ s t : ℝ, a ≤ s ∧ s < t ∧ t ≤ b ∧ gamma s = gamma t ∧ InjOn gamma (Ico a t) := by |
| 93 | obtain ⟨epsilon, hepsilon, hsep⟩ := m64Intrinsic_regular_return_separation hlocal |
| 94 | let C : Set (ℝ × ℝ) := (Icc a b ×ˢ Icc a b) ∩ |
| 95 | {p | epsilon ≤ p.2 - p.1 ∧ gamma p.1 = gamma p.2} |
| 96 | have hC : IsCompact C := (isCompact_Icc.prod isCompact_Icc).inter_right |
| 97 | ((isClosed_le continuous_const (continuous_snd.sub continuous_fst)).inter |
| 98 | (isClosed_eq (hg.comp continuous_fst) (hg.comp continuous_snd))) |
| 99 | have hpair : ∃ s ∈ Icc a b, ∃ t ∈ Icc a b, s < t ∧ gamma s = gamma t := by |
| 100 | simp only [InjOn] at hnot |
| 101 | push Not at hnot |
| 102 | obtain ⟨s, hs, t, ht, heq, hne⟩ := hnot |
| 103 | rcases lt_or_gt_of_ne hne with hlt | hlt |
| 104 | · exact ⟨s, hs, t, ht, hlt, heq⟩ |
| 105 | · exact ⟨t, ht, s, hs, hlt, heq.symm⟩ |
| 106 | obtain ⟨s, hs, t, ht, hst, heq⟩ := hpair |
| 107 | have hCne : C.Nonempty := ⟨(s, t), ⟨⟨hs, ht⟩, hsep s hs t ht hst heq, heq⟩⟩ |
| 108 | obtain ⟨p, hp, hmin⟩ := hC.exists_isMinOn hCne continuous_snd.continuousOn |
| 109 | have hplt : p.1 < p.2 := by linarith [hp.2.1] |
| 110 | refine ⟨p.1, p.2, hp.1.1.1, hplt, hp.1.2.2, hp.2.2, ?_⟩ |
| 111 | intro x hx y hy hxy |
| 112 | by_contra hne |
| 113 | wlog hlt : x < y generalizing x y |
| 114 | · exact this (x := y) (y := x) hy hx hxy.symm (Ne.symm hne) |
| 115 | (lt_of_le_of_ne (le_of_not_gt hlt) (Ne.symm hne)) |
| 116 | have hxI : x ∈ Icc a b := ⟨hx.1, hx.2.le.trans hp.1.2.2⟩ |
| 117 | have hyI : y ∈ Icc a b := ⟨hy.1, hy.2.le.trans hp.1.2.2⟩ |
| 118 | have hxyC : (x, y) ∈ C := ⟨⟨hxI, hyI⟩, hsep x hxI y hyI hlt hxy, hxy⟩ |
| 119 | have hlength := hmin hxyC |
| 120 | change p.2 ≤ y at hlength |
| 121 | exact not_le_of_gt hy.2 hlength |
| 122 | |
| 123 | /-- The first return supplies a simple loop on its own return interval. Source: |
| 124 | `proof-work/tasks/M64/reports/2026-09-24-intrinsic-radial-scalar.md`, Endpoint length and |
| 125 | actual normal return regions. -/ |
| 126 | theorem m64Intrinsic_exists_simple_return_interval |
| 127 | {gamma : ℝ → AnnulusCoordinates} (hg : Continuous gamma) {a b : ℝ} |
| 128 | (hlocal : ∀ s ∈ Icc a b, ∃ U : Set ℝ, IsOpen U ∧ s ∈ U ∧ InjOn gamma U) |
| 129 | (hnot : ¬ InjOn gamma (Icc a b)) : |
| 130 | ∃ s t : ℝ, a ≤ s ∧ s < t ∧ t ≤ b ∧ gamma s = gamma t ∧ InjOn gamma (Ico s t) := by |
| 131 | obtain ⟨s, t, has, hst, htb, heq, hinj⟩ := |
| 132 | m64Intrinsic_exists_first_return_interval hg hlocal hnot |
| 133 | exact ⟨s, t, has, hst, htb, heq, hinj.mono (Ico_subset_Ico_left has)⟩ |
| 134 | |
| 135 | /-- Smooth regular curves supply the local injectivity used in the actual simple return |
| 136 | construction. Source: `proof-work/tasks/M64/reports/2026-09-24-intrinsic-radial-scalar.md`, |
| 137 | Endpoint length and actual normal return regions. -/ |
| 138 | theorem m64Intrinsic_exists_simple_regular_loop |
| 139 | {gamma : ℝ → AnnulusCoordinates} (hg : ContDiff ℝ ∞ gamma) {a b : ℝ} |
| 140 | (hregular : ∀ s ∈ Icc a b, deriv gamma s ≠ 0) |
| 141 | (hnot : ¬ InjOn gamma (Icc a b)) : |
| 142 | ∃ s t : ℝ, a ≤ s ∧ s < t ∧ t ≤ b ∧ gamma s = gamma t ∧ InjOn gamma (Ico s t) := |
| 143 | m64Intrinsic_exists_simple_return_interval hg.continuous |
| 144 | (fun s hs => m64Intrinsic_regular_curve_locally_injective hg.contDiffAt (hregular s hs)) hnot |
| 145 | |
| 146 | end PoincareMT |