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 | /- Adapted from Mapher `PoincareMT/Proofs/M03/ConnectionMovingField.lean` at |
| 2 | f927d9e1f0810042766d3b5f64d3f4da02ee93cc. See |
| 3 | `references/ricci-flow/mapher/local-theory/port.json`. -/ |
| 4 | |
| 5 | import PoincareLib.Geometry.RicciFlow.Local.Energy.Coordinates.FamilyTangentTimeDerivative |
| 6 | import PoincareLib.Geometry.RicciFlow.Local.Energy.Comparison.ScalarMixedDerivative |
| 7 | import PoincareLib.Geometry.RicciFlow.Local.Metric.MetricPairRegularity |
| 8 | import PoincareLib.Geometry.RicciFlow.Local.Curvature.Evolution.CurvatureVectorTime |
| 9 | |
| 10 | /-! |
| 11 | # Differentiating a connection applied to a moving field |
| 12 | |
| 13 | Metric compatibility recovers joint regularity and reduces the product rule |
| 14 | to scalar mixed differentiation. Subtracting the frozen-time field makes the |
| 15 | metric-derivative terms vanish. This is a calculus prerequisite for the |
| 16 | curvature commutator in Kotschwar, arXiv:1206.3225v1, printed p. 4, (9)-(10). |
| 17 | -/ |
| 18 | |
| 19 | set_option autoImplicit false |
| 20 | set_option maxHeartbeats 2400000 |
| 21 | |
| 22 | open scoped Manifold ContDiff Bundle Topology |
| 23 | open Set |
| 24 | |
| 25 | universe u |
| 26 | |
| 27 | namespace PoincareMT.RicciFlow.Local |
| 28 | |
| 29 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 30 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 31 | |
| 32 | theorem hasDerivAt_ricciFlow_connection_moving_field |
| 33 | {J : Set ℝ} (F : RicciFlow n M J) |
| 34 | {t : ℝ} (ht : t ∈ interior J) |
| 35 | {U : Set M} (hU : IsOpen U) |
| 36 | (X : (x : M) → TangentSpace (𝓡 n) x) |
| 37 | (V : ℝ → (x : M) → TangentSpace (𝓡 n) x) |
| 38 | (hX : ContMDiffOn (𝓡 n) |
| 39 | ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% X) U) |
| 40 | (hV : ContMDiffOn (𝓘(ℝ, ℝ).prod (𝓡 n)) |
| 41 | ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ |
| 42 | (fun p : ℝ × M => Bundle.TotalSpace.mk' |
| 43 | (EuclideanSpace ℝ (Fin n)) p.2 (V p.1 p.2)) (J ×ˢ U)) |
| 44 | {x : M} (hx : x ∈ U) : |
| 45 | letI : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 46 | ⟨(F.metric 0).toRiemannianMetric⟩ |
| 47 | let dotV := fun y => deriv (fun s => V s y) t |
| 48 | let C := fun s => (F.connection s).connection (V s) x (X x) |
| 49 | let C0 := fun s => (F.connection s).connection (V t) x (X x) |
| 50 | HasDerivAt C |
| 51 | (deriv C0 t + (F.connection t).connection dotV x (X x)) t := by |
| 52 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 53 | ⟨(F.metric 0).toRiemannianMetric⟩ |
| 54 | let dotV := fun y => deriv (fun s => V s y) t |
| 55 | let C := fun s => (F.connection s).connection (V s) x (X x) |
| 56 | let C0 := fun s => (F.connection s).connection (V t) x (X x) |
| 57 | have htJ : J ∈ 𝓝 t := mem_interior_iff_mem_nhds.mp ht |
| 58 | have hVs (s : ℝ) (hs : s ∈ J) : ContMDiffOn (𝓡 n) |
| 59 | ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% (V s)) U := |
| 60 | hV.comp (contMDiffOn_const.prodMk contMDiffOn_id) (fun _ hy => ⟨hs, hy⟩) |
| 61 | have hpair {S : Set M} |
| 62 | (A B : (p : ℝ × M) → TangentSpace (𝓡 n) p.2) |
| 63 | (hA : ContMDiffOn (𝓘(ℝ, ℝ).prod (𝓡 n)) |
| 64 | ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ |
| 65 | (fun p => Bundle.TotalSpace.mk' (EuclideanSpace ℝ (Fin n)) p.2 (A p)) |
| 66 | (J ×ˢ S)) |
| 67 | (hB : ContMDiffOn (𝓘(ℝ, ℝ).prod (𝓡 n)) |
| 68 | ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ |
| 69 | (fun p => Bundle.TotalSpace.mk' (EuclideanSpace ℝ (Fin n)) p.2 (B p)) |
| 70 | (J ×ˢ S)) : |
| 71 | ContMDiffOn (𝓘(ℝ, ℝ).prod (𝓡 n)) 𝓘(ℝ, ℝ) ∞ |
| 72 | (fun p => (F.metric p.1).inner p.2 (A p) (B p)) (J ×ˢ S) := by |
| 73 | have hp := ContMDiffOn.clm_bundle_apply₂ |
| 74 | (F₁ := EuclideanSpace ℝ (Fin n)) (F₂ := EuclideanSpace ℝ (Fin n)) (F₃ := ℝ) |
| 75 | (E₁ := fun y : M => TangentSpace (𝓡 n) y) |
| 76 | (E₂ := fun y : M => TangentSpace (𝓡 n) y) (E₃ := fun _ : M => ℝ) |
| 77 | (ψ := fun p : ℝ × M => (F.metric p.1).inner p.2) (b := Prod.snd) |
| 78 | (F.smooth.mono (Set.prod_mono subset_rfl (subset_univ S))) hA hB |
| 79 | intro p hpS |
| 80 | exact (Bundle.contMDiffWithinAt_totalSpace.mp (hp p hpS)).2 |
| 81 | have hC : ContMDiffOn (𝓘(ℝ, ℝ).prod (𝓡 n)) |
| 82 | ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ |
| 83 | (fun p : ℝ × M => Bundle.TotalSpace.mk' (EuclideanSpace ℝ (Fin n)) p.2 |
| 84 | ((F.connection p.1).connection (V p.1) p.2 (X p.2))) (J ×ˢ U) := by |
| 85 | apply contMDiffOn_family_vector_of_metric_pair F.smooth hU |
| 86 | intro S hS hSU W hW |
| 87 | have hVS := hV.mono (Set.prod_mono subset_rfl hSU) |
| 88 | have hWS := hW.comp (I := 𝓘(ℝ, ℝ).prod (𝓡 n)) contMDiffOn_snd |
| 89 | (fun (p : ℝ × M) (hp : p ∈ J ×ˢ S) => hp.2) |
| 90 | have hAS := contMDiffOn_connection_family_apply F.smooth F.connection |
| 91 | hS W X hW (hX.mono hSU) |
| 92 | have hp := hpair _ _ hVS hWS |
| 93 | have hd := contMDiffOn_family_spatial_mvfderiv |
| 94 | (f := fun s y => (F.metric s).inner y (V s y) (W y)) hS hp X (hX.mono hSU) |
| 95 | apply (hd.sub (hpair _ _ hVS hAS)).congr |
| 96 | intro p hpS |
| 97 | have hVp := ((hVs p.1 hpS.1).contMDiffAt |
| 98 | (hU.mem_nhds (hSU hpS.2))).mdifferentiableAt (by simp) |
| 99 | have hWp := (hW.contMDiffAt (hS.mem_nhds hpS.2)).mdifferentiableAt (by simp) |
| 100 | rw [(F.connection p.1).localTheory_mvfderiv_inner X (V p.1) W hVp hWp] |
| 101 | ring |
| 102 | have hC0 := contMDiffOn_connection_family_apply F.smooth F.connection |
| 103 | hU (V t) X (hVs t (interior_subset ht)) hX |
| 104 | have hdot := family_tangent_time_derivative (F.metric 0) hU V hV ht |
| 105 | have hCd : HasDerivAt C (deriv C t) t := |
| 106 | (family_tangent_time_derivative (F.metric 0) hU |
| 107 | (fun s y => (F.connection s).connection (V s) y (X y)) hC ht).1 x hx |
| 108 | have hC0d : HasDerivAt C0 (deriv C0 t) t := |
| 109 | (family_tangent_time_derivative (F.metric 0) hU |
| 110 | (fun s y => (F.connection s).connection (V t) y (X y)) hC0 ht).1 x hx |
| 111 | have htest (z : TangentSpace (𝓡 n) x) : |
| 112 | (F.metric t).inner x (deriv C t - deriv C0 t) z = |
| 113 | (F.metric t).inner x ((F.connection t).connection dotV x (X x)) z := by |
| 114 | obtain ⟨Sz, hSz, hz⟩ := FiberBundle.exists_contMDiffOn_extend |
| 115 | (k := ∞) (𝓡 n) (EuclideanSpace ℝ (Fin n)) z |
| 116 | obtain ⟨S, hSsub, hS, hxS⟩ := mem_nhds_iff.mp |
| 117 | (Filter.inter_mem (hU.mem_nhds hx) hSz) |
| 118 | have hSU : S ⊆ U := fun _ hy => (hSsub hy).1 |
| 119 | let W := FiberBundle.extend (EuclideanSpace ℝ (Fin n)) z |
| 120 | have hW : ContMDiffOn (𝓡 n) |
| 121 | ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% W) S := |
| 122 | hz.mono (fun _ hy => (hSsub hy).2) |
| 123 | have hWx : W x = z := FiberBundle.extend_apply_self (EuclideanSpace ℝ (Fin n)) z |
| 124 | let L := fun s y => V s y - V t y |
| 125 | let A := fun s y => (F.connection s).connection W y (X y) |
| 126 | let f := fun s y => (F.metric s).inner y (L s y) (W y) |
| 127 | have hVS := hV.mono (Set.prod_mono subset_rfl hSU) |
| 128 | have hVtS := ((hVs t (interior_subset ht)).mono hSU).comp |
| 129 | (I := 𝓘(ℝ, ℝ).prod (𝓡 n)) contMDiffOn_snd |
| 130 | (fun (p : ℝ × M) (hp : p ∈ J ×ˢ S) => hp.2) |
| 131 | have hWS := hW.comp (I := 𝓘(ℝ, ℝ).prod (𝓡 n)) contMDiffOn_snd |
| 132 | (fun (p : ℝ × M) (hp : p ∈ J ×ˢ S) => hp.2) |
| 133 | have hp := hpair _ _ hVS hWS |
| 134 | have hp0 := hpair _ _ hVtS hWS |
| 135 | have hf : ContMDiffOn (𝓘(ℝ, ℝ).prod (𝓡 n)) 𝓘(ℝ, ℝ) ∞ |
| 136 | (Function.uncurry f) (J ×ˢ S) := by |
| 137 | apply (hp.sub hp0).congr |
| 138 | intro p _hp |
| 139 | change (F.metric p.1).inner p.2 (V p.1 p.2 - V t p.2) (W p.2) = _ |
| 140 | rw [map_sub ((F.metric p.1).inner p.2), sub_apply] |
| 141 | have hAd := (family_tangent_time_derivative (F.metric 0) hS A |
| 142 | (contMDiffOn_connection_family_apply F.smooth F.connection |
| 143 | hS W X hW (hX.mono hSU)) ht).1 x hxS |
| 144 | have hfderiv (y : M) (hy : y ∈ S) : |
| 145 | HasDerivAt (fun s => f s y) ((F.metric t).inner y (dotV y) (W y)) t := by |
| 146 | let : NormedAddCommGroup (TangentSpace (𝓡 n) y →L[ℝ] ℝ) := inferInstance |
| 147 | let : NormedSpace ℝ (TangentSpace (𝓡 n) y →L[ℝ] ℝ) := inferInstance |
| 148 | let G := fun s => (F.metric s).inner y |
| 149 | have hG : HasDerivAt G (deriv G t) t := |
| 150 | (((contDiffOn_family_metric_inner_time F.smooth y).contDiffAt htJ).differentiableAt |
| 151 | (by simp)).hasDerivAt |
| 152 | have hL := (hdot.1 y (hSU hy)).sub (hasDerivAt_const t (V t y)) |
| 153 | have hd := (hG.clm_apply hL).clm_apply (hasDerivAt_const t (W y)) |
| 154 | simpa only [f, L, G, dotV, Pi.sub_apply, sub_self, sub_zero, map_zero, add_zero, zero_add, |
| 155 | add_apply, zero_apply] using hd |
| 156 | have hspaceEq : (fun y => deriv (fun s => f s y) t) =ᶠ[𝓝 x] |
| 157 | (fun y => (F.metric t).inner y (dotV y) (W y)) := by |
| 158 | filter_upwards [hS.mem_nhds hxS] with y hy |
| 159 | exact (hfderiv y hy).deriv |
| 160 | have hdf := hasDerivAt_family_spatial_mvfderiv hS hf ht hxS (X x) |
| 161 | have hderivEq : |
| 162 | mvfderiv (𝓡 n) (fun y => deriv (fun s => f s y) t) x (X x) = |
| 163 | mvfderiv (𝓡 n) (fun y => (F.metric t).inner y (dotV y) (W y)) x (X x) := by |
| 164 | simp only [mvfderiv, hspaceEq.mfderiv_eq] |
| 165 | rw [(hfderiv x hxS).deriv] |
| 166 | rfl |
| 167 | rw [hderivEq] at hdf |
| 168 | have hdotx := (hdot.2.contMDiffAt (hU.mem_nhds hx)).mdifferentiableAt (by simp) |
| 169 | have hWx' := (hW.contMDiffAt (hS.mem_nhds hxS)).mdifferentiableAt (by simp) |
| 170 | rw [(F.connection t).localTheory_mvfderiv_inner X dotV W hdotx hWx'] at hdf |
| 171 | let : NormedAddCommGroup (TangentSpace (𝓡 n) x →L[ℝ] ℝ) := inferInstance |
| 172 | let : NormedSpace ℝ (TangentSpace (𝓡 n) x →L[ℝ] ℝ) := inferInstance |
| 173 | let G := fun s => (F.metric s).inner x |
| 174 | have hG : HasDerivAt G (deriv G t) t := |
| 175 | (((contDiffOn_family_metric_inner_time F.smooth x).contDiffAt htJ).differentiableAt |
| 176 | (by simp)).hasDerivAt |
| 177 | have hL := (hdot.1 x hx).sub (hasDerivAt_const t (V t x)) |
| 178 | have hq : HasDerivAt (fun s => G s (L s x) (A s x)) |
| 179 | (G t (dotV x) (A t x)) t := by |
| 180 | have hd := (hG.clm_apply hL).clm_apply hAd |
| 181 | simpa only [L, dotV, Pi.sub_apply, sub_self, sub_zero, map_zero, add_zero, zero_add, |
| 182 | add_apply, zero_apply] using hd |
| 183 | have hzero : C t - C0 t = 0 := sub_self _ |
| 184 | have hleft : HasDerivAt (fun s => G s (C s - C0 s) (W x)) |
| 185 | (G t (deriv C t - deriv C0 t) (W x)) t := by |
| 186 | have hd := (hG.clm_apply (hCd.sub hC0d)).clm_apply (hasDerivAt_const t (W x)) |
| 187 | simpa only [Pi.sub_apply, hzero, map_zero, add_zero, zero_add, add_apply, zero_apply] using hd |
| 188 | have heq : (fun s => G s (C s - C0 s) (W x)) =ᶠ[𝓝 t] |
| 189 | (fun s => mvfderiv (𝓡 n) (f s) x (X x) - G s (L s x) (A s x)) := by |
| 190 | filter_upwards [htJ] with s hs |
| 191 | have hsp := hp.comp (contMDiffOn_const.prodMk contMDiffOn_id) |
| 192 | (fun _ hy => ⟨hs, hy⟩) |
| 193 | have hsp0 := hp0.comp (contMDiffOn_const.prodMk contMDiffOn_id) |
| 194 | (fun _ hy => ⟨hs, hy⟩) |
| 195 | have hspx := (hsp.contMDiffAt (hS.mem_nhds hxS)).mdifferentiableAt (by simp) |
| 196 | have hsp0x := (hsp0.contMDiffAt (hS.mem_nhds hxS)).mdifferentiableAt (by simp) |
| 197 | dsimp only [Function.comp_def, id_eq] at hspx hsp0x |
| 198 | have hVx := ((hVs s hs).contMDiffAt (hU.mem_nhds hx)).mdifferentiableAt (by simp) |
| 199 | have hVtx := ((hVs t (interior_subset ht)).contMDiffAt |
| 200 | (hU.mem_nhds hx)).mdifferentiableAt (by simp) |
| 201 | have hfeq : f s = fun y => (F.metric s).inner y (V s y) (W y) - |
| 202 | (F.metric s).inner y (V t y) (W y) := by |
| 203 | funext y |
| 204 | simp only [f, L, map_sub, sub_apply] |
| 205 | rw [hfeq, mvfderiv_fun_sub hspx hsp0x, sub_apply, |
| 206 | (F.connection s).localTheory_mvfderiv_inner X (V s) W hVx hWx', |
| 207 | (F.connection s).localTheory_mvfderiv_inner X (V t) W hVtx hWx'] |
| 208 | dsimp only [G, C, C0, L, A] |
| 209 | simp only [map_sub, sub_apply] |
| 210 | ring |
| 211 | have hh := hleft.unique ((hdf.sub hq).congr_of_eventuallyEq heq) |
| 212 | dsimp only [G, A] at hh |
| 213 | rw [hWx] at hh |
| 214 | linarith only [hh] |
| 215 | have heq : deriv C t - deriv C0 t = |
| 216 | (F.connection t).connection dotV x (X x) := by |
| 217 | apply sub_eq_zero.mp |
| 218 | by_contra hne |
| 219 | have hz := htest (deriv C t - deriv C0 t - |
| 220 | (F.connection t).connection dotV x (X x)) |
| 221 | have hzero : (F.metric t).inner x |
| 222 | (deriv C t - deriv C0 t - (F.connection t).connection dotV x (X x)) |
| 223 | (deriv C t - deriv C0 t - (F.connection t).connection dotV x (X x)) = 0 := by |
| 224 | rw [map_sub ((F.metric t).inner x), sub_apply, hz, sub_self] |
| 225 | exact ((F.metric t).pos x _ hne).ne' hzero |
| 226 | apply hCd.congr_deriv |
| 227 | exact (sub_eq_iff_eq_add.mp heq).trans (add_comm _ _) |
| 228 | |
| 229 | end PoincareMT.RicciFlow.Local |