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.Curvature.IntrinsicCalculus |
| 2 | import PoincareLib.Geometry.Riemannian.Curvature.ContractedBianchi |
| 3 | import PoincareLib.Geometry.Riemannian.Tensor.TraceRegularity |
| 4 | import PoincareLib.Geometry.Riemannian.Tensor.Linearity |
| 5 | import PoincareLib.Geometry.Riemannian.Hessian.Tensor |
| 6 | |
| 7 | /-! |
| 8 | # Traces of the Ricci-flow connection variation |
| 9 | |
| 10 | The lowered connection variation is a smooth three-tensor. Contracted Bianchi |
| 11 | annihilates its first two slots, while contraction of its first and last slots |
| 12 | is minus the scalar-curvature differential. |
| 13 | -/ |
| 14 | |
| 15 | set_option autoImplicit false |
| 16 | set_option backward.isDefEq.respectTransparency false |
| 17 | |
| 18 | open scoped Manifold ContDiff Bundle BigOperators |
| 19 | |
| 20 | namespace PoincareMT.LeviCivitaData |
| 21 | |
| 22 | variable {n : ℕ} {M : Type*} [TopologicalSpace M] |
| 23 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 24 | {g : RiemannianMetric n M} |
| 25 | |
| 26 | /-- The metric lowering of the connection variation under `partial_t g = -2 Ric`. -/ |
| 27 | noncomputable def ricciConnectionVariation (D : LeviCivitaData g) : |
| 28 | CovariantTensorEvaluation n M 3 := fun x v => |
| 29 | -D.covariantTensorDerivative D.ricciEvaluation x ![v 0, v 1, v 2] - |
| 30 | D.covariantTensorDerivative D.ricciEvaluation x ![v 1, v 0, v 2] + |
| 31 | D.covariantTensorDerivative D.ricciEvaluation x ![v 2, v 0, v 1] |
| 32 | |
| 33 | theorem ricciConnectionVariation_apply (D : LeviCivitaData g) (x : M) |
| 34 | (a b c : TangentSpace (𝓡 n) x) : |
| 35 | D.ricciConnectionVariation x ![a, b, c] = |
| 36 | -D.covariantTensorDerivative D.ricciEvaluation x ![a, b, c] - |
| 37 | D.covariantTensorDerivative D.ricciEvaluation x ![b, a, c] + |
| 38 | D.covariantTensorDerivative D.ricciEvaluation x ![c, a, b] := rfl |
| 39 | |
| 40 | theorem ricciConnectionVariation_isSmooth (D : LeviCivitaData g) : |
| 41 | IsSmoothCovariantTensor D.ricciConnectionVariation := by |
| 42 | let σ : Equiv.Perm (Fin 3) := (Equiv.swap 0 2).trans (Equiv.swap 0 1) |
| 43 | have h := D.covariantTensorDerivative_isSmooth D.ricciEvaluation_isSmooth_manifold |
| 44 | convert ((h.const_mul (-1)).sub (h.perm (Equiv.swap 0 1))).add (h.perm σ) using 1 |
| 45 | funext x v |
| 46 | have h0 : ![v 0, v 1, v 2] = v := by ext i; fin_cases i <;> rfl |
| 47 | have h1 : ![v 1, v 0, v 2] = v ∘ Equiv.swap 0 1 := by |
| 48 | ext i; fin_cases i <;> simp [Equiv.swap_apply_def] |
| 49 | have h2 : ![v 2, v 0, v 1] = v ∘ σ := by |
| 50 | ext i; fin_cases i <;> simp [σ, Equiv.swap_apply_def] |
| 51 | simp only [ricciConnectionVariation, h0, h1, h2, neg_one_mul] |
| 52 | |
| 53 | private theorem covector_eq_of_basis {S T : CovariantTensorEvaluation n M 1} |
| 54 | (hS : IsSmoothCovariantTensor S) (hT : IsSmoothCovariantTensor T) |
| 55 | (x : M) (heq : ∀ i, S x ![g.orthonormalBasis x i] = |
| 56 | T x ![g.orthonormalBasis x i]) (v : Fin 1 → TangentSpace (𝓡 n) x) : |
| 57 | S x v = T x v := by |
| 58 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 59 | ⟨g.toRiemannianMetric⟩ |
| 60 | obtain ⟨A, hA⟩ := hS.1 x |
| 61 | obtain ⟨B, hB⟩ := hT.1 x |
| 62 | let a := A.toLinearMap v 0 |
| 63 | let b := B.toLinearMap v 0 |
| 64 | have ha (w : TangentSpace (𝓡 n) x) : a w = S x ![w] := by |
| 65 | change A (Function.update v 0 w) = _ |
| 66 | rw [hA] |
| 67 | congr 1 |
| 68 | ext i; fin_cases i; simp |
| 69 | have hb (w : TangentSpace (𝓡 n) x) : b w = T x ![w] := by |
| 70 | change B (Function.update v 0 w) = _ |
| 71 | rw [hB] |
| 72 | congr 1 |
| 73 | ext i; fin_cases i; simp |
| 74 | have he : a = b := (g.orthonormalBasis x).toBasis.ext (fun i => by |
| 75 | simpa only [ha, hb, OrthonormalBasis.coe_toBasis] using heq i) |
| 76 | have hv : v = ![v 0] := by ext i; fin_cases i; rfl |
| 77 | rw [hv, ← ha, ← hb, he] |
| 78 | |
| 79 | theorem tensorTrace_ricciConnectionVariation (D : LeviCivitaData g) : |
| 80 | g.tensorTrace D.ricciConnectionVariation = fun _ _ => 0 := by |
| 81 | funext x v |
| 82 | have hz : IsSmoothCovariantTensor (n := n) (k := 1) (fun (_ : M) _ => (0 : ℝ)) := by |
| 83 | simpa only [zero_mul] using |
| 84 | ((differentialEvaluation_isSmooth D.contMDiff_scalarCurvature).const_mul 0) |
| 85 | apply covector_eq_of_basis (g := g) |
| 86 | (D.ricciConnectionVariation_isSmooth.tensorTrace (g := g)) hz x ?_ v |
| 87 | intro j |
| 88 | change (∑ i, D.ricciConnectionVariation x |
| 89 | ![g.orthonormalBasis x i, g.orthonormalBasis x i, g.orthonormalBasis x j]) = 0 |
| 90 | simp only [D.ricciConnectionVariation_apply, Finset.sum_add_distrib, |
| 91 | Finset.sum_sub_distrib, Finset.sum_neg_distrib] |
| 92 | simp_rw [D.covariantTensorDerivative_ricciEvaluation_symm |
| 93 | D.intrinsicCurvatureTensorCalculus x (g.orthonormalBasis x _) (g.orthonormalBasis x _) |
| 94 | (g.orthonormalBasis x j)] |
| 95 | change -(∑ i, D.frameRicciDerivative x i j i) - |
| 96 | (∑ i, D.frameRicciDerivative x i j i) + (∑ i, D.frameRicciDerivative x j i i) = 0 |
| 97 | rw [D.frameRicciDerivative_trace D.intrinsicCurvatureTensorCalculus, |
| 98 | D.frameRicciDerivative_scalar_trace D.intrinsicCurvatureTensorCalculus] |
| 99 | ring |
| 100 | |
| 101 | theorem sum_ricciConnectionVariation_first_last (D : LeviCivitaData g) |
| 102 | (x : M) (u : TangentSpace (𝓡 n) x) : |
| 103 | (∑ i, D.ricciConnectionVariation x |
| 104 | ![g.orthonormalBasis x i, u, g.orthonormalBasis x i]) = |
| 105 | -mvfderiv (𝓡 n) D.scalarCurvature x u := by |
| 106 | simp only [D.ricciConnectionVariation_apply, Finset.sum_add_distrib, |
| 107 | Finset.sum_sub_distrib, Finset.sum_neg_distrib] |
| 108 | rw [D.sum_covariantTensorDerivative_ricci_eq_scalar_derivative |
| 109 | D.intrinsicCurvatureTensorCalculus] |
| 110 | simp_rw [D.covariantTensorDerivative_ricciEvaluation_symm |
| 111 | D.intrinsicCurvatureTensorCalculus x (g.orthonormalBasis x _) (g.orthonormalBasis x _) u] |
| 112 | ring |
| 113 | |
| 114 | theorem sum_covariantDerivative_ricciConnectionVariation_first_two |
| 115 | (D : LeviCivitaData g) (x : M) (u v : TangentSpace (𝓡 n) x) : |
| 116 | (∑ i, D.covariantTensorDerivative D.ricciConnectionVariation x |
| 117 | ![u, g.orthonormalBasis x i, g.orthonormalBasis x i, v]) = 0 := by |
| 118 | have h := D.covariantTensorDerivative_tensorTrace D.ricciConnectionVariation_isSmooth x u ![v] |
| 119 | rw [D.tensorTrace_ricciConnectionVariation] at h |
| 120 | change D.covariantTensorDerivative (fun _ _ => 0) x ![u, v] = |
| 121 | (∑ i, D.covariantTensorDerivative D.ricciConnectionVariation x |
| 122 | ![u, g.orthonormalBasis x i, g.orthonormalBasis x i, v]) at h |
| 123 | rw [← h] |
| 124 | simp [covariantTensorDerivative, mvfderiv_const] |
| 125 | |
| 126 | theorem sum_covariantDerivative_ricciConnectionVariation_first_last |
| 127 | (D : LeviCivitaData g) (x : M) (u v : TangentSpace (𝓡 n) x) : |
| 128 | (∑ i, D.covariantTensorDerivative D.ricciConnectionVariation x |
| 129 | ![u, g.orthonormalBasis x i, v, g.orthonormalBasis x i]) = |
| 130 | -D.hessian D.scalarCurvature x u v := by |
| 131 | let σ : Equiv.Perm (Fin 3) := Equiv.swap 1 2 |
| 132 | let T : CovariantTensorEvaluation n M 3 := fun y w => D.ricciConnectionVariation y (w ∘ σ) |
| 133 | have hp (y : M) (a b c : TangentSpace (𝓡 n) y) : |
| 134 | ![a, b, c] ∘ σ = ![a, c, b] := by |
| 135 | ext i; fin_cases i <;> simp [σ, Equiv.swap_apply_def] |
| 136 | have htrace : g.tensorTrace T = fun y w => -mvfderiv (𝓡 n) D.scalarCurvature y (w 0) := by |
| 137 | funext y w |
| 138 | change (∑ i, T y ![g.orthonormalBasis y i, g.orthonormalBasis y i, w 0]) = _ |
| 139 | simp only [T, hp] |
| 140 | exact D.sum_ricciConnectionVariation_first_last y (w 0) |
| 141 | have h := D.covariantTensorDerivative_tensorTrace |
| 142 | (D.ricciConnectionVariation_isSmooth.perm σ) x u ![v] |
| 143 | change D.covariantTensorDerivative (g.tensorTrace T) x ![u, v] = _ at h |
| 144 | rw [htrace] at h |
| 145 | have hd (a b c : TangentSpace (𝓡 n) x) : |
| 146 | D.covariantTensorDerivative T x ![u, a, b, c] = |
| 147 | D.covariantTensorDerivative D.ricciConnectionVariation x ![u, a, c, b] := by |
| 148 | rw [show T = (fun y w => D.ricciConnectionVariation y (w ∘ σ)) from rfl, |
| 149 | D.covariantTensorDerivative_reindex] |
| 150 | change D.covariantTensorDerivative D.ricciConnectionVariation x |
| 151 | (Fin.cons u (![a, b, c] ∘ σ)) = _ |
| 152 | rw [hp] |
| 153 | rfl |
| 154 | change _ = ∑ i, D.covariantTensorDerivative T x |
| 155 | ![u, g.orthonormalBasis x i, g.orthonormalBasis x i, v] at h |
| 156 | simp only [hd] at h |
| 157 | rw [← h] |
| 158 | have hn := congrArg (fun S => S x ![u, v]) |
| 159 | (D.covariantTensorDerivative_const_mul |
| 160 | (differentialEvaluation_isSmooth D.contMDiff_scalarCurvature) (-1)) |
| 161 | simpa only [neg_one_mul, ← D.hessian_eq_covariantTensorDerivative, |
| 162 | differentialEvaluation] using hn |
| 163 | |
| 164 | end PoincareMT.LeviCivitaData |