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.Curvature.Calculus |
| 2 | import PoincareLib.Geometry.RicciFlow.Harnack.Noncompact.CurvatureControl.Distance.FiniteCalabi |
| 3 | import PoincareLib.Geometry.RicciFlow.Harnack.Noncompact.CurvatureControl.Distance.FiniteContinuity |
| 4 | |
| 5 | /-! |
| 6 | # Backward confinement of terminal balls |
| 7 | |
| 8 | Distance supports with an additive lower time-derivative bound confine a |
| 9 | terminal ball throughout a short backward interval. The comparison uses the |
| 10 | curvature bound only inside the prescribed moving ball. |
| 11 | |
| 12 | This is the confinement step in the proof of Kleiner--Lott, Corollary 45.1(a) |
| 13 | (I.11.6(a)), p. 2684, equation (45.7), in the corrected author version of |
| 14 | 20 February 2013. |
| 15 | -/ |
| 16 | |
| 17 | set_option autoImplicit false |
| 18 | set_option backward.isDefEq.respectTransparency false |
| 19 | |
| 20 | open Set Filter |
| 21 | open scoped Manifold ContDiff Bundle Topology ENNReal |
| 22 | |
| 23 | universe u |
| 24 | |
| 25 | namespace PoincareMT.RicciFlow |
| 26 | |
| 27 | private theorem le_terminal_add_of_upper_support |
| 28 | {f : ℝ → ℝ} {a b C R : ℝ} (hC : 0 ≤ C) |
| 29 | (hf : ContinuousOn f (Icc a b)) (hgap : f b + C * (b - a) < R) |
| 30 | (hsupport : ∀ t ∈ Ioc a b, f t < R → |
| 31 | ∃ (ρ : ℝ → ℝ) (d : ℝ), ρ t = f t ∧ |
| 32 | (∀ s ∈ Icc a t, f s ≤ ρ s) ∧ HasDerivAt ρ d t ∧ -C ≤ d) : |
| 33 | ∀ s ∈ Icc a b, f s ≤ f b + C * (b - s) := by |
| 34 | intro s hs |
| 35 | have hrate (c : ℝ) (hc : C < c) (hcap : f b + c * (b - a) < R) : |
| 36 | f s ≤ f b + c * (b - s) := by |
| 37 | by_contra hnot |
| 38 | have hlt := lt_of_not_ge hnot |
| 39 | let F : ℝ → ℝ := fun t => f t + c * t |
| 40 | have hcont : ContinuousOn F (Icc s b) := |
| 41 | (hf.mono (Icc_subset_Icc_left hs.1)).add |
| 42 | (continuousOn_const.mul continuousOn_id) |
| 43 | obtain ⟨t, ht, hmin⟩ := isCompact_Icc.exists_isMinOn |
| 44 | (nonempty_Icc.mpr hs.2) hcont |
| 45 | have htb := hmin (show b ∈ Icc s b from ⟨hs.2, le_rfl⟩) |
| 46 | change f t + c * t ≤ f b + c * b at htb |
| 47 | have hst : s < t := lt_of_le_of_ne ht.1 (by |
| 48 | intro heq |
| 49 | subst t |
| 50 | nlinarith) |
| 51 | have hft : f t < R := by |
| 52 | have hca := mul_le_mul_of_nonneg_left (hs.1.trans ht.1) (hC.trans hc.le) |
| 53 | nlinarith |
| 54 | obtain ⟨ρ, d, heq, hupper, hd, hdC⟩ := |
| 55 | hsupport t ⟨hs.1.trans_lt hst, ht.2⟩ hft |
| 56 | have hlocal : IsLocalMinOn (fun r => ρ r + c * r) (Icc s t) t := by |
| 57 | filter_upwards [self_mem_nhdsWithin] with r hr |
| 58 | have hminr := hmin (show r ∈ Icc s b from ⟨hr.1, hr.2.trans ht.2⟩) |
| 59 | have hρr := hupper r ⟨hs.1.trans hr.1, hr.2⟩ |
| 60 | change f t + c * t ≤ f r + c * r at hminr |
| 61 | rw [heq] |
| 62 | linarith |
| 63 | have hcone : s - t ∈ posTangentConeAt (Icc s t) t := |
| 64 | sub_mem_posTangentConeAt_of_segment_subset |
| 65 | ((convex_Icc s t).segment_subset ⟨hst.le, le_rfl⟩ ⟨le_rfl, hst.le⟩) |
| 66 | have hder := hlocal.hasFDerivWithinAt_nonneg |
| 67 | (hd.add ((hasDerivAt_id t).const_mul c)).hasDerivWithinAt.hasFDerivWithinAt hcone |
| 68 | change (s - t) * (d + c * 1) ≥ 0 at hder |
| 69 | nlinarith [mul_neg_of_neg_of_pos (sub_neg.mpr hst) |
| 70 | (show 0 < d + c by linarith)] |
| 71 | have hlim : Tendsto (fun c : ℝ => f b + c * (b - s)) (𝓝[>] C) |
| 72 | (𝓝 (f b + C * (b - s))) := |
| 73 | (by fun_prop : Continuous (fun c : ℝ => f b + c * (b - s))).continuousAt.tendsto.mono_left |
| 74 | nhdsWithin_le_nhds |
| 75 | apply ge_of_tendsto hlim |
| 76 | have hnear : ∀ᶠ c : ℝ in 𝓝 C, f b + c * (b - a) < R := |
| 77 | (by fun_prop : Continuous (fun c : ℝ => f b + c * (b - a))).continuousAt.eventually_lt_const hgap |
| 78 | filter_upwards [self_mem_nhdsWithin, hnear.filter_mono nhdsWithin_le_nhds] with c hc hcap |
| 79 | exact hrate c hc hcap |
| 80 | |
| 81 | /-- A terminal closed ball remains in a moving ball on a short backward interval. -/ |
| 82 | theorem terminal_closedBall_distance_bound |
| 83 | {m : ℕ} {M : Type u} [TopologicalSpace M] [T3Space M] |
| 84 | [ChartedSpace (EuclideanSpace ℝ (Fin (m + 1))) M] |
| 85 | [IsManifold (𝓡 (m + 1)) ∞ M] {J : Set ℝ} |
| 86 | (hC : RicciFlowCurvatureCalculus.{u}) (F : RicciFlow (m + 1) M J) |
| 87 | {a b r r₀ Λ scale : ℝ} (hm : 0 < m) (hab : a ≤ b) |
| 88 | (hJ : Icc a b ⊆ interior J) |
| 89 | (hcomplete : ∀ t ∈ Icc a b, MetricComplete (F.metric t)) |
| 90 | (hRic : ∀ t ∈ Icc a b, ∀ x : M, ∀ v : TangentSpace (𝓡 (m + 1)) x, |
| 91 | 0 ≤ (F.connection t).ricci x v v) |
| 92 | (p : M) (hΛ : 0 ≤ Λ) (hscale : 0 < scale) (hr₀ : 0 ≤ r₀) |
| 93 | (hupper : ∀ t ∈ Icc a b, ∀ x ∈ (F.metric t).ball p r, |
| 94 | ∀ v : TangentSpace (𝓡 (m + 1)) x, |
| 95 | (F.connection t).ricci x v v ≤ Λ * (F.metric t).inner x v v) |
| 96 | (hgap : r₀ + (4 * ((m + 1 : ℕ) : ℝ) * scale + 8 * Λ / scale) * (b - a) < r) : |
| 97 | ∀ s ∈ Icc a b, ∀ x : M, (F.metric b).edist p x ≤ ENNReal.ofReal r₀ → |
| 98 | ((F.metric s).edist p x).toReal ≤ |
| 99 | r₀ + (4 * ((m + 1 : ℕ) : ℝ) * scale + 8 * Λ / scale) * (b - s) ∧ |
| 100 | x ∈ (F.metric s).ball p r := by |
| 101 | let C := 4 * ((m + 1 : ℕ) : ℝ) * scale + 8 * Λ / scale |
| 102 | have hCnonneg : 0 ≤ C := by dsimp only [C]; positivity |
| 103 | have ha : a ∈ Icc a b := ⟨le_rfl, hab⟩ |
| 104 | have hb : b ∈ Icc a b := ⟨hab, le_rfl⟩ |
| 105 | intro s hs x hx |
| 106 | have hxb : (F.metric b).edist p x ≠ ⊤ := |
| 107 | ne_top_of_le_ne_top ENNReal.ofReal_ne_top hx |
| 108 | have hfinite (t : ℝ) (ht : t ∈ Icc a b) : (F.metric t).edist p x ≠ ⊤ := |
| 109 | edist_ne_top_of_terminal_of_ricci_nonneg hC F hab hJ (hcomplete b hb) |
| 110 | hRic p x hxb ht |
| 111 | have hterminal : ((F.metric b).edist p x).toReal ≤ r₀ := by |
| 112 | simpa only [ENNReal.toReal_ofReal hr₀] using ENNReal.toReal_mono ENNReal.ofReal_ne_top hx |
| 113 | have hr : 0 < r := lt_of_le_of_lt |
| 114 | (add_nonneg hr₀ (mul_nonneg hCnonneg (sub_nonneg.mpr hab))) hgap |
| 115 | have hbound : ((F.metric s).edist p x).toReal ≤ |
| 116 | ((F.metric b).edist p x).toReal + C * (b - s) := by |
| 117 | by_cases hpx : p = x |
| 118 | · subst x |
| 119 | have hself (t : ℝ) : (F.metric t).edist p p = 0 := by |
| 120 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 (m + 1)) : M → Type _) := |
| 121 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 122 | simp only [RiemannianMetric.edist, Manifold.riemannianEDist_self] |
| 123 | simp only [hself, ENNReal.toReal_zero, zero_add] |
| 124 | exact mul_nonneg hCnonneg (sub_nonneg.mpr hs.2) |
| 125 | apply le_terminal_add_of_upper_support (R := r) hCnonneg |
| 126 | (f := fun t => ((F.metric t).edist p x).toReal) ?_ ?_ ?_ s hs |
| 127 | · intro t ht |
| 128 | exact (continuousWithinAt_toReal_edist_of_ricci_nonneg_of_finite hC F hJ |
| 129 | (hcomplete b hb) hRic p (p := (t, x)) ht (hfinite a ha)).comp |
| 130 | (f := fun q : ℝ => (q, x)) |
| 131 | (continuousWithinAt_id.prodMk continuousWithinAt_const) |
| 132 | (fun q hq => ⟨hq, mem_univ _⟩) |
| 133 | · dsimp only [C] at ⊢ |
| 134 | linarith |
| 135 | · intro t ht hdist |
| 136 | have ht' : t ∈ Icc a b := Ioc_subset_Icc_self ht |
| 137 | have hxball : x ∈ (F.metric t).ball p r := by |
| 138 | change (F.metric t).edist p x < ENNReal.ofReal r |
| 139 | rw [← ENNReal.ofReal_toReal (hfinite t ht')] |
| 140 | exact (ENNReal.ofReal_lt_ofReal_iff hr).mpr hdist |
| 141 | obtain ⟨U, ρ, _, hxU, _, heq, hmajor, _, _, hd, hlower⟩ := |
| 142 | F.exists_distance_spacetime_upper_support_of_finite (hJ ht') hm |
| 143 | (hcomplete t ht') (hRic t ht') hΛ hscale p x hxball hpx (hupper t ht') |
| 144 | exact ⟨fun q => ρ q x, _, heq, fun q _ => hmajor q x hxU, hd.hasDerivAt, hlower⟩ |
| 145 | have hbound' : ((F.metric s).edist p x).toReal ≤ r₀ + C * (b - s) := by |
| 146 | linarith |
| 147 | refine ⟨hbound', ?_⟩ |
| 148 | have hrad : r₀ + C * (b - s) < r := by |
| 149 | have h := mul_le_mul_of_nonneg_left (sub_le_sub_left hs.1 b) hCnonneg |
| 150 | change r₀ + C * (b - a) < r at hgap |
| 151 | linarith |
| 152 | change (F.metric s).edist p x < ENNReal.ofReal r |
| 153 | rw [← ENNReal.ofReal_toReal (hfinite s hs)] |
| 154 | exact (ENNReal.ofReal_lt_ofReal_iff hr).mpr (hbound'.trans_lt hrad) |
| 155 | |
| 156 | end PoincareMT.RicciFlow |