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.CurveShortening.Comparison.Compatibility.SourceNames |
| 2 | import PoincareLib.Geometry.CurveShortening.Ramp.LocalFlow.Embedding.HessianVector |
| 3 | import PoincareLib.Geometry.CurveShortening.Ramp.LocalEstimates.Curve.TensorLeibniz |
| 4 | import Mathlib.Analysis.Calculus.Deriv.Prod |
| 5 | |
| 6 | /-! |
| 7 | # Witnessed product rules for embedded curvature |
| 8 | |
| 9 | The actual selected connection and scalar Hessian identify derivatives |
| 10 | in the fixed Euclidean target. MT2007 Claim 19.1, p. 437; |
| 11 | MT2015Correction Lemmas 0.1--0.2, pp. 3--6. See |
| 12 | `2026-09-22-c2-embedded-product-rules.md`, statements 2--3. |
| 13 | -/ |
| 14 | |
| 15 | set_option autoImplicit false |
| 16 | set_option backward.isDefEq.respectTransparency false |
| 17 | |
| 18 | open Set Bundle Manifold |
| 19 | open scoped Manifold ContDiff Bundle BigOperators |
| 20 | |
| 21 | universe u v |
| 22 | |
| 23 | namespace PoincareMT.M63 |
| 24 | |
| 25 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 26 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 27 | {ι : Type v} [Fintype ι] |
| 28 | |
| 29 | local notation "W" => EuclideanSpace ℝ ι |
| 30 | |
| 31 | /-- Differentiate the actual differential applied to a moving tangent |
| 32 | field, with the literal coordinate Hessian and selected pullback |
| 33 | connection. MT2007 Claim 19.1, p. 437; embedded-product derivation, |
| 34 | statement 2. No injectivity of the smooth map is required. -/ |
| 35 | theorem hasDerivAt_embedding_pushforward {g : RiemannianMetric n M} |
| 36 | (D : LeviCivitaData g) {e : M → W} |
| 37 | (he : ContMDiff (𝓡 n) 𝓘(ℝ, W) ∞ e) |
| 38 | {gamma : ℝ → M} {x : ℝ} |
| 39 | (hgamma : ContMDiffAt 𝓘(ℝ, ℝ) (𝓡 n) ∞ gamma x) |
| 40 | (Y : (s : ℝ) → TangentSpace (𝓡 n) (gamma s)) |
| 41 | (hY : MDifferentiableAt 𝓘(ℝ, ℝ) (𝓡 n).tangent |
| 42 | (fun s => (⟨gamma s, Y s⟩ : TangentBundle (𝓡 n) M)) x) : |
| 43 | HasDerivAt (fun s => (mfderiv (𝓡 n) 𝓘(ℝ, W) e (gamma s) (Y s) : W)) |
| 44 | (HAdd.hAdd (α := W) (β := W) (γ := W) |
| 45 | (coordinateHessian D e (gamma x) (curveVelocity gamma x) (Y x)) |
| 46 | (mfderiv (𝓡 n) 𝓘(ℝ, W) e (gamma x) |
| 47 | (rampHorizontalCovariantDerivative D gamma Y x))) x := by |
| 48 | classical |
| 49 | have hcoord (i : ι) : |
| 50 | HasDerivAt (fun s => EuclideanSpace.proj i |
| 51 | (mfderiv (𝓡 n) 𝓘(ℝ, W) e (gamma s) (Y s))) |
| 52 | (EuclideanSpace.proj i (HAdd.hAdd (α := W) (β := W) (γ := W) |
| 53 | (coordinateHessian D e (gamma x) (curveVelocity gamma x) (Y x)) |
| 54 | (mfderiv (𝓡 n) 𝓘(ℝ, W) e (gamma x) |
| 55 | (rampHorizontalCovariantDerivative D gamma Y x)))) x := by |
| 56 | let f : M → ℝ := fun p => e p i |
| 57 | have hf : ContMDiff (𝓡 n) 𝓘(ℝ, ℝ) ∞ f := |
| 58 | (EuclideanSpace.proj i).contDiff.contMDiff.comp he |
| 59 | let T0 : CovariantTensorEvaluation n M 0 := fun p _ => f p |
| 60 | have hT0 : IsSmoothCovariantTensor T0 := by |
| 61 | constructor |
| 62 | · intro p |
| 63 | exact ⟨MultilinearMap.constOfIsEmpty ℝ |
| 64 | (fun _ : Fin 0 => TangentSpace (𝓡 n) p) (f p), fun _ => rfl⟩ |
| 65 | · intro U hU Z hZ |
| 66 | exact hf.contMDiffOn |
| 67 | let T1 := D.covariantTensorDerivative T0 |
| 68 | have hT1 : IsSmoothCovariantTensor T1 := |
| 69 | M04.isSmoothCovariantTensor_covariantTensorDerivative D hT0 |
| 70 | have hdf (p : M) (w : Fin 1 → TangentSpace (𝓡 n) p) : |
| 71 | T1 p w = mvfderiv (𝓡 n) f p (w 0) := by |
| 72 | simp [T1, T0, LeviCivitaData.covariantTensorDerivative] |
| 73 | have hHessian (p : M) (w : Fin 2 → TangentSpace (𝓡 n) p) : |
| 74 | D.covariantTensorDerivative T1 p w = D.hessian f p (w 0) (w 1) := by |
| 75 | have h01 : (Fin.succ 0 : Fin 2) = 1 := by decide |
| 76 | rw [LeviCivitaData.covariantTensorDerivative] |
| 77 | simp only [hdf, Fin.sum_univ_succ, Fin.sum_univ_zero, |
| 78 | Function.update_self, LeviCivitaData.hessian, LeviCivitaData.hessianOnFields, |
| 79 | FiberBundle.extend_apply_self, add_zero, h01] |
| 80 | have hproj (p : M) (V : TangentSpace (𝓡 n) p) : |
| 81 | mvfderiv (𝓡 n) f p V = |
| 82 | EuclideanSpace.proj i (mfderiv (𝓡 n) 𝓘(ℝ, W) e p V) := by |
| 83 | let L : W →L[ℝ] ℝ := EuclideanSpace.proj i |
| 84 | change mvfderiv (𝓡 n) (L ∘ e) p V = _ |
| 85 | rw [mvfderiv_comp_apply p L.differentiableAt.mdifferentiableAt |
| 86 | (he.mdifferentiable (by simp) p) V] |
| 87 | simpa only [mvfderiv, mfderiv_eq_fderiv, ContinuousLinearMap.comp_apply] using! |
| 88 | congrArg (fun K : W →L[ℝ] ℝ => K (mfderiv (𝓡 n) 𝓘(ℝ, W) e p V)) |
| 89 | (L.fderiv (x := e p)) |
| 90 | have hscalar := m63HasDerivAt_tensor_pullback D T1 hT1 hgamma |
| 91 | (fun (_ : Fin 1) s => Y s) (fun _ => hY) |
| 92 | simpa [hdf, hHessian, hproj, Fin.sum_univ_succ, coordinateHessian, f] using hscalar |
| 93 | let L : (ι → ℝ) ≃L[ℝ] W := |
| 94 | (PiLp.continuousLinearEquiv 2 ℝ (fun _ : ι => ℝ)).symm |
| 95 | have hpi := hasDerivAt_pi.mpr hcoord |
| 96 | have h := L.toContinuousLinearMap.hasFDerivAt.comp_hasDerivAt x hpi |
| 97 | convert! h using 1 |
| 98 | |
| 99 | /-- The actual coordinate Hessian differentiates its leading tensor and |
| 100 | both moving arguments. Its covariant derivative inserts the actual |
| 101 | velocity in the first slot. MT2007 Claim 19.1, p. 437; |
| 102 | embedded-product derivation, statement 3. -/ |
| 103 | theorem hasDerivAt_coordinateHessian_pullback {g : RiemannianMetric n M} |
| 104 | (D : LeviCivitaData g) {e : M → W} |
| 105 | (he : ContMDiff (𝓡 n) 𝓘(ℝ, W) ∞ e) |
| 106 | {gamma : ℝ → M} {x : ℝ} |
| 107 | (hgamma : ContMDiffAt 𝓘(ℝ, ℝ) (𝓡 n) ∞ gamma x) |
| 108 | (Y Z : (s : ℝ) → TangentSpace (𝓡 n) (gamma s)) |
| 109 | (hY : MDifferentiableAt 𝓘(ℝ, ℝ) (𝓡 n).tangent |
| 110 | (fun s => (⟨gamma s, Y s⟩ : TangentBundle (𝓡 n) M)) x) |
| 111 | (hZ : MDifferentiableAt 𝓘(ℝ, ℝ) (𝓡 n).tangent |
| 112 | (fun s => (⟨gamma s, Z s⟩ : TangentBundle (𝓡 n) M)) x) : |
| 113 | let T : ι → CovariantTensorEvaluation n M 2 := |
| 114 | fun i p w => D.hessian (fun q => e q i) p (w 0) (w 1) |
| 115 | HasDerivAt (fun s => coordinateHessian D e (gamma s) (Y s) (Z s)) |
| 116 | (WithLp.toLp 2 (fun i => D.covariantTensorDerivative (T i) (gamma x) |
| 117 | ![curveVelocity gamma x, Y x, Z x]) + |
| 118 | coordinateHessian D e (gamma x) (rampHorizontalCovariantDerivative D gamma Y x) |
| 119 | (Z x) + |
| 120 | coordinateHessian D e (gamma x) (Y x) |
| 121 | (rampHorizontalCovariantDerivative D gamma Z x)) x := by |
| 122 | classical |
| 123 | dsimp only |
| 124 | let T : ι → CovariantTensorEvaluation n M 2 := |
| 125 | fun i p w => D.hessian (fun q => e q i) p (w 0) (w 1) |
| 126 | have hcoord (i : ι) : |
| 127 | HasDerivAt (fun s => (coordinateHessian D e (gamma s) (Y s) (Z s)) i) |
| 128 | ((WithLp.toLp 2 (fun j => D.covariantTensorDerivative (T j) (gamma x) |
| 129 | ![curveVelocity gamma x, Y x, Z x]) + |
| 130 | coordinateHessian D e (gamma x) (rampHorizontalCovariantDerivative D gamma Y x) |
| 131 | (Z x) + |
| 132 | coordinateHessian D e (gamma x) (Y x) |
| 133 | (rampHorizontalCovariantDerivative D gamma Z x)) i) x := by |
| 134 | have hf : ContMDiff (𝓡 n) 𝓘(ℝ, ℝ) ∞ (fun p => e p i) := |
| 135 | (EuclideanSpace.proj i).contDiff.contMDiff.comp he |
| 136 | have hT : IsSmoothCovariantTensor (T i) := M04.isSmoothCovariantTensor_hessian D hf |
| 137 | have hfields : ∀ j : Fin 2, MDifferentiableAt 𝓘(ℝ, ℝ) (𝓡 n).tangent |
| 138 | (fun s => (⟨gamma s, ![Y, Z] j s⟩ : TangentBundle (𝓡 n) M)) x := by |
| 139 | intro j |
| 140 | fin_cases j |
| 141 | · exact hY |
| 142 | · exact hZ |
| 143 | have hscalar := m63HasDerivAt_tensor_pullback D (T i) hT hgamma ![Y, Z] hfields |
| 144 | have htuple : (fun j : Fin 2 => ![Y, Z] j x) = ![Y x, Z x] := by |
| 145 | funext j |
| 146 | fin_cases j <;> rfl |
| 147 | rw [htuple] at hscalar |
| 148 | simpa [T, Fin.sum_univ_succ, coordinateHessian, add_assoc] using hscalar |
| 149 | let L : (ι → ℝ) ≃L[ℝ] W := |
| 150 | (PiLp.continuousLinearEquiv 2 ℝ (fun _ : ι => ℝ)).symm |
| 151 | have hpi := hasDerivAt_pi.mpr hcoord |
| 152 | have h := L.toContinuousLinearMap.hasFDerivAt.comp_hasDerivAt x hpi |
| 153 | convert! h using 1 |
| 154 | |
| 155 | end PoincareMT.M63 |