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.Positivity.BasisChange |
| 3 | import PoincareLib.Geometry.RicciFlow.Harnack.Matrix.Positivity.PerturbedTimeContact |
| 4 | import PoincareLib.Geometry.RicciFlow.Harnack.Noncompact.DirectionEvaluation |
| 5 | |
| 6 | /-! # Fixed-frame coordinates for Hamilton contact quadratics |
| 7 | |
| 8 | Changing all tangent inputs to the canonical frame at one reference time |
| 9 | preserves the perturbed quadratic at every evaluation time. |
| 10 | -/ |
| 11 | |
| 12 | set_option autoImplicit false |
| 13 | set_option backward.isDefEq.respectTransparency false |
| 14 | set_option maxHeartbeats 800000 |
| 15 | |
| 16 | open scoped BigOperators Manifold ContDiff Bundle |
| 17 | |
| 18 | namespace Poincare.RicciFlow.Harnack |
| 19 | |
| 20 | section Coordinates |
| 21 | |
| 22 | variable {I J : Type*} [Fintype I] [Fintype J] |
| 23 | |
| 24 | /-- Vector coefficients after changing the tangent frame by `C`. -/ |
| 25 | noncomputable def hamiltonVectorCoordinates (C : J → I → ℝ) (W : J → ℝ) : I → ℝ := |
| 26 | fun a => ∑ i, C i a * W i |
| 27 | |
| 28 | /-- Two-form coefficients after changing both tangent inputs by `C`. -/ |
| 29 | noncomputable def hamiltonTwoFormCoordinates (C : J → I → ℝ) |
| 30 | (U : J → J → ℝ) : I → I → ℝ := |
| 31 | fun a b => ∑ i, ∑ j, C i a * C j b * U i j |
| 32 | |
| 33 | omit [Fintype I] in |
| 34 | lemma hamiltonTwoFormCoordinates_skew (C : J → I → ℝ) (U : J → J → ℝ) |
| 35 | (hU : ∀ i j, U i j = -U j i) : |
| 36 | ∀ a b, hamiltonTwoFormCoordinates C U a b = -hamiltonTwoFormCoordinates C U b a := by |
| 37 | intro a b |
| 38 | simp only [hamiltonTwoFormCoordinates, ← Finset.sum_neg_distrib] |
| 39 | rw [Finset.sum_comm] |
| 40 | apply Finset.sum_congr rfl |
| 41 | intro j _ |
| 42 | apply Finset.sum_congr rfl |
| 43 | intro i _ |
| 44 | rw [hU i j] |
| 45 | ring |
| 46 | |
| 47 | private lemma sum_coordinate_pairing {K L : Type*} [Fintype K] [Fintype L] |
| 48 | (C : J → I → ℝ) (D : L → K → ℝ) (B : I → K → ℝ) |
| 49 | (W : J → ℝ) (V : L → ℝ) : |
| 50 | (∑ i, ∑ j, (∑ a, ∑ b, C i a * B a b * D j b) * W i * V j) = |
| 51 | ∑ a, ∑ b, B a b * hamiltonVectorCoordinates C W a * |
| 52 | hamiltonVectorCoordinates D V b := by |
| 53 | simp only [hamiltonVectorCoordinates, Finset.sum_mul, Finset.mul_sum] |
| 54 | calc |
| 55 | _ = ∑ i, ∑ a, ∑ b, ∑ j, C i a * B a b * D j b * W i * V j := by |
| 56 | apply Finset.sum_congr rfl |
| 57 | intro i _ |
| 58 | exact Finset.sum_comm_cycle.symm |
| 59 | _ = ∑ a, ∑ b, ∑ i, ∑ j, C i a * B a b * D j b * W i * V j := |
| 60 | Finset.sum_comm_cycle.symm |
| 61 | _ = _ := by |
| 62 | apply Finset.sum_congr rfl |
| 63 | intro a _ |
| 64 | apply Finset.sum_congr rfl |
| 65 | intro b _ |
| 66 | rw [Finset.sum_comm] |
| 67 | apply Finset.sum_congr rfl |
| 68 | intro i _ |
| 69 | apply Finset.sum_congr rfl |
| 70 | intro j _ |
| 71 | ring |
| 72 | |
| 73 | end Coordinates |
| 74 | |
| 75 | open PoincareMT |
| 76 | |
| 77 | universe u |
| 78 | |
| 79 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 80 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 81 | {I : Type*} [Fintype I] |
| 82 | |
| 83 | /-- Coordinates of a fixed tangent frame in a metric's canonical basis. -/ |
| 84 | noncomputable def hamiltonFrameCoordinates (g : RiemannianMetric n M) (x : M) |
| 85 | (e : I → TangentSpace (𝓡 n) x) : |
| 86 | I → Fin (Module.finrank ℝ (TangentSpace (𝓡 n) x)) → ℝ := |
| 87 | fun i a => g.inner x (e i) (g.orthonormalBasis x a) |
| 88 | |
| 89 | lemma hamiltonVectorCoordinates_eq_zero_iff (g : RiemannianMetric n M) |
| 90 | (x : M) (e : I → TangentSpace (𝓡 n) x) (he : LinearIndependent ℝ e) (W : I → ℝ) : |
| 91 | hamiltonVectorCoordinates (hamiltonFrameCoordinates g x e) W = 0 ↔ W = 0 := by |
| 92 | classical |
| 93 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 94 | ⟨g.toRiemannianMetric⟩ |
| 95 | constructor |
| 96 | · intro hW |
| 97 | have hdecomp (i : I) : e i = ∑ a, |
| 98 | hamiltonFrameCoordinates g x e i a • g.orthonormalBasis x a := by |
| 99 | have h := ((g.orthonormalBasis x).sum_repr' (e i)).symm |
| 100 | change e i = ∑ a, g.inner x (g.orthonormalBasis x a) (e i) • |
| 101 | g.orthonormalBasis x a at h |
| 102 | simpa only [hamiltonFrameCoordinates, g.symm] using h |
| 103 | have hsum : ∑ i, W i • e i = 0 := by |
| 104 | simp_rw [hdecomp, Finset.smul_sum, smul_smul] |
| 105 | rw [Finset.sum_comm] |
| 106 | simp_rw [← Finset.sum_smul, mul_comm (W _)] |
| 107 | change (∑ a, hamiltonVectorCoordinates (hamiltonFrameCoordinates g x e) W a • |
| 108 | g.orthonormalBasis x a) = 0 |
| 109 | rw [hW] |
| 110 | simp |
| 111 | exact funext ((Fintype.linearIndependent_iff.mp he) W hsum) |
| 112 | · rintro rfl |
| 113 | funext a |
| 114 | simp [hamiltonVectorCoordinates] |
| 115 | |
| 116 | lemma hamiltonTwoFormCoordinates_eq_zero_iff (g : RiemannianMetric n M) |
| 117 | (x : M) (e : I → TangentSpace (𝓡 n) x) (he : LinearIndependent ℝ e) |
| 118 | (U : I → I → ℝ) : |
| 119 | hamiltonTwoFormCoordinates (hamiltonFrameCoordinates g x e) U = 0 ↔ U = 0 := by |
| 120 | classical |
| 121 | let C := hamiltonFrameCoordinates g x e |
| 122 | constructor |
| 123 | · intro hU |
| 124 | have hrow (a) : (fun j => ∑ i, C i a * U i j) = 0 := by |
| 125 | apply (hamiltonVectorCoordinates_eq_zero_iff g x e he _).mp |
| 126 | funext b |
| 127 | have hab := congrFun (congrFun hU a) b |
| 128 | change (∑ j, C j b * ∑ i, C i a * U i j) = 0 |
| 129 | simp only [Finset.mul_sum] |
| 130 | rw [Finset.sum_comm] |
| 131 | simpa only [hamiltonTwoFormCoordinates, Pi.zero_apply, mul_left_comm, mul_assoc, C] |
| 132 | using hab |
| 133 | have hcol (j) : (fun i => U i j) = 0 := by |
| 134 | apply (hamiltonVectorCoordinates_eq_zero_iff g x e he _).mp |
| 135 | funext a |
| 136 | exact congrFun (hrow a) j |
| 137 | funext i j |
| 138 | exact congrFun (hcol j) i |
| 139 | · rintro rfl |
| 140 | funext a b |
| 141 | simp [hamiltonTwoFormCoordinates] |
| 142 | |
| 143 | private lemma sqrt_sum_sq_eq_zero_iff (f : I → ℝ) : |
| 144 | Real.sqrt (∑ i, f i ^ 2) = 0 ↔ f = 0 := by |
| 145 | rw [Real.sqrt_eq_zero (Finset.sum_nonneg fun i _ => sq_nonneg (f i))] |
| 146 | constructor |
| 147 | · intro h |
| 148 | funext i |
| 149 | exact sq_eq_zero_iff.mp |
| 150 | ((Finset.sum_eq_zero_iff_of_nonneg (fun j _ => sq_nonneg (f j))).mp h i (Finset.mem_univ i)) |
| 151 | · rintro rfl |
| 152 | simp |
| 153 | |
| 154 | /-- An injective tangent frame preserves nonzero two-form/vector directions. -/ |
| 155 | lemma hamiltonCoordinates_sqrt_nonzero (g : RiemannianMetric n M) |
| 156 | (x : M) (e : I → TangentSpace (𝓡 n) x) (he : LinearIndependent ℝ e) |
| 157 | (U : I → I → ℝ) (W : I → ℝ) (hnonzero : U ≠ 0 ∨ W ≠ 0) : |
| 158 | let C := hamiltonFrameCoordinates g x e |
| 159 | Real.sqrt (∑ a, ∑ b, hamiltonTwoFormCoordinates C U a b ^ 2) ≠ 0 ∨ |
| 160 | Real.sqrt (∑ a, hamiltonVectorCoordinates C W a ^ 2) ≠ 0 := by |
| 161 | dsimp only |
| 162 | rcases hnonzero with hU | hW |
| 163 | · left |
| 164 | intro hz |
| 165 | have hpair := (sqrt_sum_sq_eq_zero_iff |
| 166 | (fun ab : Fin (Module.finrank ℝ (TangentSpace (𝓡 n) x)) × |
| 167 | Fin (Module.finrank ℝ (TangentSpace (𝓡 n) x)) => |
| 168 | hamiltonTwoFormCoordinates (hamiltonFrameCoordinates g x e) U ab.1 ab.2)).mp |
| 169 | (by simpa only [Fintype.sum_prod_type] using hz) |
| 170 | apply hU |
| 171 | apply (hamiltonTwoFormCoordinates_eq_zero_iff g x e he U).mp |
| 172 | funext a b |
| 173 | exact congrFun hpair (a, b) |
| 174 | · right |
| 175 | intro hz |
| 176 | exact hW ((hamiltonVectorCoordinates_eq_zero_iff g x e he W).mp |
| 177 | ((sqrt_sum_sq_eq_zero_iff _).mp hz)) |
| 178 | |
| 179 | /-- Normalized block coefficients stay nonzero in any independent frame. -/ |
| 180 | theorem hamiltonFrameCoordinates_sqrt_nonzero (g : RiemannianMetric n M) |
| 181 | (x : M) (e : I → TangentSpace (𝓡 n) x) (he : LinearIndependent ℝ e) |
| 182 | (z : EuclideanSpace ℝ ((I × I) ⊕ I)) (hz : ‖z‖ = 1) : |
| 183 | let C := hamiltonFrameCoordinates g x e |
| 184 | let U := fun i j => z (Sum.inl (i, j)) |
| 185 | let W := fun i => z (Sum.inr i) |
| 186 | Real.sqrt (∑ a, ∑ b, hamiltonTwoFormCoordinates C U a b ^ 2) ≠ 0 ∨ |
| 187 | Real.sqrt (∑ a, hamiltonVectorCoordinates C W a ^ 2) ≠ 0 := by |
| 188 | apply hamiltonCoordinates_sqrt_nonzero g x e he |
| 189 | by_contra h |
| 190 | push Not at h |
| 191 | have hz0 : z = 0 := by |
| 192 | ext (ij | i) |
| 193 | · exact congrFun (congrFun h.1 ij.1) ij.2 |
| 194 | · exact congrFun h.2 i |
| 195 | simp only [hz0, norm_zero, zero_ne_one] at hz |
| 196 | |
| 197 | omit [Fintype I] in |
| 198 | /-- A normalized Hamilton direction stays nonzero in any canonical frame. -/ |
| 199 | theorem hamiltonDirectionCoordinates_sqrt_nonzero (g : RiemannianMetric n M) |
| 200 | (q : HamiltonDirection n M) |
| 201 | (he : LinearIndependent ℝ (Poincare.VectorBundle.FiberFamily.vector q.1)) |
| 202 | (hq : ‖q.2‖ = 1) : |
| 203 | let C := hamiltonFrameCoordinates g q.1.val.1 |
| 204 | (Poincare.VectorBundle.FiberFamily.vector q.1) |
| 205 | let U := fun i j => q.2 (Sum.inl (i, j)) |
| 206 | let W := fun i => q.2 (Sum.inr i) |
| 207 | Real.sqrt (∑ a, ∑ b, hamiltonTwoFormCoordinates C U a b ^ 2) ≠ 0 ∨ |
| 208 | Real.sqrt (∑ a, hamiltonVectorCoordinates C W a ^ 2) ≠ 0 := |
| 209 | hamiltonFrameCoordinates_sqrt_nonzero g q.1.val.1 _ he q.2 hq |
| 210 | |
| 211 | lemma tensor_two_contraction_coordinates (g : RiemannianMetric n M) |
| 212 | {T : CovariantTensorEvaluation n M 2} (hT : IsSmoothCovariantTensor T) |
| 213 | (x : M) (e : I → TangentSpace (𝓡 n) x) (W V : I → ℝ) : |
| 214 | let C := hamiltonFrameCoordinates g x e |
| 215 | let b := g.orthonormalBasis x |
| 216 | (∑ i, ∑ j, T x ![e i, e j] * W i * V j) = |
| 217 | ∑ a, ∑ c, T x ![b a, b c] * hamiltonVectorCoordinates C W a * |
| 218 | hamiltonVectorCoordinates C V c := by |
| 219 | dsimp only |
| 220 | simpa only [hamiltonFrameCoordinates, ← tensor_two_expansion g hT] using |
| 221 | sum_coordinate_pairing (hamiltonFrameCoordinates g x e) (hamiltonFrameCoordinates g x e) |
| 222 | (fun a c => T x ![g.orthonormalBasis x a, g.orthonormalBasis x c]) W V |
| 223 | |
| 224 | lemma tensor_three_contraction_coordinates (g : RiemannianMetric n M) |
| 225 | {T : CovariantTensorEvaluation n M 3} (hT : IsSmoothCovariantTensor T) |
| 226 | (x : M) (e : I → TangentSpace (𝓡 n) x) (U : I → I → ℝ) (W : I → ℝ) : |
| 227 | let C := hamiltonFrameCoordinates g x e |
| 228 | let b := g.orthonormalBasis x |
| 229 | (∑ i, ∑ j, ∑ k, T x ![e i, e j, e k] * U i j * W k) = |
| 230 | ∑ a, ∑ c, ∑ d, T x ![b a, b c, b d] * hamiltonTwoFormCoordinates C U a c * |
| 231 | hamiltonVectorCoordinates C W d := by |
| 232 | let C := hamiltonFrameCoordinates g x e |
| 233 | have h := sum_coordinate_pairing |
| 234 | (fun (ij : I × I) (ac : Fin (Module.finrank ℝ (TangentSpace (𝓡 n) x)) × |
| 235 | Fin (Module.finrank ℝ (TangentSpace (𝓡 n) x))) => C ij.1 ac.1 * C ij.2 ac.2) C |
| 236 | (fun ac d => T x ![g.orthonormalBasis x ac.1, g.orthonormalBasis x ac.2, |
| 237 | g.orthonormalBasis x d]) (fun ij => U ij.1 ij.2) W |
| 238 | simp only [Fintype.sum_prod_type] at h |
| 239 | simpa only [C, hamiltonVectorCoordinates, hamiltonTwoFormCoordinates, |
| 240 | hamiltonFrameCoordinates, Fintype.sum_prod_type, ← tensor_three_expansion g hT] using h |
| 241 | |
| 242 | lemma tensor_four_contraction_coordinates (g : RiemannianMetric n M) |
| 243 | {T : CovariantTensorEvaluation n M 4} (hT : IsSmoothCovariantTensor T) |
| 244 | (x : M) (e : I → TangentSpace (𝓡 n) x) (U V : I → I → ℝ) : |
| 245 | let C := hamiltonFrameCoordinates g x e |
| 246 | let b := g.orthonormalBasis x |
| 247 | (∑ i, ∑ j, ∑ k, ∑ l, T x ![e i, e j, e k, e l] * U i j * V k l) = |
| 248 | ∑ a, ∑ c, ∑ d, ∑ f, T x ![b a, b c, b d, b f] * |
| 249 | hamiltonTwoFormCoordinates C U a c * hamiltonTwoFormCoordinates C V d f := by |
| 250 | let C := hamiltonFrameCoordinates g x e |
| 251 | let D := fun (ij : I × I) (ac : Fin (Module.finrank ℝ (TangentSpace (𝓡 n) x)) × |
| 252 | Fin (Module.finrank ℝ (TangentSpace (𝓡 n) x))) => C ij.1 ac.1 * C ij.2 ac.2 |
| 253 | have h := sum_coordinate_pairing D D |
| 254 | (fun ac df => T x ![g.orthonormalBasis x ac.1, g.orthonormalBasis x ac.2, |
| 255 | g.orthonormalBasis x df.1, g.orthonormalBasis x df.2]) |
| 256 | (fun ij => U ij.1 ij.2) (fun kl => V kl.1 kl.2) |
| 257 | simp only [Fintype.sum_prod_type, D, mul_assoc] at h |
| 258 | have hexp (i j k l) := tensor_four_expansion g hT x (e i) (e j) (e k) (e l) |
| 259 | simp only [mul_assoc] at hexp |
| 260 | simpa only [C, hamiltonVectorCoordinates, hamiltonTwoFormCoordinates, |
| 261 | hamiltonFrameCoordinates, Fintype.sum_prod_type, mul_assoc, ← hexp] using h |
| 262 | |
| 263 | omit [Fintype I] in |
| 264 | /-- A fixed frame can be changed to the canonical frame at `t` without |
| 265 | changing the perturbed quadratic at any varying time `s`. -/ |
| 266 | theorem perturbedHamiltonDirectionQuadratic_eq_fixed {J : Set ℝ} |
| 267 | (hC : RicciFlowCurvatureCalculus.{u}) (F : RicciFlow n M J) (T₀ t : ℝ) |
| 268 | (φ : ℝ × M → ℝ) (ψ : ℝ → ℝ) (q : HamiltonDirection n M) (s : ℝ) : |
| 269 | let C := hamiltonFrameCoordinates (F.metric t) q.1.val.1 |
| 270 | (Poincare.VectorBundle.FiberFamily.vector q.1) |
| 271 | let U := fun i j => q.2 (Sum.inl (i, j)) |
| 272 | let W := fun i => q.2 (Sum.inr i) |
| 273 | perturbedHamiltonDirectionQuadratic F T₀ φ ψ s q = |
| 274 | perturbedHamiltonFixedQuadratic F T₀ t q.1.val.1 (fun r y => φ (r, y)) ψ |
| 275 | (hamiltonTwoFormCoordinates C U) (hamiltonVectorCoordinates C W) s := by |
| 276 | let x := q.1.val.1 |
| 277 | let e := Poincare.VectorBundle.FiberFamily.vector q.1 |
| 278 | let U := fun i j => q.2 (Sum.inl (i, j)) |
| 279 | let W := fun i => q.2 (Sum.inr i) |
| 280 | let D := F.connection s |
| 281 | have hD := hC.tensor_calculus n M (F.metric s) D |
| 282 | have hM := tensor_two_contraction_coordinates (F.metric t) |
| 283 | (hamiltonM_isSmoothCovariantTensor D hD (s - T₀)) x e W W |
| 284 | have hP := tensor_three_contraction_coordinates (F.metric t) |
| 285 | (hamiltonP_isSmoothCovariantTensor D hD) x e U W |
| 286 | have hR := tensor_four_contraction_coordinates (F.metric t) hD.1 x e U U |
| 287 | have hg := tensor_two_contraction_coordinates (F.metric t) |
| 288 | (metric_isSmoothCovariantTensor (F.metric s)) x e W W |
| 289 | have hI := tensor_four_contraction_coordinates (F.metric t) |
| 290 | (metricTwoFormIdentity_isSmooth (F.metric s)) x e U U |
| 291 | dsimp only at hM hP hR hg hI |
| 292 | simp only [LeviCivitaData.riemannEvaluation, Matrix.cons_val_zero, Matrix.cons_val_one, |
| 293 | Matrix.cons_val_two, Matrix.cons_val_three, Matrix.head_cons, Matrix.tail_cons] at hM hP hR hg |
| 294 | change (_ + φ (s, x) * _ + ψ s * _) = _ |
| 295 | dsimp only [perturbedHamiltonDirectionQuadratic, hamiltonDirectionQuadratic] |
| 296 | change ((∑ i, ∑ j, hamiltonM D (s - T₀) x (e i) (e j) * W i * W j) + |
| 297 | 2 * (∑ i, ∑ j, ∑ k, hamiltonP D x (e i) (e j) (e k) * U i j * W k) + |
| 298 | (∑ i, ∑ j, ∑ k, ∑ l, D.curvatureTensor x (e i) (e j) (e k) (e l) * U i j * U k l) + |
| 299 | φ (s, x) * (∑ i, ∑ j, (F.metric s).inner x (e i) (e j) * W i * W j) + |
| 300 | ψ s * (∑ i, ∑ j, ∑ k, ∑ l, |
| 301 | metricTwoFormIdentity (F.metric s) x ![e i, e j, e k, e l] * U i j * U k l)) = _ |
| 302 | rw [hM, hP, hR, hg, hI] |
| 303 | simp only [perturbedHamiltonFixedQuadratic, add_mul, Finset.sum_add_distrib, |
| 304 | mul_assoc, ← Finset.mul_sum] |
| 305 | dsimp only [x, D, U, W, e] |
| 306 | ring |
| 307 | |
| 308 | end Poincare.RicciFlow.Harnack |