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.Reaction.P |
| 2 | import PoincareLib.Geometry.Riemannian.Tensor.Contraction.CurvatureThree |
| 3 | import PoincareLib.Geometry.Riemannian.Tensor.Contraction.TwoFive |
| 4 | |
| 5 | /-! |
| 6 | # Differentiating Hamilton's P reaction |
| 7 | |
| 8 | The product rules retain the metric contractions and all four covariant |
| 9 | curvature inputs. They expand the derivative in Chow et al., Part II, |
| 10 | (15.49), printed p. 275 (PDF p. 302). |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | set_option backward.isDefEq.respectTransparency false |
| 15 | |
| 16 | open scoped Manifold ContDiff Bundle BigOperators |
| 17 | |
| 18 | universe u |
| 19 | |
| 20 | namespace Poincare.RicciFlow.Harnack |
| 21 | |
| 22 | open PoincareMT |
| 23 | |
| 24 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 25 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 26 | {g : RiemannianMetric n M} |
| 27 | |
| 28 | lemma isSmoothCovariantTensor_hamiltonPReaction |
| 29 | (D : LeviCivitaData g) (hD : D.CurvatureTensorCalculus) : |
| 30 | IsSmoothCovariantTensor (hamiltonPReaction D) := by |
| 31 | unfold hamiltonPReaction |
| 32 | have hP := hamiltonP_isSmoothCovariantTensor D hD |
| 33 | have hA := D.isSmoothCovariantTensor_curvature_three hD hP |
| 34 | have hB := D.isSmoothCovariantTensor_curvature_three_middle hD hP |
| 35 | have hC := D.isSmoothCovariantTensor_curvature_three_last hD hP |
| 36 | have hQ := D.isSmoothCovariantTensor_two_five_contraction hD.2.1 (hD.2.2.1 _ _ hD.1) |
| 37 | simpa only [LeviCivitaData.ricciEvaluation, |
| 38 | Matrix.cons_val_zero, Matrix.cons_val_one, Matrix.cons_val_two, |
| 39 | Matrix.head_cons, Matrix.tail_cons] using |
| 40 | (((hA.const_mul 2).add (hB.const_mul 2)).add (hC.const_mul 2)).sub (hQ.const_mul 2) |
| 41 | |
| 42 | lemma covariantTensorDerivative_hamiltonPReaction |
| 43 | (D : LeviCivitaData g) (hD : D.CurvatureTensorCalculus) |
| 44 | (x : M) (p a b c : TangentSpace (𝓡 n) x) : |
| 45 | let e := g.orthonormalBasis x |
| 46 | let P : CovariantTensorEvaluation n M 3 := fun y z => hamiltonP D y (z 0) (z 1) (z 2) |
| 47 | D.covariantTensorDerivative (hamiltonPReaction D) x ![p, a, b, c] = |
| 48 | 2 * (∑ i, ∑ j, (D.covariantTensorDerivative D.riemannEvaluation x ![p, a, e i, b, e j] * |
| 49 | hamiltonP D x (e i) (e j) c + D.curvatureTensor x a (e i) b (e j) * |
| 50 | D.covariantTensorDerivative P x ![p, e i, e j, c])) + |
| 51 | 2 * (∑ i, ∑ j, (D.covariantTensorDerivative D.riemannEvaluation x ![p, a, e i, c, e j] * |
| 52 | hamiltonP D x (e i) b (e j) + D.curvatureTensor x a (e i) c (e j) * |
| 53 | D.covariantTensorDerivative P x ![p, e i, b, e j])) + |
| 54 | 2 * (∑ i, ∑ j, (D.covariantTensorDerivative D.riemannEvaluation x ![p, b, e i, c, e j] * |
| 55 | hamiltonP D x a (e i) (e j) + D.curvatureTensor x b (e i) c (e j) * |
| 56 | D.covariantTensorDerivative P x ![p, a, e i, e j])) - |
| 57 | 2 * (∑ i, ∑ j, (D.covariantTensorDerivative D.ricciEvaluation x ![p, e i, e j] * |
| 58 | D.covariantTensorDerivative D.riemannEvaluation x ![e i, a, b, c, e j] + |
| 59 | D.ricci x (e i) (e j) * D.covariantTensorDerivative |
| 60 | (D.covariantTensorDerivative D.riemannEvaluation) x ![p, e i, a, b, c, e j])) := by |
| 61 | let P : CovariantTensorEvaluation n M 3 := fun y z => hamiltonP D y (z 0) (z 1) (z 2) |
| 62 | let A : CovariantTensorEvaluation n M 3 := fun y z => |
| 63 | ∑ i, ∑ j, D.curvatureTensor y (z 0) (g.orthonormalBasis y i) (z 1) |
| 64 | (g.orthonormalBasis y j) * P y ![g.orthonormalBasis y i, g.orthonormalBasis y j, z 2] |
| 65 | let B : CovariantTensorEvaluation n M 3 := fun y z => |
| 66 | ∑ i, ∑ j, D.curvatureTensor y (z 0) (g.orthonormalBasis y i) (z 2) |
| 67 | (g.orthonormalBasis y j) * P y ![g.orthonormalBasis y i, z 1, g.orthonormalBasis y j] |
| 68 | let C : CovariantTensorEvaluation n M 3 := fun y z => |
| 69 | ∑ i, ∑ j, D.curvatureTensor y (z 1) (g.orthonormalBasis y i) (z 2) |
| 70 | (g.orthonormalBasis y j) * P y ![z 0, g.orthonormalBasis y i, g.orthonormalBasis y j] |
| 71 | let Q : CovariantTensorEvaluation n M 3 := fun y z => |
| 72 | ∑ i, ∑ j, D.ricciEvaluation y ![g.orthonormalBasis y i, g.orthonormalBasis y j] * |
| 73 | D.covariantTensorDerivative D.riemannEvaluation y |
| 74 | ![g.orthonormalBasis y i, z 0, z 1, z 2, g.orthonormalBasis y j] |
| 75 | have hP := hamiltonP_isSmoothCovariantTensor D hD |
| 76 | have hA : IsSmoothCovariantTensor A := D.isSmoothCovariantTensor_curvature_three hD hP |
| 77 | have hB : IsSmoothCovariantTensor B := D.isSmoothCovariantTensor_curvature_three_middle hD hP |
| 78 | have hC : IsSmoothCovariantTensor C := D.isSmoothCovariantTensor_curvature_three_last hD hP |
| 79 | have hQ : IsSmoothCovariantTensor Q := |
| 80 | D.isSmoothCovariantTensor_two_five_contraction hD.2.1 (hD.2.2.1 _ _ hD.1) |
| 81 | have heq : hamiltonPReaction D = fun y z => 2 * A y z + 2 * B y z + 2 * C y z - 2 * Q y z := rfl |
| 82 | rw [heq, D.covariantTensorDerivative_sub |
| 83 | (((hA.const_mul 2).add (hB.const_mul 2)).add (hC.const_mul 2)) (hQ.const_mul 2), |
| 84 | D.covariantTensorDerivative_add ((hA.const_mul 2).add (hB.const_mul 2)) (hC.const_mul 2), |
| 85 | D.covariantTensorDerivative_add (hA.const_mul 2) (hB.const_mul 2), |
| 86 | D.covariantTensorDerivative_const_mul hA, D.covariantTensorDerivative_const_mul hB, |
| 87 | D.covariantTensorDerivative_const_mul hC, D.covariantTensorDerivative_const_mul hQ] |
| 88 | dsimp only [A, B, C, Q] |
| 89 | rw [D.covariantTensorDerivative_curvature_three hD hP, |
| 90 | D.covariantTensorDerivative_curvature_three_middle hD hP, |
| 91 | D.covariantTensorDerivative_curvature_three_last hD hP, |
| 92 | D.covariantTensorDerivative_two_five_contraction hD.2.1 (hD.2.2.1 _ _ hD.1)] |
| 93 | rfl |
| 94 | |
| 95 | end Poincare.RicciFlow.Harnack |