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.MetricEndRay |
| 3 | import PoincareLib.Geometry.RicciFlow.Generalized.BoundedDistance.Analysis.Coordinates.FinitePackingCompactCompletion |
| 4 | import PoincareLib.Geometry.RicciFlow.Generalized.BoundedDistance.Tube.Limits.SelectedSphereRayCrossing |
| 5 | import PoincareLib.Geometry.RicciFlow.Generalized.BoundedDistance.Tube.Limits.SelectedNeckCofinalSequence |
| 6 | import PoincareLib.Geometry.RicciFlow.Generalized.BoundedDistance.Tube.NeckGeometry.NeckCompletionRadius |
| 7 | import PoincareLib.Geometry.RicciFlow.Generalized.BoundedDistance.Tube.NeckGeometry.NeckSpherePacking |
| 8 | import PoincareLib.Geometry.RicciFlow.Generalized.BoundedDistance.Angles.Geometry.ChordDefectLimits |
| 9 | import Mathlib.Topology.Order.LeftRightNhds |
| 10 | import Mathlib.Order.Filter.Finite |
| 11 | |
| 12 | /-! |
| 13 | # Actual chord-link packing from selected source spheres |
| 14 | |
| 15 | The model packing number and cofinal selected source necks are chosen |
| 16 | before the finite ray family. Every representative crosses the same |
| 17 | actual sphere, and joint chord limits contradict too many separated |
| 18 | directions. All source distances remain the original recut metric. |
| 19 | Source: Morgan--Tian Lemma 10.27 and Corollary 10.28, pp. 261-262; |
| 20 | M28 derivation 155. |
| 21 | -/ |
| 22 | |
| 23 | set_option autoImplicit false |
| 24 | set_option backward.isDefEq.respectTransparency false |
| 25 | |
| 26 | open Set Filter |
| 27 | open scoped Manifold ContDiff Bundle Topology ENNReal |
| 28 | |
| 29 | universe u |
| 30 | |
| 31 | namespace PoincareMT.M28 |
| 32 | |
| 33 | variable {M : Type u} [TopologicalSpace M] [T2Space M] |
| 34 | [ChartedSpace (EuclideanSpace ℝ (Fin 3)) M] |
| 35 | [IsManifold (𝓡 3) ∞ M] [MeasurableSpace M] [BorelSpace M] [T3Space M] |
| 36 | {g : RiemannianMetric 3 M} {X : Set M} |
| 37 | |
| 38 | /-- Actual selected spheres make the source-derived chord pseudometric |
| 39 | totally bounded. The joint-limit premise is supplied by the actual |
| 40 | selected-end comparison producer, not a compact-link assumption. |
| 41 | The geometric wrapper in `SelectedChordCompactness` supplies it directly. |
| 42 | Source: Lemma 10.27 and Corollary 10.28; M28 derivation 155. -/ |
| 43 | theorem totallyBounded_selected_end_ray_chord |
| 44 | (T : EpsilonTubeCertificate g X) (A : OpenCylinderModel T.carrier) |
| 45 | (U : TopologicalSpace.Opens M) (hU : (U : Set M) = A.tail true (1 / 2)) |
| 46 | (hA : SmoothSphereIsotopicIn T.carrier A.middleSphere T.cylinder.middleSphere) |
| 47 | (R : M → ℝ) (hR : ContinuousOn R T.carrier) |
| 48 | (hratio : ∀ i ∈ T.chain.shape.active, |
| 49 | ∀ y ∈ (T.chain.neck i).carrier, ∀ z ∈ (T.chain.neck i).carrier, |
| 50 | R y ≤ 2 * R z) |
| 51 | (hdiverge : ∀ B : ℝ, ∃ d : ℝ, 1 / 2 < d ∧ d < 1 ∧ |
| 52 | ∀ x ∈ T.carrier, d < (A.inverse x).2 → B < R x) |
| 53 | (f : M → ℝ) |
| 54 | (hfinite : ∀ p q : U, intrinsicEDist g (U : Set M) (p : M) (q : M) ≠ ⊤) : |
| 55 | letI := intrinsicOpenMetricSpace g U hfinite |
| 56 | ∀ (E : UniformSpace.Completion U) (alpha : ℝ), |
| 57 | E ∉ range ((↑) : U → UniformSpace.Completion U) → 0 < alpha → |
| 58 | (∀ eta : ℝ, 0 < eta → ∃ c : ℝ, 1 / 2 < c ∧ c < 1 ∧ |
| 59 | ∀ x : U, c < (A.inverse x).2 → |
| 60 | dist (x : UniformSpace.Completion U) E < eta) → |
| 61 | (∀ x : U, dist (x : UniformSpace.Completion U) E < alpha → 0 < f x) → |
| 62 | (∀ p q : U, 0 < f p → 0 < f q → |
| 63 | ∃ mu : ℝ → U, mu 0 = p ∧ mu 1 = q ∧ Continuous mu ∧ |
| 64 | (∀ t : ℝ, (3 / 4 : ℝ) ≤ (A.inverse (mu t)).2) ∧ |
| 65 | ∀ s ∈ Icc (0 : ℝ) 1, ∀ t ∈ Icc (0 : ℝ) 1, |
| 66 | (intrinsicOpenMetric g U).edist (mu s) (mu t) = |
| 67 | ENNReal.ofReal |s - t| * (intrinsicOpenMetric g U).edist p q) → |
| 68 | ∀ m : PseudoMetricSpace (MetricEndRay E alpha), |
| 69 | letI := m |
| 70 | (∀ P Q : MetricEndRay E alpha, Tendsto |
| 71 | (fun p : ℝ × ℝ => chordDefect (fun s t => dist (P.point s) (Q.point t)) p.1 p.2) |
| 72 | ((𝓝[>] (0 : ℝ)) ×ˢ (𝓝[>] (0 : ℝ))) (𝓝 (dist P Q ^ 2))) → |
| 73 | TotallyBounded (univ : Set (MetricEndRay E alpha)) := by |
| 74 | classical |
| 75 | let := intrinsicOpenMetricSpace g U hfinite |
| 76 | intro E alpha houtside halpha htail hbarrier hsegments m |
| 77 | let := m |
| 78 | intro hlimit |
| 79 | have hUV : (U : Set M) ⊆ T.carrier := by |
| 80 | rw [hU] |
| 81 | exact A.tail_subset_m28 true (by norm_num) (by norm_num) |
| 82 | have hheight : ∀ x : U, dist (x : UniformSpace.Completion U) E < alpha → |
| 83 | (3 / 4 : ℝ) ≤ (A.inverse x).2 := |
| 84 | cylinder_height_ge_threeQuarter_of_radius_barrier T A U f hfinite |
| 85 | E alpha hbarrier hsegments |
| 86 | obtain ⟨c, index, hc, hcLimit, hactive, hwhole⟩ := |
| 87 | exists_cofinal_selected_neck_sequence T A R hR hratio hdiverge |
| 88 | apply Metric.totallyBounded_univ_of_finite_pair_collision |
| 89 | intro d0 hd0 |
| 90 | let eta : ℝ := d0 / 8 |
| 91 | have heta : 0 < eta := div_pos hd0 (by norm_num) |
| 92 | obtain ⟨K, _hKpos, hpacking⟩ := exists_central_sphere_packing_number.{u} heta |
| 93 | refine ⟨K, ?_⟩ |
| 94 | intro P |
| 95 | by_contra! hseparated |
| 96 | have hlarge : ∀ᶠ p : ℝ × ℝ in ((𝓝[>] (0 : ℝ)) ×ˢ (𝓝[>] (0 : ℝ))), |
| 97 | ∀ i j : Fin (K + 1), i ≠ j → |
| 98 | 3 * d0 ^ 2 / 4 < |
| 99 | chordDefect (fun s t => dist ((P i).point s) ((P j).point t)) p.1 p.2 := by |
| 100 | apply Filter.eventually_all.mpr |
| 101 | intro i |
| 102 | apply Filter.eventually_all.mpr |
| 103 | intro j |
| 104 | by_cases hij : i = j |
| 105 | · exact Eventually.of_forall fun _p hne => (hne hij).elim |
| 106 | · have hsq : d0 ^ 2 ≤ dist (P i) (P j) ^ 2 := |
| 107 | (sq_le_sq₀ hd0.le dist_nonneg).mpr (hseparated i j hij) |
| 108 | have hmargin : 3 * d0 ^ 2 / 4 < dist (P i) (P j) ^ 2 := by |
| 109 | nlinarith only [hsq, sq_pos_of_pos hd0] |
| 110 | exact ((hlimit (P i) (P j)).eventually (lt_mem_nhds hmargin)).mono |
| 111 | fun _p hp _hne => hp |
| 112 | obtain ⟨S, hS, V, hV, hSV⟩ := Filter.mem_prod_iff.mp hlarge |
| 113 | obtain ⟨a, ha, hIa⟩ := (nhdsGT_basis (0 : ℝ)).mem_iff.mp hS |
| 114 | obtain ⟨b, hb, hIb⟩ := (nhdsGT_basis (0 : ℝ)).mem_iff.mp hV |
| 115 | let tau : ℝ := min a b |
| 116 | have htau : 0 < tau := lt_min ha hb |
| 117 | have hrectangle (s : ℝ) (hs : s ∈ Ioo (0 : ℝ) tau) |
| 118 | (t : ℝ) (ht : t ∈ Ioo (0 : ℝ) tau) |
| 119 | (i j : Fin (K + 1)) (hij : i ≠ j) : |
| 120 | 3 * d0 ^ 2 / 4 < |
| 121 | chordDefect (fun u v => dist ((P i).point u) ((P j).point v)) s t := |
| 122 | hSV (show (s, t) ∈ S ×ˢ V from |
| 123 | ⟨hIa ⟨hs.1, hs.2.trans_le (min_le_left _ _)⟩, |
| 124 | hIb ⟨ht.1, ht.2.trans_le (min_le_right _ _)⟩⟩) i j hij |
| 125 | obtain ⟨d, _hdhalf, hd1, hdecay⟩ := htail tau htau |
| 126 | have hdEventually : ∀ᶠ n in atTop, d < c n := |
| 127 | hcLimit.eventually (lt_mem_nhds hd1) |
| 128 | have hstarts : ∀ᶠ n in atTop, ∀ j : Fin (K + 1), |
| 129 | (A.inverse ((P j).point (P j).length)).2 < c n := by |
| 130 | apply Filter.eventually_all.mpr |
| 131 | intro j |
| 132 | exact hcLimit.eventually (lt_mem_nhds |
| 133 | (A.inverse_mem ((P j).point (P j).length) |
| 134 | (hUV ((P j).point (P j).length).property)).2.2) |
| 135 | obtain ⟨n, hnD, hnStart⟩ := (hdEventually.and hstarts).exists |
| 136 | let N := T.chain.neck (index n) |
| 137 | have hNU : N.carrier ⊆ (U : Set M) := by |
| 138 | intro x hx |
| 139 | have hh := (A.mem_tail_iff_m28 true |
| 140 | (lt_trans (by norm_num) (hc n).1) (hc n).2).mp (hwhole n hx) |
| 141 | rw [hU] |
| 142 | exact (A.mem_tail_iff_m28 true (by norm_num) (by norm_num)).mpr |
| 143 | ⟨hh.1, (hc n).1.trans hh.2⟩ |
| 144 | have hcross (j : Fin (K + 1)) : |
| 145 | ∃ v ∈ Ioo (0 : ℝ) (P j).length, |
| 146 | ((P j).inward v : M) ∈ N.central_sphere := by |
| 147 | have hcontinuous : ContinuousOn (P j).inward (Ico (0 : ℝ) (P j).length) := |
| 148 | (P j).continuousOn_point.comp (continuous_const.sub continuous_id).continuousOn |
| 149 | (fun t ht => ⟨sub_pos.mpr ht.2, sub_le_self _ ht.1⟩) |
| 150 | have hlower (t : ℝ) (ht : t ∈ Ico (0 : ℝ) (P j).length) : |
| 151 | (3 / 4 : ℝ) ≤ (A.inverse ((P j).inward t)).2 := by |
| 152 | apply hheight |
| 153 | rw [(P j).inward_radius t ht] |
| 154 | have hsmall := (P j).length_lt |
| 155 | linarith only [hsmall, ht.1, halpha] |
| 156 | apply exists_inward_ray_crossing_selected_sphere T A U hU hA (index n) |
| 157 | (hactive n) (hc n).1 (hc n).2 (hwhole n) hfinite E houtside |
| 158 | (P j).length (P j).length_pos (P j).inward hcontinuous hlower |
| 159 | (P j).inward_radius |
| 160 | simpa only [MetricEndRay.inward, sub_zero] using hnStart j |
| 161 | choose v hv hSphere using hcross |
| 162 | let x : Fin (K + 1) → U := fun j => (P j).inward (v j) |
| 163 | let s : Fin (K + 1) → ℝ := fun j => (P j).length - v j |
| 164 | have hspos (j : Fin (K + 1)) : 0 < s j := sub_pos.mpr (hv j).2 |
| 165 | have hxradius (j : Fin (K + 1)) : |
| 166 | dist (x j : UniformSpace.Completion U) E = s j := |
| 167 | (P j).inward_radius (v j) ⟨(hv j).1.le, (hv j).2⟩ |
| 168 | have hssmall (j : Fin (K + 1)) : s j < tau := by |
| 169 | rw [← hxradius j] |
| 170 | apply hdecay |
| 171 | have hNpoint : (x j : M) ∈ N.carrier := N.central_sphere_subset (hSphere j) |
| 172 | have hh := (A.mem_tail_iff_m28 true |
| 173 | (lt_trans (by norm_num) (hc n).1) (hc n).2).mp (hwhole n hNpoint) |
| 174 | exact hnD.trans hh.2 |
| 175 | have hscaleLower (j : Fin (K + 1)) : N.scale / 4 ≤ s j := by |
| 176 | have h := (neck_completion_radius_lower N U hNU hfinite E houtside |
| 177 | (x j) (hSphere j)).2.le |
| 178 | rwa [hxradius j] at h |
| 179 | obtain ⟨i, j, hij, hshort⟩ := hpacking M g N U |
| 180 | (N.central_sphere_subset.trans hNU) x hSphere |
| 181 | have hed : (intrinsicOpenMetric g U).edist (x i) (x j) = |
| 182 | ENNReal.ofReal (dist (x i) (x j)) := by |
| 183 | change edist (x i) (x j) = _ |
| 184 | exact edist_dist _ _ |
| 185 | rw [hed] at hshort |
| 186 | have hdist : dist (x i) (x j) < eta * N.scale := |
| 187 | (ENNReal.ofReal_lt_ofReal_iff (mul_pos heta N.scale_pos)).mp hshort |
| 188 | have hsq : dist (x i) (x j) ^ 2 < (eta * N.scale) ^ 2 := |
| 189 | (sq_lt_sq₀ dist_nonneg (mul_pos heta N.scale_pos).le).mpr hdist |
| 190 | have hproduct : N.scale ^ 2 / 16 ≤ s i * s j := by |
| 191 | have h := mul_le_mul (hscaleLower i) (hscaleLower j) |
| 192 | (div_nonneg N.scale_pos.le (by norm_num)) (hspos i).le |
| 193 | nlinarith only [h] |
| 194 | have hupper : chordDefect (fun u w => dist ((P i).point u) ((P j).point w)) |
| 195 | (s i) (s j) < d0 ^ 2 / 4 := by |
| 196 | change (dist (x i) (x j) ^ 2 - (s i - s j) ^ 2) / (s i * s j) < d0 ^ 2 / 4 |
| 197 | apply (div_lt_iff₀ (mul_pos (hspos i) (hspos j))).mpr |
| 198 | have hscaled := mul_le_mul_of_nonneg_left hproduct |
| 199 | (div_nonneg (sq_nonneg d0) (by norm_num : (0 : ℝ) ≤ 4)) |
| 200 | dsimp only [eta] at hsq |
| 201 | nlinarith only [hsq, hscaled, sq_nonneg (s i - s j)] |
| 202 | have hlower := hrectangle (s i) ⟨hspos i, hssmall i⟩ |
| 203 | (s j) ⟨hspos j, hssmall j⟩ i j hij |
| 204 | nlinarith only [hlower, hupper, sq_pos_of_pos hd0] |
| 205 | |
| 206 | end PoincareMT.M28 |