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.Analysis.C1.MixedDerivative |
| 3 | import PoincareLib.Geometry.CurveShortening.Ramp.LocalFlow.C1.ChartPullback |
| 4 | import Mathlib.Analysis.Calculus.ContDiff.Deriv |
| 5 | |
| 6 | /-! |
| 7 | # Covariant commutation with a C1 time velocity |
| 8 | |
| 9 | The actual time equation supplies the mixed derivative needed for |
| 10 | torsion cancellation and time differentiation of the spatial velocity. |
| 11 | MT2007 Claim 19.1, p. 437, and Lemma 19.6, pp. 441-442; |
| 12 | `2026-09-22-fixed-label-c2-speed-evolution.md`, statement 2. |
| 13 | -/ |
| 14 | |
| 15 | set_option autoImplicit false |
| 16 | set_option backward.isDefEq.respectTransparency false |
| 17 | |
| 18 | open Set Filter |
| 19 | open scoped Manifold ContDiff Bundle Topology |
| 20 | |
| 21 | universe u |
| 22 | |
| 23 | namespace PoincareMT.M63 |
| 24 | |
| 25 | open Proofs.M09 |
| 26 | |
| 27 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 28 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 29 | |
| 30 | local notation "E" => EuclideanSpace ℝ (Fin n) |
| 31 | |
| 32 | /-- A C1 actual time velocity gives a genuine time derivative of the |
| 33 | spatial velocity and the selected connection's torsion identity. |
| 34 | MT2007 Lemma 19.6, pp. 441-442; fixed-label C2 speed evolution, |
| 35 | statement 2. Joint C2 regularity is not assumed. -/ |
| 36 | theorem pullback_velocity_commute_of_time_velocity_c1 |
| 37 | {g : RiemannianMetric n M} (D : LeviCivitaData g) (c : ℝ → ℝ → M) |
| 38 | {Omega : Set (ℝ × ℝ)} (hOmega : IsOpen Omega) |
| 39 | (hc : ContMDiffOn 𝓘(ℝ, ℝ × ℝ) (𝓡 n) 1 |
| 40 | (fun z : ℝ × ℝ => c z.1 z.2) Omega) |
| 41 | (hT : ContMDiffOn 𝓘(ℝ, ℝ × ℝ) ((𝓡 n).prod (𝓡 n)) 1 |
| 42 | (fun z : ℝ × ℝ => (⟨c z.1 z.2, |
| 43 | curveVelocity (fun s => c z.1 s) z.2⟩ : TangentBundle (𝓡 n) M)) Omega) |
| 44 | {x t : ℝ} (hxt : (x, t) ∈ Omega) : |
| 45 | MDifferentiableAt 𝓘(ℝ, ℝ) ((𝓡 n).prod (𝓡 n)) |
| 46 | (fun s => (⟨c x s, curveVelocity (fun y => c y s) x⟩ : |
| 47 | TangentBundle (𝓡 n) M)) t ∧ |
| 48 | rampHorizontalCovariantDerivative D (fun s => c x s) |
| 49 | (fun s => curveVelocity (fun y => c y s) x) t = |
| 50 | rampHorizontalCovariantDerivative D (fun y => c y t) |
| 51 | (fun y => curveVelocity (fun s => c y s) t) x := by |
| 52 | let p := c x t |
| 53 | let e := chartAt E p |
| 54 | let U := Omega ∩ (fun z : ℝ × ℝ => c z.1 z.2) ⁻¹' e.source |
| 55 | have hU : IsOpen U := hc.continuousOn.isOpen_inter_preimage hOmega e.open_source |
| 56 | have hbase : c x t ∈ e.source := mem_chart_source E p |
| 57 | have hz : (x, t) ∈ U := ⟨hxt, hbase⟩ |
| 58 | let q : ℝ × ℝ → E := fun z => e (c z.1 z.2) |
| 59 | let R : ℝ × ℝ → E := fun z => |
| 60 | mfderiv (𝓡 n) (𝓡 n) e (c z.1 z.2) (curveVelocity (fun s => c z.1 s) z.2) |
| 61 | have hq : ContDiffOn ℝ 1 q U := |
| 62 | (contMDiffOn_chart.comp (hc.mono inter_subset_left) (fun z hz => hz.2)).contDiffOn |
| 63 | have hchart : ContMDiffOn (𝓡 n) (𝓡 n) 2 e e.source := contMDiffOn_chart |
| 64 | have hpush := (hchart.contMDiffOn_tangentMapWithin (m := 1) (by norm_num) |
| 65 | e.open_source.uniqueMDiffOn).comp (hT.mono inter_subset_left) (fun z hz => hz.2) |
| 66 | have hR : ContDiffOn ℝ 1 R U := by |
| 67 | have h := ((contMDiff_snd_tangentBundle_modelSpace (n := 1) E (𝓡 n)).comp_contMDiffOn |
| 68 | hpush).contDiffOn |
| 69 | apply h.congr |
| 70 | intro z hz |
| 71 | change mfderiv (𝓡 n) (𝓡 n) e (c z.1 z.2) |
| 72 | (curveVelocity (fun s => c z.1 s) z.2) = |
| 73 | mfderivWithin (𝓡 n) (𝓡 n) e e.source (c z.1 z.2) |
| 74 | (curveVelocity (fun s => c z.1 s) z.2) |
| 75 | rw [mfderivWithin_of_isOpen e.open_source hz.2] |
| 76 | have hcAt (z : ℝ × ℝ) (hz : z ∈ U) : |
| 77 | MDifferentiableAt 𝓘(ℝ, ℝ × ℝ) (𝓡 n) |
| 78 | (fun z : ℝ × ℝ => c z.1 z.2) z := |
| 79 | (hc.contMDiffAt (hOmega.mem_nhds hz.1)).mdifferentiableAt (by norm_num) |
| 80 | have hfst (z : ℝ × ℝ) : MDifferentiableAt 𝓘(ℝ, ℝ) 𝓘(ℝ, ℝ × ℝ) |
| 81 | (fun y : ℝ => (y, z.2)) z.1 := |
| 82 | (differentiableAt_id.prodMk (differentiableAt_const z.2)).mdifferentiableAt |
| 83 | have hsnd (z : ℝ × ℝ) : MDifferentiableAt 𝓘(ℝ, ℝ) 𝓘(ℝ, ℝ × ℝ) |
| 84 | (fun s : ℝ => (z.1, s)) z.2 := |
| 85 | ((differentiableAt_const z.1).prodMk differentiableAt_id).mdifferentiableAt |
| 86 | have htime (z : ℝ × ℝ) (hz : z ∈ U) : |
| 87 | HasDerivAt (fun s => q (z.1, s)) (R z) z.2 := |
| 88 | hasDerivAt_chart_curve p (fun s => c z.1 s) z.2 hz.2 |
| 89 | (by simpa only [Function.comp_def] using (hcAt z hz).comp z.2 (hsnd z)) |
| 90 | have hspace (z : ℝ × ℝ) (hz : z ∈ U) : |
| 91 | DifferentiableAt ℝ (fun y => q (y, z.2)) z.1 := by |
| 92 | have hdq : DifferentiableAt ℝ q z := |
| 93 | (hq.contDiffAt (hU.mem_nhds hz)).differentiableAt (by norm_num) |
| 94 | have hline : DifferentiableAt ℝ (fun y : ℝ => (y, z.2)) z.1 := |
| 95 | differentiableAt_id.prodMk (differentiableAt_const z.2) |
| 96 | exact hdq.comp z.1 (g := q) (f := fun y : ℝ => (y, z.2)) hline |
| 97 | have hX (z : ℝ × ℝ) (hz : z ∈ U) : |
| 98 | chartVectorField p (deriv (fun y => q (y, z.2)) z.1) (c z.1 z.2) = |
| 99 | curveVelocity (fun y => c y z.2) z.1 := |
| 100 | chartVectorField_coordinate_velocity p (fun y => c y z.2) z.1 _ hz.2 |
| 101 | (by simpa only [Function.comp_def] using (hcAt z hz).comp z.1 (hfst z)) |
| 102 | (hspace z hz).hasDerivAt |
| 103 | have hY (z : ℝ × ℝ) (hz : z ∈ U) : |
| 104 | chartVectorField p (R z) (c z.1 z.2) = curveVelocity (fun s => c z.1 s) z.2 := |
| 105 | chartVectorField_coordinate_velocity p (fun s => c z.1 s) z.2 _ hz.2 |
| 106 | (by simpa only [Function.comp_def] using (hcAt z hz).comp z.2 (hsnd z)) (htime z hz) |
| 107 | let V : Set ℝ := (fun s : ℝ => (x, s)) ⁻¹' U |
| 108 | let W : Set ℝ := (fun y : ℝ => (y, t)) ⁻¹' U |
| 109 | have hV : IsOpen V := hU.preimage (continuous_const.prodMk continuous_id) |
| 110 | have hW : IsOpen W := hU.preimage (continuous_id.prodMk continuous_const) |
| 111 | let v : ℝ → E := fun s => deriv (fun y => q (y, s)) x |
| 112 | let w : ℝ → E := fun y => R (y, t) |
| 113 | have hdv (s : ℝ) (hs : s ∈ V) : HasDerivAt v (fderiv ℝ R (x, s) (1, 0)) s := |
| 114 | hasDerivAt_spatialDeriv_of_time_equation hU hq hR htime hs |
| 115 | have hv : ContDiffOn ℝ 1 v V := by |
| 116 | apply (contDiffOn_succ_iff_deriv_of_isOpen (n := 0) hV).mpr |
| 117 | refine ⟨fun s hs => (hdv s hs).differentiableAt.differentiableWithinAt, by simp, ?_⟩ |
| 118 | apply contDiffOn_zero.mpr |
| 119 | have hRx : ContinuousOn (fun z : ℝ × ℝ => fderiv ℝ R z (1, 0)) U := |
| 120 | ((hR.fderiv_of_isOpen hU (m := 0) (by norm_num)).clm_apply |
| 121 | (contDiffOn_const (c := ((1 : ℝ), (0 : ℝ))))).continuousOn |
| 122 | have hcont := hRx.comp (s := V) (f := fun s : ℝ => (x, s)) |
| 123 | (continuous_const.prodMk continuous_id).continuousOn (fun _ hs => hs) |
| 124 | exact hcont.congr (fun s hs => (hdv s hs).deriv) |
| 125 | have hw : ContDiffOn ℝ 1 w W := |
| 126 | hR.comp (contDiffOn_id.prodMk contDiffOn_const) (fun _ hy => hy) |
| 127 | have hcTime : ContMDiffOn 𝓘(ℝ, ℝ) (𝓡 n) 1 (fun s => c x s) V := |
| 128 | (hc.mono inter_subset_left).comp |
| 129 | (contDiff_const.prodMk contDiff_id).contMDiff.contMDiffOn (fun _ hs => hs) |
| 130 | have hXtime : ContMDiffOn 𝓘(ℝ, ℝ) ((𝓡 n).prod (𝓡 n)) 1 |
| 131 | (fun s => (⟨c x s, curveVelocity (fun y => c y s) x⟩ : |
| 132 | TangentBundle (𝓡 n) M)) V := by |
| 133 | have h := (chartVectorField_param_contMDiff_one p v V hv).comp |
| 134 | (contMDiffOn_id.prodMk hcTime) (fun s hs => ⟨hs, hs.2⟩) |
| 135 | apply h.congr |
| 136 | intro s hs |
| 137 | exact congrArg (Bundle.TotalSpace.mk' E (c x s)) (hX (x, s) hs).symm |
| 138 | refine ⟨(hXtime.contMDiffAt (hV.mem_nhds hz)).mdifferentiableAt (by norm_num), ?_⟩ |
| 139 | have hleft : rampHorizontalCovariantDerivative D (fun s => c x s) |
| 140 | (fun s => curveVelocity (fun y => c y s) x) t = |
| 141 | chartVectorField p (deriv v t) (c x t) + |
| 142 | D.connection (chartVectorField p (v t)) (c x t) (curveVelocity (fun s => c x s) t) := by |
| 143 | calc |
| 144 | _ = rampHorizontalCovariantDerivative D (fun s => c x s) |
| 145 | (fun s => chartVectorField p (v s) (c x s)) t := |
| 146 | M62.pullback_congr D (γ := fun s => c x s) |
| 147 | (Y := fun s => curveVelocity (fun y => c y s) x) |
| 148 | (Z := fun s => chartVectorField p (v s) (c x s)) (by |
| 149 | filter_upwards [hV.mem_nhds hz] with s hs |
| 150 | exact (hX (x, s) hs).symm) |
| 151 | _ = _ := pullback_chart_field_of_contDiff_one D p (gamma := fun s => c x s) (x := t) |
| 152 | (by simpa only [Function.comp_def] using (hcAt (x, t) hz).comp t (hsnd (x, t))) |
| 153 | hbase hV hz v hv |
| 154 | have hright : rampHorizontalCovariantDerivative D (fun y => c y t) |
| 155 | (fun y => curveVelocity (fun s => c y s) t) x = |
| 156 | chartVectorField p (deriv w x) (c x t) + |
| 157 | D.connection (chartVectorField p (w x)) (c x t) (curveVelocity (fun y => c y t) x) := by |
| 158 | calc |
| 159 | _ = rampHorizontalCovariantDerivative D (fun y => c y t) |
| 160 | (fun y => chartVectorField p (w y) (c y t)) x := |
| 161 | M62.pullback_congr D (γ := fun y => c y t) |
| 162 | (Y := fun y => curveVelocity (fun s => c y s) t) |
| 163 | (Z := fun y => chartVectorField p (w y) (c y t)) (by |
| 164 | filter_upwards [hW.mem_nhds hz] with y hy |
| 165 | exact (hY (y, t) hy).symm) |
| 166 | _ = _ := pullback_chart_field_of_contDiff_one D p (gamma := fun y => c y t) (x := x) |
| 167 | (by simpa only [Function.comp_def] using (hcAt (x, t) hz).comp x (hfst (x, t))) |
| 168 | hbase hW hz w hw |
| 169 | have hdw : HasDerivAt w (fderiv ℝ R (x, t) (1, 0)) x := by |
| 170 | have hdR : DifferentiableAt ℝ R (x, t) := |
| 171 | (hR.contDiffAt (hU.mem_nhds hz)).differentiableAt (by norm_num) |
| 172 | exact M08.coordinateSlice_fst_hasDerivAt R hdR |
| 173 | have hfield (z : E) := |
| 174 | ((chartVectorField_smooth p z).contMDiffAt (e.open_source.mem_nhds hbase)).mdifferentiableAt |
| 175 | (by simp) |
| 176 | have htor := D.connection.torsion_eq_zero_iff.mp D.torsion_eq_zero |
| 177 | (hfield (w x)) (hfield (v t)) |
| 178 | rw [chartVectorField_bracket p (w x) (v t) (c x t) hbase] at htor |
| 179 | have hconn := sub_eq_zero.mp htor |
| 180 | rw [hleft, hright, (hdv t hz).deriv, hdw.deriv, ← hY (x, t) hz, ← hX (x, t) hz] |
| 181 | exact congrArg (_ + ·) hconn |
| 182 | |
| 183 | end PoincareMT.M63 |