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.Generalized.BoundedDistance.GeometryImports |
| 2 | import PoincareLib.Geometry.RicciFlow.Generalized.BoundedDistance.Tube.Geometry.FixedWallIntrinsicSegments |
| 3 | import PoincareLib.Geometry.RicciFlow.Generalized.BoundedDistance.Tube.IntrinsicGeometry.IntrinsicMetricSpace |
| 4 | import PoincareLib.Geometry.RicciFlow.Generalized.BoundedDistance.Tube.IntrinsicGeometry.IntrinsicMetricRayRegularity |
| 5 | import Mathlib.Topology.MetricSpace.Completion |
| 6 | import Mathlib.Topology.Order.Compact |
| 7 | |
| 8 | /-! |
| 9 | # Completion-radius barrier from the actual selected back sphere |
| 10 | |
| 11 | The compact central sphere has a positive minimum completion radius. |
| 12 | Every original-region path from its nonpositive side to a high positive |
| 13 | tail crosses this same sphere. The crossing suffix gives the barrier |
| 14 | without completeness or an attained endpoint distance. Exact metric |
| 15 | segments then retain a radius bound at every tested parameter. |
| 16 | Source: Morgan--Tian Lemmas 10.18 and 10.21, pp. 258-259, and |
| 17 | Proposition 10.29, pp. 262-263; M28 derivation 138. |
| 18 | -/ |
| 19 | |
| 20 | set_option autoImplicit false |
| 21 | set_option backward.isDefEq.respectTransparency false |
| 22 | |
| 23 | open Set |
| 24 | open scoped Manifold ContDiff Bundle Topology ENNReal |
| 25 | |
| 26 | universe u |
| 27 | |
| 28 | namespace PoincareMT.M28 |
| 29 | |
| 30 | /-- A metric segment's completion radius is bounded by the sum of its |
| 31 | endpoint radii. This includes degenerate segments and needs neither |
| 32 | smoothness nor completeness of the original metric space. |
| 33 | Source: Lemma 10.16, p. 258; M28 derivation 138. -/ |
| 34 | theorem completion_radius_le_endpoint_sum_of_metric_segment |
| 35 | {Y : Type*} [MetricSpace Y] (E : UniformSpace.Completion Y) |
| 36 | {p q : Y} {gamma : ℝ → Y} (h0 : gamma 0 = p) (h1 : gamma 1 = q) |
| 37 | (hmetric : ∀ s ∈ Icc (0 : ℝ) 1, ∀ t ∈ Icc (0 : ℝ) 1, |
| 38 | dist (gamma s) (gamma t) = |s - t| * dist p q) : |
| 39 | ∀ t ∈ Icc (0 : ℝ) 1, |
| 40 | dist (gamma t : UniformSpace.Completion Y) E ≤ |
| 41 | dist (p : UniformSpace.Completion Y) E + |
| 42 | dist (q : UniformSpace.Completion Y) E := by |
| 43 | intro t ht |
| 44 | have hstart := hmetric 0 (by norm_num) t ht |
| 45 | rw [h0] at hstart |
| 46 | have hstart' : dist p (gamma t) = t * dist p q := by |
| 47 | simpa only [zero_sub, abs_neg, abs_of_nonneg ht.1] using hstart |
| 48 | have hend := hmetric t ht 1 (by norm_num) |
| 49 | rw [h1] at hend |
| 50 | have hend' : dist (gamma t) q = (1 - t) * dist p q := by |
| 51 | simpa only [abs_of_nonpos (sub_nonpos.mpr ht.2), neg_sub] using hend |
| 52 | have hp := dist_triangle (gamma t : UniformSpace.Completion Y) |
| 53 | (p : UniformSpace.Completion Y) E |
| 54 | have hq := dist_triangle (gamma t : UniformSpace.Completion Y) |
| 55 | (q : UniformSpace.Completion Y) E |
| 56 | have hpq := dist_triangle_right (p : UniformSpace.Completion Y) |
| 57 | (q : UniformSpace.Completion Y) E |
| 58 | rw [UniformSpace.Completion.dist_eq, dist_comm (gamma t) p, hstart'] at hp |
| 59 | rw [UniformSpace.Completion.dist_eq, hend'] at hq |
| 60 | rw [UniformSpace.Completion.dist_eq] at hpq |
| 61 | nlinarith |
| 62 | |
| 63 | variable {M : Type u} [TopologicalSpace M] [T2Space M] |
| 64 | [ChartedSpace (EuclideanSpace ℝ (Fin 3)) M] |
| 65 | [IsManifold (𝓡 3) ∞ M] [MeasurableSpace M] [BorelSpace M] [T3Space M] |
| 66 | {g : RiemannianMetric 3 M} {X : Set M} |
| 67 | |
| 68 | /-- The retained selected sphere gives one positive radius threshold, |
| 69 | chosen before all tested endpoints. The minimum and crossing estimates |
| 70 | use the actual original-region metric and literal selected sphere. |
| 71 | Source: Lemmas 10.18 and 10.21, pp. 258-259; M28 derivation 138. -/ |
| 72 | theorem exists_selected_sphere_radius_barrier |
| 73 | (T : EpsilonTubeCertificate g X) (A : OpenCylinderModel T.carrier) |
| 74 | (U : TopologicalSpace.Opens M) (hU : (U : Set M) = A.tail true (1 / 2)) |
| 75 | (i : ℤ) (f : M → ℝ) (hf : ContinuousOn f T.carrier) |
| 76 | (hzero : ∀ x ∈ T.carrier, f x = 0 ↔ x ∈ (T.chain.neck i).central_sphere) |
| 77 | (hNU : (T.chain.neck i).carrier ⊆ (U : Set M)) |
| 78 | {b : ℝ} (hb : b < 1) |
| 79 | (hhigh : ∀ x ∈ T.carrier, b < (A.inverse x).2 → 0 < f x) |
| 80 | (hfinite : ∀ p q : U, intrinsicEDist g (U : Set M) (p : M) (q : M) ≠ ⊤) : |
| 81 | letI := intrinsicOpenMetricSpace g U hfinite |
| 82 | ∀ E : UniformSpace.Completion U, |
| 83 | E ∉ Set.range ((↑) : U → UniformSpace.Completion U) → |
| 84 | (∀ eta : ℝ, 0 < eta → ∃ c : ℝ, 1 / 2 < c ∧ c < 1 ∧ |
| 85 | ∀ x : U, c < (A.inverse x).2 → dist (x : UniformSpace.Completion U) E < eta) → |
| 86 | ∃ alpha : ℝ, 0 < alpha ∧ |
| 87 | (∃ z : U, (z : M) ∈ (T.chain.neck i).central_sphere ∧ |
| 88 | dist (z : UniformSpace.Completion U) E = alpha) ∧ |
| 89 | (∀ z : U, (z : M) ∈ (T.chain.neck i).central_sphere → |
| 90 | alpha ≤ dist (z : UniformSpace.Completion U) E) ∧ |
| 91 | (∀ x q : U, f x ≤ 0 → 0 < f q → |
| 92 | alpha - dist (q : UniformSpace.Completion U) E ≤ dist x q) ∧ |
| 93 | (∀ x : U, f x ≤ 0 → alpha ≤ dist (x : UniformSpace.Completion U) E) ∧ |
| 94 | ∀ x : U, dist (x : UniformSpace.Completion U) E < alpha → 0 < f x := by |
| 95 | classical |
| 96 | let := intrinsicOpenMetricSpace g U hfinite |
| 97 | intro E houtside htail |
| 98 | let r : U → ℝ := fun x => dist (x : UniformSpace.Completion U) E |
| 99 | let gU := intrinsicOpenMetric g U |
| 100 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 3) : U → Type _) := |
| 101 | ⟨gU.toRiemannianMetric⟩ |
| 102 | have hed (x y : U) : gU.edist x y = ENNReal.ofReal (dist x y) := by |
| 103 | change edist x y = _ |
| 104 | exact edist_dist x y |
| 105 | have hUV : (U : Set M) ⊆ T.carrier := by |
| 106 | rw [hU] |
| 107 | exact A.tail_subset_m28 true (by norm_num) (by norm_num) |
| 108 | have hcontinuous : Continuous r := |
| 109 | (UniformSpace.Completion.continuous_coe U).dist continuous_const |
| 110 | have hpositive (x : U) : 0 < r x := |
| 111 | dist_pos.mpr fun hx => houtside ⟨x, hx⟩ |
| 112 | have htriangle (x y : U) : |
| 113 | |r x - r y| ≤ dist x y ∧ dist x y ≤ r x + r y := by |
| 114 | constructor |
| 115 | · simpa only [UniformSpace.Completion.dist_eq] using |
| 116 | abs_dist_sub_le (x : UniformSpace.Completion U) (y : UniformSpace.Completion U) E |
| 117 | · simpa only [UniformSpace.Completion.dist_eq] using |
| 118 | dist_triangle_right (x : UniformSpace.Completion U) (y : UniformSpace.Completion U) E |
| 119 | let S : Set U := (Subtype.val : U → M) ⁻¹' (T.chain.neck i).central_sphere |
| 120 | let center : U := ⟨(T.chain.neck i).center, |
| 121 | hNU ((T.chain.neck i).central_sphere_subset (T.chain.neck i).center_on_central_sphere)⟩ |
| 122 | have hSnonempty : S.Nonempty := ⟨center, (T.chain.neck i).center_on_central_sphere⟩ |
| 123 | have hScompact : IsCompact S := |
| 124 | Topology.IsEmbedding.subtypeVal.isInducing.isCompact_preimage' |
| 125 | (T.chain.neck i).isCompact_central_sphere |
| 126 | (fun z hz => ⟨⟨z, hNU ((T.chain.neck i).central_sphere_subset hz)⟩, rfl⟩) |
| 127 | obtain ⟨z0, hz0, hminimum⟩ := hScompact.exists_isMinOn hSnonempty hcontinuous.continuousOn |
| 128 | let alpha : ℝ := r z0 |
| 129 | have hmin (z : U) (hz : z ∈ S) : alpha ≤ r z := hminimum hz |
| 130 | have hcrossBound (x q : U) (hx : f x ≤ 0) (hq : 0 < f q) : |
| 131 | alpha - r q ≤ dist x q := by |
| 132 | apply le_of_not_gt |
| 133 | intro hbad |
| 134 | have hcost : 0 < alpha - r q := lt_of_le_of_lt dist_nonneg hbad |
| 135 | have hdist : gU.edist x q < ENNReal.ofReal (alpha - r q) := by |
| 136 | rw [hed] |
| 137 | exact (ENNReal.ofReal_lt_ofReal_iff hcost).mpr hbad |
| 138 | obtain ⟨gamma, h0, h1, hgamma, hlength⟩ := |
| 139 | Manifold.exists_lt_of_riemannianEDist_lt hdist |
| 140 | have hheight : ContinuousOn (fun t => f (gamma t)) (Icc (0 : ℝ) 1) := |
| 141 | hf.comp (continuous_subtype_val.comp_continuousOn hgamma.continuousOn) |
| 142 | (fun t (_ : t ∈ Icc (0 : ℝ) 1) => hUV (gamma t).property) |
| 143 | obtain ⟨t, ht, hft⟩ := intermediate_value_Icc zero_le_one hheight |
| 144 | (show 0 ∈ Icc (f (gamma 0)) (f (gamma 1)) from |
| 145 | ⟨by simpa only [h0] using hx, by simpa only [h1] using hq.le⟩) |
| 146 | have htS : gamma t ∈ S := |
| 147 | (hzero (gamma t) (hUV (gamma t).property)).mp hft |
| 148 | have hradius := (le_abs_self (r (gamma t) - r q)).trans (htriangle (gamma t) q).1 |
| 149 | have hescape : ENNReal.ofReal (alpha - r q) ≤ gU.edist (gamma t) q := by |
| 150 | rw [hed] |
| 151 | exact ENNReal.ofReal_le_ofReal (by linarith [hmin (gamma t) htS]) |
| 152 | have hsuffix : gU.edist (gamma t) q ≤ gU.pathELength gamma t 1 := |
| 153 | Manifold.riemannianEDist_le_pathELength |
| 154 | (hgamma.mono (Icc_subset_Icc ht.1 le_rfl)) rfl h1 ht.2 |
| 155 | have htotal : gU.pathELength gamma t 1 ≤ gU.pathELength gamma 0 1 := |
| 156 | Manifold.pathELength_mono ht.1 le_rfl |
| 157 | exact (not_lt_of_ge (hescape.trans (hsuffix.trans htotal))) hlength |
| 158 | have hbarrier (x : U) (hx : f x ≤ 0) : alpha ≤ r x := by |
| 159 | apply le_of_not_gt |
| 160 | intro hsmallx |
| 161 | obtain ⟨c, _hchalf, hc1, hdecay⟩ := htail ((alpha - r x) / 4) (by linarith) |
| 162 | let d : ℝ := max (max b c) (3 / 4 : ℝ) |
| 163 | have hdpos : 0 < d := lt_max_of_lt_right (by norm_num) |
| 164 | have hd1 : d < 1 := max_lt (max_lt hb hc1) (by norm_num) |
| 165 | obtain ⟨q0, hq0⟩ := A.tail_nonempty true hdpos hd1 |
| 166 | have hqread := (A.mem_tail_iff_m28 true hdpos hd1).mp hq0 |
| 167 | have hqU : q0 ∈ (U : Set M) := by |
| 168 | rw [hU] |
| 169 | exact (A.mem_tail_iff_m28 true (by norm_num) (by norm_num)).mpr |
| 170 | ⟨hqread.1, (by norm_num : (1 / 2 : ℝ) < 3 / 4).trans |
| 171 | ((le_max_right _ _).trans_lt hqread.2)⟩ |
| 172 | let q : U := ⟨q0, hqU⟩ |
| 173 | have hqb : b < (A.inverse q).2 := |
| 174 | ((le_max_left _ _).trans (le_max_left _ _)).trans_lt hqread.2 |
| 175 | have hqc : c < (A.inverse q).2 := |
| 176 | ((le_max_right _ _).trans (le_max_left _ _)).trans_lt hqread.2 |
| 177 | have hqpositive : 0 < f q := hhigh q (hUV q.property) hqb |
| 178 | have hqsmall : r q < (alpha - r x) / 4 := hdecay q hqc |
| 179 | have hcross := hcrossBound x q hx hqpositive |
| 180 | have hupper := (htriangle x q).2 |
| 181 | linarith |
| 182 | refine ⟨alpha, hpositive z0, ⟨z0, hz0, rfl⟩, hmin, hcrossBound, hbarrier, ?_⟩ |
| 183 | intro x hx |
| 184 | exact lt_of_not_ge fun hfx => (not_le_of_gt hx) (hbarrier x hfx) |
| 185 | |
| 186 | omit [MeasurableSpace M] [BorelSpace M] [T3Space M] in |
| 187 | /-- The same retained fixed-wall provider supplies actual segments |
| 188 | between all points below its radius barrier, with real-distance and |
| 189 | radius readouts on the unchanged intrinsic metric. |
| 190 | Source: Lemma 10.21, p. 259; M28 derivation 138. -/ |
| 191 | theorem exists_intrinsic_segment_below_completion_radius_barrier |
| 192 | (T : EpsilonTubeCertificate g X) (A : OpenCylinderModel T.carrier) |
| 193 | (U : TopologicalSpace.Opens M) (f : M → ℝ) |
| 194 | (hfinite : ∀ p q : U, intrinsicEDist g (U : Set M) (p : M) (q : M) ≠ ⊤) : |
| 195 | letI := intrinsicOpenMetricSpace g U hfinite |
| 196 | ∀ (E : UniformSpace.Completion U) (alpha : ℝ), |
| 197 | (∀ x : U, dist (x : UniformSpace.Completion U) E < alpha → 0 < f x) → |
| 198 | (∀ p q : U, 0 < f p → 0 < f q → |
| 199 | ∃ mu : ℝ → U, mu 0 = p ∧ mu 1 = q ∧ Continuous mu ∧ |
| 200 | (∀ t : ℝ, (3 / 4 : ℝ) ≤ (A.inverse (mu t)).2) ∧ |
| 201 | ∀ s ∈ Icc (0 : ℝ) 1, ∀ t ∈ Icc (0 : ℝ) 1, |
| 202 | (intrinsicOpenMetric g U).edist (mu s) (mu t) = |
| 203 | ENNReal.ofReal |s - t| * (intrinsicOpenMetric g U).edist p q) → |
| 204 | ∀ p q : U, |
| 205 | dist (p : UniformSpace.Completion U) E < alpha → |
| 206 | dist (q : UniformSpace.Completion U) E < alpha → |
| 207 | ∃ mu : ℝ → U, mu 0 = p ∧ mu 1 = q ∧ Continuous mu ∧ |
| 208 | (∀ t : ℝ, (3 / 4 : ℝ) ≤ (A.inverse (mu t)).2) ∧ |
| 209 | (∀ s ∈ Icc (0 : ℝ) 1, ∀ t ∈ Icc (0 : ℝ) 1, |
| 210 | dist (mu s) (mu t) = |s - t| * dist p q) ∧ |
| 211 | ∀ t ∈ Icc (0 : ℝ) 1, |
| 212 | dist (mu t : UniformSpace.Completion U) E ≤ |
| 213 | dist (p : UniformSpace.Completion U) E + |
| 214 | dist (q : UniformSpace.Completion U) E := by |
| 215 | let := intrinsicOpenMetricSpace g U hfinite |
| 216 | intro E alpha hbarrier hsegments p q hp hq |
| 217 | obtain ⟨mu, h0, h1, hcontinuous, hlower, hmetric⟩ := |
| 218 | hsegments p q (hbarrier p hp) (hbarrier q hq) |
| 219 | let gU := intrinsicOpenMetric g U |
| 220 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 3) : U → Type _) := |
| 221 | ⟨gU.toRiemannianMetric⟩ |
| 222 | have hed (x y : U) : gU.edist x y = ENNReal.ofReal (dist x y) := by |
| 223 | change edist x y = _ |
| 224 | exact edist_dist x y |
| 225 | have hreal (s : ℝ) (hs : s ∈ Icc (0 : ℝ) 1) |
| 226 | (t : ℝ) (ht : t ∈ Icc (0 : ℝ) 1) : |
| 227 | dist (mu s) (mu t) = |s - t| * dist p q := by |
| 228 | have h := hmetric s hs t ht |
| 229 | rw [hed, hed, ← ENNReal.ofReal_mul (abs_nonneg (s - t))] at h |
| 230 | exact (ENNReal.ofReal_eq_ofReal_iff dist_nonneg |
| 231 | (mul_nonneg (abs_nonneg _) dist_nonneg)).mp h |
| 232 | exact ⟨mu, h0, h1, hcontinuous, hlower, hreal, |
| 233 | completion_radius_le_endpoint_sum_of_metric_segment E h0 h1 hreal⟩ |
| 234 | |
| 235 | omit [MeasurableSpace M] [BorelSpace M] [T3Space M] in |
| 236 | /-- The same fixed-wall provider gives actual affine smooth cross-segments |
| 237 | at every pair below its radius barrier, including coincident endpoints. |
| 238 | All tested points, heights and radius bounds are retained. This is the |
| 239 | closed cross-pair supplier for Lemma 10.21, p. 259; derivation 147. -/ |
| 240 | theorem exists_smooth_intrinsic_segment_below_completion_radius_barrier |
| 241 | (T : EpsilonTubeCertificate g X) (A : OpenCylinderModel T.carrier) |
| 242 | (U : TopologicalSpace.Opens M) (f : M → ℝ) |
| 243 | (hfinite : ∀ p q : U, intrinsicEDist g (U : Set M) (p : M) (q : M) ≠ ⊤) : |
| 244 | letI := intrinsicOpenMetricSpace g U hfinite |
| 245 | ∀ (E : UniformSpace.Completion U) (alpha : ℝ), |
| 246 | (∀ x : U, dist (x : UniformSpace.Completion U) E < alpha → 0 < f x) → |
| 247 | (∀ p q : U, 0 < f p → 0 < f q → |
| 248 | ∃ mu : ℝ → U, mu 0 = p ∧ mu 1 = q ∧ Continuous mu ∧ |
| 249 | (∀ t : ℝ, (3 / 4 : ℝ) ≤ (A.inverse (mu t)).2) ∧ |
| 250 | ∀ s ∈ Icc (0 : ℝ) 1, ∀ t ∈ Icc (0 : ℝ) 1, |
| 251 | (intrinsicOpenMetric g U).edist (mu s) (mu t) = |
| 252 | ENNReal.ofReal |s - t| * (intrinsicOpenMetric g U).edist p q) → |
| 253 | ∀ p q : U, |
| 254 | dist (p : UniformSpace.Completion U) E < alpha → |
| 255 | dist (q : UniformSpace.Completion U) E < alpha → |
| 256 | ∃ nu : ℝ → U, nu 0 = p ∧ nu 1 = q ∧ |
| 257 | (intrinsicOpenMetric g U).IsGeodesicOn nu (Icc 0 1) ∧ |
| 258 | ContMDiffOn 𝓘(ℝ, ℝ) (𝓡 3) ∞ nu (Icc 0 1) ∧ |
| 259 | (∀ t ∈ Icc (0 : ℝ) 1, (3 / 4 : ℝ) ≤ (A.inverse (nu t)).2) ∧ |
| 260 | (∀ s ∈ Icc (0 : ℝ) 1, ∀ t ∈ Icc (0 : ℝ) 1, |
| 261 | (intrinsicOpenMetric g U).edist (nu s) (nu t) = ENNReal.ofReal |
| 262 | (|s - t| * ((intrinsicOpenMetric g U).edist p q).toReal)) ∧ |
| 263 | ∀ t ∈ Icc (0 : ℝ) 1, |
| 264 | dist (nu t : UniformSpace.Completion U) E ≤ |
| 265 | dist (p : UniformSpace.Completion U) E + |
| 266 | dist (q : UniformSpace.Completion U) E := by |
| 267 | let := intrinsicOpenMetricSpace g U hfinite |
| 268 | intro E alpha hbarrier hsegments p q hp hq |
| 269 | have hedist (x y : U) : |
| 270 | (intrinsicOpenMetric g U).edist x y = ENNReal.ofReal (dist x y) := by |
| 271 | rw [intrinsicOpenMetric_edist, ← intrinsicOpenMetricSpace_edist g U hfinite, |
| 272 | edist_dist] |
| 273 | obtain ⟨mu, h0, h1, hcontinuous, hlower, hmetric, hradius⟩ := |
| 274 | exists_intrinsic_segment_below_completion_radius_barrier |
| 275 | T A U f hfinite E alpha hbarrier hsegments p q hp hq |
| 276 | obtain ⟨nu, hnu, heq, hsmooth⟩ := |
| 277 | exists_geodesic_eq_intrinsic_unit_metric_segment g U hfinite |
| 278 | (L := dist p q) dist_nonneg hcontinuous.continuousOn hmetric |
| 279 | refine ⟨nu, (heq (by norm_num)).trans h0, (heq (by norm_num)).trans h1, |
| 280 | hnu, hsmooth, ?_, ?_, ?_⟩ |
| 281 | · intro t ht |
| 282 | rw [heq ht] |
| 283 | exact hlower t |
| 284 | · intro s hs t ht |
| 285 | rw [heq hs, heq ht, hedist, hedist, |
| 286 | ENNReal.toReal_ofReal dist_nonneg, hmetric s hs t ht] |
| 287 | · intro t ht |
| 288 | rw [heq ht] |
| 289 | exact hradius t ht |
| 290 | |
| 291 | end PoincareMT.M28 |