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.ReducedGeometry.ReducedLength.Action.ActionCongruence |
| 2 | import PoincareLib.Geometry.RicciFlow.ReducedGeometry.ReducedLength.Action.SmoothSquareActionDifferential |
| 3 | import PoincareLib.Geometry.RicciFlow.ReducedGeometry.ReducedLength.Exponential.FamilySquareVelocity |
| 4 | import PoincareLib.Geometry.RicciFlow.ReducedGeometry.ReducedLength.Action.NormalizedActionDerivative |
| 5 | import PoincareLib.Geometry.RicciFlow.ReducedGeometry.ReducedLength.Coordinates.ParametricCurveDerivative |
| 6 | |
| 7 | /-! |
| 8 | # First derivatives of the actual comparison-action representative |
| 9 | |
| 10 | The endpoint differential supplies every spatial direction. The time |
| 11 | identity retains the spatial term from the moving-endpoint chain rule. |
| 12 | -/ |
| 13 | |
| 14 | set_option autoImplicit false |
| 15 | set_option maxSynthPendingDepth 3 |
| 16 | |
| 17 | open scoped Manifold ContDiff Bundle Topology |
| 18 | open Filter |
| 19 | |
| 20 | universe u |
| 21 | |
| 22 | namespace PoincareMT.ReducedLength |
| 23 | |
| 24 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 25 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] |
| 26 | [IsManifold (𝓡 n) ∞ M] [ConnectedSpace M] |
| 27 | {J : Set ℝ} {F : RicciFlow n M J} {T τmax : ℝ} {p : M} |
| 28 | {E : Type} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] |
| 29 | |
| 30 | set_option maxHeartbeats 1800000 in |
| 31 | -- The parameter, square-time and spacetime derivatives keep their actual base equalities. |
| 32 | set_option backward.isDefEq.respectTransparency false in |
| 33 | theorem comparison_family_first_derivatives |
| 34 | (hM04 : RicciFlowCurvatureTheory.{u}) (hL : LGeodesicTheory F T τmax) |
| 35 | (hτmax : 0 < τmax) (hwindow : Set.Icc (T - τmax) T ⊆ J) |
| 36 | (A : LExponentialFamily F T τmax p) (Z : TangentSpace (𝓡 n) p) |
| 37 | (b : ℝ) (hb : 0 < b) (hmax : b < τmax) |
| 38 | (f : E × ℝ → M) (Ω : Set (E × ℝ)) (hΩ : IsOpen Ω) |
| 39 | (hf : ContMDiffOn (𝓘(ℝ, E × ℝ)) (𝓡 n) ∞ f Ω) |
| 40 | (hsegment : ∀ s ∈ Set.Icc 0 (Real.sqrt b), ((0 : E), s) ∈ Ω) |
| 41 | (hbase : ∀ s, f (0, s) = A.squareFamily Z s) |
| 42 | (hfixed : ∀ x, f (x, 0) = p) |
| 43 | (B : M × ℝ → ℝ) |
| 44 | (hB : ContMDiffAt ((𝓡 n).prod (𝓘(ℝ, ℝ))) (𝓘(ℝ, ℝ)) ∞ B (A.gamma Z b, b)) |
| 45 | (hpull : (fun z : E × ℝ ↦ B (f (z.1, Real.sqrt z.2), z.2)) =ᶠ[𝓝 (0, b)] |
| 46 | (fun z ↦ backwardLLength F T 0 z.2 (fun t ↦ f (z.1, Real.sqrt t)) / |
| 47 | (2 * Real.sqrt z.2))) |
| 48 | (hsurj : Function.Surjective (mfderiv (𝓘(ℝ, E)) (𝓡 n) |
| 49 | (fun x ↦ f (x, Real.sqrt b)) 0)) : |
| 50 | (∀ v : TangentSpace (𝓡 n) (A.gamma Z b), |
| 51 | mvfderiv (𝓡 n) (fun q ↦ B (q, b)) (A.gamma Z b) v = |
| 52 | (F.metric (T - b)).inner (A.gamma Z b) (curveVelocity (A.gamma Z) b) v) ∧ |
| 53 | reducedLengthGradientNormSq F T B b (A.gamma Z b) = |
| 54 | (F.metric (T - b)).inner (A.gamma Z b) |
| 55 | (curveVelocity (A.gamma Z) b) (curveVelocity (A.gamma Z) b) ∧ |
| 56 | deriv (fun t ↦ B (A.gamma Z b, t)) b = |
| 57 | ((F.connection (T - b)).scalarCurvature (A.gamma Z b) - |
| 58 | (F.metric (T - b)).inner (A.gamma Z b) |
| 59 | (curveVelocity (A.gamma Z) b) (curveVelocity (A.gamma Z) b)) / 2 - |
| 60 | B (A.gamma Z b, b) / (2 * b) := by |
| 61 | let c := Real.sqrt b |
| 62 | have hc : 0 < c := Real.sqrt_pos.mpr hb |
| 63 | have hc2 : c ^ 2 = b := Real.sq_sqrt hb.le |
| 64 | have hcmax : c < Real.sqrt τmax := Real.sqrt_lt_sqrt hb.le hmax |
| 65 | have hden : 2 * c ≠ 0 := (mul_pos zero_lt_two hc).ne' |
| 66 | have hsq : A.squareFamily Z c = A.gamma Z b := by |
| 67 | rw [A.square_agrees Z c ⟨hc.le, hcmax⟩, hc2] |
| 68 | have hfc : f (0, c) = A.gamma Z b := (hbase c).trans hsq |
| 69 | let k : E → M := fun x ↦ f (x, c) |
| 70 | let S : E → ℝ := fun x ↦ backwardLLength F T 0 b (fun t ↦ f (x, Real.sqrt t)) |
| 71 | have hk : MDifferentiableAt (𝓘(ℝ, E)) (𝓡 n) k 0 := |
| 72 | ((hf.contMDiffAt (hΩ.mem_nhds (hsegment c ⟨hc.le, le_rfl⟩))).comp 0 |
| 73 | (contDiffAt_id.prodMk contDiffAt_const).contMDiffAt).mdifferentiableAt (by simp) |
| 74 | have hBs : MDifferentiableAt (𝓡 n) (𝓘(ℝ, ℝ)) (fun q ↦ B (q, b)) (k 0) := by |
| 75 | rw [show k 0 = A.gamma Z b from hfc] |
| 76 | exact (hB.comp (A.gamma Z b) (contMDiffAt_id.prodMk contMDiffAt_const)).mdifferentiableAt |
| 77 | (by simp) |
| 78 | have hS : ContDiffAt ℝ ∞ S 0 := by |
| 79 | have h := contDiffAt_smoothSquareFamily_action F hM04 T τmax hτmax hwindow |
| 80 | f Ω hΩ hf ((0 : E), b) ⟨hb, hmax⟩ (fun r hr ↦ hsegment _ |
| 81 | ⟨mul_nonneg hc.le hr.1, mul_le_of_le_one_right hc.le hr.2⟩) |
| 82 | exact h.comp 0 (contDiffAt_id.prodMk contDiffAt_const) |
| 83 | have hN : HasFDerivAt (fun x : E ↦ S x / (2 * c)) |
| 84 | ((2 * c)⁻¹ • fderiv ℝ S 0) 0 := by |
| 85 | convert! ((hS.differentiableAt (by simp)).hasFDerivAt.const_mul (2 * c)⁻¹) using 1 <;> |
| 86 | simp only [Function.comp_def, id_eq, div_eq_mul_inv, mul_comm] <;> rfl |
| 87 | have hpullS : (fun x : E ↦ B (k x, b)) =ᶠ[𝓝 0] (fun x ↦ S x / (2 * c)) := |
| 88 | hpull.comp_tendsto (continuous_id.prodMk continuous_const).continuousAt |
| 89 | have hcomp := (hBs.hasMFDerivAt.comp 0 hk.hasMFDerivAt).hasFDerivAt |
| 90 | have hmaps := (hcomp.congr_of_eventuallyEq hpullS.symm).unique hN |
| 91 | have hfirst (v : E) : fderiv ℝ S 0 v = |
| 92 | (2 * c) * (F.metric (T - b)).inner (A.gamma Z b) |
| 93 | (curveVelocity (A.gamma Z) b) (mfderiv (𝓘(ℝ, E)) (𝓡 n) k 0 v) := by |
| 94 | have h := fderiv_smoothSquareFamily_action hM04 hL hτmax hwindow A Z b hb hmax |
| 95 | f Ω hΩ hf 0 v hsegment (fun s _ ↦ hbase s) |
| 96 | have hv : (curveVelocity (n := n) (fun r : ℝ ↦ f (0 + r • v, c)) 0 : |
| 97 | EuclideanSpace ℝ (Fin n)) = mfderiv (𝓘(ℝ, E)) (𝓡 n) k 0 v := |
| 98 | curveVelocity_comp_initial_line k 0 v hk |
| 99 | have hzero : (curveVelocity (n := n) (fun r : ℝ ↦ f (0 + r • v, 0)) 0 : |
| 100 | EuclideanSpace ℝ (Fin n)) = 0 := by |
| 101 | have heq : (fun r : ℝ ↦ f (0 + r • v, 0)) = (fun _ ↦ p) := |
| 102 | funext (fun _ ↦ hfixed _) |
| 103 | rw [heq] |
| 104 | simp only [curveVelocity, mfderiv_const, zero_apply] |
| 105 | have hsvel := lExponentialFamily_square_velocity_eq A Z c ⟨hc, hcmax⟩ |
| 106 | rw [hc2] at hsvel |
| 107 | rw [hv, hzero, map_zero, sub_zero, hsq, hsvel, map_smul, smul_apply, smul_eq_mul] at h |
| 108 | exact h |
| 109 | have hspace (v : TangentSpace (𝓡 n) (A.gamma Z b)) : |
| 110 | mvfderiv (𝓡 n) (fun q ↦ B (q, b)) (A.gamma Z b) v = |
| 111 | (F.metric (T - b)).inner (A.gamma Z b) (curveVelocity (A.gamma Z) b) v := by |
| 112 | obtain ⟨x, hx⟩ := hsurj v |
| 113 | have heval := congrArg (fun L : E →L[ℝ] ℝ ↦ L x) hmaps |
| 114 | change mvfderiv (𝓡 n) (fun q ↦ B (q, b)) (k 0) |
| 115 | (mfderiv (𝓘(ℝ, E)) (𝓡 n) k 0 x) = (2 * c)⁻¹ * fderiv ℝ S 0 x at heval |
| 116 | have hx' : (mfderiv (𝓘(ℝ, E)) (𝓡 n) k 0 x : EuclideanSpace ℝ (Fin n)) = v := hx |
| 117 | rw [hfirst x, hx'] at heval |
| 118 | rw [show k 0 = A.gamma Z b from hfc] at heval |
| 119 | simpa only [← mul_assoc, inv_mul_cancel₀ hden, one_mul] using heval |
| 120 | refine ⟨hspace, reducedLengthGradientNormSq_eq_of_differential F T b B _ _ hspace, ?_⟩ |
| 121 | have hpullT0 : (fun t ↦ B (f (0, Real.sqrt t), t)) =ᶠ[𝓝 b] |
| 122 | (fun t ↦ backwardLLength F T 0 t (fun r ↦ f (0, Real.sqrt r)) / |
| 123 | (2 * Real.sqrt t)) := |
| 124 | hpull.comp_tendsto (continuous_const.prodMk continuous_id).continuousAt |
| 125 | have hpullT : (fun t ↦ B (A.gamma Z t, t)) =ᶠ[𝓝 b] |
| 126 | (fun t ↦ A.action Z t / (2 * Real.sqrt t)) := by |
| 127 | filter_upwards [hpullT0, isOpen_Ioo.mem_nhds |
| 128 | (show b ∈ Set.Ioo 0 τmax from ⟨hb, hmax⟩)] with t ht htime |
| 129 | have hft : f (0, Real.sqrt t) = A.gamma Z t := by |
| 130 | rw [hbase, A.square_agrees Z (Real.sqrt t) |
| 131 | ⟨Real.sqrt_nonneg _, Real.sqrt_lt_sqrt htime.1.le htime.2⟩, |
| 132 | Real.sq_sqrt htime.1.le] |
| 133 | have hact : backwardLLength F T 0 t (fun r ↦ f (0, Real.sqrt r)) = A.action Z t := by |
| 134 | apply backwardLLength_congr_Ioo F T 0 t htime.1.le |
| 135 | intro r hr |
| 136 | change f (0, Real.sqrt r) = A.gamma Z r |
| 137 | rw [hbase, A.square_agrees Z (Real.sqrt r) |
| 138 | ⟨Real.sqrt_nonneg _, Real.sqrt_lt_sqrt hr.1.le (hr.2.trans htime.2)⟩, |
| 139 | Real.sq_sqrt hr.1.le] |
| 140 | simpa only [hft, hact] using ht |
| 141 | have hswap := (hB.comp (b, A.gamma Z b) |
| 142 | (contMDiffAt_snd.prodMk contMDiffAt_fst)).mdifferentiableAt (by simp) |
| 143 | have hcurve := (lExponentialFamily_gammaSlice_contMDiffAt A Z b hb hmax).mdifferentiableAt |
| 144 | (by simp) |
| 145 | have hchain := hasDerivAt_parametric_curve (fun z : ℝ × M ↦ B (z.2, z.1)) |
| 146 | (A.gamma Z) b hswap hcurve |
| 147 | have hactual := (lExponentialFamily_normalizedAction_hasDerivAt hM04 hwindow A Z b hb hmax).congr_of_eventuallyEq hpullT |
| 148 | have hd := hchain.unique hactual |
| 149 | have hcenter := hpullT.self_of_nhds |
| 150 | dsimp only at hd hcenter |
| 151 | rw [hspace, ← hcenter] at hd |
| 152 | linarith |
| 153 | |
| 154 | end PoincareMT.ReducedLength |