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.Harnack.Matrix.Positivity.Contact |
| 2 | import PoincareLib.Geometry.Riemannian.ScalarOperators.Product |
| 3 | import PoincareLib.Geometry.Riemannian.Tensor.MaximumPrinciple.SupportingLaplacian |
| 4 | |
| 5 | /-! |
| 6 | # Spatial differentiation at a null Hamilton direction |
| 7 | |
| 8 | The Laplacian of a matrix quadratic retains the first spatial derivatives of |
| 9 | the test vector. At a positive-semidefinite null direction, its second |
| 10 | derivatives cancel. This is the spatial contact calculation used with the |
| 11 | prescribed extensions in Chow et al., Part II, Theorem 15.16, pp. 272-273, |
| 12 | and Section 15.4.5, p. 287. |
| 13 | -/ |
| 14 | |
| 15 | set_option autoImplicit false |
| 16 | set_option backward.isDefEq.respectTransparency false |
| 17 | |
| 18 | open scoped Manifold ContDiff Bundle BigOperators Topology |
| 19 | open Matrix |
| 20 | |
| 21 | universe u |
| 22 | |
| 23 | namespace Poincare.RicciFlow.Harnack |
| 24 | |
| 25 | open PoincareMT |
| 26 | |
| 27 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 28 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 29 | {g : RiemannianMetric n M} {I : Type} [Fintype I] |
| 30 | |
| 31 | /-- Second derivatives of the test vector cancel at a positive-semidefinite |
| 32 | null direction. The mixed first-derivative terms remain explicit. -/ |
| 33 | lemma laplacian_quadratic_at_null |
| 34 | (D : LeviCivitaData g) {A : M → Matrix I I ℝ} {z : M → I → ℝ} |
| 35 | (hA : ∀ i j, ContMDiff (𝓡 n) 𝓘(ℝ, ℝ) ∞ (fun y => A y i j)) |
| 36 | (hz : ∀ i, ContMDiff (𝓡 n) 𝓘(ℝ, ℝ) ∞ (fun y => z y i)) |
| 37 | {x : M} (hpos : (A x).PosSemidef) |
| 38 | (hnull : z x ⬝ᵥ (A x *ᵥ z x) = 0) : |
| 39 | D.laplacian (fun y => z y ⬝ᵥ (A y *ᵥ z y)) x = |
| 40 | (∑ i, ∑ j, z x i * D.laplacian (fun y => A y i j) x * z x j) + |
| 41 | 2 * (∑ i, ∑ j, |
| 42 | (z x i * g.inner x (D.gradient (fun y => A y i j) x) |
| 43 | (D.gradient (fun y => z y j) x) + |
| 44 | z x j * g.inner x (D.gradient (fun y => z y i) x) |
| 45 | (D.gradient (fun y => A y i j) x) + |
| 46 | A x i j * g.inner x (D.gradient (fun y => z y i) x) |
| 47 | (D.gradient (fun y => z y j) x))) := by |
| 48 | have hzero : A x *ᵥ z x = 0 := |
| 49 | (hpos.dotProduct_mulVec_zero_iff (z x)).mp (by simpa only [star_trivial] using hnull) |
| 50 | have hright (i : I) : (∑ j, A x i j * z x j) = 0 := congrFun hzero i |
| 51 | have hleft (j : I) : (∑ i, z x i * A x i j) = 0 := by |
| 52 | have hs (i : I) : A x i j = A x j i := by |
| 53 | simpa only [star_trivial] using hpos.1.apply j i |
| 54 | simpa only [hs, mul_comm] using hright j |
| 55 | have hcross₁ : (∑ i, ∑ j, |
| 56 | z x i * A x i j * D.laplacian (fun y => z y j) x) = 0 := by |
| 57 | rw [Finset.sum_comm] |
| 58 | simp only [← Finset.sum_mul, hleft, zero_mul, Finset.sum_const_zero] |
| 59 | have hcross₂ : (∑ i, ∑ j, |
| 60 | D.laplacian (fun y => z y i) x * (A x i j * z x j)) = 0 := by |
| 61 | simp only [← Finset.mul_sum, hright, mul_zero, Finset.sum_const_zero] |
| 62 | have hterm (i j : I) : |
| 63 | D.laplacian (fun y => z y i * A y i j * z y j) x = |
| 64 | z x i * A x i j * D.laplacian (fun y => z y j) x + |
| 65 | D.laplacian (fun y => z y i) x * (A x i j * z x j) + |
| 66 | z x i * D.laplacian (fun y => A y i j) x * z x j + |
| 67 | 2 * (z x i * g.inner x (D.gradient (fun y => A y i j) x) |
| 68 | (D.gradient (fun y => z y j) x) + |
| 69 | z x j * g.inner x (D.gradient (fun y => z y i) x) |
| 70 | (D.gradient (fun y => A y i j) x) + |
| 71 | A x i j * g.inner x (D.gradient (fun y => z y i) x) |
| 72 | (D.gradient (fun y => z y j) x)) := by |
| 73 | erw [D.laplacian_mul (f := fun y => z y i * A y i j) |
| 74 | (h := fun y => z y j) ((hz i).mul (hA i j)) (hz j), |
| 75 | D.laplacian_mul (hz i) (hA i j), |
| 76 | D.gradient_mul ((hz i x).mdifferentiableAt (by simp)) |
| 77 | ((hA i j x).mdifferentiableAt (by simp))] |
| 78 | simp only [map_add, map_smul, _root_.add_apply, _root_.smul_apply, smul_eq_mul] |
| 79 | ring |
| 80 | have heval : (fun y => z y ⬝ᵥ (A y *ᵥ z y)) = |
| 81 | (fun y => ∑ i, ∑ j, z y i * A y i j * z y j) := by |
| 82 | funext y |
| 83 | simp only [dotProduct, mulVec, Finset.mul_sum, mul_assoc] |
| 84 | rw [heval] |
| 85 | have hsmooth (i : I) : ContMDiff (𝓡 n) 𝓘(ℝ, ℝ) ∞ |
| 86 | (fun y => ∑ j, z y i * A y i j * z y j) := by |
| 87 | exact ContMDiff.sum fun j _ => ((hz i).mul (hA i j)).mul (hz j) |
| 88 | erw [D.laplacian_sum_on_open (fun i y => ∑ j, z y i * A y i j * z y j) isOpen_univ |
| 89 | (fun i => (hsmooth i).contMDiffOn) (Set.mem_univ x)] |
| 90 | have hsum (i : I) := D.laplacian_sum_on_open |
| 91 | (fun j y => z y i * A y i j * z y j) isOpen_univ |
| 92 | (fun j => (((hz i).mul (hA i j)).mul (hz j)).contMDiffOn) (Set.mem_univ x) |
| 93 | simp_rw [hsum, hterm] |
| 94 | simp only [Finset.sum_add_distrib, hcross₁, hcross₂, zero_add] |
| 95 | simp only [← Finset.mul_sum, Finset.sum_add_distrib] |
| 96 | |
| 97 | /-- A spatial null direction gives the diffusion inequality with arbitrary |
| 98 | smooth variations of the test vector. -/ |
| 99 | lemma laplacian_quadratic_nonneg_at_null |
| 100 | (D : LeviCivitaData g) {A : M → Matrix I I ℝ} {z : M → I → ℝ} |
| 101 | (hA : ∀ i j, ContMDiff (𝓡 n) 𝓘(ℝ, ℝ) ∞ (fun y => A y i j)) |
| 102 | (hz : ∀ i, ContMDiff (𝓡 n) 𝓘(ℝ, ℝ) ∞ (fun y => z y i)) |
| 103 | {x : M} (hpos : ∀ᶠ y in 𝓝 x, (A y).PosSemidef) |
| 104 | (hnull : z x ⬝ᵥ (A x *ᵥ z x) = 0) : |
| 105 | 0 ≤ (∑ i, ∑ j, z x i * D.laplacian (fun y => A y i j) x * z x j) + |
| 106 | 2 * (∑ i, ∑ j, |
| 107 | (z x i * g.inner x (D.gradient (fun y => A y i j) x) |
| 108 | (D.gradient (fun y => z y j) x) + |
| 109 | z x j * g.inner x (D.gradient (fun y => z y i) x) |
| 110 | (D.gradient (fun y => A y i j) x) + |
| 111 | A x i j * g.inner x (D.gradient (fun y => z y i) x) |
| 112 | (D.gradient (fun y => z y j) x))) := by |
| 113 | rw [← laplacian_quadratic_at_null D hA hz hpos.self_of_nhds hnull] |
| 114 | apply D.laplacian_nonneg_of_isLocalMin |
| 115 | · simp only [dotProduct, mulVec] |
| 116 | exact ContMDiff.sum fun i _ => (hz i).mul |
| 117 | (ContMDiff.sum fun j _ => (hA i j).mul (hz j)) |
| 118 | · filter_upwards [hpos] with y hy |
| 119 | change z x ⬝ᵥ (A x *ᵥ z x) ≤ z y ⬝ᵥ (A y *ᵥ z y) |
| 120 | rw [hnull] |
| 121 | simpa only [star_trivial] using hy.dotProduct_mulVec_nonneg (z y) |
| 122 | |
| 123 | private lemma exists_smooth_scalar_germ [T2Space M] |
| 124 | {f : M → ℝ} {U : Set M} (hU : IsOpen U) |
| 125 | (hf : ContMDiffOn (𝓡 n) 𝓘(ℝ, ℝ) ∞ f U) {x : M} (hx : x ∈ U) : |
| 126 | ∃ F : M → ℝ, ContMDiff (𝓡 n) 𝓘(ℝ, ℝ) ∞ F ∧ F =ᶠ[𝓝 x] f := by |
| 127 | obtain ⟨b, -, hb⟩ := (SmoothBumpFunction.nhds_basis_tsupport (I := 𝓡 n) x).mem_iff.mp |
| 128 | (hU.mem_nhds hx) |
| 129 | refine ⟨fun y => b y * f y, ?_, ?_⟩ |
| 130 | · apply contMDiff_of_tsupport |
| 131 | intro y hy |
| 132 | have hyU : y ∈ U := hb (tsupport_mul_subset_left hy) |
| 133 | exact b.contMDiffAt.mul ((hf y hyU).contMDiffAt (hU.mem_nhds hyU)) |
| 134 | · filter_upwards [b.eventuallyEq_one] with y hy |
| 135 | simp only [hy, Pi.one_apply, one_mul] |
| 136 | |
| 137 | private lemma exists_smooth_scalar_first_jet [T2Space M] |
| 138 | (x : M) (c : ℝ) (L : TangentSpace (𝓡 n) x →L[ℝ] ℝ) : |
| 139 | ∃ f : M → ℝ, ContMDiff (𝓡 n) 𝓘(ℝ, ℝ) ∞ f ∧ f x = c ∧ |
| 140 | mvfderiv (𝓡 n) f x = L := by |
| 141 | let chart := extChartAt (𝓡 n) x |
| 142 | let e : TangentSpace (𝓡 n) x ≃L[ℝ] EuclideanSpace ℝ (Fin n) := |
| 143 | { toFun := fun v => v |
| 144 | invFun := fun v => v |
| 145 | map_add' := by intros; rfl |
| 146 | map_smul' := by intros; rfl |
| 147 | left_inv := fun _ => rfl |
| 148 | right_inv := fun _ => rfl } |
| 149 | let Lc : EuclideanSpace ℝ (Fin n) →L[ℝ] ℝ := |
| 150 | L.comp e.symm.toContinuousLinearMap |
| 151 | let h : EuclideanSpace ℝ (Fin n) → ℝ := fun v => c + Lc (v - chart x) |
| 152 | have hL : ContDiff ℝ ∞ (fun v : EuclideanSpace ℝ (Fin n) => Lc (v - chart x)) := |
| 153 | Lc.contDiff.comp (contDiff_id.sub contDiff_const) |
| 154 | have hh : ContDiff ℝ ∞ h := contDiff_const.add hL |
| 155 | have hlocal : ContMDiffOn (𝓡 n) 𝓘(ℝ, ℝ) ∞ (h ∘ chart) chart.source := by |
| 156 | apply hh.contMDiff.comp_contMDiffOn |
| 157 | simpa only [chart, extChartAt_source] using |
| 158 | (contMDiffOn_extChartAt (I := 𝓡 n) (x := x) (n := ∞)) |
| 159 | obtain ⟨f, hf, heq⟩ := exists_smooth_scalar_germ |
| 160 | (isOpen_extChartAt_source x) hlocal (mem_extChartAt_source x) |
| 161 | refine ⟨f, hf, ?_, ?_⟩ |
| 162 | · rw [heq.self_of_nhds] |
| 163 | simp [h] |
| 164 | · rw [Poincare.mvfderiv_eq_of_eventuallyEq heq] |
| 165 | have hd := (Lc.hasFDerivAt.comp (chart x) |
| 166 | ((hasFDerivAt_id (chart x)).sub_const (chart x))).const_add c |
| 167 | have hd' : fderiv ℝ h (chart x) = Lc := by |
| 168 | simpa only [h, Function.comp_def, id_eq, ContinuousLinearMap.comp_id] using! hd.fderiv |
| 169 | rw [mvfderiv_comp x (hh.differentiable (by simp)).differentiableAt.mdifferentiableAt |
| 170 | (mdifferentiableAt_extChartAt (mem_chart_source _ _))] |
| 171 | simp only [mfderiv_extChartAt_self, ContinuousLinearMap.comp_id] |
| 172 | simp only [mvfderiv, mfderiv_eq_fderiv] |
| 173 | ext v |
| 174 | change fderiv ℝ h (chart x) (e v) = L v |
| 175 | rw [hd'] |
| 176 | change L (e.symm (e v)) = L v |
| 177 | rw [e.symm_apply_apply] |
| 178 | |
| 179 | /-- Local smoothness suffices for the null-direction diffusion inequality; |
| 180 | no behavior of the test fields away from the contact neighborhood is needed. -/ |
| 181 | lemma laplacian_quadratic_nonneg_at_null_on_open [T2Space M] |
| 182 | (D : LeviCivitaData g) {A : M → Matrix I I ℝ} {z : M → I → ℝ} |
| 183 | {U : Set M} (hU : IsOpen U) |
| 184 | (hA : ∀ i j, ContMDiffOn (𝓡 n) 𝓘(ℝ, ℝ) ∞ (fun y => A y i j) U) |
| 185 | (hz : ∀ i, ContMDiffOn (𝓡 n) 𝓘(ℝ, ℝ) ∞ (fun y => z y i) U) |
| 186 | {x : M} (hx : x ∈ U) (hpos : ∀ᶠ y in 𝓝 x, (A y).PosSemidef) |
| 187 | (hnull : z x ⬝ᵥ (A x *ᵥ z x) = 0) : |
| 188 | 0 ≤ (∑ i, ∑ j, z x i * D.laplacian (fun y => A y i j) x * z x j) + |
| 189 | 2 * (∑ i, ∑ j, |
| 190 | (z x i * g.inner x (D.gradient (fun y => A y i j) x) |
| 191 | (D.gradient (fun y => z y j) x) + |
| 192 | z x j * g.inner x (D.gradient (fun y => z y i) x) |
| 193 | (D.gradient (fun y => A y i j) x) + |
| 194 | A x i j * g.inner x (D.gradient (fun y => z y i) x) |
| 195 | (D.gradient (fun y => z y j) x))) := by |
| 196 | classical |
| 197 | choose B hB hBeq using fun i j => exists_smooth_scalar_germ hU (hA i j) hx |
| 198 | choose w hw hweq using fun i => exists_smooth_scalar_germ hU (hz i) hx |
| 199 | have hmatrix : (fun y i j => B i j y) =ᶠ[𝓝 x] A := by |
| 200 | filter_upwards [Filter.eventually_all.mpr |
| 201 | (fun i => Filter.eventually_all.mpr (hBeq i))] with y hy |
| 202 | exact funext fun i => funext fun j => hy i j |
| 203 | have hvector : (fun y i => w i y) =ᶠ[𝓝 x] z := by |
| 204 | filter_upwards [Filter.eventually_all.mpr hweq] with y hy |
| 205 | exact funext hy |
| 206 | have hpositive : ∀ᶠ y in 𝓝 x, Matrix.PosSemidef (fun i j => B i j y) := by |
| 207 | filter_upwards [hmatrix, hpos] with y hy hp |
| 208 | simpa only [hy] using hp |
| 209 | have hnull' : (fun i => w i x) ⬝ᵥ ((fun i j => B i j x) *ᵥ (fun i => w i x)) = 0 := by |
| 210 | simpa only [hmatrix.self_of_nhds, hvector.self_of_nhds] using hnull |
| 211 | have h := laplacian_quadratic_nonneg_at_null D hB hw hpositive hnull' |
| 212 | have hgrad {f k : M → ℝ} (heq : f =ᶠ[𝓝 x] k) : D.gradient f x = D.gradient k x := by |
| 213 | unfold LeviCivitaData.gradient |
| 214 | rw [Poincare.mvfderiv_eq_of_eventuallyEq heq] |
| 215 | simpa only [(hweq _).self_of_nhds, (hBeq _ _).self_of_nhds, |
| 216 | D.laplacian_eq_of_eventuallyEq (hBeq _ _), hgrad (hBeq _ _), hgrad (hweq _)] using h |
| 217 | |
| 218 | /-- The first derivatives of a test direction can be prescribed freely at |
| 219 | spatial contact. Only the matrix coefficients need local smoothness. -/ |
| 220 | lemma quadratic_diffusion_nonneg_of_prescribed_gradients [T2Space M] |
| 221 | (D : LeviCivitaData g) {A : M → Matrix I I ℝ} |
| 222 | {U : Set M} (hU : IsOpen U) |
| 223 | (hA : ∀ i j, ContMDiffOn (𝓡 n) 𝓘(ℝ, ℝ) ∞ (fun y => A y i j) U) |
| 224 | {x : M} (hx : x ∈ U) (hpos : ∀ᶠ y in 𝓝 x, (A y).PosSemidef) |
| 225 | (z : I → ℝ) (hnull : z ⬝ᵥ (A x *ᵥ z) = 0) |
| 226 | (V : I → TangentSpace (𝓡 n) x) : |
| 227 | 0 ≤ (∑ i, ∑ j, z i * D.laplacian (fun y => A y i j) x * z j) + |
| 228 | 2 * (∑ i, ∑ j, |
| 229 | (z i * g.inner x (D.gradient (fun y => A y i j) x) (V j) + |
| 230 | z j * g.inner x (V i) (D.gradient (fun y => A y i j) x) + |
| 231 | A x i j * g.inner x (V i) (V j))) := by |
| 232 | classical |
| 233 | choose w hw hwval hwderiv using |
| 234 | fun i => exists_smooth_scalar_first_jet x (z i) (g.inner x (V i)) |
| 235 | have hwgrad (i : I) : D.gradient (w i) x = V i := by |
| 236 | apply (g.inner_isInvertible x).injective |
| 237 | ext v |
| 238 | rw [D.inner_gradient, hwderiv i] |
| 239 | have hn : (fun i => w i x) ⬝ᵥ (A x *ᵥ (fun i => w i x)) = 0 := by |
| 240 | simpa only [hwval] using hnull |
| 241 | have h := laplacian_quadratic_nonneg_at_null_on_open D hU hA |
| 242 | (fun i => (hw i).contMDiffOn) hx hpos hn |
| 243 | simpa only [hwval, hwgrad] using h |
| 244 | |
| 245 | end Poincare.RicciFlow.Harnack |