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.Analysis.First.LastFrontier |
| 2 | import PoincareLib.Geometry.CurveShortening.Comparison.IntrinsicComparison.Region.Minimizer |
| 3 | |
| 4 | /-! Confined competitors obtained by replacing all frontier excursions. |
| 5 | First and last contacts suffice even for infinitely many crossings. |
| 6 | Source: the geodesic-side step in MT Claim 19.40, pp. 470-471. -/ |
| 7 | |
| 8 | noncomputable section |
| 9 | set_option autoImplicit false |
| 10 | set_option warningAsError true |
| 11 | set_option backward.isDefEq.respectTransparency false |
| 12 | |
| 13 | open Set |
| 14 | open scoped ENNReal |
| 15 | |
| 16 | namespace PoincareMT |
| 17 | |
| 18 | private theorem affine_variation_le |
| 19 | (G : RiemannianMetric 2 AnnulusCoordinates) {f : ℝ → AnnulusCoordinates} |
| 20 | {C : ℝ} (hC : 0 ≤ C) |
| 21 | (hlip : ∀ s ∈ Icc 0 1, ∀ t ∈ Icc 0 1, |
| 22 | G.edist (f s) (f t) ≤ ENNReal.ofReal (C * |s - t|)) |
| 23 | {a b : ℝ} (ha : a ∈ Icc 0 1) (hb : b ∈ Icc 0 1) (hab : a ≤ b) : |
| 24 | m64IntrinsicCurveVariation G (fun t => f (a + (b - a) * t)) 0 1 ≤ |
| 25 | ENNReal.ofReal ((b - a) * C) := by |
| 26 | have hparam : MapsTo (fun t : ℝ => a + (b - a) * t) (Icc 0 1) (Icc 0 1) := by |
| 27 | intro t ht |
| 28 | constructor <;> nlinarith [ha.1, hb.2, ht.1, ht.2] |
| 29 | apply m64Intrinsic_curveVariation_le_of_edist_le G |
| 30 | (mul_nonneg (sub_nonneg.mpr hab) hC) |
| 31 | intro s hs t ht |
| 32 | convert hlip _ (hparam hs) _ (hparam ht) using 1 |
| 33 | congr 1 |
| 34 | rw [show a + (b - a) * s - (a + (b - a) * t) = (b - a) * (s - t) by ring, |
| 35 | abs_mul, abs_of_nonneg (sub_nonneg.mpr hab)] |
| 36 | ring |
| 37 | |
| 38 | /-- Actual distance-realizing frontier connectors turn any finite-speed path in the |
| 39 | neighborhood into a confined competitor with the same bound. Source: MT Claim 19.40, pp. |
| 40 | 470-471; `proof-work/tasks/M64/derivations/2026-09-27-minimal-contact-regularity.md`, |
| 41 | Sections 4-5. -/ |
| 42 | theorem m64Intrinsic_exists_confined_competitor_of_frontier_segments |
| 43 | (G : RiemannianMetric 2 AnnulusCoordinates) {K O : Set AnnulusCoordinates} |
| 44 | (hK : IsClosed K) {f : ℝ → AnnulusCoordinates} |
| 45 | (hc : ContinuousOn f (Icc 0 1)) (h0 : f 0 ∈ K) (h1 : f 1 ∈ K) |
| 46 | (hO : MapsTo f (Icc 0 1) O) {C : ℝ} (hC : 0 ≤ C) |
| 47 | (hlip : ∀ s ∈ Icc 0 1, ∀ t ∈ Icc 0 1, |
| 48 | G.edist (f s) (f t) ≤ ENNReal.ofReal (C * |s - t|)) |
| 49 | (hside : ∀ p ∈ frontier K ∩ O, ∀ q ∈ frontier K ∩ O, |
| 50 | ∃ g : ℝ → AnnulusCoordinates, ContinuousOn g (Icc 0 1) ∧ |
| 51 | g 0 = p ∧ g 1 = q ∧ MapsTo g (Icc 0 1) K ∧ |
| 52 | m64IntrinsicCurveVariation G g 0 1 ≤ G.edist p q) : |
| 53 | ∃ g : ℝ → AnnulusCoordinates, ContinuousOn g (Icc 0 1) ∧ |
| 54 | g 0 = f 0 ∧ g 1 = f 1 ∧ MapsTo g (Icc 0 1) K ∧ |
| 55 | m64IntrinsicCurveVariation G g 0 1 ≤ ENNReal.ofReal C := by |
| 56 | rcases m64_path_confined_or_first_last_frontier hK hc h0 h1 with hconf | hcontacts |
| 57 | · exact ⟨f, hc, rfl, rfl, hconf, m64Intrinsic_curveVariation_le_of_edist_le G hC hlip⟩ |
| 58 | obtain ⟨a, b, ha, hb, hab, hfa, hfb, hleft, hright⟩ := hcontacts |
| 59 | obtain ⟨g, hgc, hg0, hg1, hgconf, hgvar⟩ := |
| 60 | hside (f a) ⟨hfa, hO ha⟩ (f b) ⟨hfb, hO hb⟩ |
| 61 | let l := fun t : ℝ => f (0 + (a - 0) * t) |
| 62 | let r := fun t : ℝ => f (b + (1 - b) * t) |
| 63 | have hlmap : MapsTo (fun t : ℝ => 0 + (a - 0) * t) (Icc 0 1) (Icc 0 a) := by |
| 64 | intro t ht |
| 65 | constructor <;> nlinarith [ht.1, ht.2, ha.1] |
| 66 | have hrmap : MapsTo (fun t : ℝ => b + (1 - b) * t) (Icc 0 1) (Icc b 1) := by |
| 67 | intro t ht |
| 68 | constructor <;> nlinarith [ht.1, ht.2, hb.2] |
| 69 | have hlc : ContinuousOn l (Icc 0 1) := |
| 70 | (hc.mono (Icc_subset_Icc le_rfl ha.2)).comp (by fun_prop) hlmap |
| 71 | have hrc : ContinuousOn r (Icc 0 1) := |
| 72 | (hc.mono (Icc_subset_Icc hb.1 le_rfl)).comp (by fun_prop) hrmap |
| 73 | have hl1 : l 1 = g 0 := by simp only [l, sub_zero, zero_add, mul_one, hg0] |
| 74 | obtain ⟨q, hqc, hq0, hq1, hqimage, hqvar⟩ := |
| 75 | m64Intrinsic_exists_join_with_variation G hlc hgc hl1 |
| 76 | have hqr : q 1 = r 0 := by simp only [hq1, hg1, r, mul_zero, add_zero] |
| 77 | obtain ⟨tau, htc, ht0, ht1, htimage, htvar⟩ := |
| 78 | m64Intrinsic_exists_join_with_variation G hqc hrc hqr |
| 79 | refine ⟨tau, htc, ?_, ?_, ?_, ?_⟩ |
| 80 | · simpa only [hq0, l, mul_zero, add_zero] using ht0 |
| 81 | · simpa only [r, mul_one, add_sub_cancel] using ht1 |
| 82 | · intro t ht |
| 83 | rcases htimage t ht with ⟨s, hs, heq⟩ | ⟨s, hs, heq⟩ |
| 84 | · rw [← heq] |
| 85 | rcases hqimage s hs with ⟨u, hu, heq'⟩ | ⟨u, hu, heq'⟩ |
| 86 | · rw [← heq'] |
| 87 | exact hleft (hlmap hu) |
| 88 | · rw [← heq'] |
| 89 | exact hgconf hu |
| 90 | · rw [← heq] |
| 91 | exact hright (hrmap hs) |
| 92 | · have hlvar := affine_variation_le G hC hlip (by simp : (0 : ℝ) ∈ Icc 0 1) ha ha.1 |
| 93 | have hrvar := affine_variation_le G hC hlip hb (by simp : (1 : ℝ) ∈ Icc 0 1) hb.2 |
| 94 | have hgvar' : m64IntrinsicCurveVariation G g 0 1 ≤ ENNReal.ofReal ((b - a) * C) := by |
| 95 | have h := hgvar.trans (hlip a ha b hb) |
| 96 | simpa only [abs_of_nonpos (sub_nonpos.mpr hab), neg_sub, mul_comm] using h |
| 97 | rw [htvar, hqvar] |
| 98 | apply (add_le_add (add_le_add hlvar hgvar') hrvar).trans_eq |
| 99 | rw [← ENNReal.ofReal_add (mul_nonneg (sub_nonneg.mpr ha.1) hC) |
| 100 | (mul_nonneg (sub_nonneg.mpr hab) hC), |
| 101 | ← ENNReal.ofReal_add |
| 102 | (add_nonneg (mul_nonneg (sub_nonneg.mpr ha.1) hC) |
| 103 | (mul_nonneg (sub_nonneg.mpr hab) hC)) |
| 104 | (mul_nonneg (sub_nonneg.mpr hb.2) hC)] |
| 105 | congr 1 |
| 106 | ring |
| 107 | |
| 108 | end PoincareMT |