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.Surgery.StandardCap.Persistence.Scalar.Calculus.CurvatureDifference |
| 2 | import PoincareLib.Geometry.RicciFlow.Surgery.StandardCap.Persistence.Analysis.Jets.BilinearEvaluationDerivative |
| 3 | |
| 4 | /-! |
| 5 | # Differentiating the lowered connection correction |
| 6 | |
| 7 | The metric derivative contributes the first error on the connection |
| 8 | correction. All remaining terms are the Koszul permutation of the |
| 9 | second error. Morgan--Tian, pp. 3-7, Definition 9.76 and Lemma 11.2; |
| 10 | see the lowered calculation in M44 derivation 31. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | set_option backward.isDefEq.respectTransparency false |
| 15 | |
| 16 | open scoped Manifold ContDiff Topology BigOperators |
| 17 | |
| 18 | namespace PoincareMT.M44 |
| 19 | |
| 20 | open CoordinateExponential |
| 21 | |
| 22 | local notation "E" => EuclideanSpace ℝ (Fin 3) |
| 23 | |
| 24 | /-- Ordinary differentiation of a fixed bilinear evaluation commutes |
| 25 | with evaluating its coefficient derivative. Source: the product rule |
| 26 | in the lowered Koszul calculation, M44 derivation 31. -/ |
| 27 | theorem fderiv_metric_evaluation (h : RiemannianMetric 3 E) (x d u v : E) : |
| 28 | fderiv ℝ (fun y => h.euclideanCoefficients y u v) x d = |
| 29 | fderiv ℝ h.euclideanCoefficients x d u v := by |
| 30 | have hh := ((h.contDiffAt_euclideanCoefficients x).differentiableAt (by simp)).hasFDerivAt |
| 31 | have he := (hh.clm_apply (hasFDerivAt_const u x)).clm_apply (hasFDerivAt_const v x) |
| 32 | simpa only [ContinuousLinearMap.comp_apply, ContinuousLinearMap.flip_apply, |
| 33 | add_apply, zero_apply, map_zero, add_zero, zero_add] using |
| 34 | congrArg (fun L => L d) he.fderiv |
| 35 | |
| 36 | /-- The ordinary derivative of the lowered actual correction has |
| 37 | the two expected product-rule terms. Source: pp. 3-4 in M44 derivation 31. -/ |
| 38 | theorem fderiv_inner_connectionDifference (g h : RiemannianMetric 3 E) |
| 39 | (x d u v w : E) : |
| 40 | fderiv ℝ (fun y => h.euclideanCoefficients y (connectionDifference g h y u v) w) x d = |
| 41 | fderiv ℝ h.euclideanCoefficients x d (connectionDifference g h x u v) w + |
| 42 | h.inner x (fderiv ℝ (connectionDifference g h) x d u v) w := by |
| 43 | exact fderiv_bilinear_evaluation_bilinear |
| 44 | ((h.contDiffAt_euclideanCoefficients x).differentiableAt (by simp)) |
| 45 | ((contDiff_connectionDifference g h).differentiable (by simp) x) d u v w |
| 46 | |
| 47 | set_option maxHeartbeats 800000 in |
| 48 | -- The three covariant slots cross the native and tangent-space coefficient instances. |
| 49 | /-- The covariant derivative of the lowered correction differs from |
| 50 | lowering its covariant derivative by exactly the first error term. |
| 51 | Source: pp. 3-7, M44 derivation 31. -/ |
| 52 | theorem covariant_koszul_error_eq_lowered {g h : RiemannianMetric 3 E} |
| 53 | (D : LeviCivitaData g) (D' : LeviCivitaData h) (x d u v w : E) : |
| 54 | D.covariantTensorDerivative |
| 55 | (koszulPermutation (D.covariantTensorDerivative (metricError g h))) x ![d, u, v, w] = |
| 56 | 2 * h.inner x (covariantConnectionDifference g h x d u v) w + |
| 57 | 2 * D.covariantTensorDerivative (metricError g h) x |
| 58 | ![d, connectionDifference g h x u v, w] := by |
| 59 | let A := D.covariantTensorDerivative (metricError g h) |
| 60 | let Q := koszulPermutation A |
| 61 | have hA : IsSmoothCovariantTensor A := |
| 62 | D.covariantTensorDerivative_isSmooth (metricError_isSmooth g h) |
| 63 | have hQ : IsSmoothCovariantTensor Q := koszulPermutation_isSmooth hA |
| 64 | have hQeval (y a b c : E) : Q y ![a, b, c] = |
| 65 | 2 * h.inner y (connectionDifference g h y a b) c := by |
| 66 | change koszulPermutation A y ![a, b, c] = _ |
| 67 | erw [koszulPermutation_apply] |
| 68 | exact (inner_connectionDifference D D' y a b c).symm |
| 69 | have hc := D.fderiv_covariantTensor_pullback_model hQ |
| 70 | (q := id) (V := fun i (_ : E) => (![u, v, w] : Fin 3 → E) i) (p := x) |
| 71 | differentiableAt_id (fun i => differentiableAt_const ((![u, v, w] : Fin 3 → E) i)) d |
| 72 | have hc' : fderiv ℝ (fun y => Q y ![u, v, w]) x d = |
| 73 | D.covariantTensorDerivative Q x ![d, u, v, w] + |
| 74 | Q x ![christoffelBilinear g.euclideanCoefficients x d u, v, w] + |
| 75 | Q x ![u, christoffelBilinear g.euclideanCoefficients x d v, w] + |
| 76 | Q x ![u, v, christoffelBilinear g.euclideanCoefficients x d w] := by |
| 77 | have h0 (a : E) : Function.update (![u, v, w] : Fin 3 → E) 0 a = ![a, v, w] := by |
| 78 | ext i |
| 79 | fin_cases i <;> rfl |
| 80 | have h1 (a : E) : Function.update (![u, v, w] : Fin 3 → E) 1 a = ![u, a, w] := by |
| 81 | ext i |
| 82 | fin_cases i <;> rfl |
| 83 | have h2 (a : E) : Function.update (![u, v, w] : Fin 3 → E) 2 a = ![u, v, a] := by |
| 84 | ext i |
| 85 | fin_cases i <;> rfl |
| 86 | simpa! [id_eq, LeviCivitaData.manifoldCovDerivAlong_model, |
| 87 | ConnectionVariation.covDerivAlong_def, Fin.sum_univ_three, h0, h1, h2, |
| 88 | add_assoc] using hc |
| 89 | have hh := (h.contDiffAt_euclideanCoefficients x).differentiableAt (by simp) |
| 90 | have hC := (contDiff_connectionDifference g h).differentiable (by simp) x |
| 91 | have hinner := ((hh.clm_apply |
| 92 | ((hC.clm_apply (differentiableAt_const u)).clm_apply (differentiableAt_const v))).clm_apply |
| 93 | (differentiableAt_const w)) |
| 94 | have hder : fderiv ℝ (fun y => Q y ![u, v, w]) x d = |
| 95 | 2 * (fderiv ℝ h.euclideanCoefficients x d (connectionDifference g h x u v) w + |
| 96 | h.inner x (fderiv ℝ (connectionDifference g h) x d u v) w) := by |
| 97 | simp_rw [hQeval] |
| 98 | change fderiv ℝ (fun y => 2 * |
| 99 | h.euclideanCoefficients y (connectionDifference g h y u v) w) x d = _ |
| 100 | rw [fderiv_const_mul hinner, smul_apply, smul_eq_mul, fderiv_inner_connectionDifference] |
| 101 | have hm := fderiv_bilinear_eq_covariant D |
| 102 | (contDiff_iff_contDiffAt.mpr h.contDiffAt_euclideanCoefficients) |
| 103 | x d (connectionDifference g h x u v) w |
| 104 | rw [fderiv_metric_evaluation] at hm |
| 105 | change fderiv ℝ h.euclideanCoefficients x d (connectionDifference g h x u v) w = |
| 106 | D.covariantTensorDerivative (fun y z => h.inner y (z 0) (z 1)) x |
| 107 | ![d, connectionDifference g h x u v, w] + |
| 108 | h.inner x (christoffelBilinear g.euclideanCoefficients x d |
| 109 | (connectionDifference g h x u v)) w + |
| 110 | h.inner x (connectionDifference g h x u v) |
| 111 | (christoffelBilinear g.euclideanCoefficients x d w) at hm |
| 112 | rw [covariant_metric_eq_error D h] at hm |
| 113 | rw [hder, hm, hQeval, hQeval, hQeval] at hc' |
| 114 | change D.covariantTensorDerivative Q x ![d, u, v, w] = _ |
| 115 | simp only [covariantConnectionDifference, map_sub, map_add, sub_apply, add_apply] |
| 116 | linarith! only [hc'] |
| 117 | |
| 118 | /-- The lowered covariant connection derivative is controlled by the |
| 119 | second error and the first-error connection term, with all four slots |
| 120 | explicit. Source: the quantitative round perturbation in M44 derivation 31. -/ |
| 121 | theorem inner_covariantConnectionDifference {g h : RiemannianMetric 3 E} |
| 122 | (D : LeviCivitaData g) (D' : LeviCivitaData h) (x d u v w : E) : |
| 123 | 2 * h.inner x (covariantConnectionDifference g h x d u v) w = |
| 124 | D.iteratedCovariantTensorDerivative (metricError g h) 2 x ![d, u, v, w] + |
| 125 | D.iteratedCovariantTensorDerivative (metricError g h) 2 x ![d, v, w, u] - |
| 126 | D.iteratedCovariantTensorDerivative (metricError g h) 2 x ![d, w, u, v] - |
| 127 | 2 * D.covariantTensorDerivative (metricError g h) x |
| 128 | ![d, connectionDifference g h x u v, w] := by |
| 129 | have hh := covariant_koszul_error_eq_lowered D D' x d u v w |
| 130 | rw [covariant_koszulPermutation D |
| 131 | (D.covariantTensorDerivative_isSmooth (metricError_isSmooth g h))] at hh |
| 132 | change _ = _ at hh |
| 133 | dsimp only [LeviCivitaData.iteratedCovariantTensorDerivative] |
| 134 | linarith only [hh] |
| 135 | |
| 136 | end PoincareMT.M44 |