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.ScalarEvolution.CurvatureVariation |
| 2 | import PoincareLib.Geometry.RicciFlow.Tensor.TimeDerivative.Trace |
| 3 | |
| 4 | /-! |
| 5 | # Scalar-curvature evolution |
| 6 | |
| 7 | Tracing the intrinsic curvature first variation gives |
| 8 | `partial_t R = Delta R + 2 |Ric|^2` at every interior flow time. |
| 9 | -/ |
| 10 | |
| 11 | set_option autoImplicit false |
| 12 | set_option backward.isDefEq.respectTransparency false |
| 13 | |
| 14 | open Set |
| 15 | open scoped Manifold ContDiff Bundle Topology BigOperators |
| 16 | |
| 17 | namespace PoincareMT |
| 18 | |
| 19 | variable {n : ℕ} {M : Type*} [TopologicalSpace M] |
| 20 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 21 | |
| 22 | namespace RicciFlow |
| 23 | |
| 24 | variable {J : Set ℝ} |
| 25 | |
| 26 | private noncomputable def ricciVariation (F : RicciFlow n M J) (t : ℝ) : |
| 27 | CovariantTensorEvaluation n M 2 := fun x v => |
| 28 | let D := F.connection t |
| 29 | let b := (F.metric t).orthonormalBasis x |
| 30 | (∑ i, (-2 * D.ricci x (D.curvature x (v 0) (b i) (b i)) (v 1) + |
| 31 | D.covariantTensorDerivative D.ricciConnectionVariation x ![v 0, b i, b i, v 1] - |
| 32 | D.covariantTensorDerivative D.ricciConnectionVariation x ![b i, v 0, b i, v 1])) + |
| 33 | 2 * ∑ i, ∑ j, D.ricci x (b i) (b j) * D.curvatureTensor x (v 0) (b i) (v 1) (b j) |
| 34 | |
| 35 | private theorem hasDerivAt_ricci_connectionVariation |
| 36 | (F : RicciFlow n M J) {t : ℝ} (ht : t ∈ interior J) |
| 37 | (x : M) (v : Fin 2 → TangentSpace (𝓡 n) x) : |
| 38 | HasDerivAt (fun s => (F.connection s).ricciEvaluation x v) |
| 39 | (ricciVariation F t x v) t := by |
| 40 | let σ : Equiv.Perm (Fin 4) := |
| 41 | { toFun := ![2, 0, 3, 1] |
| 42 | invFun := ![1, 3, 0, 2] |
| 43 | left_inv := by decide |
| 44 | right_inv := by decide } |
| 45 | let T : ℝ → CovariantTensorEvaluation n M 4 := fun s y w => |
| 46 | (F.connection s).riemannEvaluation y (w ∘ σ) |
| 47 | let W : ℝ → CovariantTensorEvaluation n M 4 := fun _ y w => |
| 48 | let D := F.connection t; |
| 49 | -2 * D.ricci y (D.curvature y (w 2) (w 0) (w 1)) (w 3) + |
| 50 | D.covariantTensorDerivative D.ricciConnectionVariation y ![w 2, w 0, w 1, w 3] - |
| 51 | D.covariantTensorDerivative D.ricciConnectionVariation y ![w 0, w 2, w 1, w 3] |
| 52 | have hW (z : Fin 4 → TangentSpace (𝓡 n) x) : |
| 53 | HasDerivAt (fun s => T s x z) (W t x z) t := |
| 54 | F.hasDerivAt_curvatureTensor_connectionVariation ht x (z 2) (z 0) (z 3) (z 1) |
| 55 | have h := F.hasDerivAt_tensorTrace (T := T) (W := W) ht x |
| 56 | (fun s => (F.connection s).riemannEvaluation_isSmooth_manifold.perm σ) hW v |
| 57 | have htrace (s : ℝ) : (F.metric s).tensorTrace (T s) x v = |
| 58 | (F.connection s).ricciEvaluation x v := rfl |
| 59 | simp_rw [htrace] at h |
| 60 | apply h.congr_deriv |
| 61 | rfl |
| 62 | |
| 63 | end RicciFlow |
| 64 | |
| 65 | namespace LeviCivitaData |
| 66 | |
| 67 | variable {g : RiemannianMetric n M} |
| 68 | |
| 69 | private theorem sum_ricci_curvature_eq_sum_ricci_sq (D : LeviCivitaData g) (x : M) : |
| 70 | (∑ i, ∑ j, D.ricci x |
| 71 | (D.curvature x (g.orthonormalBasis x i) (g.orthonormalBasis x j) |
| 72 | (g.orthonormalBasis x j)) (g.orthonormalBasis x i)) = D.ricciNormSq x := by |
| 73 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 74 | ⟨g.toRiemannianMetric⟩ |
| 75 | let b := g.orthonormalBasis x |
| 76 | obtain ⟨A, hA⟩ := D.ricciEvaluation_isSmooth_manifold.1 x |
| 77 | let B := bilinearOfTwoTensor A |
| 78 | have hB (a c : TangentSpace (𝓡 n) x) : B a c = D.ricci x a c := (hA ![a, c]).symm |
| 79 | have hexp (a c : TangentSpace (𝓡 n) x) : |
| 80 | D.ricci x a c = ∑ k, g.inner x a (b k) * D.ricci x (b k) c := by |
| 81 | conv_lhs => rw [← hB, ← b.sum_repr' a] |
| 82 | simp only [map_sum, map_smul, LinearMap.sum_apply, LinearMap.smul_apply, |
| 83 | hB, smul_eq_mul] |
| 84 | apply Finset.sum_congr rfl |
| 85 | intro k _ |
| 86 | rw [real_inner_comm] |
| 87 | rfl |
| 88 | change (∑ i, ∑ j, D.ricci x (D.curvature x (b i) (b j) (b j)) (b i)) = _ |
| 89 | conv_lhs => arg 2; ext i; arg 2; ext j; rw [hexp] |
| 90 | change (∑ i, ∑ j, ∑ k, |
| 91 | D.curvatureTensor x (b i) (b j) (b k) (b j) * D.ricci x (b k) (b i)) = _ |
| 92 | calc |
| 93 | _ = ∑ i, ∑ k, D.ricci x (b i) (b k) * D.ricci x (b k) (b i) := by |
| 94 | apply Finset.sum_congr rfl |
| 95 | intro i _ |
| 96 | rw [Finset.sum_comm] |
| 97 | simp only [← Finset.sum_mul, ricci, b] |
| 98 | _ = D.ricciNormSq x := by |
| 99 | unfold ricciNormSq |
| 100 | apply Finset.sum_congr rfl |
| 101 | intro i _ |
| 102 | apply Finset.sum_congr rfl |
| 103 | intro j _ |
| 104 | rw [D.ricci_symmetric x (b j) (b i)] |
| 105 | exact (pow_two _).symm |
| 106 | |
| 107 | private theorem sum_ricci_curvature_contraction (D : LeviCivitaData g) (x : M) : |
| 108 | (∑ k, ∑ i, ∑ j, |
| 109 | D.ricci x (g.orthonormalBasis x i) (g.orthonormalBasis x j) * |
| 110 | D.curvatureTensor x (g.orthonormalBasis x k) (g.orthonormalBasis x i) |
| 111 | (g.orthonormalBasis x k) (g.orthonormalBasis x j)) = D.ricciNormSq x := by |
| 112 | let b := g.orthonormalBasis x |
| 113 | change (∑ k, ∑ i, ∑ j, D.ricci x (b i) (b j) * |
| 114 | D.curvatureTensor x (b k) (b i) (b k) (b j)) = _ |
| 115 | rw [Finset.sum_comm] |
| 116 | calc |
| 117 | _ = ∑ i, ∑ j, D.ricci x (b i) (b j) * D.ricci x (b i) (b j) := by |
| 118 | apply Finset.sum_congr rfl |
| 119 | intro i _ |
| 120 | rw [Finset.sum_comm] |
| 121 | apply Finset.sum_congr rfl |
| 122 | intro j _ |
| 123 | rw [← Finset.mul_sum] |
| 124 | congr 1 |
| 125 | unfold ricci |
| 126 | apply Finset.sum_congr rfl |
| 127 | intro k _ |
| 128 | rw [D.curvatureTensor_swap_first, D.curvatureTensor_swap_last x (b i)] |
| 129 | simp only [neg_neg] |
| 130 | rfl |
| 131 | _ = D.ricciNormSq x := by simp only [ricciNormSq, pow_two, b] |
| 132 | |
| 133 | private theorem sum_connectionVariation_derivative_eq_laplacian (D : LeviCivitaData g) (x : M) : |
| 134 | (∑ i, ∑ j, |
| 135 | (D.covariantTensorDerivative D.ricciConnectionVariation x |
| 136 | ![g.orthonormalBasis x i, g.orthonormalBasis x j, |
| 137 | g.orthonormalBasis x j, g.orthonormalBasis x i] - |
| 138 | D.covariantTensorDerivative D.ricciConnectionVariation x |
| 139 | ![g.orthonormalBasis x j, g.orthonormalBasis x i, |
| 140 | g.orthonormalBasis x j, g.orthonormalBasis x i])) = |
| 141 | D.laplacian D.scalarCurvature x := by |
| 142 | simp only [Finset.sum_sub_distrib, |
| 143 | D.sum_covariantDerivative_ricciConnectionVariation_first_two, |
| 144 | zero_sub, Finset.sum_neg_distrib] |
| 145 | rw [Finset.sum_comm] |
| 146 | simp only [D.sum_covariantDerivative_ricciConnectionVariation_first_last, |
| 147 | Finset.sum_neg_distrib, neg_neg, laplacian] |
| 148 | |
| 149 | end LeviCivitaData |
| 150 | |
| 151 | namespace RicciFlow |
| 152 | |
| 153 | variable {J : Set ℝ} |
| 154 | |
| 155 | /-- Scalar curvature satisfies its intrinsic evolution equation on every |
| 156 | interior time slice of the actual Ricci flow. -/ |
| 157 | theorem hasDerivAt_scalarCurvature |
| 158 | (F : RicciFlow n M J) {t : ℝ} (ht : t ∈ interior J) (x : M) : |
| 159 | HasDerivAt (fun s => (F.connection s).scalarCurvature x) |
| 160 | ((F.connection t).laplacian (F.connection t).scalarCurvature x + |
| 161 | 2 * (F.connection t).ricciNormSq x) t := by |
| 162 | let T : ℝ → CovariantTensorEvaluation n M 2 := fun s => (F.connection s).ricciEvaluation |
| 163 | let W : ℝ → CovariantTensorEvaluation n M 2 := fun _ => ricciVariation F t |
| 164 | have h := F.hasDerivAt_tensorTrace (T := T) (W := W) ht x |
| 165 | (fun s => (F.connection s).ricciEvaluation_isSmooth_manifold) |
| 166 | (F.hasDerivAt_ricci_connectionVariation ht x) Fin.elim0 |
| 167 | change HasDerivAt (fun s => (F.connection s).scalarCurvature x) _ t at h |
| 168 | apply h.congr_deriv |
| 169 | let D := F.connection t |
| 170 | have hnorm : (∑ i, ∑ j, D.ricci x ((F.metric t).orthonormalBasis x i) |
| 171 | ((F.metric t).orthonormalBasis x j) * D.ricci x ((F.metric t).orthonormalBasis x i) |
| 172 | ((F.metric t).orthonormalBasis x j)) = D.ricciNormSq x := by |
| 173 | simp only [LeviCivitaData.ricciNormSq, pow_two] |
| 174 | change (∑ i, ricciVariation F t x |
| 175 | ![(F.metric t).orthonormalBasis x i, (F.metric t).orthonormalBasis x i]) + |
| 176 | 2 * (∑ i, ∑ j, D.ricci x ((F.metric t).orthonormalBasis x i) |
| 177 | ((F.metric t).orthonormalBasis x j) * D.ricci x ((F.metric t).orthonormalBasis x i) |
| 178 | ((F.metric t).orthonormalBasis x j)) = _ |
| 179 | rw [hnorm] |
| 180 | simp only [ricciVariation, Matrix.cons_val_zero, Matrix.cons_val_one, |
| 181 | Finset.sum_add_distrib, Finset.sum_sub_distrib, ← Finset.mul_sum] |
| 182 | have hconn := D.sum_connectionVariation_derivative_eq_laplacian x |
| 183 | simp only [Finset.sum_sub_distrib] at hconn |
| 184 | have hcurv := D.sum_ricci_curvature_eq_sum_ricci_sq x |
| 185 | have hreaction := D.sum_ricci_curvature_contraction x |
| 186 | dsimp only [D] at hconn hcurv hreaction hnorm ⊢ |
| 187 | rw [hcurv, hreaction] |
| 188 | linarith |
| 189 | |
| 190 | end RicciFlow |
| 191 | |
| 192 | end PoincareMT |