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.CurveShortening.Evolution.Orthogonality |
| 2 | import PoincareLib.Geometry.RicciFlow.CurveShortening.Evolution.Regularity |
| 3 | import PoincareLib.Geometry.RicciFlow.CurveShortening.Connection.MetricVariation |
| 4 | import PoincareLib.Geometry.RicciFlow.CurveShortening.Connection.Torsion |
| 5 | import PoincareLib.Geometry.RicciFlow.Curvature.Calculus.Tensors.RicciRegularity |
| 6 | |
| 7 | /-! |
| 8 | # Actual speed evolution under curve shortening |
| 9 | |
| 10 | The evolving metric rule, pullback torsion and curvature orthogonality give |
| 11 | the two speed derivatives in MT2007 Lemma 19.6, pp. 441-442, as corrected by |
| 12 | Lemma 0.1, p. 3. No curvature norm is differentiated at a zero. |
| 13 | See `references/ricci-flow/mapher/curve-evolution/derivations/2026-09-19-speed-evolution.md`. |
| 14 | -/ |
| 15 | |
| 16 | set_option autoImplicit false |
| 17 | set_option maxSynthPendingDepth 3 |
| 18 | set_option backward.isDefEq.respectTransparency false |
| 19 | |
| 20 | open scoped Manifold ContDiff Bundle Topology |
| 21 | |
| 22 | universe u |
| 23 | |
| 24 | namespace PoincareMT.M62 |
| 25 | |
| 26 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 27 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 28 | {a b : ℝ} (F : RicciFlow n M (Set.Icc a b)) (c : ℝ → ℝ → M) |
| 29 | |
| 30 | /-- The actual speed square has the corrected time derivative. |
| 31 | MT2007 Lemma 19.6, pp. 441-442; correction Lemma 0.1, p. 3. -/ |
| 32 | theorem hasDerivAt_speed_sq (hc : M62ShrinkingCurve F c) {t : ℝ} |
| 33 | (ht : t ∈ Set.Ioo a b) (x : ℝ) : |
| 34 | HasDerivAt (fun s ↦ (curveSpeed F c s x) ^ 2) |
| 35 | (-2 * (m62TangentRicci F c t x + m62CurvatureSquared F c t x) * |
| 36 | (curveSpeed F c t x) ^ 2) t := by |
| 37 | have hclosed := Set.Ioo_subset_Icc_self ht |
| 38 | have hopen : IsOpen (Set.univ ×ˢ Set.Ioo a b : Set (ℝ × ℝ)) := |
| 39 | isOpen_univ.prod isOpen_Ioo |
| 40 | have hmem : (x, t) ∈ (Set.univ ×ˢ Set.Ioo a b : Set (ℝ × ℝ)) := ⟨Set.mem_univ _, ht⟩ |
| 41 | have htime : MDifferentiableAt (𝓘(ℝ, ℝ)) (𝓘(ℝ, ℝ × ℝ)) |
| 42 | (fun s : ℝ ↦ (x, s)) t := |
| 43 | ((differentiableAt_const x).prodMk differentiableAt_id).mdifferentiableAt |
| 44 | have hspace : MDifferentiableAt (𝓘(ℝ, ℝ)) (𝓘(ℝ, ℝ × ℝ)) |
| 45 | (fun y : ℝ ↦ (y, t)) x := |
| 46 | (differentiableAt_id.prodMk (differentiableAt_const t)).mdifferentiableAt |
| 47 | have hγtime := (((hc.joint_smooth (x, t) hmem).contMDiffAt |
| 48 | (hopen.mem_nhds hmem)).mdifferentiableAt (by simp)).comp t htime |
| 49 | have hXtime := ((((spatial_velocity_joint_contMDiff F c hc) (x, t) hmem).contMDiffAt |
| 50 | (hopen.mem_nhds hmem)).mdifferentiableAt (by simp)).comp t htime |
| 51 | have hHspace := ((((curvature_joint_contMDiff F c hc) (x, t) hmem).contMDiffAt |
| 52 | (hopen.mem_nhds hmem)).mdifferentiableAt (by simp)).comp x hspace |
| 53 | have hS := (unitTangent_contMDiff F c hc hclosed x).mdifferentiableAt (by simp) |
| 54 | have hγspace := (hc.spatial_regular t hclosed x).mdifferentiableAt (by norm_num) |
| 55 | let D := F.connection t |
| 56 | let X := fun y ↦ curveVelocity (n := n) (fun z ↦ c z t) y |
| 57 | let S := spatialUnitTangent F c t |
| 58 | let H := m62CurvatureVector F c t |
| 59 | let v := curveSpeed F c t x |
| 60 | have hv : v ≠ 0 := (speed_pos F c hc hclosed x).ne' |
| 61 | have hX : X x = v • S x := by |
| 62 | symm |
| 63 | change v • (v⁻¹ • X x) = X x |
| 64 | rw [smul_smul, mul_inv_cancel₀ hv, one_smul] |
| 65 | have hDS : rampHorizontalCovariantDerivative D (fun y ↦ c y t) S x = v • H x := by |
| 66 | symm |
| 67 | change v • (v⁻¹ • rampHorizontalCovariantDerivative D (fun y ↦ c y t) S x) = _ |
| 68 | rw [smul_smul, mul_inv_cancel₀ hv, one_smul] |
| 69 | have hpair : HasDerivAt (fun y ↦ (F.metric t).inner (c y t) (S y) (H y)) |
| 70 | ((F.metric t).inner (c x t) |
| 71 | (rampHorizontalCovariantDerivative D (fun y ↦ c y t) S x) (H x) + |
| 72 | (F.metric t).inner (c x t) (S x) |
| 73 | (rampHorizontalCovariantDerivative D (fun y ↦ c y t) H x)) x := |
| 74 | hasDerivAt_metric_pairing D hγspace hS hHspace |
| 75 | have hzero : (fun y ↦ (F.metric t).inner (c y t) (S y) (H y)) = fun _ : ℝ ↦ 0 := by |
| 76 | funext y |
| 77 | rw [(F.metric t).symm (c y t) (S y) (H y)] |
| 78 | exact curvature_unitTangent_inner_zero F c hc hclosed y |
| 79 | rw [hzero] at hpair |
| 80 | have hvalue := hpair.unique (hasDerivAt_const x (0 : ℝ)) |
| 81 | rw [hDS] at hvalue |
| 82 | simp only [map_smul, smul_apply, smul_eq_mul] at hvalue |
| 83 | have hcrossS : (F.metric t).inner (c x t) (S x) |
| 84 | (rampHorizontalCovariantDerivative D (fun y ↦ c y t) H x) = |
| 85 | -v * m62CurvatureSquared F c t x := by |
| 86 | change v * m62CurvatureSquared F c t x + _ = 0 at hvalue |
| 87 | linarith |
| 88 | have hcross : (F.metric t).inner (c x t) (X x) |
| 89 | (rampHorizontalCovariantDerivative D (fun y ↦ c y t) H x) = |
| 90 | -v ^ 2 * m62CurvatureSquared F c t x := by |
| 91 | rw [hX] |
| 92 | simp only [map_smul, smul_apply, smul_eq_mul, hcrossS] |
| 93 | ring |
| 94 | have hcross' := (F.metric t).symm (c x t) |
| 95 | (rampHorizontalCovariantDerivative D (fun y ↦ c y t) H x) (X x) |
| 96 | rw [hcross] at hcross' |
| 97 | obtain ⟨A, hA⟩ := (RicciFlowAnalysis.isSmoothCovariantTensor_ricciEvaluation D).1 (c x t) |
| 98 | have hscale := A.map_smul_univ (fun _ : Fin 2 ↦ v) (fun _ : Fin 2 ↦ S x) |
| 99 | rw [← hA, ← hA] at hscale |
| 100 | have hRic : D.ricci (c x t) (X x) (X x) = v ^ 2 * m62TangentRicci F c t x := by |
| 101 | rw [hX] |
| 102 | simpa only [LeviCivitaData.ricciEvaluation, Finset.prod_const, Finset.card_univ, |
| 103 | Fintype.card_fin, smul_eq_mul, m62TangentRicci, D, S] using hscale |
| 104 | have hcommute := pullback_velocity_commute D c hopen hc.joint_smooth hmem |
| 105 | have heq : (fun y ↦ curveVelocity (fun s ↦ c y s) t) = H := |
| 106 | funext (hc.equation t ht) |
| 107 | rw [heq] at hcommute |
| 108 | have hflow := hasDerivAt_flow_metric_pairing F (γ := fun s ↦ c x s) |
| 109 | (Y := fun s ↦ curveVelocity (fun y ↦ c y s) x) |
| 110 | (Z := fun s ↦ curveVelocity (fun y ↦ c y s) x) ht hγtime hXtime hXtime |
| 111 | apply (hflow.congr_of_eventuallyEq |
| 112 | (Filter.Eventually.of_forall (fun s ↦ speed_sq F c s x))).congr_deriv |
| 113 | rw [hcommute] |
| 114 | change -2 * D.ricci (c x t) (X x) (X x) + |
| 115 | (F.metric t).inner (c x t) |
| 116 | (rampHorizontalCovariantDerivative D (fun y ↦ c y t) H x) (X x) + |
| 117 | (F.metric t).inner (c x t) (X x) |
| 118 | (rampHorizontalCovariantDerivative D (fun y ↦ c y t) H x) = _ |
| 119 | rw [hcross, hcross', hRic] |
| 120 | ring |
| 121 | |
| 122 | /-- Positive speed has the corrected time derivative, including at zero |
| 123 | curvature; correction Lemma 0.1, p. 3. -/ |
| 124 | theorem hasDerivAt_speed (hc : M62ShrinkingCurve F c) {t : ℝ} |
| 125 | (ht : t ∈ Set.Ioo a b) (x : ℝ) : |
| 126 | HasDerivAt (fun s ↦ curveSpeed F c s x) |
| 127 | (-(m62TangentRicci F c t x + m62CurvatureSquared F c t x) * |
| 128 | curveSpeed F c t x) t := by |
| 129 | have hv := (speed_pos F c hc (Set.Ioo_subset_Icc_self ht) x).ne' |
| 130 | have h := (hasDerivAt_speed_sq F c hc ht x).sqrt (pow_ne_zero 2 hv) |
| 131 | have heq : (fun s ↦ curveSpeed F c s x) =ᶠ[𝓝 t] |
| 132 | (fun s ↦ Real.sqrt (curveSpeed F c s x ^ 2)) := |
| 133 | Filter.Eventually.of_forall fun s ↦ (Real.sqrt_sq (speed_nonneg F c s x)).symm |
| 134 | apply (h.congr_of_eventuallyEq heq).congr_deriv |
| 135 | rw [Real.sqrt_sq (speed_nonneg F c t x)] |
| 136 | field_simp |
| 137 | |
| 138 | end PoincareMT.M62 |