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.Connection.Regularity |
| 2 | import PoincareLib.Geometry.Riemannian.ScalarOperators |
| 3 | |
| 4 | /-! |
| 5 | # Connection regularity at included time endpoints |
| 6 | |
| 7 | The metric is smooth within its time domain. Taking spatial derivatives |
| 8 | preserves this time regularity, including at endpoints. The Koszul formula |
| 9 | then gives the same conclusion for the retained connection. |
| 10 | -/ |
| 11 | |
| 12 | set_option autoImplicit false |
| 13 | set_option backward.isDefEq.respectTransparency false |
| 14 | |
| 15 | open scoped Manifold ContDiff Bundle Topology |
| 16 | open Bundle Filter Set |
| 17 | |
| 18 | universe u |
| 19 | |
| 20 | namespace PoincareMT.RicciFlow |
| 21 | |
| 22 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 23 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 24 | {J : Set ℝ} |
| 25 | |
| 26 | lemma contMDiffWithinAt_inner_fields (F : RicciFlow n M J) {t : ℝ} |
| 27 | (ht : t ∈ J) {x : M} |
| 28 | {X Y : (x : M) → TangentSpace (𝓡 n) x} |
| 29 | (hX : ContMDiffAt (𝓡 n) ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% X) x) |
| 30 | (hY : ContMDiffAt (𝓡 n) ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% Y) x) : |
| 31 | ContMDiffWithinAt (𝓘(ℝ, ℝ).prod (𝓡 n)) 𝓘(ℝ, ℝ) ∞ |
| 32 | (fun p : ℝ × M => (F.metric p.1).inner p.2 (X p.2) (Y p.2)) (J ×ˢ univ) (t, x) := by |
| 33 | have hg := F.smooth (t, x) ⟨ht, mem_univ x⟩ |
| 34 | have hX' : ContMDiffWithinAt (𝓘(ℝ, ℝ).prod (𝓡 n)) |
| 35 | ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ |
| 36 | (fun p : ℝ × M => TotalSpace.mk' (EuclideanSpace ℝ (Fin n)) p.2 (X p.2)) |
| 37 | (J ×ˢ univ) (t, x) := (hX.comp (t, x) contMDiffAt_snd).contMDiffWithinAt |
| 38 | have hY' : ContMDiffWithinAt (𝓘(ℝ, ℝ).prod (𝓡 n)) |
| 39 | ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ |
| 40 | (fun p : ℝ × M => TotalSpace.mk' (EuclideanSpace ℝ (Fin n)) p.2 (Y p.2)) |
| 41 | (J ×ˢ univ) (t, x) := (hY.comp (t, x) contMDiffAt_snd).contMDiffWithinAt |
| 42 | have h := hg.clm_bundle_apply₂ (F₃ := ℝ) (E₃ := fun _ : M => ℝ) hX' hY' |
| 43 | exact (contMDiffWithinAt_totalSpace.mp h).2 |
| 44 | |
| 45 | private lemma contDiffWithinAt_mvfderiv_time |
| 46 | {f : ℝ × M → ℝ} {t : ℝ} {x : M} (ht : t ∈ J) |
| 47 | (hf : ContMDiffWithinAt (𝓘(ℝ, ℝ).prod (𝓡 n)) 𝓘(ℝ, ℝ) ∞ f (J ×ˢ univ) (t, x)) |
| 48 | (hspace : ∀ s, MDifferentiableAt (𝓡 n) 𝓘(ℝ, ℝ) (fun y => f (s, y)) x) |
| 49 | (v : TangentSpace (𝓡 n) x) : |
| 50 | ContDiffWithinAt ℝ ∞ (fun s => mvfderiv (𝓡 n) (fun y => f (s, y)) x v) J t := by |
| 51 | let e := extChartAt (𝓡 n) x |
| 52 | have hx : e.symm (e x) = x := e.left_inv (mem_extChartAt_source x) |
| 53 | have hs : ContMDiffAt 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) (𝓡 n) ∞ e.symm (e x) := |
| 54 | (contMDiffOn_extChartAt_symm x).contMDiffAt |
| 55 | ((isOpen_extChartAt_target x).mem_nhds (mem_extChartAt_target x)) |
| 56 | have hc : ContDiffWithinAt ℝ ∞ |
| 57 | (fun p : ℝ × EuclideanSpace ℝ (Fin n) => f (p.1, e.symm p.2)) |
| 58 | (J ×ˢ univ) (t, e x) := by |
| 59 | have hp : ContMDiffAt (𝓘(ℝ, ℝ).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) |
| 60 | (𝓘(ℝ, ℝ).prod (𝓡 n)) ∞ |
| 61 | (fun p : ℝ × EuclideanSpace ℝ (Fin n) => (p.1, e.symm p.2)) (t, e x) := |
| 62 | contMDiffAt_fst.prodMk (hs.comp (t, e x) contMDiffAt_snd) |
| 63 | have h := hf.comp_of_eq hp.contMDiffWithinAt |
| 64 | (show MapsTo (fun p : ℝ × EuclideanSpace ℝ (Fin n) => (p.1, e.symm p.2)) |
| 65 | (J ×ˢ univ) (J ×ˢ univ) from fun p hp => ⟨hp.1, mem_univ _⟩) (by simp [hx]) |
| 66 | simp +instances only [← modelWithCornersSelf_prod, chartedSpaceSelf_prod] at h |
| 67 | exact h.contDiffWithinAt |
| 68 | have hd := hc.fderivWithin (f := fun s z => f (s, e.symm z)) |
| 69 | (g := fun _ : ℝ => e x) contDiffWithinAt_const uniqueDiffOn_univ |
| 70 | (m := ∞) (by simp) ht (by simp) |
| 71 | simp only [fderivWithin_univ] at hd |
| 72 | let w : EuclideanSpace ℝ (Fin n) := |
| 73 | (mfderiv 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) (𝓡 n) e.symm (e x)).inverse v |
| 74 | have hh := hd.clm_apply (contDiffWithinAt_const (c := w)) |
| 75 | apply hh.congr_of_eventuallyEq_insert |
| 76 | apply Filter.Eventually.of_forall |
| 77 | intro s |
| 78 | have h := Poincare.Manifold.VectorField.fderiv_comp_extChartAt_symm |
| 79 | (p := x) (by simpa [e, hx] using hspace s) (mem_extChartAt_target x) w |
| 80 | have hi := Poincare.Manifold.VectorField.isInvertible_mfderiv_extChartAt_symm |
| 81 | (I := 𝓡 n) (p := x) (mem_extChartAt_target x) |
| 82 | change fderiv ℝ ((fun y => f (s, y)) ∘ e.symm) (e x) w = |
| 83 | mfderiv (𝓡 n) 𝓘(ℝ, ℝ) (fun y => f (s, y)) (e.symm (e x)) |
| 84 | (mfderiv 𝓘(ℝ, EuclideanSpace ℝ (Fin n)) (𝓡 n) e.symm (e x) w) at h |
| 85 | dsimp only [w] at h |
| 86 | rw [hi.self_apply_inverse, hx] at h |
| 87 | exact h.symm |
| 88 | |
| 89 | private lemma contDiffWithinAt_clm_of_apply |
| 90 | {E G : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 91 | [NormedAddCommGroup G] [NormedSpace ℝ G] [FiniteDimensional ℝ E] |
| 92 | {f : ℝ → E →L[ℝ] G} {t : ℝ} |
| 93 | (hf : ∀ v, ContDiffWithinAt ℝ ∞ (fun s => f s v) J t) : |
| 94 | ContDiffWithinAt ℝ ∞ f J t := by |
| 95 | let d := Module.finrank ℝ E |
| 96 | have hd : d = Module.finrank ℝ (Fin d → ℝ) := (Module.finrank_fin_fun ℝ).symm |
| 97 | let e₁ : E ≃L[ℝ] (Fin d → ℝ) := ContinuousLinearEquiv.ofFinrankEq hd |
| 98 | let e₂ := (e₁.arrowCongr (1 : G ≃L[ℝ] G)).trans (ContinuousLinearEquiv.piRing (Fin d)) |
| 99 | rw [← Function.id_comp f, ← e₂.symm_comp_self] |
| 100 | exact e₂.symm.contDiff.contDiffAt.comp_contDiffWithinAt t |
| 101 | (contDiffWithinAt_pi.mpr fun i => hf _) |
| 102 | |
| 103 | lemma contDiffWithinAt_inner_time (F : RicciFlow n M J) {t : ℝ} |
| 104 | (ht : t ∈ J) (x : M) (v w : TangentSpace (𝓡 n) x) : |
| 105 | ContDiffWithinAt ℝ ∞ (fun s => (F.metric s).inner x v w) J t := by |
| 106 | have h := F.contMDiffWithinAt_inner_fields ht |
| 107 | (FiberBundle.contMDiffAt_extend (𝓡 n) (EuclideanSpace ℝ (Fin n)) v) |
| 108 | (FiberBundle.contMDiffAt_extend (𝓡 n) (EuclideanSpace ℝ (Fin n)) w) |
| 109 | have h' := h.comp t (contMDiffWithinAt_id.prodMk contMDiffWithinAt_const) |
| 110 | (show MapsTo (fun s : ℝ => (s, x)) J (J ×ˢ univ) from fun s hs => ⟨hs, mem_univ _⟩) |
| 111 | simpa only [Function.comp_def, id_eq, FiberBundle.extend_apply_self] using h'.contDiffWithinAt |
| 112 | |
| 113 | private lemma contDiffWithinAt_inner_connection_time |
| 114 | (F : RicciFlow n M J) {t : ℝ} (ht : t ∈ J) {x : M} |
| 115 | {X Y Z : (x : M) → TangentSpace (𝓡 n) x} |
| 116 | (hX : ContMDiffAt (𝓡 n) ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% X) x) |
| 117 | (hY : ContMDiffAt (𝓡 n) ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% Y) x) |
| 118 | (hZ : ContMDiffAt (𝓡 n) ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% Z) x) : |
| 119 | ContDiffWithinAt ℝ ∞ (fun s => |
| 120 | (F.metric s).inner x ((F.connection s).connection Y x (X x)) (Z x)) J t := by |
| 121 | have hspace (s : ℝ) (U V : (x : M) → TangentSpace (𝓡 n) x) |
| 122 | (hU : ContMDiffAt (𝓡 n) ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% U) x) |
| 123 | (hV : ContMDiffAt (𝓡 n) ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% V) x) : |
| 124 | MDifferentiableAt (𝓡 n) 𝓘(ℝ, ℝ) (fun y => (F.metric s).inner y (U y) (V y)) x := by |
| 125 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 126 | ⟨(F.metric s).toRiemannianMetric⟩ |
| 127 | exact (hU.inner_bundle hV).mdifferentiableAt (by simp) |
| 128 | have h := (((((contDiffWithinAt_mvfderiv_time ht |
| 129 | (F.contMDiffWithinAt_inner_fields ht hY hZ) (fun s => hspace s Y Z hY hZ) (X x)).add |
| 130 | (contDiffWithinAt_mvfderiv_time ht (F.contMDiffWithinAt_inner_fields ht hZ hX) |
| 131 | (fun s => hspace s Z X hZ hX) (Y x))).sub |
| 132 | (contDiffWithinAt_mvfderiv_time ht (F.contMDiffWithinAt_inner_fields ht hX hY) |
| 133 | (fun s => hspace s X Y hX hY) (Z x))).add |
| 134 | (F.contDiffWithinAt_inner_time ht x (VectorField.mlieBracket (𝓡 n) X Y x) (Z x))).sub |
| 135 | (F.contDiffWithinAt_inner_time ht x (VectorField.mlieBracket (𝓡 n) Y Z x) (X x))).add |
| 136 | (F.contDiffWithinAt_inner_time ht x (VectorField.mlieBracket (𝓡 n) Z X x) (Y x)) |
| 137 | apply (h.const_smul (1 / 2 : ℝ)).congr_of_eventuallyEq_insert |
| 138 | exact Filter.Eventually.of_forall fun s => by |
| 139 | have hk := (F.connection s).koszul_identity |
| 140 | (hX.mdifferentiableAt (by simp)) (hY.mdifferentiableAt (by simp)) |
| 141 | (hZ.mdifferentiableAt (by simp)) |
| 142 | dsimp only [LeviCivitaData.covariantDerivativeOnFields] at hk |
| 143 | simp only [smul_eq_mul] |
| 144 | linarith |
| 145 | |
| 146 | private lemma contDiffWithinAt_connection_apply |
| 147 | (F : RicciFlow n M J) {t : ℝ} (ht : t ∈ J) {x : M} |
| 148 | {Y : (y : M) → TangentSpace (𝓡 n) y} |
| 149 | (hY : ContMDiffAt (𝓡 n) ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% Y) x) |
| 150 | (v : TangentSpace (𝓡 n) x) : |
| 151 | letI : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 152 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 153 | ContDiffWithinAt ℝ ∞ (fun s => (F.connection s).connection Y x v) J t := by |
| 154 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 155 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 156 | let : NormedAddCommGroup (TangentSpace (𝓡 n) x) := inferInstance |
| 157 | let : NormedSpace ℝ (TangentSpace (𝓡 n) x) := inferInstance |
| 158 | let : NormedAddCommGroup (TangentSpace (𝓡 n) x →L[ℝ] ℝ) := inferInstance |
| 159 | let : NormedSpace ℝ (TangentSpace (𝓡 n) x →L[ℝ] ℝ) := inferInstance |
| 160 | let : FiniteDimensional ℝ (TangentSpace (𝓡 n) x) := |
| 161 | VectorBundle.finiteDimensional ℝ (EuclideanSpace ℝ (Fin n)) |
| 162 | (TangentSpace (𝓡 n) : M → Type _) x |
| 163 | have hg : ContDiffWithinAt ℝ ∞ (fun s => (F.metric s).inner x) J t := |
| 164 | contDiffWithinAt_clm_of_apply fun u => contDiffWithinAt_clm_of_apply fun w => |
| 165 | F.contDiffWithinAt_inner_time ht x u w |
| 166 | have hdual : ContDiffWithinAt ℝ ∞ (fun s => |
| 167 | (F.metric s).inner x ((F.connection s).connection Y x v)) J t := by |
| 168 | apply contDiffWithinAt_clm_of_apply |
| 169 | intro w |
| 170 | have h := contDiffWithinAt_inner_connection_time F ht |
| 171 | (FiberBundle.contMDiffAt_extend (𝓡 n) (EuclideanSpace ℝ (Fin n)) v) hY |
| 172 | (FiberBundle.contMDiffAt_extend (𝓡 n) (EuclideanSpace ℝ (Fin n)) w) |
| 173 | simpa only [FiberBundle.extend_apply_self] using h |
| 174 | have hi := ((F.metric t).inner_isInvertible x).contDiffAt_map_inverse.comp_contDiffWithinAt t hg |
| 175 | have h := hi.clm_apply hdual |
| 176 | apply h.congr_of_eventuallyEq_insert |
| 177 | exact Filter.Eventually.of_forall fun s => |
| 178 | (((F.metric s).inner_isInvertible x).inverse_apply_self _).symm |
| 179 | |
| 180 | /-- The retained connection is smooth in time within the full time domain, |
| 181 | including every included endpoint. -/ |
| 182 | theorem contDiffWithinAt_connection |
| 183 | (F : RicciFlow n M J) {t : ℝ} (ht : t ∈ J) {x : M} |
| 184 | {Y : (y : M) → TangentSpace (𝓡 n) y} |
| 185 | (hY : ContMDiffAt (𝓡 n) |
| 186 | ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% Y) x) : |
| 187 | letI : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 188 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 189 | ContDiffWithinAt ℝ ∞ (fun s => (F.connection s).connection Y x) J t := by |
| 190 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 191 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 192 | let : FiniteDimensional ℝ (TangentSpace (𝓡 n) x) := |
| 193 | VectorBundle.finiteDimensional ℝ (EuclideanSpace ℝ (Fin n)) |
| 194 | (TangentSpace (𝓡 n) : M → Type _) x |
| 195 | exact contDiffWithinAt_clm_of_apply (contDiffWithinAt_connection_apply F ht hY) |
| 196 | |
| 197 | /-- The Hessian of a fixed scalar function is smooth in time up to included |
| 198 | endpoints, using the retained connection and no extra boundary certificate. -/ |
| 199 | lemma contDiffWithinAt_hessian |
| 200 | (F : RicciFlow n M J) {t : ℝ} (ht : t ∈ J) |
| 201 | (f : M → ℝ) (x : M) (u v : TangentSpace (𝓡 n) x) : |
| 202 | ContDiffWithinAt ℝ ∞ (fun s => (F.connection s).hessian f x u v) J t := by |
| 203 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 204 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 205 | have h := (F.contDiffWithinAt_connection ht |
| 206 | (FiberBundle.contMDiffAt_extend (𝓡 n) (EuclideanSpace ℝ (Fin n)) v)).clm_apply |
| 207 | (contDiffWithinAt_const (c := u)) |
| 208 | have h' := (mvfderiv (𝓡 n) f x).contDiff.contDiffAt.comp_contDiffWithinAt t h |
| 209 | have h'' := (contDiffWithinAt_const (c := |
| 210 | mvfderiv (𝓡 n) (fun y => mvfderiv (𝓡 n) f y |
| 211 | (FiberBundle.extend (EuclideanSpace ℝ (Fin n)) v y)) x u)).sub h' |
| 212 | simp only [LeviCivitaData.hessian, LeviCivitaData.hessianOnFields, |
| 213 | FiberBundle.extend_apply_self, Function.comp_def] at h'' ⊢ |
| 214 | convert h'' using 1 |
| 215 | |
| 216 | end PoincareMT.RicciFlow |