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.Ramp.LocalFlow.Constant.SpeedInitialApproximation |
| 2 | import PoincareLib.Geometry.CurveShortening.Ramp.Analysis.Periodic.SmoothApproximation |
| 3 | import Mathlib.Topology.MetricSpace.Thickening |
| 4 | import Mathlib.Topology.ContinuousMap.Compact |
| 5 | |
| 6 | /-! |
| 7 | # A compact pool of actual smooth initial curves |
| 8 | |
| 9 | Finite nets of actual compact initial data and positive constant-speed |
| 10 | approximation give one retained compact pool on the prescribed period. |
| 11 | MT2007 Claim 19.1, p. 437, Lemma 19.6, pp. 441-442, and Lemma 19.17, |
| 12 | pp. 449-450; `2026-09-23-compact-smooth-initial-pool.md`. |
| 13 | -/ |
| 14 | |
| 15 | set_option autoImplicit false |
| 16 | |
| 17 | open Set Filter |
| 18 | open scoped Manifold ContDiff Topology |
| 19 | |
| 20 | universe u v w |
| 21 | |
| 22 | namespace PoincareMT.M63 |
| 23 | |
| 24 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 25 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 26 | {ι : Type v} [Fintype ι] {Z : Type w} [TopologicalSpace Z] |
| 27 | [CompactSpace Z] [Nonempty Z] {a b L0 : ℝ} [Fact (0 < L0)] |
| 28 | |
| 29 | local notation "W" => EuclideanSpace ℝ ι |
| 30 | local notation "X" => C(AddCircle L0, W) |
| 31 | local notation "J" => ((X × X) × X) × ℝ |
| 32 | |
| 33 | /-- A compact family of actual constant-speed C2 data has finite smooth |
| 34 | approximation levels whose exact augmented union is compact inside the |
| 35 | same open guard. MT2007 Claim 19.1, p. 437; compact initial-pool derivation. -/ |
| 36 | theorem exists_compact_smooth_initial_pool |
| 37 | (F : RicciFlow n M (Icc a b)) {tau : ℝ} (htau : tau ∈ Icc a b) |
| 38 | {e : M → W} (he : ContMDiff (𝓡 n) 𝓘(ℝ, W) ∞ e) |
| 39 | {U : Set W} (hU : IsOpen U) (heU : range e ⊆ U) {ρ : W → M} |
| 40 | (hρ : ContMDiffOn 𝓘(ℝ, W) (𝓡 n) ∞ ρ U) (hρe : ∀ p, ρ (e p) = p) |
| 41 | (gamma : Z → ℝ → M) |
| 42 | (hperiod : ∀ z, Function.Periodic (gamma z) L0) |
| 43 | (hC2 : ∀ z, ContMDiff 𝓘(ℝ, ℝ) (𝓡 n) 2 (gamma z)) |
| 44 | (himm : ∀ z x, curveVelocity (n := n) (gamma z) x ≠ 0) |
| 45 | (Q : Z → J) (hQ : Continuous Q) |
| 46 | (hjets : ∀ z (x : ℝ), |
| 47 | (Q z).1.1.1 (x : AddCircle L0) = e (gamma z x) ∧ |
| 48 | (Q z).1.1.2 (x : AddCircle L0) = deriv (fun y => e (gamma z y)) x ∧ |
| 49 | (Q z).1.2 (x : AddCircle L0) = deriv (deriv (fun y => e (gamma z y))) x) |
| 50 | (hspeed : ∀ z x, curveSpeed F (fun y _ => gamma z y) tau x = (Q z).2) |
| 51 | {O : Set J} (hO : IsOpen O) (hQO : range Q ⊆ O) |
| 52 | (eps : ℕ → ℝ) (heps : ∀ j, 0 < eps j) |
| 53 | (heps0 : Tendsto eps atTop (𝓝 0)) : |
| 54 | ∃ P : ℕ → Finset J, |
| 55 | (∀ j, (P j).Nonempty) ∧ |
| 56 | (∀ j p, p ∈ P j → |
| 57 | let r : ℝ → W := fun x => p.1.1.1 (x : AddCircle L0) |
| 58 | 0 < p.2 ∧ ContDiff ℝ ∞ r ∧ Function.Periodic r L0 ∧ |
| 59 | (∀ x, r x ∈ U ∧ e (ρ (r x)) = r x) ∧ |
| 60 | (∀ x, mfderiv 𝓘(ℝ, W) (𝓡 n) ρ (r x) (deriv r x) ≠ 0) ∧ |
| 61 | (∀ x : ℝ, HasDerivAt r (p.1.1.2 (x : AddCircle L0)) x ∧ |
| 62 | HasDerivAt (fun y : ℝ => p.1.1.2 (y : AddCircle L0)) |
| 63 | (p.1.2 (x : AddCircle L0)) x) ∧ |
| 64 | (∀ x, curveSpeed F (fun y _ => ρ (r y)) tau x = p.2)) ∧ |
| 65 | (∀ j p, p ∈ P j → ∃ z, dist p (Q z) < eps j) ∧ |
| 66 | (∀ j z, ∃ p, p ∈ P j ∧ dist p (Q z) < eps j) ∧ |
| 67 | IsCompact (range Q ∪ ⋃ j, (P j : Set J)) ∧ |
| 68 | (range Q ∪ ⋃ j, (P j : Set J)) ⊆ O := by |
| 69 | classical |
| 70 | let Good : J → Prop := fun p => |
| 71 | let r : ℝ → W := fun x => p.1.1.1 (x : AddCircle L0) |
| 72 | 0 < p.2 ∧ ContDiff ℝ ∞ r ∧ Function.Periodic r L0 ∧ |
| 73 | (∀ x, r x ∈ U ∧ e (ρ (r x)) = r x) ∧ |
| 74 | (∀ x, mfderiv 𝓘(ℝ, W) (𝓡 n) ρ (r x) (deriv r x) ≠ 0) ∧ |
| 75 | (∀ x : ℝ, HasDerivAt r (p.1.1.2 (x : AddCircle L0)) x ∧ |
| 76 | HasDerivAt (fun y : ℝ => p.1.1.2 (y : AddCircle L0)) |
| 77 | (p.1.2 (x : AddCircle L0)) x) ∧ |
| 78 | (∀ x, curveSpeed F (fun y _ => ρ (r y)) tau x = p.2) |
| 79 | have descend (f : ℝ → W) (hf : Continuous f) (hp : Function.Periodic f L0) : |
| 80 | ∃ q : X, ∀ x : ℝ, q (x : AddCircle L0) = f x := by |
| 81 | refine ⟨⟨hp.lift, |
| 82 | (QuotientAddGroup.isQuotientMap_mk (AddSubgroup.zmultiples L0)).continuous_iff.mpr hf⟩, |
| 83 | fun x => Function.Periodic.lift_coe hp x⟩ |
| 84 | have approximate (z : Z) (δ : ℝ) (hδ : 0 < δ) : |
| 85 | ∃ p : J, Good p ∧ dist p (Q z) ≤ δ := by |
| 86 | have hv : 0 < (Q z).2 := by |
| 87 | rw [← hspeed z 0] |
| 88 | exact Real.sqrt_pos.mpr ((F.metric tau).pos _ _ (himm z 0)) |
| 89 | obtain ⟨r, m, hm, hmdist, hr, hrp, hfix, hrimm, hrspeed, hnear⟩ := |
| 90 | exists_smooth_positive_constantSpeed_C2_approximation F he hU heU hρ hρe htau |
| 91 | (Fact.out : 0 < L0) (hperiod z) (hC2 z) (himm z) hv (hspeed z) hδ |
| 92 | have hr1 : ContDiff ℝ ∞ (deriv r) := (contDiff_infty_iff_deriv.mp hr).2 |
| 93 | have hr1p := hrp.deriv_of_differentiable (hr.differentiable (by simp)) |
| 94 | have hr2p := hr1p.deriv_of_differentiable (hr1.differentiable (by simp)) |
| 95 | obtain ⟨r0, h0⟩ := descend r hr.continuous hrp |
| 96 | obtain ⟨r1, h1⟩ := descend (deriv r) hr1.continuous hr1p |
| 97 | obtain ⟨r2, h2⟩ := descend (deriv (deriv r)) (hr1.continuous_deriv (by simp)) hr2p |
| 98 | have hgood : Good (((r0, r1), r2), m) := by |
| 99 | have hfixed0 := hfix |
| 100 | have himm0 := hrimm |
| 101 | have hspeed0 := hrspeed |
| 102 | rw [← funext h0] at hfixed0 himm0 hspeed0 |
| 103 | dsimp only [Good] |
| 104 | refine ⟨hm, ?_, ?_, hfixed0, himm0, ?_, hspeed0⟩ |
| 105 | · rw [funext h0] |
| 106 | exact hr |
| 107 | · rw [funext h0] |
| 108 | exact hrp |
| 109 | · intro x |
| 110 | constructor |
| 111 | · rw [funext h0, h1] |
| 112 | exact ((hr.differentiable (by simp)) x).hasDerivAt |
| 113 | · rw [funext h1, h2] |
| 114 | exact ((hr1.differentiable (by simp)) x).hasDerivAt |
| 115 | have hd0 : dist r0 (Q z).1.1.1 ≤ δ := by |
| 116 | apply (ContinuousMap.dist_le hδ.le).mpr |
| 117 | intro q |
| 118 | obtain ⟨x, rfl⟩ := QuotientAddGroup.mk_surjective q |
| 119 | rw [h0, (hjets z x).1, dist_eq_norm] |
| 120 | exact (hnear x).1.le |
| 121 | have hd1 : dist r1 (Q z).1.1.2 ≤ δ := by |
| 122 | apply (ContinuousMap.dist_le hδ.le).mpr |
| 123 | intro q |
| 124 | obtain ⟨x, rfl⟩ := QuotientAddGroup.mk_surjective q |
| 125 | rw [h1, (hjets z x).2.1, dist_eq_norm] |
| 126 | exact (hnear x).2.1.le |
| 127 | have hd2 : dist r2 (Q z).1.2 ≤ δ := by |
| 128 | apply (ContinuousMap.dist_le hδ.le).mpr |
| 129 | intro q |
| 130 | obtain ⟨x, rfl⟩ := QuotientAddGroup.mk_surjective q |
| 131 | rw [h2, (hjets z x).2.2, dist_eq_norm] |
| 132 | exact (hnear x).2.2.le |
| 133 | refine ⟨(((r0, r1), r2), m), hgood, ?_⟩ |
| 134 | simp only [Prod.dist_eq] |
| 135 | exact max_le (max_le (max_le hd0 hd1) hd2) |
| 136 | (by simpa only [Real.dist_eq] using hmdist.le) |
| 137 | let K : Set J := range Q |
| 138 | have hK : IsCompact K := isCompact_range hQ |
| 139 | have hKne : K.Nonempty := range_nonempty Q |
| 140 | obtain ⟨eta, heta, hetaO⟩ := hK.exists_thickening_subset_open hO hQO |
| 141 | let delta : ℕ → ℝ := fun j => min (eps j / 4) (eta / 4) |
| 142 | have hdpos (j : ℕ) : 0 < delta j := |
| 143 | lt_min (div_pos (heps j) (by norm_num)) (div_pos heta (by norm_num)) |
| 144 | have hdeps (j : ℕ) : 2 * delta j < eps j := by |
| 145 | have h := min_le_left (eps j / 4) (eta / 4) |
| 146 | dsimp only [delta] |
| 147 | linarith [heps j] |
| 148 | have hdeta (j : ℕ) : delta j < eta := by |
| 149 | have h := min_le_right (eps j / 4) (eta / 4) |
| 150 | dsimp only [delta] |
| 151 | linarith |
| 152 | have level (j : ℕ) : ∃ P : Finset J, |
| 153 | P.Nonempty ∧ (∀ p ∈ P, Good p) ∧ |
| 154 | (∀ p ∈ P, ∃ z, dist p (Q z) ≤ delta j) ∧ |
| 155 | ∀ z, ∃ p ∈ P, dist p (Q z) < 2 * delta j := by |
| 156 | obtain ⟨T, hTK, hTfin, hcover⟩ := |
| 157 | Metric.finite_approx_of_totallyBounded hK.totallyBounded (delta j) (hdpos j) |
| 158 | let : Fintype T := hTfin.fintype |
| 159 | have centers (q : T) : ∃ z, Q z = (q : J) := hTK q.property |
| 160 | choose z hz using centers |
| 161 | have samples (q : T) : ∃ p : J, Good p ∧ dist p (q : J) ≤ delta j := by |
| 162 | obtain ⟨p, hp, hd⟩ := approximate (z q) (delta j) (hdpos j) |
| 163 | exact ⟨p, hp, by simpa only [hz q] using hd⟩ |
| 164 | choose sample hsample hsampleDist using samples |
| 165 | let P : Finset J := Finset.univ.image sample |
| 166 | have hmem (q : T) : sample q ∈ P := Finset.mem_image.mpr ⟨q, Finset.mem_univ _, rfl⟩ |
| 167 | obtain ⟨q, hq, _hqnear⟩ := mem_iUnion₂.mp (hcover hKne.choose_spec) |
| 168 | refine ⟨P, ⟨sample ⟨q, hq⟩, hmem _⟩, ?_, ?_, ?_⟩ |
| 169 | · intro p hp |
| 170 | obtain ⟨q, _hq, rfl⟩ := Finset.mem_image.mp hp |
| 171 | exact hsample q |
| 172 | · intro p hp |
| 173 | obtain ⟨q, _hq, rfl⟩ := Finset.mem_image.mp hp |
| 174 | exact ⟨z q, by simpa only [hz q] using hsampleDist q⟩ |
| 175 | · intro w |
| 176 | obtain ⟨q, hq, hnear⟩ := mem_iUnion₂.mp (hcover (mem_range_self w)) |
| 177 | refine ⟨sample ⟨q, hq⟩, hmem _, ?_⟩ |
| 178 | have hnear' : dist q (Q w) < delta j := (dist_comm _ _).trans_lt hnear |
| 179 | calc |
| 180 | dist (sample ⟨q, hq⟩) (Q w) ≤ |
| 181 | dist (sample ⟨q, hq⟩) q + dist q (Q w) := dist_triangle _ _ _ |
| 182 | _ < delta j + delta j := add_lt_add_of_le_of_lt (hsampleDist _) hnear' |
| 183 | _ = 2 * delta j := by ring |
| 184 | choose P hPne hPgood hPcenter hPcover using level |
| 185 | have hnear (j : ℕ) (p : J) (hp : p ∈ P j) : ∃ z, dist p (Q z) < eps j := by |
| 186 | obtain ⟨z, hz⟩ := hPcenter j p hp |
| 187 | exact ⟨z, hz.trans_lt (by linarith [hdeps j, hdpos j])⟩ |
| 188 | have hcover (j : ℕ) (z : Z) : ∃ p, p ∈ P j ∧ dist p (Q z) < eps j := by |
| 189 | obtain ⟨p, hp, hd⟩ := hPcover j z |
| 190 | exact ⟨p, hp, hd.trans (hdeps j)⟩ |
| 191 | let Kplus : Set J := K ∪ ⋃ j, (P j : Set J) |
| 192 | have hguard : Kplus ⊆ O := by |
| 193 | intro p hp |
| 194 | rcases hp with hp | hp |
| 195 | · exact hQO hp |
| 196 | · obtain ⟨j, hj⟩ := mem_iUnion.mp hp |
| 197 | obtain ⟨z, hz⟩ := hPcenter j p hj |
| 198 | exact hetaO (Metric.mem_thickening_iff.mpr |
| 199 | ⟨Q z, mem_range_self _, hz.trans_lt (hdeta j)⟩) |
| 200 | let finitePrefix : ℕ → Set J := fun N => ⋃ j ∈ (Finset.range N : Set ℕ), (P j : Set J) |
| 201 | have hprefixFinite (N : ℕ) : (finitePrefix N).Finite := |
| 202 | (Finset.finite_toSet _).biUnion (fun j _ => (P j).finite_toSet) |
| 203 | have hprefixMem (N j : ℕ) (hj : j < N) {p : J} (hp : p ∈ P j) : p ∈ finitePrefix N := |
| 204 | mem_iUnion₂.mpr ⟨j, Finset.mem_range.mpr hj, hp⟩ |
| 205 | have hprefixSub (N : ℕ) : finitePrefix N ⊆ Kplus := by |
| 206 | intro p hp |
| 207 | obtain ⟨j, _hj, hp⟩ := mem_iUnion₂.mp hp |
| 208 | exact Or.inr (mem_iUnion.mpr ⟨j, hp⟩) |
| 209 | have hsmall (ε : ℝ) (hε : 0 < ε) : ∃ N, ∀ j ≥ N, eps j < ε := |
| 210 | eventually_atTop.mp (heps0.eventually (gt_mem_nhds hε)) |
| 211 | have htotal : TotallyBounded Kplus := by |
| 212 | apply Metric.totallyBounded_iff.mpr |
| 213 | intro ε hε |
| 214 | obtain ⟨N, hN⟩ := hsmall (ε / 3) (by positivity) |
| 215 | obtain ⟨T, _hTK, hTfin, hTcover⟩ := |
| 216 | Metric.finite_approx_of_totallyBounded hK.totallyBounded (ε / 3) (by positivity) |
| 217 | refine ⟨T ∪ finitePrefix N, hTfin.union (hprefixFinite N), ?_⟩ |
| 218 | intro p hp |
| 219 | rcases hp with hp | hp |
| 220 | · obtain ⟨q, hq, hqdist⟩ := mem_iUnion₂.mp (hTcover hp) |
| 221 | refine mem_iUnion₂.mpr ⟨q, Or.inl hq, ?_⟩ |
| 222 | exact (Metric.mem_ball.mp hqdist).trans (by linarith) |
| 223 | · obtain ⟨j, hj⟩ := mem_iUnion.mp hp |
| 224 | by_cases hjN : j < N |
| 225 | · exact mem_iUnion₂.mpr |
| 226 | ⟨p, Or.inr (hprefixMem N j hjN hj), Metric.mem_ball_self hε⟩ |
| 227 | · obtain ⟨z, hz⟩ := hnear j p hj |
| 228 | obtain ⟨q, hq, hqdist⟩ := mem_iUnion₂.mp (hTcover (mem_range_self z)) |
| 229 | refine mem_iUnion₂.mpr ⟨q, Or.inl hq, ?_⟩ |
| 230 | have hsum := (dist_triangle p (Q z) q).trans_lt (add_lt_add hz hqdist) |
| 231 | exact hsum.trans (by linarith [hN j (Nat.le_of_not_gt hjN)]) |
| 232 | have hclosed : IsClosed Kplus := by |
| 233 | apply isOpen_compl_iff.mp |
| 234 | apply Metric.isOpen_iff.mpr |
| 235 | intro y hy |
| 236 | have hyK : y ∈ Kᶜ := fun h => hy (Or.inl h) |
| 237 | obtain ⟨ε, hε, hball⟩ := Metric.isOpen_iff.mp hK.isClosed.isOpen_compl y hyK |
| 238 | obtain ⟨N, hN⟩ := hsmall (ε / 3) (by positivity) |
| 239 | have hyPrefix : y ∈ (finitePrefix N)ᶜ := fun h => hy (hprefixSub N h) |
| 240 | obtain ⟨η, hη, hballPrefix⟩ := |
| 241 | Metric.isOpen_iff.mp (hprefixFinite N).isClosed.isOpen_compl y hyPrefix |
| 242 | refine ⟨min (ε / 3) η, lt_min (by positivity) hη, ?_⟩ |
| 243 | intro p hp hpk |
| 244 | have hpε : dist p y < ε / 3 := hp.trans_le (min_le_left _ _) |
| 245 | have hpη : dist p y < η := hp.trans_le (min_le_right _ _) |
| 246 | rcases hpk with hpk | hpk |
| 247 | · exact hball (hpε.trans (by linarith)) hpk |
| 248 | · obtain ⟨j, hj⟩ := mem_iUnion.mp hpk |
| 249 | by_cases hjN : j < N |
| 250 | · exact hballPrefix hpη (hprefixMem N j hjN hj) |
| 251 | · obtain ⟨z, hz⟩ := hnear j p hj |
| 252 | have hz' : dist (Q z) p < ε / 3 := by |
| 253 | rw [dist_comm] |
| 254 | exact hz.trans (hN j (Nat.le_of_not_gt hjN)) |
| 255 | have hd : dist (Q z) y < ε := |
| 256 | ((dist_triangle _ p _).trans_lt (add_lt_add hz' hpε)).trans (by linarith) |
| 257 | exact hball hd (mem_range_self z) |
| 258 | exact ⟨P, hPne, hPgood, hnear, hcover, htotal.isCompact_of_isClosed hclosed, hguard⟩ |
| 259 | |
| 260 | end PoincareMT.M63 |