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.Riemannian.Heat.Kernel.LineArclength |
| 2 | import Mathlib.Topology.Algebra.Order.Archimedean |
| 3 | |
| 4 | /-! |
| 5 | # Periods of geodesics on compact one-dimensional manifolds |
| 6 | |
| 7 | A nonstationary geodesic has the same velocity whenever it returns to a |
| 8 | point. On a compact connected manifold such a return must occur. |
| 9 | -/ |
| 10 | |
| 11 | set_option autoImplicit false |
| 12 | set_option backward.isDefEq.respectTransparency false |
| 13 | |
| 14 | open Set Filter |
| 15 | open scoped Manifold ContDiff Bundle Topology |
| 16 | |
| 17 | namespace PoincareMT.RiemannianMetric |
| 18 | |
| 19 | variable {M : Type*} [TopologicalSpace M] [T3Space M] |
| 20 | [ChartedSpace (EuclideanSpace ℝ (Fin 1)) M] [IsManifold (𝓡 1) ∞ M] |
| 21 | |
| 22 | omit [T3Space M] in |
| 23 | theorem line_geodesic_chart_deriv_ne_zero (g : RiemannianMetric 1 M) |
| 24 | {γ : ℝ → M} (hγ : g.IsGeodesicOn γ univ) {p : M} (hp : γ 0 = p) |
| 25 | {v : EuclideanSpace ℝ (Fin 1)} (hv0 : v ≠ 0) |
| 26 | (hv : HasDerivAt (fun t => extChartAt (𝓡 1) p (γ t)) v 0) (t : ℝ) : |
| 27 | deriv (fun u => extChartAt (𝓡 1) (γ t) (γ u)) t ≠ 0 := by |
| 28 | have hspeed : 0 < g.tangentNorm p v := Real.sqrt_pos.mpr (g.pos p v hv0) |
| 29 | have hnorm := (line_geodesic_chart_speed g hγ |
| 30 | (hγ.hasDerivAt_chart_at (mem_univ t) (γ t) (mem_extChartAt_source _)).1).trans |
| 31 | (line_geodesic_speed g hγ hp hv t) |
| 32 | intro hz |
| 33 | simp only [hz, tangentNorm, map_zero, Real.sqrt_zero] at hnorm |
| 34 | exact hspeed.ne' hnorm.symm |
| 35 | |
| 36 | omit [T3Space M] in |
| 37 | theorem line_geodesic_mfderiv_bijective (g : RiemannianMetric 1 M) |
| 38 | {γ : ℝ → M} (hγ : g.IsGeodesicOn γ univ) {p : M} (hp : γ 0 = p) |
| 39 | {v : EuclideanSpace ℝ (Fin 1)} (hv0 : v ≠ 0) |
| 40 | (hv : HasDerivAt (fun t => extChartAt (𝓡 1) p (γ t)) v 0) (t : ℝ) : |
| 41 | Function.Bijective (mfderiv 𝓘(ℝ, ℝ) (𝓡 1) γ t) := by |
| 42 | let L : ℝ →L[ℝ] EuclideanSpace ℝ (Fin 1) := mfderiv 𝓘(ℝ, ℝ) (𝓡 1) γ t |
| 43 | have hne : L 1 ≠ 0 := by |
| 44 | intro hz |
| 45 | have hn := line_geodesic_speed g hγ hp hv t |
| 46 | change L 1 = 0 at hz |
| 47 | change g.tangentNorm (γ t) (L 1) = g.tangentNorm p v at hn |
| 48 | simp only [hz, tangentNorm, map_zero, Real.sqrt_zero] at hn |
| 49 | exact (Real.sqrt_pos.mpr (g.pos p v hv0)).ne' hn.symm |
| 50 | have hL (r : ℝ) : L r = r • L 1 := by |
| 51 | simpa only [smul_eq_mul, mul_one] using L.map_smul r (1 : ℝ) |
| 52 | change Function.Bijective L |
| 53 | constructor |
| 54 | · intro a b hab |
| 55 | have hz : (a - b) • L 1 = 0 := by rw [← hL, map_sub, hab, sub_self] |
| 56 | exact sub_eq_zero.mp ((smul_eq_zero.mp hz).resolve_right hne) |
| 57 | · intro w |
| 58 | obtain ⟨a, ha⟩ := exists_smul_eq_of_finrank_eq_one |
| 59 | (finrank_euclideanSpace_fin : Module.finrank ℝ (EuclideanSpace ℝ (Fin 1)) = 1) |
| 60 | hne w |
| 61 | exact ⟨a, (hL a).trans ha⟩ |
| 62 | |
| 63 | /-- Every repeated point of a nonstationary line geodesic gives a period. -/ |
| 64 | theorem periodic_line_geodesic_of_eq (g : RiemannianMetric 1 M) |
| 65 | {γ : ℝ → M} (hγ : g.IsGeodesicOn γ univ) {p : M} (hp : γ 0 = p) |
| 66 | {v : EuclideanSpace ℝ (Fin 1)} (hv0 : v ≠ 0) |
| 67 | (hv : HasDerivAt (fun t => extChartAt (𝓡 1) p (γ t)) v 0) |
| 68 | {a b : ℝ} (hab : γ a = γ b) : Function.Periodic γ (b - a) := by |
| 69 | have hspeed : 0 < g.tangentNorm p v := Real.sqrt_pos.mpr (g.pos p v hv0) |
| 70 | have hnorm (t : ℝ) : |
| 71 | g.tangentNorm (γ t) (deriv (fun u => extChartAt (𝓡 1) (γ t) (γ u)) t) = |
| 72 | g.tangentNorm p v := |
| 73 | (line_geodesic_chart_speed g hγ |
| 74 | (hγ.hasDerivAt_chart_at (mem_univ t) (γ t) (mem_extChartAt_source _)).1).trans |
| 75 | (line_geodesic_speed g hγ hp hv t) |
| 76 | have hne := line_geodesic_chart_deriv_ne_zero g hγ hp hv0 hv |
| 77 | let va := deriv (fun t => extChartAt (𝓡 1) (γ a) (γ t)) a |
| 78 | let vb := deriv (fun t => extChartAt (𝓡 1) (γ a) (γ t)) b |
| 79 | have hva := (hγ.hasDerivAt_chart_at (mem_univ a) (γ a) (mem_extChartAt_source _)).1 |
| 80 | have hvb := (hγ.hasDerivAt_chart_at (mem_univ b) (γ a) |
| 81 | (by rw [hab]; exact mem_extChartAt_source _)).1 |
| 82 | obtain ⟨c, hcv⟩ := exists_smul_eq_of_finrank_eq_one |
| 83 | (finrank_euclideanSpace_fin : Module.finrank ℝ (EuclideanSpace ℝ (Fin 1)) = 1) |
| 84 | (hne a) vb |
| 85 | have hcabs : |c| = 1 := by |
| 86 | have hna : g.tangentNorm (γ a) va = g.tangentNorm p v := hnorm a |
| 87 | have hnb : g.tangentNorm (γ a) vb = g.tangentNorm p v := by |
| 88 | change Real.sqrt (g.inner (γ a) vb vb) = _ |
| 89 | dsimp only [vb] |
| 90 | rw [hab] |
| 91 | exact hnorm b |
| 92 | rw [← hcv] at hnb |
| 93 | have hsmul : g.tangentNorm (γ a) (c • va) = |c| * g.tangentNorm (γ a) va := by |
| 94 | simp only [tangentNorm, map_smul, smul_apply, smul_eq_mul] |
| 95 | rw [← mul_assoc, ← pow_two, Real.sqrt_mul (sq_nonneg c), Real.sqrt_sq_eq_abs] |
| 96 | rw [hsmul, hna] at hnb |
| 97 | exact mul_right_cancel₀ hspeed.ne' (hnb.trans (one_mul _).symm) |
| 98 | have hleft : g.IsGeodesicOn (fun t => γ (c * t + a)) univ := |
| 99 | fun t _ => hγ.comp_affine c a t (mem_univ _) |
| 100 | have hright : g.IsGeodesicOn (fun t => γ (t + b)) univ := |
| 101 | fun t _ => hγ.comp_add b t (mem_univ _) |
| 102 | have hdleft : HasDerivAt (fun t => extChartAt (𝓡 1) (γ a) (γ (c * t + a))) |
| 103 | (c • va) 0 := by |
| 104 | have hd : HasDerivAt (fun t => extChartAt (𝓡 1) (γ a) (γ t)) va (c * 0 + a) := by |
| 105 | simpa only [mul_zero, zero_add] using hva |
| 106 | simpa only [Function.comp_def, id_eq, mul_one] using! |
| 107 | hd.scomp 0 (((hasDerivAt_id (0 : ℝ)).const_mul c).add_const a) |
| 108 | have hdright : HasDerivAt (fun t => extChartAt (𝓡 1) (γ a) (γ (t + b))) vb 0 := by |
| 109 | have hd : HasDerivAt (fun t => extChartAt (𝓡 1) (γ a) (γ t)) vb (0 + b) := by |
| 110 | simpa only [zero_add] using hvb |
| 111 | simpa only [Function.comp_def, id_eq, one_smul] using! |
| 112 | hd.scomp 0 ((hasDerivAt_id (0 : ℝ)).add_const b) |
| 113 | have hall (t : ℝ) : γ (c * t + a) = γ (t + b) := |
| 114 | (hleft.eq_nhds_on_of_initial_data hright |
| 115 | (convex_univ : Convex ℝ (univ : Set ℝ)).isPreconnected (mem_univ 0) (γ a) |
| 116 | (by simpa only [mul_zero, zero_add] using mem_extChartAt_source (I := 𝓡 1) (γ a)) |
| 117 | (by simpa only [mul_zero, zero_add] using hab) |
| 118 | (hdleft.deriv.trans (hcv.trans hdright.deriv.symm)) t (mem_univ t)).self_of_nhds |
| 119 | rcases (abs_eq (by norm_num : (0 : ℝ) ≤ 1)).mp hcabs with hc1 | hcm |
| 120 | · intro t |
| 121 | have hh := hall (t - a) |
| 122 | rw [hc1, one_mul] at hh |
| 123 | convert hh.symm using 1 <;> congr 1 <;> ring |
| 124 | · exfalso |
| 125 | let t := (a - b) / 2 |
| 126 | let s := (a + b) / 2 |
| 127 | have hts : c * t + a = s := by dsimp [t, s]; rw [hcm]; ring |
| 128 | have hts' : t + b = s := by dsimp [t, s]; ring |
| 129 | let w := deriv (fun u => extChartAt (𝓡 1) (γ s) (γ u)) s |
| 130 | have hd := (hγ.hasDerivAt_chart_at (mem_univ s) (γ s) (mem_extChartAt_source _)).1 |
| 131 | have hdL : HasDerivAt (fun u => extChartAt (𝓡 1) (γ s) (γ (c * u + a))) |
| 132 | (c • w) t := by |
| 133 | have hd' : HasDerivAt (fun u => extChartAt (𝓡 1) (γ s) (γ u)) w (c * t + a) := by |
| 134 | simpa only [hts] using hd |
| 135 | simpa only [Function.comp_def, id_eq, mul_one] using! |
| 136 | hd'.scomp t (((hasDerivAt_id t).const_mul c).add_const a) |
| 137 | have hdR : HasDerivAt (fun u => extChartAt (𝓡 1) (γ s) (γ (u + b))) w t := by |
| 138 | have hd' : HasDerivAt (fun u => extChartAt (𝓡 1) (γ s) (γ u)) w (t + b) := by |
| 139 | simpa only [hts'] using hd |
| 140 | simpa only [Function.comp_def, id_eq, one_smul] using! |
| 141 | hd'.scomp t ((hasDerivAt_id t).add_const b) |
| 142 | have hzero : c • w = w := hdL.unique |
| 143 | (hdR.congr_of_eventuallyEq (Eventually.of_forall (fun u => congrArg _ (hall u)))) |
| 144 | rw [hcm, neg_one_smul] at hzero |
| 145 | have hzero' : w + w = 0 := by |
| 146 | calc |
| 147 | w + w = (-w) + w := by rw [hzero] |
| 148 | _ = 0 := neg_add_cancel w |
| 149 | have htwo : (2 : ℝ) • w = 0 := by simpa only [two_smul] using hzero' |
| 150 | exact hne s ((smul_eq_zero.mp htwo).resolve_left (by norm_num)) |
| 151 | |
| 152 | /-- The chart velocities agree at any two times when a nonstationary line |
| 153 | geodesic passes through the same point. -/ |
| 154 | theorem line_geodesic_chart_deriv_eq_of_eq (g : RiemannianMetric 1 M) |
| 155 | {γ : ℝ → M} (hγ : g.IsGeodesicOn γ univ) {p : M} (hp : γ 0 = p) |
| 156 | {v : EuclideanSpace ℝ (Fin 1)} (hv0 : v ≠ 0) |
| 157 | (hv : HasDerivAt (fun t => extChartAt (𝓡 1) p (γ t)) v 0) |
| 158 | {a b : ℝ} (hab : γ a = γ b) : |
| 159 | deriv (fun t => extChartAt (𝓡 1) (γ a) (γ t)) a = |
| 160 | deriv (fun t => extChartAt (𝓡 1) (γ a) (γ t)) b := by |
| 161 | have hper := periodic_line_geodesic_of_eq g hγ hp hv0 hv hab |
| 162 | have ha := (hγ.hasDerivAt_chart_at (mem_univ a) (γ a) (mem_extChartAt_source _)).1 |
| 163 | have hb := (hγ.hasDerivAt_chart_at (mem_univ b) (γ a) |
| 164 | (by rw [hab]; exact mem_extChartAt_source _)).1 |
| 165 | have hab' : a + (b - a) = b := by ring |
| 166 | have hb' : HasDerivAt (fun t => extChartAt (𝓡 1) (γ a) (γ t)) |
| 167 | (deriv (fun t => extChartAt (𝓡 1) (γ a) (γ t)) b) (a + (b - a)) := by |
| 168 | simpa only [hab'] using hb |
| 169 | have hshift : HasDerivAt (fun t => extChartAt (𝓡 1) (γ a) (γ (t + (b - a)))) |
| 170 | (deriv (fun t => extChartAt (𝓡 1) (γ a) (γ t)) b) a := by |
| 171 | simpa only [Function.comp_def, id_eq, one_smul] using! |
| 172 | hb'.scomp a ((hasDerivAt_id a).add_const (b - a)) |
| 173 | exact ha.unique (hshift.congr_of_eventuallyEq |
| 174 | (Eventually.of_forall (fun t => congrArg (extChartAt (𝓡 1) (γ a)) (hper t).symm))) |
| 175 | |
| 176 | /-- A nonstationary complete geodesic on a compact connected line manifold |
| 177 | has a positive period. -/ |
| 178 | theorem exists_pos_period_line_geodesic [CompactSpace M] [PreconnectedSpace M] |
| 179 | (g : RiemannianMetric 1 M) (hc : MetricComplete g) |
| 180 | {γ : ℝ → M} (hγ : g.IsGeodesicOn γ univ) {p : M} (hp : γ 0 = p) |
| 181 | {v : EuclideanSpace ℝ (Fin 1)} (hv0 : v ≠ 0) |
| 182 | (hv : HasDerivAt (fun t => extChartAt (𝓡 1) p (γ t)) v 0) : |
| 183 | ∃ T : ℝ, 0 < T ∧ Function.Periodic γ T := by |
| 184 | have hsurj := g.surjective_global_line_geodesic hc hγ hp hv0 hv |
| 185 | have hninj : ¬ Function.Injective γ := by |
| 186 | intro hi |
| 187 | let e := Equiv.ofBijective γ ⟨hi, hsurj⟩ |
| 188 | have he : ContMDiff 𝓘(ℝ, ℝ) (𝓡 1) ∞ e := contMDiff_global_line_geodesic hγ |
| 189 | have hei := contMDiff_symm_of_line_coordinate e he |
| 190 | (line_geodesic_chart_deriv_ne_zero g hγ hp hv0 hv) |
| 191 | have hcompact := isCompact_univ.image hei.continuous |
| 192 | rw [image_univ, range_eq_univ.mpr e.symm.surjective] at hcompact |
| 193 | exact noncompact_univ ℝ hcompact |
| 194 | obtain ⟨a, b, hab, hne⟩ := Function.not_injective_iff.mp hninj |
| 195 | have hper := periodic_line_geodesic_of_eq g hγ hp hv0 hv hab |
| 196 | rcases lt_or_gt_of_ne (sub_ne_zero.mpr (Ne.symm hne)) with hneg | hpos |
| 197 | · exact ⟨-(b - a), neg_pos.mpr hneg, hper.neg⟩ |
| 198 | · exact ⟨b - a, hpos, hper⟩ |
| 199 | |
| 200 | private def periodSubgroup (γ : ℝ → M) : AddSubgroup ℝ where |
| 201 | carrier := {T | Function.Periodic γ T} |
| 202 | zero_mem' := Function.periodic_with_period_zero γ |
| 203 | add_mem' := fun h₁ h₂ => h₁.add_period h₂ |
| 204 | neg_mem' := fun h => h.neg |
| 205 | |
| 206 | /-- A compact connected line geodesic has a positive fundamental period; |
| 207 | its fibers are exactly the cosets of the subgroup generated by that period. -/ |
| 208 | theorem exists_fundamental_period_line_geodesic [CompactSpace M] [PreconnectedSpace M] |
| 209 | (g : RiemannianMetric 1 M) (hc : MetricComplete g) |
| 210 | {γ : ℝ → M} (hγ : g.IsGeodesicOn γ univ) {p : M} (hp : γ 0 = p) |
| 211 | {v : EuclideanSpace ℝ (Fin 1)} (hv0 : v ≠ 0) |
| 212 | (hv : HasDerivAt (fun t => extChartAt (𝓡 1) p (γ t)) v 0) : |
| 213 | ∃ T : ℝ, 0 < T ∧ Function.Periodic γ T ∧ |
| 214 | (∀ a b : ℝ, γ a = γ b ↔ a - b ∈ AddSubgroup.zmultiples T) ∧ |
| 215 | ∀ S : ℝ, 0 < S → Function.Periodic γ S → T ≤ S := by |
| 216 | let P := periodSubgroup γ |
| 217 | have hmem (t : ℝ) : t ∈ P ↔ γ t = γ 0 := by |
| 218 | constructor |
| 219 | · exact Function.Periodic.eq |
| 220 | · intro ht |
| 221 | change Function.Periodic γ t |
| 222 | simpa only [sub_zero] using periodic_line_geodesic_of_eq g hγ hp hv0 hv ht.symm |
| 223 | have hclosed : IsClosed (P : Set ℝ) := by |
| 224 | convert isClosed_eq (contMDiff_global_line_geodesic hγ).continuous continuous_const using 1 |
| 225 | ext t |
| 226 | exact hmem t |
| 227 | have hndense : ¬ Dense (P : Set ℝ) := by |
| 228 | intro hd |
| 229 | have htop : (P : Set ℝ) = univ := hclosed.closure_eq.symm.trans hd.closure_eq |
| 230 | have heq : γ = fun _ => γ 0 := funext fun t => (hmem t).mp (by |
| 231 | change t ∈ (P : Set ℝ) |
| 232 | rw [htop] |
| 233 | trivial) |
| 234 | have hne := line_geodesic_chart_deriv_ne_zero g hγ hp hv0 hv 0 |
| 235 | apply hne |
| 236 | rw [heq] |
| 237 | exact deriv_const _ _ |
| 238 | obtain ⟨a, ha⟩ := P.dense_or_cyclic.resolve_left hndense |
| 239 | rw [← AddSubgroup.zmultiples_eq_closure] at ha |
| 240 | obtain ⟨S, hS, hperS⟩ := exists_pos_period_line_geodesic g hc hγ hp hv0 hv |
| 241 | have hane : a ≠ 0 := by |
| 242 | intro hz |
| 243 | have hSmem : S ∈ AddSubgroup.zmultiples a := ha ▸ hperS |
| 244 | obtain ⟨k, hk⟩ := AddSubgroup.mem_zmultiples_iff.mp hSmem |
| 245 | rw [hz, smul_zero] at hk |
| 246 | exact hS.ne' hk.symm |
| 247 | obtain ⟨T, hT, hPT⟩ : ∃ T : ℝ, 0 < T ∧ P = AddSubgroup.zmultiples T := by |
| 248 | rcases lt_or_gt_of_ne hane with hneg | hpos |
| 249 | · exact ⟨-a, neg_pos.mpr hneg, ha.trans AddSubgroup.zmultiples_neg.symm⟩ |
| 250 | · exact ⟨a, hpos, ha⟩ |
| 251 | have hper : Function.Periodic γ T := by |
| 252 | show T ∈ P |
| 253 | rw [hPT] |
| 254 | exact AddSubgroup.mem_zmultiples_iff.mpr ⟨1, one_smul ℤ T⟩ |
| 255 | refine ⟨T, hT, hper, ?_, ?_⟩ |
| 256 | · intro a b |
| 257 | constructor |
| 258 | · intro hab |
| 259 | rw [← hPT] |
| 260 | exact periodic_line_geodesic_of_eq g hγ hp hv0 hv hab.symm |
| 261 | · intro hab |
| 262 | have hperiod : Function.Periodic γ (a - b) := by rwa [← hPT] at hab |
| 263 | simpa only [add_sub_cancel] using hperiod b |
| 264 | · intro S hS hperiod |
| 265 | have hSmem : S ∈ AddSubgroup.zmultiples T := hPT ▸ hperiod |
| 266 | obtain ⟨k, hk⟩ := AddSubgroup.mem_zmultiples_iff.mp hSmem |
| 267 | have hkpos : (0 : ℤ) < k := by |
| 268 | by_contra h |
| 269 | have hkneg : (k : ℝ) ≤ 0 := by exact_mod_cast le_of_not_gt h |
| 270 | have : k • T ≤ 0 := by simpa only [zsmul_eq_mul] using mul_nonpos_of_nonpos_of_nonneg hkneg hT.le |
| 271 | linarith |
| 272 | have hkone : (1 : ℝ) ≤ k := by exact_mod_cast hkpos |
| 273 | rw [← hk, zsmul_eq_mul] |
| 274 | nlinarith |
| 275 | |
| 276 | end PoincareMT.RiemannianMetric |