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.Evolution.Flow |
| 2 | import PoincareLib.Geometry.RicciFlow.CurveShortening.Connection.FrameForms |
| 3 | import Mathlib.Geometry.Manifold.MFDeriv.NormedSpace |
| 4 | import Mathlib.Analysis.Calculus.Deriv.Comp |
| 5 | |
| 6 | /-! |
| 7 | # Metric compatibility along a parameterized curve |
| 8 | |
| 9 | The frozen local-frame pullback derivative obeys the metric product rule, |
| 10 | including for stationary or self-intersecting curves. This is the spatial |
| 11 | calculus used in Morgan--Tian Lemma 19.6, pp. 441-442, and the 2015 correction, |
| 12 | Lemma 0.1, p. 3. The frame bridge is derived in |
| 13 | `references/ricci-flow/mapher/curve-evolution/derivations/2026-09-19-pullback-metric.md`. |
| 14 | -/ |
| 15 | |
| 16 | set_option autoImplicit false |
| 17 | set_option maxSynthPendingDepth 3 |
| 18 | |
| 19 | open scoped Manifold ContDiff Bundle Topology |
| 20 | open Filter |
| 21 | |
| 22 | universe u |
| 23 | |
| 24 | namespace PoincareMT.M62 |
| 25 | |
| 26 | open PoincareMT.ReducedLengthMinimum.Variation.Geometry |
| 27 | |
| 28 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 29 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 30 | |
| 31 | set_option backward.isDefEq.respectTransparency false in |
| 32 | /-- Metric compatibility for the actual frozen-frame pullback derivative. |
| 33 | Morgan--Tian Lemma 19.6, pp. 441-442; correction Lemma 0.1, p. 3. -/ |
| 34 | theorem hasDerivAt_metric_pairing {g : RiemannianMetric n M} |
| 35 | (D : LeviCivitaData g) {γ : ℝ → M} |
| 36 | {Y Z : (s : ℝ) → TangentSpace (𝓡 n) (γ s)} {x : ℝ} |
| 37 | (hγ : MDifferentiableAt (𝓘(ℝ, ℝ)) (𝓡 n) γ x) |
| 38 | (hY : MDifferentiableAt (𝓘(ℝ, ℝ)) ((𝓡 n).prod (𝓡 n)) |
| 39 | (fun s ↦ (⟨γ s, Y s⟩ : TangentBundle (𝓡 n) M)) x) |
| 40 | (hZ : MDifferentiableAt (𝓘(ℝ, ℝ)) ((𝓡 n).prod (𝓡 n)) |
| 41 | (fun s ↦ (⟨γ s, Z s⟩ : TangentBundle (𝓡 n) M)) x) : |
| 42 | HasDerivAt (fun s ↦ g.inner (γ s) (Y s) (Z s)) |
| 43 | (g.inner (γ x) (rampHorizontalCovariantDerivative D γ Y x) (Z x) + |
| 44 | g.inner (γ x) (Y x) (rampHorizontalCovariantDerivative D γ Z x)) x := by |
| 45 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 46 | ⟨g.toRiemannianMetric⟩ |
| 47 | let p := γ x |
| 48 | let e := trivializationAt (EuclideanSpace ℝ (Fin n)) (TangentSpace (𝓡 n)) p |
| 49 | have hp : p ∈ e.baseSet := FiberBundle.mem_baseSet_trivializationAt' p |
| 50 | let y : ℝ → EuclideanSpace ℝ (Fin n) := fun s ↦ (e ⟨γ s, Y s⟩).2 |
| 51 | let z : ℝ → EuclideanSpace ℝ (Fin n) := fun s ↦ (e ⟨γ s, Z s⟩).2 |
| 52 | let v : ℝ → TangentSpace (𝓡 n) p := fun s ↦ e.symmL ℝ p (y s) |
| 53 | let w : ℝ → TangentSpace (𝓡 n) p := fun s ↦ e.symmL ℝ p (z s) |
| 54 | have hy : DifferentiableAt ℝ y x := by |
| 55 | rw [mdifferentiableAt_totalSpace] at hY |
| 56 | exact hY.2.differentiableAt |
| 57 | have hz : DifferentiableAt ℝ z x := by |
| 58 | rw [mdifferentiableAt_totalSpace] at hZ |
| 59 | exact hZ.2.differentiableAt |
| 60 | have hv : HasDerivAt v (e.symmL ℝ p (deriv y x)) x := |
| 61 | (e.symmL ℝ p).hasFDerivAt.comp_hasDerivAt x hy.hasDerivAt |
| 62 | have hw : HasDerivAt w (e.symmL ℝ p (deriv z x)) x := |
| 63 | (e.symmL ℝ p).hasFDerivAt.comp_hasDerivAt x hz.hasDerivAt |
| 64 | have hvx : v x = Y x := by |
| 65 | change e.symmL ℝ p (e ⟨p, Y x⟩).2 = Y x |
| 66 | rw [← e.continuousLinearMapAt_apply_of_mem ℝ hp] |
| 67 | exact e.symmL_continuousLinearMapAt hp _ |
| 68 | have hwx : w x = Z x := by |
| 69 | change e.symmL ℝ p (e ⟨p, Z x⟩).2 = Z x |
| 70 | rw [← e.continuousLinearMapAt_apply_of_mem ℝ hp] |
| 71 | exact e.symmL_continuousLinearMapAt hp _ |
| 72 | let G := frameMetricForm g p |
| 73 | have hG : MDifferentiableAt (𝓡 n) |
| 74 | (𝓘(ℝ, TangentSpace (𝓡 n) p →L[ℝ] TangentSpace (𝓡 n) p →L[ℝ] ℝ)) G p := |
| 75 | ((frameMetricForm_smooth g p).contMDiffAt (e.open_baseSet.mem_nhds hp)).mdifferentiableAt |
| 76 | (by simp) |
| 77 | have hGcurve : HasDerivAt (fun s ↦ G (γ s)) |
| 78 | (mvfderiv (𝓡 n) G p (curveVelocity γ x)) x := by |
| 79 | exact (hG.hasMFDerivAt.comp x hγ.hasMFDerivAt).hasFDerivAt.hasDerivAt |
| 80 | have hpair := (hGcurve.clm_apply hv).clm_apply hw |
| 81 | have heval (a b : TangentSpace (𝓡 n) p) : |
| 82 | mvfderiv (𝓡 n) G p (curveVelocity γ x) a b = |
| 83 | g.inner p (frozenConnectionEndomorphism D p (curveVelocity γ x) a) b + |
| 84 | g.inner p a (frozenConnectionEndomorphism D p (curveVelocity γ x) b) := by |
| 85 | let L := (ContinuousLinearMap.apply ℝ ℝ b).comp |
| 86 | (ContinuousLinearMap.apply ℝ (TangentSpace (𝓡 n) p →L[ℝ] ℝ) a) |
| 87 | have h := L.hasMFDerivAt.comp p hG.hasMFDerivAt |
| 88 | have hvalue : mvfderiv (𝓡 n) (fun q ↦ G q a b) p (curveVelocity γ x) = |
| 89 | mvfderiv (𝓡 n) G p (curveVelocity γ x) a b := by |
| 90 | exact congrArg (fun A : TangentSpace (𝓡 n) p →L[ℝ] ℝ ↦ A (curveVelocity γ x)) |
| 91 | h.mfderiv |
| 92 | rw [← hvalue] |
| 93 | exact frameMetricForm_derivative D p (curveVelocity γ x) a b |
| 94 | have hnear : ∀ᶠ s in 𝓝 x, γ s ∈ e.baseSet := |
| 95 | hγ.continuousAt (e.open_baseSet.mem_nhds hp) |
| 96 | have hrep (s : ℝ) (hs : γ s ∈ e.baseSet) |
| 97 | (A : (r : ℝ) → TangentSpace (𝓡 n) (γ r)) : |
| 98 | extensionMap p (γ s) (e.symmL ℝ p (e ⟨γ s, A s⟩).2) = A s := by |
| 99 | change e.symmL ℝ (γ s) |
| 100 | (e.continuousLinearMapAt ℝ p (e.symmL ℝ p (e ⟨γ s, A s⟩).2)) = A s |
| 101 | rw [e.continuousLinearMapAt_symmL hp, |
| 102 | ← e.continuousLinearMapAt_apply_of_mem ℝ hs] |
| 103 | exact e.symmL_continuousLinearMapAt hs _ |
| 104 | have heq : (fun s ↦ g.inner (γ s) (Y s) (Z s)) =ᶠ[𝓝 x] |
| 105 | (fun s ↦ G (γ s) (v s) (w s)) := by |
| 106 | filter_upwards [hnear] with s hs |
| 107 | dsimp only [G, frameMetricForm_apply, v, w, y, z] |
| 108 | rw [hrep s hs Y, hrep s hs Z] |
| 109 | apply (hpair.congr_of_eventuallyEq heq).congr_deriv |
| 110 | simp only [hvx, hwx, add_apply, heval, G, p, |
| 111 | frameMetricForm_self, rampHorizontalCovariantDerivative, |
| 112 | frozenConnectionEndomorphism_apply, map_add] |
| 113 | ring |
| 114 | |
| 115 | end PoincareMT.M62 |