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.Riemannian.Connection |
| 2 | import Mathlib.Analysis.Calculus.FDeriv.Symmetric |
| 3 | import Mathlib.Geometry.Manifold.ContMDiff.Atlas |
| 4 | import Mathlib.Tactic |
| 5 | |
| 6 | /-! Adapted from Mapher06/Poincare-MorganTian, `PoincareMT/Proofs/M04/MixedTimeSpatial.lean`, |
| 7 | revision `f927d9e1f0810042766d3b5f64d3f4da02ee93cc`. See the curvature import record under |
| 8 | `references/ricci-flow/mapher/curvature/`. -/ |
| 9 | |
| 10 | /-! |
| 11 | # Mixed differentiation in a fixed manifold chart |
| 12 | |
| 13 | The time/spatial interchange used in Topping's connection variation formula |
| 14 | is Schwarz symmetry in the chart based at the supplied tangent fiber. |
| 15 | -/ |
| 16 | |
| 17 | set_option autoImplicit false |
| 18 | |
| 19 | open scoped Manifold ContDiff Bundle |
| 20 | open Set Topology Filter |
| 21 | |
| 22 | universe u |
| 23 | |
| 24 | namespace PoincareMT.RicciFlowAnalysis |
| 25 | |
| 26 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 27 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 28 | |
| 29 | set_option maxHeartbeats 1000000 in |
| 30 | -- The chartwise interchange of time and spatial derivatives needs extra elaboration. |
| 31 | set_option backward.isDefEq.respectTransparency false in |
| 32 | theorem hasDerivAt_mvfderiv_time |
| 33 | {J : Set ℝ} {U : Set M} {f : ℝ × M → ℝ} {h : M → ℝ} {t : ℝ} {x : M} |
| 34 | (hU : IsOpen U) |
| 35 | (hf : ContMDiffOn (𝓘(ℝ, ℝ).prod (𝓡 n)) 𝓘(ℝ, ℝ) ∞ f (J ×ˢ U)) |
| 36 | (ht : t ∈ interior J) (hx : x ∈ U) |
| 37 | (htime : ∀ y ∈ U, HasDerivAt (fun s ↦ f (s, y)) (h y) t) |
| 38 | (v : TangentSpace (𝓡 n) x) : |
| 39 | HasDerivAt (fun s ↦ mvfderiv (𝓡 n) (fun y ↦ f (s, y)) x v) |
| 40 | (mvfderiv (𝓡 n) h x v) t := by |
| 41 | let E := EuclideanSpace ℝ (Fin n) |
| 42 | let e := extChartAt (𝓡 n) x |
| 43 | let z := e x |
| 44 | have hex : e.symm z = x := e.left_inv (mem_extChartAt_source x) |
| 45 | have heU : e.symm ⁻¹' U ∈ 𝓝 z := by |
| 46 | apply (continuousAt_extChartAt_symm x).preimage_mem_nhds |
| 47 | change U ∈ 𝓝 (e.symm z) |
| 48 | rw [hex] |
| 49 | exact hU.mem_nhds hx |
| 50 | obtain ⟨W, hWsub, hW, hzW⟩ := mem_nhds_iff.mp |
| 51 | (inter_mem (extChartAt_target_mem_nhds (I := 𝓡 n) x) heU) |
| 52 | let S := interior J ×ˢ W |
| 53 | have hS : IsOpen S := isOpen_interior.prod hW |
| 54 | have heSmooth : ContMDiffOn 𝓘(ℝ, E) (𝓡 n) ∞ e.symm W := |
| 55 | (contMDiffOn_extChartAt_symm x).mono fun _ hq ↦ (hWsub hq).1 |
| 56 | let G : ℝ × E → ℝ := fun p ↦ f (p.1, e.symm p.2) |
| 57 | let k : E → ℝ := fun q ↦ h (e.symm q) |
| 58 | have hmap : ContMDiffOn (𝓘(ℝ, ℝ).prod 𝓘(ℝ, E)) |
| 59 | (𝓘(ℝ, ℝ).prod (𝓡 n)) ∞ (fun p : ℝ × E ↦ (p.1, e.symm p.2)) S := |
| 60 | contMDiffOn_fst.prodMk (heSmooth.comp contMDiffOn_snd (fun _ hp ↦ hp.2)) |
| 61 | have hGm := hf.comp hmap |
| 62 | (show MapsTo (fun p : ℝ × E ↦ (p.1, e.symm p.2)) S (J ×ˢ U) from |
| 63 | fun _ hp ↦ ⟨interior_subset hp.1, (hWsub hp.2).2⟩) |
| 64 | have hG : ContDiffOn ℝ ∞ G S := by |
| 65 | rw [← contMDiffOn_iff_contDiffOn] |
| 66 | rw [modelWithCornersSelf_prod, ← chartedSpaceSelf_prod] |
| 67 | exact hGm |
| 68 | have hG2 (s : ℝ) (q : E) (hs : s ∈ interior J) (hq : q ∈ W) : |
| 69 | ContDiffAt ℝ 2 G (s, q) := |
| 70 | (contDiffOn_infty.mp hG 2).contDiffAt (hS.mem_nhds ⟨hs, hq⟩) |
| 71 | have hD : HasFDerivAt (fderiv ℝ G) (fderiv ℝ (fderiv ℝ G) (t, z)) (t, z) := |
| 72 | (((hG2 t z ht hzW).fderiv_right (m := 1) (by norm_num)).differentiableAt |
| 73 | (by norm_num)).hasFDerivAt |
| 74 | have hkeq : k =ᶠ[𝓝 z] fun q ↦ fderiv ℝ G (t, q) ((1 : ℝ), (0 : E)) := by |
| 75 | filter_upwards [hW.mem_nhds hzW] with q hq |
| 76 | have hline : HasDerivAt (fun s : ℝ ↦ (s, q)) ((1 : ℝ), (0 : E)) t := |
| 77 | (hasDerivAt_id t).prodMk (hasDerivAt_const t q) |
| 78 | have hjoint := ((hG2 t q ht hq).differentiableAt (by norm_num)).hasFDerivAt |
| 79 | have hd : HasDerivAt (fun s ↦ G (s, q)) |
| 80 | (fderiv ℝ G (t, q) ((1 : ℝ), (0 : E))) t := by |
| 81 | simpa only [Function.comp_apply] using! hjoint.comp_hasDerivAt t hline |
| 82 | exact (htime (e.symm q) (hWsub hq).2).unique hd |
| 83 | have hspace : HasFDerivAt (fun q : E ↦ (t, q)) |
| 84 | ((0 : E →L[ℝ] ℝ).prod (ContinuousLinearMap.id ℝ E)) z := |
| 85 | (hasFDerivAt_const t z).prodMk (hasFDerivAt_id z) |
| 86 | have hkJoint := (hD.comp z hspace).clm_apply |
| 87 | (hasFDerivAt_const ((1 : ℝ), (0 : E)) z) |
| 88 | have hk : DifferentiableAt ℝ k z := |
| 89 | hkJoint.differentiableAt.congr_of_eventuallyEq hkeq |
| 90 | have hkval : fderiv ℝ k z v = |
| 91 | fderiv ℝ (fderiv ℝ G) (t, z) ((0 : ℝ), v) ((1 : ℝ), (0 : E)) := by |
| 92 | rw [hkeq.fderiv_eq] |
| 93 | have heq := congrArg (fun L : E →L[ℝ] ℝ ↦ L v) hkJoint.fderiv |
| 94 | simpa only [Function.comp_apply, add_apply, ContinuousLinearMap.comp_apply, |
| 95 | ContinuousLinearMap.flip_apply, ContinuousLinearMap.prod_apply, zero_apply, |
| 96 | ContinuousLinearMap.id_apply, zero_add, map_zero] using! heq |
| 97 | have hline : HasDerivAt (fun s : ℝ ↦ (s, z)) ((1 : ℝ), (0 : E)) t := |
| 98 | (hasDerivAt_id t).prodMk (hasDerivAt_const t z) |
| 99 | have hdJoint := (hD.comp_hasDerivAt t hline).clm_apply |
| 100 | (hasDerivAt_const t (((0 : ℝ), v) : ℝ × E)) |
| 101 | have hdTime : HasDerivAt (fun s ↦ fderiv ℝ G (s, z) ((0 : ℝ), v)) |
| 102 | (fderiv ℝ k z v) t := by |
| 103 | have hsym := ((hG2 t z ht hzW).isSymmSndFDerivAt (by norm_num)).eq |
| 104 | ((1 : ℝ), (0 : E)) ((0 : ℝ), v) |
| 105 | apply hdJoint.congr_deriv |
| 106 | simpa only [map_zero, add_zero, hkval] using hsym |
| 107 | have hsliceEq : (fun s ↦ fderiv ℝ (fun q : E ↦ G (s, q)) z v) =ᶠ[𝓝 t] |
| 108 | (fun s ↦ fderiv ℝ G (s, z) ((0 : ℝ), v)) := by |
| 109 | filter_upwards [isOpen_interior.mem_nhds ht] with s hs |
| 110 | have hembed : HasFDerivAt (fun q : E ↦ (s, q)) |
| 111 | ((0 : E →L[ℝ] ℝ).prod (ContinuousLinearMap.id ℝ E)) z := |
| 112 | (hasFDerivAt_const s z).prodMk (hasFDerivAt_id z) |
| 113 | have hcomp := ((hG2 s z hs hzW).differentiableAt (by norm_num)).hasFDerivAt.comp z hembed |
| 114 | have heq := congrArg (fun L : E →L[ℝ] ℝ ↦ L v) hcomp.fderiv |
| 115 | simpa only [Function.comp_apply, ContinuousLinearMap.comp_apply, |
| 116 | ContinuousLinearMap.prod_apply, zero_apply, |
| 117 | ContinuousLinearMap.id_apply] using! heq |
| 118 | have hdSlice := hdTime.congr_of_eventuallyEq hsliceEq |
| 119 | let : IsManifold (𝓡 n) 1 M := IsManifold.of_le (n := ∞) |
| 120 | (WithTop.coe_le_coe.mpr (show (1 : ℕ∞) ≤ (⊤ : ℕ∞) from le_top)) |
| 121 | have hh : MDifferentiableAt (𝓡 n) 𝓘(ℝ, ℝ) h x := by |
| 122 | rw [← mdifferentiableWithinAt_univ] |
| 123 | apply DifferentiableWithinAt.mdifferentiableWithinAt_of_comp_extChartAt_symm |
| 124 | simpa only [preimage_univ, ModelWithCorners.range_eq_univ, inter_univ, |
| 125 | differentiableWithinAt_univ] using! hk |
| 126 | have hchart {a : M → ℝ} (ha : MDifferentiableAt (𝓡 n) 𝓘(ℝ, ℝ) a x) : |
| 127 | mvfderiv (𝓡 n) a x = fderiv ℝ (fun q : E ↦ a (e.symm q)) z := by |
| 128 | simpa [writtenInExtChartAt, extChartAt_model_space_eq_id, e, z, |
| 129 | ModelWithCorners.range_eq_univ] using! ha.mvfderiv |
| 130 | have htimeEq : (fun s ↦ mvfderiv (𝓡 n) (fun y ↦ f (s, y)) x v) =ᶠ[𝓝 t] |
| 131 | (fun s ↦ fderiv ℝ (fun q : E ↦ G (s, q)) z v) := by |
| 132 | filter_upwards [isOpen_interior.mem_nhds ht] with s hs |
| 133 | have hsm : ContMDiffOn (𝓡 n) (𝓘(ℝ, ℝ).prod (𝓡 n)) ∞ |
| 134 | (fun y : M ↦ (s, y)) U := contMDiffOn_const.prodMk contMDiffOn_id |
| 135 | have hsf := hf.comp hsm |
| 136 | (show MapsTo (fun y : M ↦ (s, y)) U (J ×ˢ U) from |
| 137 | fun _ hy ↦ ⟨interior_subset hs, hy⟩) |
| 138 | have hdiff := (hsf.contMDiffAt (hU.mem_nhds hx)).mdifferentiableAt (by simp) |
| 139 | have heq := congrArg (fun L : E →L[ℝ] ℝ ↦ L v) (hchart hdiff) |
| 140 | simpa only [Function.comp_apply, G] using! heq |
| 141 | have hvalue : fderiv ℝ k z v = mvfderiv (𝓡 n) h x v := by |
| 142 | have heq := congrArg (fun L : E →L[ℝ] ℝ ↦ L v) (hchart hh) |
| 143 | simpa only [k] using! heq.symm |
| 144 | exact (hdSlice.congr_deriv hvalue).congr_of_eventuallyEq htimeEq |
| 145 | |
| 146 | end PoincareMT.RicciFlowAnalysis |
| 147 |