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.Calculus |
| 2 | import PoincareLib.Geometry.RicciFlow.Harnack.Matrix.Spacetime |
| 3 | import PoincareLib.Geometry.RicciFlow.Harnack.Matrix.Evolution.P |
| 4 | import PoincareLib.Geometry.RicciFlow.Tensor.TimeDerivative.General |
| 5 | import PoincareLib.Geometry.RicciFlow.Tensor.TimeDerivative.Trace |
| 6 | import PoincareLib.Geometry.RicciFlow.Harnack.Matrix.Evolution.Gradient |
| 7 | import PoincareLib.Geometry.RicciFlow.Tensor.HeatTrace |
| 8 | |
| 9 | /-! |
| 10 | # Time differentiation of Hamilton's divergence |
| 11 | |
| 12 | The derivative includes variation of the inverse metric and of the |
| 13 | connection in each of the three tensor slots. This is the time part of |
| 14 | Chow et al., Part II, (15.48), printed p. 275 (PDF p. 302). |
| 15 | -/ |
| 16 | |
| 17 | set_option autoImplicit false |
| 18 | set_option backward.isDefEq.respectTransparency false |
| 19 | |
| 20 | open scoped Manifold ContDiff Bundle Topology BigOperators |
| 21 | |
| 22 | universe u |
| 23 | |
| 24 | namespace Poincare.RicciFlow.Harnack |
| 25 | |
| 26 | open PoincareMT |
| 27 | |
| 28 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 29 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 30 | {J : Set ℝ} |
| 31 | |
| 32 | /-- Differentiating the divergence uses no extra spacetime-regularity premise. -/ |
| 33 | theorem hasDerivAt_divergence_hamiltonP |
| 34 | (hC : RicciFlowCurvatureCalculus.{u}) (F : RicciFlow n M J) |
| 35 | {t : ℝ} (ht : t ∈ interior J) (x : M) |
| 36 | (u v : TangentSpace (𝓡 n) x) : |
| 37 | letI : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 38 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 39 | let D := F.connection t |
| 40 | let b := (F.metric t).orthonormalBasis x |
| 41 | let Pdot : CovariantTensorEvaluation n M 3 := fun y z => |
| 42 | deriv (fun s => hamiltonP (F.connection s) y (z 0) (z 1) (z 2)) t |
| 43 | let A := fun z : TangentSpace (𝓡 n) x => deriv (fun s => |
| 44 | (F.connection s).connection (FiberBundle.extend (EuclideanSpace ℝ (Fin n)) z) x) t |
| 45 | HasDerivAt |
| 46 | (fun s => (F.metric s).tensorTrace ((F.connection s).covariantTensorDerivative |
| 47 | (fun y z => hamiltonP (F.connection s) y (z 0) (z 1) (z 2))) x ![u, v]) |
| 48 | ((∑ i, (D.covariantTensorDerivative Pdot x ![b i, b i, u, v] - |
| 49 | (hamiltonP D x (A (b i) (b i)) u v + |
| 50 | hamiltonP D x (b i) (A u (b i)) v + |
| 51 | hamiltonP D x (b i) u (A v (b i))))) + |
| 52 | 2 * ∑ i, ∑ j, D.ricci x (b i) (b j) * |
| 53 | D.covariantTensorDerivative |
| 54 | (fun y z => hamiltonP D y (z 0) (z 1) (z 2)) x ![b i, b j, u, v]) t := by |
| 55 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 56 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 57 | let T : ℝ → CovariantTensorEvaluation n M 3 := fun s y z => |
| 58 | hamiltonP (F.connection s) y (z 0) (z 1) (z 2) |
| 59 | let W : ℝ → CovariantTensorEvaluation n M 3 := fun s y z => |
| 60 | deriv (fun r => T r y z) s |
| 61 | let A := fun (y : M) (z : TangentSpace (𝓡 n) y) => deriv (fun s => |
| 62 | (F.connection s).connection (FiberBundle.extend (EuclideanSpace ℝ (Fin n)) z) y) t |
| 63 | let Q : ℝ → CovariantTensorEvaluation n M 4 := fun _ y z => |
| 64 | (F.connection t).covariantTensorDerivative (W t) y z - |
| 65 | ∑ i : Fin 3, T t y (Function.update (fun j => z j.succ) i (A y (z i.succ) (z 0))) |
| 66 | have hT (s) := hamiltonP_isSmoothCovariantTensor (F.connection s) |
| 67 | (hC.tensor_calculus n M (F.metric s) (F.connection s)) |
| 68 | have hreg (y : M) (X : Fin 3 → (z : M) → TangentSpace (𝓡 n) z) |
| 69 | (hX : ∀ i, ContMDiffAt (𝓡 n) ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ |
| 70 | (T% (X i)) y) := contMDiffAt_hamiltonP_fields hC F ht hX |
| 71 | have hW (y : M) (z : Fin 3 → TangentSpace (𝓡 n) y) : |
| 72 | HasDerivAt (fun s => T s y z) (W t y z) t := |
| 73 | (hasDerivAt_hamiltonP_evolution hC F ht y (z 0) (z 1) (z 2)).differentiableAt.hasDerivAt |
| 74 | have hQ (z : Fin 4 → TangentSpace (𝓡 n) x) : |
| 75 | HasDerivAt (fun s => (F.connection s).covariantTensorDerivative (T s) x z) |
| 76 | (Q t x z) t := by |
| 77 | have h := F.hasDerivAt_covariantTensorDerivative_time_all ht x hT hreg hW |
| 78 | (z 0) (fun i => z i.succ) |
| 79 | have heq : Fin.cons (z 0) (fun i : Fin 3 => z i.succ) = z := by |
| 80 | ext i |
| 81 | exact Fin.cases rfl (fun _ => rfl) i |
| 82 | simpa only [heq, Q, A] using h |
| 83 | have h := F.hasDerivAt_tensorTrace (T := fun s => |
| 84 | (F.connection s).covariantTensorDerivative (T s)) (W := Q) ht x |
| 85 | (fun s => (hC.tensor_calculus n M (F.metric s) (F.connection s)).2.2.1 _ _ (hT s)) |
| 86 | hQ ![u, v] |
| 87 | convert h using 1 |
| 88 | simp only [RiemannianMetric.tensorTrace, Q, Fin.sum_univ_three, |
| 89 | Matrix.Fin.cons_vecCons, Matrix.cons_val_zero, T, W, A] |
| 90 | rfl |
| 91 | |
| 92 | /-- The divergence commutator in Chow et al., Part II, (15.48). -/ |
| 93 | theorem tensorHeatOperator_divergence_hamiltonP_commutator |
| 94 | (hC : RicciFlowCurvatureCalculus.{u}) (F : RicciFlow n M J) |
| 95 | {t : ℝ} (ht : t ∈ interior J) (x : M) |
| 96 | (u v : TangentSpace (𝓡 n) x) : |
| 97 | let D := F.connection t |
| 98 | let e := (F.metric t).orthonormalBasis x |
| 99 | let P : ℝ → CovariantTensorEvaluation n M 3 := fun s y z => |
| 100 | hamiltonP (F.connection s) y (z 0) (z 1) (z 2) |
| 101 | F.tensorHeatOperator (fun s => (F.metric s).tensorTrace |
| 102 | ((F.connection s).covariantTensorDerivative (P s))) t x ![u, v] - |
| 103 | (F.metric t).tensorTrace (D.covariantTensorDerivative (F.tensorHeatOperator P t)) x ![u, v] = |
| 104 | 2 * (∑ i, ∑ j, D.ricci x (e i) (e j) * |
| 105 | D.covariantTensorDerivative (P t) x ![e i, e j, u, v]) + |
| 106 | 2 * (∑ k, ∑ i, ∑ j, D.curvatureTensor x (e k) (e i) u (e j) * |
| 107 | D.covariantTensorDerivative (P t) x ![e i, e k, e j, v]) + |
| 108 | 2 * (∑ k, ∑ i, ∑ j, D.curvatureTensor x (e k) (e i) v (e j) * |
| 109 | D.covariantTensorDerivative (P t) x ![e i, e k, u, e j]) := by |
| 110 | let D := F.connection t |
| 111 | let e := (F.metric t).orthonormalBasis x |
| 112 | let P : ℝ → CovariantTensorEvaluation n M 3 := fun s y z => |
| 113 | hamiltonP (F.connection s) y (z 0) (z 1) (z 2) |
| 114 | let W : ℝ → CovariantTensorEvaluation n M 3 := fun s y z => |
| 115 | deriv (fun r => P r y z) s |
| 116 | let Q : ℝ → CovariantTensorEvaluation n M 4 := fun s => |
| 117 | (F.connection s).covariantTensorDerivative (P s) |
| 118 | let Qdot : ℝ → CovariantTensorEvaluation n M 4 := fun s y z => |
| 119 | deriv (fun r => Q r y z) s |
| 120 | have hD := hC.tensor_calculus n M (F.metric t) D |
| 121 | have hP (s) := hamiltonP_isSmoothCovariantTensor (F.connection s) |
| 122 | (hC.tensor_calculus n M (F.metric s) (F.connection s)) |
| 123 | have hreg (y : M) (X : Fin 3 → (z : M) → TangentSpace (𝓡 n) z) |
| 124 | (hX : ∀ i, ContMDiffAt (𝓡 n) ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ |
| 125 | (T% (X i)) y) := contMDiffAt_hamiltonP_fields hC F ht hX |
| 126 | have hW (y : M) (z : Fin 3 → TangentSpace (𝓡 n) y) : |
| 127 | HasDerivAt (fun s => P s y z) (W t y z) t := |
| 128 | (hasDerivAt_hamiltonP_evolution hC F ht y (z 0) (z 1) (z 2)).differentiableAt.hasDerivAt |
| 129 | have hQ (s) : IsSmoothCovariantTensor (Q s) := |
| 130 | (hC.tensor_calculus n M (F.metric s) (F.connection s)).2.2.1 _ _ (hP s) |
| 131 | have hQdot (y : M) (z : Fin 4 → TangentSpace (𝓡 n) y) : |
| 132 | HasDerivAt (fun s => Q s y z) (Qdot t y z) t := by |
| 133 | have h := F.hasDerivAt_covariantTensorDerivative_time_all ht y hP hreg hW |
| 134 | (z 0) (fun i => z i.succ) |
| 135 | have hz : Fin.cons (z 0) (fun i : Fin 3 => z i.succ) = z := by |
| 136 | ext i |
| 137 | exact Fin.cases rfl (fun _ => rfl) i |
| 138 | rw [hz] at h |
| 139 | exact h.differentiableAt.hasDerivAt |
| 140 | have htrace := F.tensorHeatOperator_tensorTrace_four hC ht hQ hQdot x u v |
| 141 | have hcurv (i j) : (∑ k, D.curvatureTensor x (e k) (e i) (e k) (e j)) = |
| 142 | D.ricci x (e i) (e j) := by |
| 143 | apply Finset.sum_congr rfl |
| 144 | intro k _ |
| 145 | rw [(hD.2.2.2.1 x (e k) (e i) (e k) (e j)).2.1, |
| 146 | (hD.2.2.2.1 x (e k) (e j) (e k) (e i)).1, |
| 147 | (hD.2.2.2.1 x (e k) (e j) (e i) (e k)).2.1, |
| 148 | (hD.2.2.2.1 x (e i) (e k) (e k) (e j)).1, neg_neg] |
| 149 | have hfirst : (∑ k, ∑ i, ∑ j, D.curvatureTensor x (e k) (e i) (e k) (e j) * |
| 150 | Q t x ![e i, e j, u, v]) = |
| 151 | ∑ i, ∑ j, D.ricci x (e i) (e j) * Q t x ![e i, e j, u, v] := by |
| 152 | rw [Finset.sum_comm] |
| 153 | apply Finset.sum_congr rfl |
| 154 | intro i _ |
| 155 | rw [Finset.sum_comm] |
| 156 | apply Finset.sum_congr rfl |
| 157 | intro j _ |
| 158 | rw [← Finset.sum_mul, hcurv] |
| 159 | dsimp only |
| 160 | change F.tensorHeatOperator (fun s => (F.metric s).tensorTrace (Q s)) t x ![u, v] - |
| 161 | (F.metric t).tensorTrace (D.covariantTensorDerivative (F.tensorHeatOperator P t)) x ![u, v] = _ |
| 162 | rw [htrace] |
| 163 | change (∑ i, F.tensorHeatOperator Q t x ![e i, e i, u, v]) - |
| 164 | (∑ i, D.covariantTensorDerivative (F.tensorHeatOperator P t) x ![e i, e i, u, v]) = _ |
| 165 | rw [← Finset.sum_sub_distrib] |
| 166 | have hgrad (i) := tensorHeatOperator_covariantHamiltonP_commutator hC F ht x (e i) (e i) u v |
| 167 | change ∀ i, F.tensorHeatOperator Q t x ![e i, e i, u, v] - |
| 168 | D.covariantTensorDerivative (F.tensorHeatOperator P t) x ![e i, e i, u, v] = _ at hgrad |
| 169 | simp_rw [hgrad] |
| 170 | simp only [Finset.sum_add_distrib, ← Finset.mul_sum] |
| 171 | dsimp only [D, e, Q, P] at hfirst |
| 172 | rw [hfirst] |
| 173 | |
| 174 | /-- Substitution of the P evolution in the divergence commutator, (15.49). -/ |
| 175 | theorem tensorHeatOperator_divergence_hamiltonP |
| 176 | (hC : RicciFlowCurvatureCalculus.{u}) (F : RicciFlow n M J) |
| 177 | {t : ℝ} (ht : t ∈ interior J) (x : M) |
| 178 | (u v : TangentSpace (𝓡 n) x) : |
| 179 | let D := F.connection t |
| 180 | let e := (F.metric t).orthonormalBasis x |
| 181 | let P : ℝ → CovariantTensorEvaluation n M 3 := fun s y z => |
| 182 | hamiltonP (F.connection s) y (z 0) (z 1) (z 2) |
| 183 | F.tensorHeatOperator (fun s => (F.metric s).tensorTrace |
| 184 | ((F.connection s).covariantTensorDerivative (P s))) t x ![u, v] = |
| 185 | (F.metric t).tensorTrace (D.covariantTensorDerivative (hamiltonPReaction D)) x ![u, v] + |
| 186 | 2 * (∑ i, ∑ j, D.ricci x (e i) (e j) * |
| 187 | D.covariantTensorDerivative (P t) x ![e i, e j, u, v]) + |
| 188 | 2 * (∑ k, ∑ i, ∑ j, D.curvatureTensor x (e k) (e i) u (e j) * |
| 189 | D.covariantTensorDerivative (P t) x ![e i, e k, e j, v]) + |
| 190 | 2 * (∑ k, ∑ i, ∑ j, D.curvatureTensor x (e k) (e i) v (e j) * |
| 191 | D.covariantTensorDerivative (P t) x ![e i, e k, u, e j]) := by |
| 192 | have h := tensorHeatOperator_divergence_hamiltonP_commutator hC F ht x u v |
| 193 | dsimp only at h ⊢ |
| 194 | rw [tensorHeatOperator_hamiltonP hC F ht] at h |
| 195 | linarith only [h] |
| 196 | |
| 197 | end Poincare.RicciFlow.Harnack |