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.RicciFlow.Surgery.Metric.Distance.MetricComparison |
| 2 | import Mathlib.Topology.Order.Compact |
| 3 | |
| 4 | /-! |
| 5 | # Path comparison across a collapsed tail |
| 6 | |
| 7 | The first and last times at the tip split a continuous collapsed path |
| 8 | into two smooth portions. Their endpoint distance bounds extend by |
| 9 | continuity, without assuming differentiability of the collapse at the |
| 10 | tail boundary. This supplies the path argument in Claim 13.1, p.332. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | |
| 15 | open scoped Manifold ContDiff ENNReal Topology |
| 16 | |
| 17 | universe u v |
| 18 | |
| 19 | namespace PoincareMT.MetricSurgery |
| 20 | |
| 21 | variable {X : Type u} {Y : Type v} [TopologicalSpace X] [TopologicalSpace Y] |
| 22 | [ChartedSpace (EuclideanSpace ℝ (Fin 3)) X] |
| 23 | [ChartedSpace (EuclideanSpace ℝ (Fin 3)) Y] |
| 24 | [IsManifold (𝓡 3) ∞ X] [IsManifold (𝓡 3) ∞ Y] [T3Space Y] |
| 25 | |
| 26 | theorem edist_le_pathELength_of_avoiding_tip (g : RiemannianMetric 3 X) |
| 27 | (h : RiemannianMetric 3 Y) (gamma : ℝ → X) (z : ℝ → Y) (tip : Y) |
| 28 | {a b : ℝ} (hab : a ≤ b) (hz : ContinuousOn z (Set.Icc a b)) |
| 29 | (hsegment : ∀ c d : ℝ, a ≤ c → c ≤ d → d ≤ b → |
| 30 | (∀ t ∈ Set.Icc c d, z t ≠ tip) → |
| 31 | h.edist (z c) (z d) ≤ g.pathELength gamma c d) : |
| 32 | h.edist (z a) (z b) ≤ g.pathELength gamma a b := by |
| 33 | let Z : Set ℝ := Set.Icc a b ∩ z ⁻¹' {tip} |
| 34 | by_cases hZ : Z.Nonempty |
| 35 | · have hcompact : IsCompact Z := isCompact_Icc.of_isClosed_subset |
| 36 | (hz.preimage_isClosed_of_isClosed isClosed_Icc isClosed_singleton) Set.inter_subset_left |
| 37 | obtain ⟨c, hc, hmin⟩ := hcompact.exists_isLeast hZ |
| 38 | obtain ⟨d, hd, hmax⟩ := hcompact.exists_isGreatest hZ |
| 39 | have hac : a ≤ c := hc.1.1 |
| 40 | have hcb : c ≤ b := hc.1.2 |
| 41 | have had : a ≤ d := hd.1.1 |
| 42 | have hdb : d ≤ b := hd.1.2 |
| 43 | have hcd : c ≤ d := hmin hd |
| 44 | have hctip : z c = tip := hc.2 |
| 45 | have hdtip : z d = tip := hd.2 |
| 46 | have hprefix : h.edist (z a) tip ≤ g.pathELength gamma a c := by |
| 47 | by_cases hacEq : a = c |
| 48 | · rw [hacEq, hctip, metric_edist_self] |
| 49 | exact bot_le |
| 50 | have hbound : ∀ t ∈ Set.Ico a c, |
| 51 | h.edist (z a) (z t) ≤ g.pathELength gamma a c := by |
| 52 | intro t ht |
| 53 | have havoid : ∀ s ∈ Set.Icc a t, z s ≠ tip := by |
| 54 | intro s hs heq |
| 55 | have hcs : c ≤ s := hmin ⟨⟨hs.1, hs.2.trans (ht.2.le.trans hcb)⟩, heq⟩ |
| 56 | exact (not_lt_of_ge hcs) (hs.2.trans_lt ht.2) |
| 57 | exact (hsegment a t le_rfl ht.1 (ht.2.le.trans hcb) havoid).trans |
| 58 | (metric_pathELength_mono g gamma le_rfl ht.2.le) |
| 59 | have hcont : ContinuousOn (fun t => h.edist (z a) (z t)) (Set.Icc a c) := |
| 60 | (metric_edist_continuous h).comp_continuousOn |
| 61 | (continuousOn_const.prodMk (hz.mono (Set.Icc_subset_Icc le_rfl hcb))) |
| 62 | have hlim := le_on_closure hbound |
| 63 | (by simpa only [closure_Ico hacEq] using hcont) continuousOn_const |
| 64 | (x := c) (by rw [closure_Ico hacEq]; exact ⟨hac, le_rfl⟩) |
| 65 | simpa only [hctip] using hlim |
| 66 | have hsuffix : h.edist tip (z b) ≤ g.pathELength gamma d b := by |
| 67 | by_cases hdbEq : d = b |
| 68 | · rw [← hdbEq, hdtip, metric_edist_self] |
| 69 | exact bot_le |
| 70 | have hbound : ∀ t ∈ Set.Ioc d b, |
| 71 | h.edist (z t) (z b) ≤ g.pathELength gamma d b := by |
| 72 | intro t ht |
| 73 | have havoid : ∀ s ∈ Set.Icc t b, z s ≠ tip := by |
| 74 | intro s hs heq |
| 75 | have hsd : s ≤ d := hmax ⟨⟨had.trans (ht.1.le.trans hs.1), hs.2⟩, heq⟩ |
| 76 | exact (not_lt_of_ge hsd) (ht.1.trans_le hs.1) |
| 77 | exact (hsegment t b (had.trans ht.1.le) ht.2 le_rfl havoid).trans |
| 78 | (metric_pathELength_mono g gamma ht.1.le le_rfl) |
| 79 | have hcont : ContinuousOn (fun t => h.edist (z t) (z b)) (Set.Icc d b) := |
| 80 | (metric_edist_continuous h).comp_continuousOn |
| 81 | ((hz.mono (Set.Icc_subset_Icc had le_rfl)).prodMk continuousOn_const) |
| 82 | have hlim := le_on_closure hbound |
| 83 | (by simpa only [closure_Ioc hdbEq] using hcont) continuousOn_const |
| 84 | (x := d) (by rw [closure_Ioc hdbEq]; exact ⟨le_rfl, hdb⟩) |
| 85 | simpa only [hdtip] using hlim |
| 86 | calc |
| 87 | h.edist (z a) (z b) ≤ h.edist (z a) tip + h.edist tip (z b) := |
| 88 | metric_edist_triangle h _ _ _ |
| 89 | _ ≤ g.pathELength gamma a c + g.pathELength gamma d b := add_le_add hprefix hsuffix |
| 90 | _ ≤ g.pathELength gamma a d + g.pathELength gamma d b := |
| 91 | add_le_add (metric_pathELength_mono g gamma le_rfl hcd) le_rfl |
| 92 | _ = g.pathELength gamma a b := metric_pathELength_add g gamma had hdb |
| 93 | · apply hsegment a b le_rfl hab le_rfl |
| 94 | intro t ht heq |
| 95 | exact hZ ⟨t, ht, heq⟩ |
| 96 | |
| 97 | theorem edist_comp_le_pathELength_off_tip (g : RiemannianMetric 3 X) |
| 98 | (h : RiemannianMetric 3 Y) {f : X → Y} {U : Set X} (tip : Y) |
| 99 | (hf : ContinuousOn f U) |
| 100 | (hsmooth : ∀ x ∈ U, f x ≠ tip → ContMDiffAt (𝓡 3) (𝓡 3) ∞ f x) |
| 101 | (hmetric : ∀ x ∈ U, f x ≠ tip → ∀ v : TangentSpace (𝓡 3) x, |
| 102 | h.inner (f x) (mfderiv (𝓡 3) (𝓡 3) f x v) (mfderiv (𝓡 3) (𝓡 3) f x v) ≤ |
| 103 | g.inner x v v) |
| 104 | {gamma : ℝ → X} {a b : ℝ} (hab : a ≤ b) |
| 105 | (hgamma : ContMDiffOn 𝓘(ℝ, ℝ) (𝓡 3) 1 gamma (Set.Icc a b)) |
| 106 | (hU : gamma '' Set.Icc a b ⊆ U) : |
| 107 | h.edist (f (gamma a)) (f (gamma b)) ≤ g.pathELength gamma a b := by |
| 108 | apply edist_le_pathELength_of_avoiding_tip g h gamma (f ∘ gamma) tip hab |
| 109 | (hf.comp hgamma.continuousOn (Set.mapsTo_iff_image_subset.mpr hU)) |
| 110 | intro c d hac hcd hdb havoid |
| 111 | let V : Set X := U ∩ {x | f x ≠ tip} |
| 112 | apply edist_comp_le_pathELength_of_pullback_bound g h |
| 113 | (U := V) (fun x hx => hsmooth x hx.1 hx.2) (fun x hx => hmetric x hx.1 hx.2) |
| 114 | hcd (hgamma.mono (Set.Icc_subset_Icc hac hdb)) |
| 115 | rintro _ ⟨t, ht, rfl⟩ |
| 116 | exact ⟨hU ⟨t, ⟨hac.trans ht.1, ht.2.trans hdb⟩, rfl⟩, havoid t ht⟩ |
| 117 | |
| 118 | theorem edist_le_intrinsicEDist_off_tip (g : RiemannianMetric 3 X) |
| 119 | (h : RiemannianMetric 3 Y) {f : X → Y} {U : Set X} (tip : Y) |
| 120 | (hf : ContinuousOn f U) |
| 121 | (hsmooth : ∀ x ∈ U, f x ≠ tip → ContMDiffAt (𝓡 3) (𝓡 3) ∞ f x) |
| 122 | (hmetric : ∀ x ∈ U, f x ≠ tip → ∀ v : TangentSpace (𝓡 3) x, |
| 123 | h.inner (f x) (mfderiv (𝓡 3) (𝓡 3) f x v) (mfderiv (𝓡 3) (𝓡 3) f x v) ≤ |
| 124 | g.inner x v v) (x y : X) : |
| 125 | h.edist (f x) (f y) ≤ intrinsicEDist g U x y := by |
| 126 | apply le_sInf |
| 127 | rintro L ⟨gamma, hgamma, hzero, hone, hU, rfl⟩ |
| 128 | have hle := edist_comp_le_pathELength_off_tip g h tip hf hsmooth hmetric zero_le_one hgamma hU |
| 129 | simpa only [hzero, hone] using hle |
| 130 | |
| 131 | end PoincareMT.MetricSurgery |