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.Analysis.Matrix.Determinant |
| 2 | import PoincareLib.Geometry.RicciFlow.Basic |
| 3 | import PoincareLib.Geometry.Riemannian.Measure.Density |
| 4 | import PoincareLib.Geometry.Riemannian.Measure.Basic |
| 5 | import PoincareLib.Geometry.Riemannian.Tensor.Contraction |
| 6 | import Mathlib.Analysis.Calculus.ParametricIntegral |
| 7 | import Mathlib.Analysis.Calculus.Deriv.Prod |
| 8 | import Mathlib.MeasureTheory.Function.LocallyIntegrable |
| 9 | |
| 10 | /-! |
| 11 | # Local volume evolution for curvature control |
| 12 | |
| 13 | Jacobi's formula and the retained Ricci-flow equation give the local |
| 14 | volume-density evolution used in the fixed-ball volume argument of |
| 15 | Cabezas-Rivas--Wilking, Proposition 4.3, equation (4.2), p. 3161. |
| 16 | |
| 17 | The determinant argument follows AxelWorkspace's |
| 18 | `MorganTianLib/Ch03/RicciFlow/VolumeEvolution.lean` at revision |
| 19 | `f1cdb30cabdc8781d2d3dec86d3d99ab1820f30e`, and Chow--Liao--Qin's |
| 20 | `Geometry/Flow/RicciFlow/Evolution/Volume.lean` at revision |
| 21 | `1b535dd102b94cc42b107cca27059687888f08b3`. |
| 22 | -/ |
| 23 | |
| 24 | set_option autoImplicit false |
| 25 | set_option backward.isDefEq.respectTransparency false |
| 26 | |
| 27 | open Set MeasureTheory Filter |
| 28 | open scoped Manifold ContDiff Bundle BigOperators Topology |
| 29 | |
| 30 | universe u |
| 31 | |
| 32 | namespace PoincareMT.RicciFlow |
| 33 | |
| 34 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 35 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 36 | {J : Set ℝ} |
| 37 | |
| 38 | private lemma scalar_eq_inverse_gram_ricci |
| 39 | {g : RiemannianMetric n M} (D : LeviCivitaData g) |
| 40 | (hD : D.CurvatureTensorCalculus) (x : M) |
| 41 | (b : Module.Basis (Fin n) ℝ (TangentSpace (𝓡 n) x)) : |
| 42 | D.scalarCurvature x = |
| 43 | ∑ i, ∑ j, (Matrix.of (fun i j => g.inner x (b i) (b j)))⁻¹ i j * |
| 44 | D.ricci x (b i) (b j) := by |
| 45 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 46 | ⟨g.toRiemannianMetric⟩ |
| 47 | obtain ⟨A, hA⟩ := hD.2.1.1 x |
| 48 | have h := bilinear_sum_basis_eq_inverse_gram (bilinearOfTwoTensor A) |
| 49 | b (g.orthonormalBasis x) |
| 50 | change (∑ a, bilinearOfTwoTensor A (g.orthonormalBasis x a) (g.orthonormalBasis x a)) = |
| 51 | ∑ i, ∑ j, (Matrix.of (fun i j => g.inner x (b i) (b j)))⁻¹ i j * |
| 52 | bilinearOfTwoTensor A (b i) (b j) at h |
| 53 | simpa only [LeviCivitaData.scalarCurvature, bilinearOfTwoTensor_apply, ← hA, |
| 54 | LeviCivitaData.ricciEvaluation, |
| 55 | Matrix.cons_val_zero, Matrix.cons_val_one] using h |
| 56 | |
| 57 | private lemma hasDerivAt_basis_density |
| 58 | (F : RicciFlow n M J) {t : ℝ} (ht : t ∈ interior J) (x : M) |
| 59 | (hD : (F.connection t).CurvatureTensorCalculus) |
| 60 | (b : Module.Basis (Fin n) ℝ (TangentSpace (𝓡 n) x)) : |
| 61 | HasDerivAt |
| 62 | (fun s => Real.sqrt (Matrix.of (fun i j => (F.metric s).inner x (b i) (b j))).det) |
| 63 | (-(F.connection t).scalarCurvature x * |
| 64 | Real.sqrt (Matrix.of (fun i j => (F.metric t).inner x (b i) (b j))).det) t := by |
| 65 | classical |
| 66 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 67 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 68 | let G := fun s => Matrix.of (fun i j => (F.metric s).inner x (b i) (b j)) |
| 69 | let G' := Matrix.of (fun i j => -2 * (F.connection t).ricci x (b i) (b j)) |
| 70 | have hpos : 0 < (G t).det := |
| 71 | (Matrix.posDef_gram_of_linearIndependent b.linearIndependent).det_pos |
| 72 | have hd := Poincare.Matrix.hasDerivAt_sqrt_det_eq_half_trace_inv_mul G G' t |
| 73 | (fun i j => (F.equation t (interior_subset ht) x (b i) (b j)).hasDerivAt |
| 74 | (mem_interior_iff_mem_nhds.mp ht)) hpos |
| 75 | have hscalar := scalar_eq_inverse_gram_ricci (F.connection t) hD x b |
| 76 | have hsymm (i j : Fin n) : |
| 77 | (F.connection t).ricci x (b j) (b i) = |
| 78 | (F.connection t).ricci x (b i) (b j) := |
| 79 | (hD.2.2.2.1 x (b j) (b i) (b j) (b i)).2.2.2 |
| 80 | have htrace : Matrix.trace ((G t)⁻¹ * G') = |
| 81 | -2 * (F.connection t).scalarCurvature x := by |
| 82 | rw [hscalar] |
| 83 | simp only [Matrix.trace, Matrix.diag_apply, Matrix.mul_apply, G', Matrix.of_apply, |
| 84 | hsymm, Finset.mul_sum] |
| 85 | dsimp only [G] |
| 86 | congr 1 |
| 87 | ext i |
| 88 | congr 1 |
| 89 | ext j |
| 90 | ring |
| 91 | rw [htrace] at hd |
| 92 | convert hd using 1 |
| 93 | ring |
| 94 | |
| 95 | /-- The retained Ricci-flow equation differentiates the local metric density. |
| 96 | Only the differential of the fixed parametrization at the selected point is used. -/ |
| 97 | theorem hasDerivAt_pullbackVolumeDensity |
| 98 | (F : RicciFlow n M J) {t : ℝ} (ht : t ∈ interior J) |
| 99 | (hD : (F.connection t).CurvatureTensorCalculus) |
| 100 | (f : EuclideanSpace ℝ (Fin n) → M) (x : EuclideanSpace ℝ (Fin n)) |
| 101 | (hi : Function.Injective (mfderiv (𝓡 n) (𝓡 n) f x)) : |
| 102 | HasDerivAt (fun s => (F.metric s).pullbackVolumeDensity f x) |
| 103 | (-(F.connection t).scalarCurvature (f x) * |
| 104 | (F.metric t).pullbackVolumeDensity f x) t := by |
| 105 | let L : EuclideanSpace ℝ (Fin n) →ₗ[ℝ] EuclideanSpace ℝ (Fin n) := |
| 106 | (mfderiv (𝓡 n) (𝓡 n) f x).toLinearMap |
| 107 | let e := LinearEquiv.ofInjectiveEndo L hi |
| 108 | let b : Module.Basis (Fin n) ℝ (TangentSpace (𝓡 n) (f x)) := |
| 109 | (EuclideanSpace.basisFun (Fin n) ℝ).toBasis.map e |
| 110 | have hb (i : Fin n) : b i = |
| 111 | mfderiv (𝓡 n) (𝓡 n) f x (EuclideanSpace.basisFun (Fin n) ℝ i) := rfl |
| 112 | simpa only [RiemannianMetric.pullbackVolumeDensity, hb] using |
| 113 | F.hasDerivAt_basis_density ht (f x) hD b |
| 114 | |
| 115 | private lemma contDiffAt_pullback_inner_spacetime |
| 116 | (F : RicciFlow n M J) {t : ℝ} (ht : t ∈ interior J) |
| 117 | {f : EuclideanSpace ℝ (Fin n) → M} {x : EuclideanSpace ℝ (Fin n)} |
| 118 | (hf : ContMDiffAt (𝓡 n) (𝓡 n) ∞ f x) |
| 119 | (v w : EuclideanSpace ℝ (Fin n)) : |
| 120 | ContDiffAt ℝ ∞ (fun p : ℝ × EuclideanSpace ℝ (Fin n) => |
| 121 | (F.metric p.1).inner (f p.2) (mfderiv (𝓡 n) (𝓡 n) f p.2 v) |
| 122 | (mfderiv (𝓡 n) (𝓡 n) f p.2 w)) (t, x) := by |
| 123 | have hg := (F.smooth (t, f x) ⟨interior_subset ht, mem_univ _⟩).contMDiffAt |
| 124 | (prod_mem_nhds (mem_interior_iff_mem_nhds.mp ht) Filter.univ_mem) |
| 125 | have hp : ContMDiffAt (𝓘(ℝ, ℝ).prod (𝓡 n)) |
| 126 | (𝓘(ℝ, ℝ).prod (𝓡 n)) ∞ |
| 127 | (fun p : ℝ × EuclideanSpace ℝ (Fin n) => (p.1, f p.2)) (t, x) := |
| 128 | contMDiffAt_fst.prodMk (hf.comp (t, x) contMDiffAt_snd) |
| 129 | have hv (v : EuclideanSpace ℝ (Fin n)) : |
| 130 | ContMDiffAt (𝓘(ℝ, ℝ).prod (𝓡 n)) ((𝓡 n).prod (𝓡 n)) ∞ |
| 131 | (fun p : ℝ × EuclideanSpace ℝ (Fin n) => |
| 132 | Bundle.TotalSpace.mk' (EuclideanSpace ℝ (Fin n)) (f p.2) |
| 133 | (mfderiv (𝓡 n) (𝓡 n) f p.2 v)) (t, x) := |
| 134 | (RiemannianMetric.contMDiffAt_mfderiv_const_vector hf v).comp |
| 135 | (t, x) contMDiffAt_snd |
| 136 | have h := (hg.comp (t, x) hp).clm_bundle_apply₂ (F₃ := ℝ) |
| 137 | (E₃ := Bundle.Trivial M ℝ) (hv v) (hv w) |
| 138 | have hh := (Bundle.contMDiffAt_totalSpace.mp h).2 |
| 139 | simp +instances only [← modelWithCornersSelf_prod, chartedSpaceSelf_prod] at hh |
| 140 | exact hh.contDiffAt |
| 141 | |
| 142 | /-- The same density is jointly smooth on each immersion germ at interior times. -/ |
| 143 | lemma contDiffAt_pullbackVolumeDensity_spacetime |
| 144 | (F : RicciFlow n M J) {t : ℝ} (ht : t ∈ interior J) |
| 145 | {f : EuclideanSpace ℝ (Fin n) → M} {x : EuclideanSpace ℝ (Fin n)} |
| 146 | (hf : ContMDiffAt (𝓡 n) (𝓡 n) ∞ f x) |
| 147 | (hi : Function.Injective (mfderiv (𝓡 n) (𝓡 n) f x)) : |
| 148 | ContDiffAt ℝ ∞ (fun p : ℝ × EuclideanSpace ℝ (Fin n) => |
| 149 | (F.metric p.1).pullbackVolumeDensity f p.2) (t, x) := by |
| 150 | classical |
| 151 | let b := EuclideanSpace.basisFun (Fin n) ℝ |
| 152 | let G := fun p : ℝ × EuclideanSpace ℝ (Fin n) => |
| 153 | Matrix.of (fun i j => (F.metric p.1).inner (f p.2) |
| 154 | (mfderiv (𝓡 n) (𝓡 n) f p.2 (b i)) (mfderiv (𝓡 n) (𝓡 n) f p.2 (b j))) |
| 155 | have hdet : ContDiffAt ℝ ∞ (fun p => (G p).det) (t, x) := by |
| 156 | have heq : (fun p => (G p).det) = fun p => |
| 157 | ∑ σ : Equiv.Perm (Fin n), (Equiv.Perm.sign σ : ℝ) * ∏ i, G p (σ i) i := by |
| 158 | funext p |
| 159 | simp [Matrix.det_apply, Units.smul_def] |
| 160 | rw [heq] |
| 161 | apply ContDiffAt.sum |
| 162 | intro σ _ |
| 163 | apply contDiffAt_const.mul |
| 164 | exact contDiffAt_prod fun i _ => F.contDiffAt_pullback_inner_spacetime ht hf _ _ |
| 165 | exact hdet.sqrt ((F.metric t).pullback_gram_det_ne_zero (f x) |
| 166 | (mfderiv (𝓡 n) (𝓡 n) f x).toLinearMap hi) |
| 167 | |
| 168 | /-- A containing compact coordinate set supplies domination for volume evolution |
| 169 | on every measurable subset. -/ |
| 170 | theorem hasDerivAt_integral_pullbackVolumeDensity_of_subset |
| 171 | (F : RicciFlow n M J) {t : ℝ} (ht : t ∈ interior J) |
| 172 | (hD : (F.connection t).CurvatureTensorCalculus) |
| 173 | (f : EuclideanSpace ℝ (Fin n) → M) {K L : Set (EuclideanSpace ℝ (Fin n))} |
| 174 | (hK : MeasurableSet K) (hL : IsCompact L) (hKL : K ⊆ L) |
| 175 | (hf : ∀ x ∈ L, ContMDiffAt (𝓡 n) (𝓡 n) ∞ f x) |
| 176 | (hi : ∀ x ∈ L, Function.Injective (mfderiv (𝓡 n) (𝓡 n) f x)) : |
| 177 | HasDerivAt (fun s => ∫ x in K, (F.metric s).pullbackVolumeDensity f x) |
| 178 | (∫ x in K, -(F.connection t).scalarCurvature (f x) * |
| 179 | (F.metric t).pullbackVolumeDensity f x) t := by |
| 180 | let ρ := fun p : ℝ × EuclideanSpace ℝ (Fin n) => |
| 181 | (F.metric p.1).pullbackVolumeDensity f p.2 |
| 182 | let q := fun s x => fderiv ℝ ρ (s, x) (1, 0) |
| 183 | have hsmooth (s : ℝ) (hs : s ∈ interior J) (x : EuclideanSpace ℝ (Fin n)) |
| 184 | (hx : x ∈ L) : ContDiffAt ℝ ∞ ρ (s, x) := |
| 185 | F.contDiffAt_pullbackVolumeDensity_spacetime hs (hf x hx) (hi x hx) |
| 186 | have hρ (s : ℝ) (hs : s ∈ interior J) : ContinuousOn (fun x => ρ (s, x)) L := by |
| 187 | intro x hx |
| 188 | exact ((hsmooth s hs x hx).continuousAt.comp |
| 189 | (continuousAt_const.prodMk continuousAt_id)).continuousWithinAt |
| 190 | have hq : ContinuousOn (fun p : ℝ × EuclideanSpace ℝ (Fin n) => q p.1 p.2) |
| 191 | (interior J ×ˢ L) := by |
| 192 | rintro ⟨s, x⟩ ⟨hs, hx⟩ |
| 193 | exact (((hsmooth s hs x hx).fderiv_right (m := ∞) (by simp)).clm_apply |
| 194 | contDiffAt_const).continuousAt.continuousWithinAt |
| 195 | have hqs (s : ℝ) (hs : s ∈ interior J) : ContinuousOn (q s) L := |
| 196 | hq.comp (continuousOn_const.prodMk continuousOn_id) (fun _ hx => ⟨hs, hx⟩) |
| 197 | have hd (s : ℝ) (hs : s ∈ interior J) (x : EuclideanSpace ℝ (Fin n)) |
| 198 | (hx : x ∈ L) : HasDerivAt (fun r => ρ (r, x)) (q s x) s := by |
| 199 | exact ((hsmooth s hs x hx).differentiableAt (by simp)).hasFDerivAt.comp_hasDerivAt s |
| 200 | ((hasDerivAt_id s).prodMk (hasDerivAt_const s x)) |
| 201 | obtain ⟨r, hr, hball⟩ := Metric.isOpen_iff.mp isOpen_interior t ht |
| 202 | have hcl : Metric.closedBall t (r / 2) ⊆ interior J := |
| 203 | (Metric.closedBall_subset_ball (by linarith)).trans hball |
| 204 | obtain ⟨C, hC⟩ := ((isCompact_closedBall t (r / 2)).prod hL).exists_bound_of_continuousOn |
| 205 | (hq.mono (prod_mono hcl Subset.rfl)) |
| 206 | have hbound : Integrable (fun _ : EuclideanSpace ℝ (Fin n) => C) |
| 207 | (volume.restrict K) := integrableOn_const |
| 208 | (lt_of_le_of_lt (measure_mono hKL) hL.measure_lt_top).ne |
| 209 | have hint := (hasDerivAt_integral_of_dominated_loc_of_deriv_le |
| 210 | (F := fun s x => ρ (s, x)) (F' := q) (μ := volume.restrict K) |
| 211 | (bound := fun _ => C) |
| 212 | (Metric.closedBall_mem_nhds t (by positivity : 0 < r / 2)) |
| 213 | (by |
| 214 | filter_upwards [isOpen_interior.mem_nhds ht] with s hs |
| 215 | exact ((hρ s hs).mono hKL).aestronglyMeasurable hK) |
| 216 | (((hρ t ht).integrableOn_compact hL).mono_set hKL) |
| 217 | (((hqs t ht).mono hKL).aestronglyMeasurable hK) |
| 218 | (by |
| 219 | filter_upwards [ae_restrict_mem hK] with x hx |
| 220 | intro s hs |
| 221 | exact hC (s, x) ⟨hs, hKL hx⟩) |
| 222 | hbound |
| 223 | (by |
| 224 | filter_upwards [ae_restrict_mem hK] with x hx |
| 225 | intro s hs |
| 226 | exact hd s (hcl hs) x (hKL hx))).2 |
| 227 | apply hint.congr_deriv |
| 228 | apply setIntegral_congr_fun hK |
| 229 | intro x hx |
| 230 | exact (hd t ht x (hKL hx)).unique |
| 231 | (F.hasDerivAt_pullbackVolumeDensity ht hD f x (hi x (hKL hx))) |
| 232 | |
| 233 | /-- Compact coordinate sets supply the domination for the volume derivative. -/ |
| 234 | theorem hasDerivAt_integral_pullbackVolumeDensity |
| 235 | (F : RicciFlow n M J) {t : ℝ} (ht : t ∈ interior J) |
| 236 | (hD : (F.connection t).CurvatureTensorCalculus) |
| 237 | (f : EuclideanSpace ℝ (Fin n) → M) {K : Set (EuclideanSpace ℝ (Fin n))} |
| 238 | (hK : IsCompact K) |
| 239 | (hf : ∀ x ∈ K, ContMDiffAt (𝓡 n) (𝓡 n) ∞ f x) |
| 240 | (hi : ∀ x ∈ K, Function.Injective (mfderiv (𝓡 n) (𝓡 n) f x)) : |
| 241 | HasDerivAt (fun s => ∫ x in K, (F.metric s).pullbackVolumeDensity f x) |
| 242 | (∫ x in K, -(F.connection t).scalarCurvature (f x) * |
| 243 | (F.metric t).pullbackVolumeDensity f x) t := |
| 244 | F.hasDerivAt_integral_pullbackVolumeDensity_of_subset ht hD f |
| 245 | hK.measurableSet hK Subset.rfl hf hi |
| 246 | |
| 247 | end PoincareMT.RicciFlow |