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.Analysis.Coordinates.MetricEndRayEndpoint |
| 3 | import PoincareLib.Geometry.RicciFlow.Generalized.BoundedDistance.Analysis.Geometry.ChordConeDistanceScaling |
| 4 | import PoincareLib.Geometry.RicciFlow.Generalized.BoundedDistance.Cone.Geometry.ChordConeAnnulus |
| 5 | import Mathlib.Order.Filter.Finite |
| 6 | |
| 7 | /-! |
| 8 | # Uniform annular distortion from actual finite end rays |
| 9 | |
| 10 | A finite realized net is chosen before the scale and any moving ray |
| 11 | data. The endpoint comparison transfers that net to the source, and |
| 12 | fixed-pair limits then bound the distortion for every tested datum. |
| 13 | Source: Morgan--Tian Proposition 10.29, pp. 262-263; derivation 158. |
| 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 |
| 22 | |
| 23 | universe u |
| 24 | |
| 25 | namespace PoincareMT.M28 |
| 26 | |
| 27 | variable {X : Type u} [MetricSpace X] |
| 28 | {E : UniformSpace.Completion X} {alpha : ℝ} |
| 29 | [PseudoMetricSpace (MetricEndRay E alpha)] |
| 30 | |
| 31 | /-- A literal finite ray and a closed annular radius determine a point |
| 32 | of the completed chord annulus. Source: Proposition 10.29; derivation 158. -/ |
| 33 | def metricEndRayAnnularPoint {a b : ℝ} (P : MetricEndRay E alpha) |
| 34 | (s : Icc a b) : |
| 35 | ChordConeAnnulus (UniformSpace.Completion (MetricEndRay E alpha)) a b := |
| 36 | ((P : UniformSpace.Completion (MetricEndRay E alpha)), s) |
| 37 | |
| 38 | section Annulus |
| 39 | |
| 40 | variable {a b : ℝ} (ha : 0 < a) (hab : a ≤ b) |
| 41 | (htriangle : ∀ x y z : UniformSpace.Completion (MetricEndRay E alpha), |
| 42 | ∀ r s t : ℝ, 0 < r → 0 < s → 0 < t → |
| 43 | chordConeDistance r t (dist x z) ≤ |
| 44 | chordConeDistance r s (dist x y) + chordConeDistance s t (dist y z)) |
| 45 | |
| 46 | /-- Realized annular points retain the ray pseudometric in the exact |
| 47 | cone formula. Source: Proposition 10.29; derivation 158. -/ |
| 48 | theorem metricEndRayAnnularPoint_dist |
| 49 | (P Q : MetricEndRay E alpha) (s t : Icc a b) : |
| 50 | letI := chordConeAnnulusMetric ha hab htriangle |
| 51 | dist (metricEndRayAnnularPoint P s) (metricEndRayAnnularPoint Q t) = |
| 52 | chordConeDistance s t (dist P Q) := by |
| 53 | let := chordConeAnnulusMetric ha hab htriangle |
| 54 | rw [chordConeAnnulus_dist_eq ha hab htriangle] |
| 55 | simp only [metricEndRayAnnularPoint, UniformSpace.Completion.dist_eq] |
| 56 | |
| 57 | /-- Included endpoint comparison and homogeneity give the source-to-cone |
| 58 | distance bound for every tested pair, including moving data. |
| 59 | Source: Proposition 10.29; derivation 158. -/ |
| 60 | theorem metricEndRay_annular_scaled_dist_le |
| 61 | (hupper : ∀ P Q : MetricEndRay E alpha, |
| 62 | ∀ s ∈ Ioo (0 : ℝ) P.length, ∀ t ∈ Ioo (0 : ℝ) Q.length, |
| 63 | chordDefect (fun u v => dist (P.point u) (Q.point v)) s t ≤ dist P Q ^ 2) |
| 64 | (P Q : MetricEndRay E alpha) (s t : Icc a b) {h : ℝ} |
| 65 | (hh : 0 < h) (hP : h * (s : ℝ) ≤ P.length) |
| 66 | (hQ : h * (t : ℝ) ≤ Q.length) : |
| 67 | letI := chordConeAnnulusMetric ha hab htriangle |
| 68 | dist (P.point (h * s)) (Q.point (h * t)) / h ≤ |
| 69 | dist (metricEndRayAnnularPoint P s) (metricEndRayAnnularPoint Q t) := by |
| 70 | let := chordConeAnnulusMetric ha hab htriangle |
| 71 | have hs : h * (s : ℝ) ∈ Ioc (0 : ℝ) P.length := |
| 72 | ⟨mul_pos hh (ha.trans_le s.property.1), hP⟩ |
| 73 | have ht : h * (t : ℝ) ∈ Ioc (0 : ℝ) Q.length := |
| 74 | ⟨mul_pos hh (ha.trans_le t.property.1), hQ⟩ |
| 75 | have hb := P.dist_le_chordConeDistance Q (hupper P Q) |
| 76 | (h * s) hs (h * t) ht |
| 77 | rw [chordConeDistance_mul h hh.le] at hb |
| 78 | rw [metricEndRayAnnularPoint_dist ha hab htriangle] |
| 79 | exact (div_le_iff₀ hh).mpr (by simpa only [mul_comm] using hb) |
| 80 | |
| 81 | /-- Compactness and density provide a finite net with actual finite-ray |
| 82 | labels chosen before the scale. Source: Proposition 10.29; derivation 158. -/ |
| 83 | theorem exists_finite_metricEndRay_annular_net |
| 84 | [CompactSpace (UniformSpace.Completion (MetricEndRay E alpha))] |
| 85 | (epsilon : ℝ) (hepsilon : 0 < epsilon) : |
| 86 | letI := chordConeAnnulusMetric ha hab htriangle |
| 87 | ∃ F : Finset (MetricEndRay E alpha × Icc a b), |
| 88 | ∀ z : ChordConeAnnulus (UniformSpace.Completion (MetricEndRay E alpha)) a b, |
| 89 | ∃ i ∈ F, dist z (metricEndRayAnnularPoint i.1 i.2) < epsilon := by |
| 90 | classical |
| 91 | let := chordConeAnnulusMetric ha hab htriangle |
| 92 | let : CompactSpace (ChordConeAnnulus |
| 93 | (UniformSpace.Completion (MetricEndRay E alpha)) a b) := chordConeAnnulus_compact |
| 94 | have hdense : DenseRange (fun i : MetricEndRay E alpha × Icc a b => |
| 95 | metricEndRayAnnularPoint i.1 i.2) := by |
| 96 | change DenseRange (Prod.map |
| 97 | ((↑) : MetricEndRay E alpha → |
| 98 | UniformSpace.Completion (MetricEndRay E alpha)) (id : Icc a b → Icc a b)) |
| 99 | exact UniformSpace.Completion.denseRange_coe.prodMap denseRange_id |
| 100 | let O (i : MetricEndRay E alpha × Icc a b) := |
| 101 | Metric.ball (metricEndRayAnnularPoint i.1 i.2) epsilon |
| 102 | have hcover : (univ : Set (ChordConeAnnulus |
| 103 | (UniformSpace.Completion (MetricEndRay E alpha)) a b)) ⊆ ⋃ i, O i := by |
| 104 | intro z _hz |
| 105 | obtain ⟨i, hi⟩ := hdense.exists_dist_lt z hepsilon |
| 106 | exact mem_iUnion.mpr ⟨i, hi⟩ |
| 107 | obtain ⟨F, hF⟩ := isCompact_univ.elim_finite_subcover O |
| 108 | (fun _ => Metric.isOpen_ball) hcover |
| 109 | refine ⟨F, fun z => ?_⟩ |
| 110 | obtain ⟨i, hi, hzi⟩ := mem_iUnion₂.mp (hF (mem_univ z)) |
| 111 | exact ⟨i, hi, hzi⟩ |
| 112 | |
| 113 | /-- Fixed-pair limits and the global endpoint bound give distortion |
| 114 | tending to zero uniformly over every tested pair of ray data and closed |
| 115 | annular radii. Source: Proposition 10.29; derivation 158. -/ |
| 116 | theorem eventually_metricEndRay_annular_distortion |
| 117 | [CompactSpace (UniformSpace.Completion (MetricEndRay E alpha))] |
| 118 | (hupper : ∀ P Q : MetricEndRay E alpha, |
| 119 | ∀ s ∈ Ioo (0 : ℝ) P.length, ∀ t ∈ Ioo (0 : ℝ) Q.length, |
| 120 | chordDefect (fun u v => dist (P.point u) (Q.point v)) s t ≤ dist P Q ^ 2) |
| 121 | (hscaled : ∀ P Q : MetricEndRay E alpha, ∀ r s : ℝ, 0 < r → 0 < s → Tendsto |
| 122 | (fun h : ℝ => dist (P.point (h * r)) (Q.point (h * s)) / h) |
| 123 | (𝓝[>] (0 : ℝ)) (𝓝 (chordConeDistance r s (dist P Q)))) : |
| 124 | letI := chordConeAnnulusMetric ha hab htriangle |
| 125 | ∀ eta : ℝ, 0 < eta → ∀ᶠ h : ℝ in 𝓝[>] (0 : ℝ), |
| 126 | ∀ P Q : MetricEndRay E alpha, ∀ s t : Icc a b, |
| 127 | h * (s : ℝ) ≤ P.length → h * (t : ℝ) ≤ Q.length → |
| 128 | 0 ≤ dist (metricEndRayAnnularPoint P s) (metricEndRayAnnularPoint Q t) - |
| 129 | dist (P.point (h * s)) (Q.point (h * t)) / h ∧ |
| 130 | dist (metricEndRayAnnularPoint P s) (metricEndRayAnnularPoint Q t) - |
| 131 | dist (P.point (h * s)) (Q.point (h * t)) / h < eta := by |
| 132 | classical |
| 133 | let := chordConeAnnulusMetric ha hab htriangle |
| 134 | intro eta heta |
| 135 | let epsilon := eta / 8 |
| 136 | have hepsilon : 0 < epsilon := div_pos heta (by norm_num) |
| 137 | obtain ⟨F, hF⟩ := exists_finite_metricEndRay_annular_net |
| 138 | ha hab htriangle epsilon hepsilon |
| 139 | have hid : Tendsto (fun h : ℝ => h) (𝓝[>] (0 : ℝ)) (𝓝 (0 : ℝ)) := |
| 140 | tendsto_nhds_of_tendsto_nhdsWithin tendsto_id |
| 141 | have hlength : ∀ᶠ h : ℝ in 𝓝[>] (0 : ℝ), |
| 142 | ∀ i ∈ F, h * b < i.1.length := by |
| 143 | apply F.eventually_all.mpr |
| 144 | intro i _hi |
| 145 | have hmul : Tendsto (fun h : ℝ => h * b) |
| 146 | (𝓝[>] (0 : ℝ)) (𝓝 (0 : ℝ)) := by |
| 147 | simpa only [zero_mul] using hid.mul_const b |
| 148 | exact hmul.eventually (Iio_mem_nhds i.1.length_pos) |
| 149 | have hpairs : ∀ᶠ h : ℝ in 𝓝[>] (0 : ℝ), |
| 150 | ∀ i ∈ F, ∀ j ∈ F, |
| 151 | dist (metricEndRayAnnularPoint i.1 i.2) (metricEndRayAnnularPoint j.1 j.2) < |
| 152 | dist (i.1.point (h * i.2)) (j.1.point (h * j.2)) / h + epsilon := by |
| 153 | apply F.eventually_all.mpr |
| 154 | intro i _hi |
| 155 | apply F.eventually_all.mpr |
| 156 | intro j _hj |
| 157 | have hij : Tendsto |
| 158 | (fun h : ℝ => dist (i.1.point (h * i.2)) (j.1.point (h * j.2)) / h) |
| 159 | (𝓝[>] (0 : ℝ)) |
| 160 | (𝓝 (dist (metricEndRayAnnularPoint i.1 i.2) |
| 161 | (metricEndRayAnnularPoint j.1 j.2))) := by |
| 162 | rw [metricEndRayAnnularPoint_dist ha hab htriangle] |
| 163 | exact hscaled i.1 j.1 i.2 j.2 |
| 164 | (ha.trans_le i.2.property.1) (ha.trans_le j.2.property.1) |
| 165 | filter_upwards [hij.eventually (Ioi_mem_nhds |
| 166 | (show dist (metricEndRayAnnularPoint i.1 i.2) |
| 167 | (metricEndRayAnnularPoint j.1 j.2) - epsilon < |
| 168 | dist (metricEndRayAnnularPoint i.1 i.2) |
| 169 | (metricEndRayAnnularPoint j.1 j.2) by linarith only [hepsilon]))] with h hh |
| 170 | linarith only [hh] |
| 171 | filter_upwards [self_mem_nhdsWithin, hlength, hpairs] with h hh hlength hpairs |
| 172 | have hhpos : 0 < h := hh |
| 173 | intro P Q s t hP hQ |
| 174 | have hforward := metricEndRay_annular_scaled_dist_le |
| 175 | ha hab htriangle hupper P Q s t hhpos hP hQ |
| 176 | refine ⟨sub_nonneg.mpr hforward, ?_⟩ |
| 177 | obtain ⟨i, hi, hPi⟩ := hF (metricEndRayAnnularPoint P s) |
| 178 | obtain ⟨j, hj, hQj⟩ := hF (metricEndRayAnnularPoint Q t) |
| 179 | have hiLength : h * (i.2 : ℝ) ≤ i.1.length := |
| 180 | (mul_le_mul_of_nonneg_left i.2.property.2 hhpos.le).trans (hlength i hi).le |
| 181 | have hjLength : h * (j.2 : ℝ) ≤ j.1.length := |
| 182 | (mul_le_mul_of_nonneg_left j.2.property.2 hhpos.le).trans (hlength j hj).le |
| 183 | have hsourcePi : dist (P.point (h * s)) (i.1.point (h * i.2)) / h < epsilon := |
| 184 | (metricEndRay_annular_scaled_dist_le ha hab htriangle hupper |
| 185 | P i.1 s i.2 hhpos hP hiLength).trans_lt hPi |
| 186 | have hsourceQj : dist (Q.point (h * t)) (j.1.point (h * j.2)) / h < epsilon := |
| 187 | (metricEndRay_annular_scaled_dist_le ha hab htriangle hupper |
| 188 | Q j.1 t j.2 hhpos hQ hjLength).trans_lt hQj |
| 189 | have hsourceiP : dist (i.1.point (h * i.2)) (P.point (h * s)) / h < epsilon := by |
| 190 | simpa only [dist_comm] using hsourcePi |
| 191 | have hjQ : dist (metricEndRayAnnularPoint j.1 j.2) |
| 192 | (metricEndRayAnnularPoint Q t) < epsilon := by |
| 193 | simpa only [dist_comm] using hQj |
| 194 | have hsourceTriangle : |
| 195 | dist (i.1.point (h * i.2)) (j.1.point (h * j.2)) / h ≤ |
| 196 | dist (i.1.point (h * i.2)) (P.point (h * s)) / h + |
| 197 | dist (P.point (h * s)) (Q.point (h * t)) / h + |
| 198 | dist (Q.point (h * t)) (j.1.point (h * j.2)) / h := by |
| 199 | simpa only [add_div] using div_le_div_of_nonneg_right |
| 200 | (dist_triangle4 (i.1.point (h * i.2)) (P.point (h * s)) |
| 201 | (Q.point (h * t)) (j.1.point (h * j.2))) hhpos.le |
| 202 | have hconeTriangle := dist_triangle4 (metricEndRayAnnularPoint P s) |
| 203 | (metricEndRayAnnularPoint i.1 i.2) (metricEndRayAnnularPoint j.1 j.2) |
| 204 | (metricEndRayAnnularPoint Q t) |
| 205 | have hfixed := hpairs i hi j hj |
| 206 | have herror : |
| 207 | dist (metricEndRayAnnularPoint P s) (metricEndRayAnnularPoint Q t) - |
| 208 | dist (P.point (h * s)) (Q.point (h * t)) / h < 5 * epsilon := by |
| 209 | linarith only [hconeTriangle, hPi, hjQ, hfixed, |
| 210 | hsourceTriangle, hsourceiP, hsourceQj] |
| 211 | dsimp only [epsilon] at herror |
| 212 | linarith only [herror, heta] |
| 213 | |
| 214 | end Annulus |
| 215 | |
| 216 | end PoincareMT.M28 |