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.Connection.Regularity |
| 2 | import PoincareLib.Geometry.Manifold.ContDiff.TimeDerivative |
| 3 | import PoincareLib.Geometry.Manifold.Curve.Velocity |
| 4 | import Mathlib.Analysis.Calculus.ParametricIntervalIntegral |
| 5 | |
| 6 | /-! # Time variation of a fixed curve's length |
| 7 | |
| 8 | Adapted from Chow--Liao--Qin, `pathLength_timeDeriv_of_ricciFlow`. |
| 9 | See `references/ricci-flow/chow-liao-qin-2026/length-variation-reuse.md`. |
| 10 | -/ |
| 11 | |
| 12 | set_option autoImplicit false |
| 13 | set_option backward.isDefEq.respectTransparency false |
| 14 | set_option maxHeartbeats 800000 |
| 15 | |
| 16 | open Set Filter MeasureTheory Bundle |
| 17 | open scoped Manifold ContDiff Topology |
| 18 | |
| 19 | universe u |
| 20 | |
| 21 | namespace PoincareMT.RicciFlow |
| 22 | |
| 23 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 24 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 25 | {J : Set ℝ} |
| 26 | |
| 27 | private lemma contMDiffAt_speed_sq |
| 28 | (F : RicciFlow n M J) {γ : ℝ → M} {I : Set ℝ} |
| 29 | (hI : IsOpen I) (hγ : ContMDiffOn 𝓘(ℝ, ℝ) (𝓡 n) ∞ γ I) |
| 30 | {s u : ℝ} (hs : s ∈ interior J) (hu : u ∈ I) : |
| 31 | ContMDiffAt (𝓘(ℝ, ℝ).prod 𝓘(ℝ, ℝ)) 𝓘(ℝ, ℝ) ∞ |
| 32 | (fun p : ℝ × ℝ => (F.metric p.1).inner (γ p.2) |
| 33 | (mfderiv 𝓘(ℝ, ℝ) (𝓡 n) γ p.2 1) |
| 34 | (mfderiv 𝓘(ℝ, ℝ) (𝓡 n) γ p.2 1)) (s, u) := by |
| 35 | have hg := (F.smooth (s, γ u) ⟨interior_subset hs, mem_univ _⟩).contMDiffAt |
| 36 | (prod_mem_nhds (mem_interior_iff_mem_nhds.mp hs) univ_mem) |
| 37 | have hbase : ContMDiffAt (𝓘(ℝ, ℝ).prod 𝓘(ℝ, ℝ)) |
| 38 | (𝓘(ℝ, ℝ).prod (𝓡 n)) ∞ (fun p : ℝ × ℝ => (p.1, γ p.2)) (s, u) := |
| 39 | contMDiffAt_fst.prodMk |
| 40 | ((hγ u hu).contMDiffAt (hI.mem_nhds hu) |>.comp (s, u) contMDiffAt_snd) |
| 41 | have hv : ContMDiffAt (𝓘(ℝ, ℝ).prod 𝓘(ℝ, ℝ)) |
| 42 | ((𝓡 n).prod (𝓡 n)) ∞ |
| 43 | (fun p : ℝ × ℝ => (⟨γ p.2, mfderiv 𝓘(ℝ, ℝ) (𝓡 n) γ p.2 1⟩ : |
| 44 | TotalSpace (EuclideanSpace ℝ (Fin n)) (TangentSpace (𝓡 n)))) (s, u) := |
| 45 | ((Poincare.Manifold.contMDiffOn_velocity_lift hI hγ u hu).contMDiffAt |
| 46 | (hI.mem_nhds hu)).comp (s, u) contMDiffAt_snd |
| 47 | have h := (hg.comp (s, u) hbase).clm_bundle_apply₂ |
| 48 | (F₃ := ℝ) (E₃ := fun _ : M => ℝ) hv hv |
| 49 | exact (contMDiffAt_totalSpace.mp h).2 |
| 50 | |
| 51 | /-- A smooth moving point has jointly continuous speed when evaluated in |
| 52 | the metrics of a smooth flow. The curve parameter and metric time vary |
| 53 | independently. -/ |
| 54 | theorem continuousAt_curve_speed |
| 55 | (F : RicciFlow n M J) {γ : ℝ → M} {I : Set ℝ} |
| 56 | (hI : IsOpen I) (hγ : ContMDiffOn 𝓘(ℝ, ℝ) (𝓡 n) ∞ γ I) |
| 57 | {s u : ℝ} (hs : s ∈ interior J) (hu : u ∈ I) : |
| 58 | ContinuousAt (fun p : ℝ × ℝ => (F.metric p.1).tangentNorm (γ p.2) |
| 59 | (mfderiv 𝓘(ℝ, ℝ) (𝓡 n) γ p.2 1)) (s, u) := |
| 60 | Real.continuous_sqrt.continuousAt.comp |
| 61 | (contMDiffAt_speed_sq F hI hγ hs hu).continuousAt |
| 62 | |
| 63 | /-- The time derivative of a fixed regular curve's length is the integral of |
| 64 | minus its Ricci evaluation divided by its speed. -/ |
| 65 | theorem hasDerivAt_integral_speed |
| 66 | (F : RicciFlow n M J) {γ : ℝ → M} {I : Set ℝ} {a b t : ℝ} |
| 67 | (hab : a ≤ b) (hI : IsOpen I) (hsub : Icc a b ⊆ I) |
| 68 | (hγ : ContMDiffOn 𝓘(ℝ, ℝ) (𝓡 n) ∞ γ I) |
| 69 | (ht : t ∈ interior J) |
| 70 | (hvel : ∀ u ∈ Icc a b, mfderiv 𝓘(ℝ, ℝ) (𝓡 n) γ u 1 ≠ 0) : |
| 71 | HasDerivAt (fun s => ∫ u in a..b, |
| 72 | (F.metric s).tangentNorm (γ u) (mfderiv 𝓘(ℝ, ℝ) (𝓡 n) γ u 1)) |
| 73 | (∫ u in a..b, -(F.connection t).ricci (γ u) |
| 74 | (mfderiv 𝓘(ℝ, ℝ) (𝓡 n) γ u 1) |
| 75 | (mfderiv 𝓘(ℝ, ℝ) (𝓡 n) γ u 1) / |
| 76 | (F.metric t).tangentNorm (γ u) (mfderiv 𝓘(ℝ, ℝ) (𝓡 n) γ u 1)) t := by |
| 77 | let v := fun u => mfderiv 𝓘(ℝ, ℝ) (𝓡 n) γ u 1 |
| 78 | let G := fun s u => (F.metric s).inner (γ u) (v u) (v u) |
| 79 | let speed := fun s u => Real.sqrt (G s u) |
| 80 | let speed' := fun s u => deriv (fun r => G r u) s / (2 * Real.sqrt (G s u)) |
| 81 | obtain ⟨α, β, htcc, htnhds, hwin⟩ := |
| 82 | exists_Icc_mem_subset_of_mem_nhds (isOpen_interior.mem_nhds ht) |
| 83 | have htopen : t ∈ Ioo α β := by |
| 84 | simpa only [interior_Icc] using mem_interior_iff_mem_nhds.mpr htnhds |
| 85 | let K : Set (ℝ × ℝ) := Icc α β ×ˢ Icc a b |
| 86 | have hG : ∀ p ∈ K, ContMDiffAt (𝓘(ℝ, ℝ).prod 𝓘(ℝ, ℝ)) 𝓘(ℝ, ℝ) ∞ |
| 87 | (fun q : ℝ × ℝ => G q.1 q.2) p := by |
| 88 | intro p hp |
| 89 | exact contMDiffAt_speed_sq F hI hγ (hwin hp.1) (hsub hp.2) |
| 90 | have hpos : ∀ s, ∀ u ∈ Icc a b, 0 < G s u := by |
| 91 | intro s u hu |
| 92 | exact (F.metric s).pos (γ u) (v u) (hvel u hu) |
| 93 | have hspeed : ContinuousOn (fun p : ℝ × ℝ => speed p.1 p.2) K := |
| 94 | fun p hp => Real.continuous_sqrt.continuousAt.comp_continuousWithinAt |
| 95 | (hG p hp).continuousAt.continuousWithinAt |
| 96 | have hspeed' : ContinuousOn (fun p : ℝ × ℝ => speed' p.1 p.2) K := by |
| 97 | intro p hp |
| 98 | exact ((Poincare.Manifold.contMDiffAt_deriv_time (hG p hp)).continuousAt.div |
| 99 | (continuousAt_const.mul (Real.continuous_sqrt.continuousAt.comp |
| 100 | (hG p hp).continuousAt)) |
| 101 | (ne_of_gt (mul_pos two_pos (Real.sqrt_pos.mpr (hpos p.1 p.2 hp.2))))).continuousWithinAt |
| 102 | have hslice : ∀ s ∈ Icc α β, ContinuousOn (speed s) (Icc a b) := by |
| 103 | intro s hs |
| 104 | have hparam : ContinuousOn (fun u : ℝ => (s, u)) (Icc a b) := |
| 105 | (continuous_const.prodMk continuous_id).continuousOn |
| 106 | have hc := hspeed.comp hparam (fun u hu => show (s, u) ∈ K from ⟨hs, hu⟩) |
| 107 | exact hc |
| 108 | have hslice' : ∀ s ∈ Icc α β, ContinuousOn (speed' s) (Icc a b) := by |
| 109 | intro s hs |
| 110 | have hparam : ContinuousOn (fun u : ℝ => (s, u)) (Icc a b) := |
| 111 | (continuous_const.prodMk continuous_id).continuousOn |
| 112 | have hc := hspeed'.comp hparam (fun u hu => show (s, u) ∈ K from ⟨hs, hu⟩) |
| 113 | exact hc |
| 114 | have hpoint : ∀ s ∈ Ioo α β, ∀ u ∈ Icc a b, |
| 115 | HasDerivAt (fun r => speed r u) (speed' s u) s := by |
| 116 | intro s hs u hu |
| 117 | have hmetric := (F.equation s (interior_subset (hwin ⟨hs.1.le, hs.2.le⟩)) |
| 118 | (γ u) (v u) (v u)).hasDerivAt |
| 119 | (mem_interior_iff_mem_nhds.mp (hwin ⟨hs.1.le, hs.2.le⟩)) |
| 120 | exact hmetric.differentiableAt.hasDerivAt.sqrt (ne_of_gt (hpos s u hu)) |
| 121 | obtain ⟨C, hC⟩ := (isCompact_Icc.prod isCompact_Icc).exists_bound_of_continuousOn hspeed' |
| 122 | have hkey := intervalIntegral.hasDerivAt_integral_of_dominated_loc_of_deriv_le |
| 123 | (μ := volume) (a := a) (b := b) (F := speed) (F' := speed') (x₀ := t) |
| 124 | (bound := fun _ => C) (s := Ioo α β) (Ioo_mem_nhds htopen.1 htopen.2) |
| 125 | (eventually_of_mem (Ioo_mem_nhds htopen.1 htopen.2) (fun s hs => by |
| 126 | rw [uIoc_of_le hab] |
| 127 | exact ((hslice s ⟨hs.1.le, hs.2.le⟩).mono Ioc_subset_Icc_self).aestronglyMeasurable |
| 128 | measurableSet_Ioc)) |
| 129 | ((hslice t htcc).intervalIntegrable_of_Icc hab) |
| 130 | (by |
| 131 | rw [uIoc_of_le hab] |
| 132 | exact ((hslice' t htcc).mono Ioc_subset_Icc_self).aestronglyMeasurable |
| 133 | measurableSet_Ioc) |
| 134 | (Eventually.of_forall (fun u hu s hs => by |
| 135 | rw [uIoc_of_le hab] at hu |
| 136 | exact hC (s, u) ⟨⟨hs.1.le, hs.2.le⟩, ⟨hu.1.le, hu.2⟩⟩)) |
| 137 | intervalIntegrable_const |
| 138 | (Eventually.of_forall (fun u hu s hs => by |
| 139 | rw [uIoc_of_le hab] at hu |
| 140 | exact hpoint s hs u ⟨hu.1.le, hu.2⟩)) |
| 141 | apply hkey.2.congr_deriv |
| 142 | apply intervalIntegral.integral_congr |
| 143 | intro u hu |
| 144 | rw [uIcc_of_le hab] at hu |
| 145 | dsimp only [speed', G, v] |
| 146 | rw [(F.equation t (interior_subset ht) (γ u) |
| 147 | (mfderiv 𝓘(ℝ, ℝ) (𝓡 n) γ u 1) (mfderiv 𝓘(ℝ, ℝ) (𝓡 n) γ u 1)).hasDerivAt |
| 148 | (mem_interior_iff_mem_nhds.mp ht) |>.deriv] |
| 149 | dsimp only [RiemannianMetric.tangentNorm] |
| 150 | ring |
| 151 | |
| 152 | end PoincareMT.RicciFlow |