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.Manifold.ContDiff.TimeDerivative |
| 3 | import PoincareLib.Geometry.Riemannian.Tensor.Operations |
| 4 | |
| 5 | set_option autoImplicit false |
| 6 | set_option backward.isDefEq.respectTransparency false |
| 7 | |
| 8 | open scoped Manifold ContDiff Bundle Topology BigOperators |
| 9 | open Filter Set |
| 10 | |
| 11 | universe u |
| 12 | |
| 13 | namespace PoincareMT.RicciFlow |
| 14 | |
| 15 | open PoincareMT |
| 16 | |
| 17 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 18 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 19 | {J : Set ℝ} |
| 20 | |
| 21 | private lemma contDiffAt_clm_of_apply |
| 22 | {E G : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 23 | [NormedAddCommGroup G] [NormedSpace ℝ G] [FiniteDimensional ℝ E] |
| 24 | {f : ℝ → E →L[ℝ] G} {t : ℝ} |
| 25 | (hf : ∀ v, ContDiffAt ℝ ∞ (fun s => f s v) t) : |
| 26 | ContDiffAt ℝ ∞ f t := by |
| 27 | let d := Module.finrank ℝ E |
| 28 | have hd : d = Module.finrank ℝ (Fin d → ℝ) := (Module.finrank_fin_fun ℝ).symm |
| 29 | let e₁ : E ≃L[ℝ] (Fin d → ℝ) := ContinuousLinearEquiv.ofFinrankEq hd |
| 30 | let e₂ := (e₁.arrowCongr (1 : G ≃L[ℝ] G)).trans |
| 31 | (ContinuousLinearEquiv.piRing (Fin d)) |
| 32 | rw [← Function.id_comp f, ← e₂.symm_comp_self] |
| 33 | exact e₂.symm.contDiff.contDiffAt.comp t |
| 34 | (contDiffAt_pi.mpr fun i => hf _) |
| 35 | |
| 36 | lemma hasDerivAt_covariantTensorEvaluation_moving_left |
| 37 | (F : RicciFlow n M J) {T W : ℝ → CovariantTensorEvaluation n M 2} |
| 38 | {t : ℝ} {x : M} |
| 39 | (hT : ∀ s, IsSmoothCovariantTensor (T s)) |
| 40 | (hreg : ∀ (y : M) (X Y : (z : M) → TangentSpace (𝓡 n) z), |
| 41 | ContMDiffAt (𝓡 n) ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% X) y → |
| 42 | ContMDiffAt (𝓡 n) ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% Y) y → |
| 43 | ContMDiffAt (𝓘(ℝ, ℝ).prod (𝓡 n)) 𝓘(ℝ, ℝ) ∞ |
| 44 | (fun p : ℝ × M => T p.1 p.2 ![X p.2, Y p.2]) (t, y)) |
| 45 | (hW : ∀ (y : M) (z : Fin 2 → TangentSpace (𝓡 n) y), |
| 46 | HasDerivAt (fun s => T s y z) (W t y z) t) |
| 47 | (ht : t ∈ interior J) (u v w : TangentSpace (𝓡 n) x) |
| 48 | {V : ℝ → TangentSpace (𝓡 n) x} {V' : TangentSpace (𝓡 n) x} |
| 49 | (hV : HasDerivAt V V' t) : |
| 50 | letI : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 51 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 52 | HasDerivAt (fun s => T s x ![V s, w]) |
| 53 | (W t x ![V t, w] + T t x ![V', w]) t := by |
| 54 | letI : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 55 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 56 | letI : FiniteDimensional ℝ (TangentSpace (𝓡 n) x) := |
| 57 | VectorBundle.finiteDimensional ℝ (EuclideanSpace ℝ (Fin n)) |
| 58 | (TangentSpace (𝓡 n) : M → Type _) x |
| 59 | let Y := FiberBundle.extend (EuclideanSpace ℝ (Fin n)) w |
| 60 | choose B hB using fun s => (hT s).1 x |
| 61 | have hY := FiberBundle.contMDiffAt_extend (𝓡 n) (EuclideanSpace ℝ (Fin n)) (k := ∞) w |
| 62 | let L : ℝ → (TangentSpace (𝓡 n) x) →L[ℝ] ℝ := fun s => |
| 63 | ((B s).toLinearMap ![0, w] 0).toContinuousLinearMap |
| 64 | have hL (s : ℝ) (q : TangentSpace (𝓡 n) x) : L s q = T s x ![q, w] := by |
| 65 | have hu : Function.update ![0, w] 0 q = ![q, w] := by ext i; fin_cases i <;> simp |
| 66 | simpa [L, hu] using (hB s ![q, w]).symm |
| 67 | have hLs : ContDiffAt ℝ ∞ L t := by |
| 68 | apply contDiffAt_clm_of_apply |
| 69 | intro q |
| 70 | let Xq := FiberBundle.extend (EuclideanSpace ℝ (Fin n)) q |
| 71 | have hXq := FiberBundle.contMDiffAt_extend (𝓡 n) (EuclideanSpace ℝ (Fin n)) (k := ∞) q |
| 72 | have hp : ContMDiffAt 𝓘(ℝ, ℝ) (𝓘(ℝ, ℝ).prod (𝓡 n)) ∞ |
| 73 | (fun s : ℝ => (s, x)) t := |
| 74 | contMDiffAt_id.prodMk contMDiffAt_const |
| 75 | have h := (hreg x Xq Y hXq hY).comp t hp |
| 76 | have hc := h.contDiffAt |
| 77 | convert hc using 1 <;> ext s <;> simp [L, hL, Xq, Y, |
| 78 | FiberBundle.extend_apply_self] |
| 79 | have hLd := (hLs.differentiableAt (by simp)).hasDerivAt |
| 80 | have hLfixed := hLd.clm_apply (hasDerivAt_const t (V t)) |
| 81 | have hW' := hW x ![V t, w] |
| 82 | have hcoef : (deriv L t) (V t) = W t x ![V t, w] := by |
| 83 | simpa only [map_zero, add_zero] using hLfixed.unique (hW'.congr_of_eventuallyEq |
| 84 | (Filter.Eventually.of_forall fun s => by simp only [hL])) |
| 85 | have htime := hLd.clm_apply hV |
| 86 | simpa only [hL, hcoef, add_comm] using htime |
| 87 | |
| 88 | lemma hasDerivAt_covariantTensorEvaluation_moving_right |
| 89 | (F : RicciFlow n M J) {T W : ℝ → CovariantTensorEvaluation n M 2} |
| 90 | {t : ℝ} {x : M} |
| 91 | (hT : ∀ s, IsSmoothCovariantTensor (T s)) |
| 92 | (hreg : ∀ (y : M) (X Y : (z : M) → TangentSpace (𝓡 n) z), |
| 93 | ContMDiffAt (𝓡 n) ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% X) y → |
| 94 | ContMDiffAt (𝓡 n) ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% Y) y → |
| 95 | ContMDiffAt (𝓘(ℝ, ℝ).prod (𝓡 n)) 𝓘(ℝ, ℝ) ∞ |
| 96 | (fun p : ℝ × M => T p.1 p.2 ![X p.2, Y p.2]) (t, y)) |
| 97 | (hW : ∀ (y : M) (z : Fin 2 → TangentSpace (𝓡 n) y), |
| 98 | HasDerivAt (fun s => T s y z) (W t y z) t) |
| 99 | (ht : t ∈ interior J) (u v w : TangentSpace (𝓡 n) x) |
| 100 | {V : ℝ → TangentSpace (𝓡 n) x} {V' : TangentSpace (𝓡 n) x} |
| 101 | (hV : HasDerivAt V V' t) : |
| 102 | letI : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 103 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 104 | HasDerivAt (fun s => T s x ![w, V s]) |
| 105 | (W t x ![w, V t] + T t x ![w, V']) t := by |
| 106 | letI : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 107 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 108 | letI : FiniteDimensional ℝ (TangentSpace (𝓡 n) x) := |
| 109 | VectorBundle.finiteDimensional ℝ (EuclideanSpace ℝ (Fin n)) |
| 110 | (TangentSpace (𝓡 n) : M → Type _) x |
| 111 | let X := FiberBundle.extend (EuclideanSpace ℝ (Fin n)) w |
| 112 | choose B hB using fun s => (hT s).1 x |
| 113 | let L : ℝ → (TangentSpace (𝓡 n) x) →L[ℝ] ℝ := fun s => |
| 114 | ((B s).toLinearMap ![w, 0] 1).toContinuousLinearMap |
| 115 | have hL (s : ℝ) (q : TangentSpace (𝓡 n) x) : L s q = T s x ![w, q] := by |
| 116 | have hu : Function.update ![w, 0] 1 q = ![w, q] := by ext i; fin_cases i <;> simp |
| 117 | simpa [L, hu] using (hB s ![w, q]).symm |
| 118 | have hLs : ContDiffAt ℝ ∞ L t := by |
| 119 | apply contDiffAt_clm_of_apply |
| 120 | intro q |
| 121 | let Yq := FiberBundle.extend (EuclideanSpace ℝ (Fin n)) q |
| 122 | have hX := FiberBundle.contMDiffAt_extend (𝓡 n) (EuclideanSpace ℝ (Fin n)) (k := ∞) w |
| 123 | have hYq := FiberBundle.contMDiffAt_extend (𝓡 n) (EuclideanSpace ℝ (Fin n)) (k := ∞) q |
| 124 | have hp : ContMDiffAt 𝓘(ℝ, ℝ) (𝓘(ℝ, ℝ).prod (𝓡 n)) ∞ |
| 125 | (fun s : ℝ => (s, x)) t := contMDiffAt_id.prodMk contMDiffAt_const |
| 126 | have h := (hreg x X Yq hX hYq).comp t hp |
| 127 | have hc := h.contDiffAt |
| 128 | convert hc using 1 <;> ext s <;> simp [L, hL, X, Yq, FiberBundle.extend_apply_self] |
| 129 | have hLd := (hLs.differentiableAt (by simp)).hasDerivAt |
| 130 | have hLfixed := hLd.clm_apply (hasDerivAt_const t (V t)) |
| 131 | have hW' := hW x ![w, V t] |
| 132 | have hcoef : (deriv L t) (V t) = W t x ![w, V t] := by |
| 133 | simpa only [map_zero, add_zero] using hLfixed.unique (hW'.congr_of_eventuallyEq |
| 134 | (Filter.Eventually.of_forall fun s => by simp only [hL])) |
| 135 | have htime := hLd.clm_apply hV |
| 136 | simpa only [hL, hcoef, add_comm] using htime |
| 137 | |
| 138 | lemma hasDerivAt_covariantTensorDerivative_time |
| 139 | (F : RicciFlow n M J) {T W : ℝ → CovariantTensorEvaluation n M 2} |
| 140 | {t : ℝ} (ht : t ∈ interior J) (x : M) |
| 141 | (hT : ∀ s, IsSmoothCovariantTensor (T s)) |
| 142 | (hreg : ∀ (y : M) (X Y : (z : M) → TangentSpace (𝓡 n) z), |
| 143 | ContMDiffAt (𝓡 n) ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% X) y → |
| 144 | ContMDiffAt (𝓡 n) ((𝓡 n).prod 𝓘(ℝ, EuclideanSpace ℝ (Fin n))) ∞ (T% Y) y → |
| 145 | ContMDiffAt (𝓘(ℝ, ℝ).prod (𝓡 n)) 𝓘(ℝ, ℝ) ∞ |
| 146 | (fun p : ℝ × M => T p.1 p.2 ![X p.2, Y p.2]) (t, y)) |
| 147 | (hW : ∀ (y : M) (z : Fin 2 → TangentSpace (𝓡 n) y), |
| 148 | HasDerivAt (fun s => T s y z) (W t y z) t) |
| 149 | (u v w : TangentSpace (𝓡 n) x) : |
| 150 | letI : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 151 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 152 | let A := fun z : TangentSpace (𝓡 n) x => deriv (fun s => |
| 153 | (F.connection s).connection (FiberBundle.extend (EuclideanSpace ℝ (Fin n)) z) x) t |
| 154 | HasDerivAt (fun s => |
| 155 | (F.connection s).covariantTensorDerivative (T s) x ![u, v, w]) |
| 156 | ((F.connection t).covariantTensorDerivative (W t) x ![u, v, w] - |
| 157 | T t x ![A v u, w] - T t x ![v, A w u]) t := by |
| 158 | letI : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 159 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 160 | let X := fun z : TangentSpace (𝓡 n) x => |
| 161 | FiberBundle.extend (EuclideanSpace ℝ (Fin n)) z |
| 162 | have hX (z : TangentSpace (𝓡 n) x) := |
| 163 | FiberBundle.contMDiffAt_extend (𝓡 n) (EuclideanSpace ℝ (Fin n)) (k := ∞) z |
| 164 | have hconn (z : TangentSpace (𝓡 n) x) := |
| 165 | ((F.contDiffAt_connection ht (hX z)).differentiableAt (by simp)).hasDerivAt |
| 166 | have hconnU (z : TangentSpace (𝓡 n) x) := (hconn z).clm_apply (hasDerivAt_const t u) |
| 167 | simp only [map_zero, add_zero] at hconnU |
| 168 | have hraw := Poincare.Manifold.hasDerivAt_mvfderiv_time |
| 169 | (hreg x (X v) (X w) (hX v) (hX w)) |
| 170 | (fun y => hW y ![X v y, X w y]) u |
| 171 | have hl := hasDerivAt_covariantTensorEvaluation_moving_left F hT hreg hW ht u v w |
| 172 | (V := fun s => (F.connection s).connection |
| 173 | (FiberBundle.extend (EuclideanSpace ℝ (Fin n)) v) x u) (hconnU v) |
| 174 | have hr := hasDerivAt_covariantTensorEvaluation_moving_right F hT hreg hW ht u w v |
| 175 | (V := fun s => (F.connection s).connection |
| 176 | (FiberBundle.extend (EuclideanSpace ℝ (Fin n)) w) x u) (hconnU w) |
| 177 | have h := hraw.sub (hl.add hr) |
| 178 | have hu0 (a b c : TangentSpace (𝓡 n) x) : Function.update ![a, b] 0 c = ![c, b] := by |
| 179 | ext i; fin_cases i <;> simp |
| 180 | have hu1 (a b c : TangentSpace (𝓡 n) x) : Function.update ![a, b] 1 c = ![a, c] := by |
| 181 | ext i; fin_cases i <;> simp |
| 182 | have heval (y : M) : |
| 183 | (fun i : Fin 2 => FiberBundle.extend (EuclideanSpace ℝ (Fin n)) (![v, w] i) y) = |
| 184 | ![X v y, X w y] := by |
| 185 | ext i; fin_cases i <;> rfl |
| 186 | convert h using 1 <;> try rfl |
| 187 | · funext s |
| 188 | simp [LeviCivitaData.covariantTensorDerivative, Fin.sum_univ_two, hu0, hu1, X, heval] |
| 189 | · simp [LeviCivitaData.covariantTensorDerivative, Fin.sum_univ_two, hu0, hu1, X, heval] |
| 190 | ring |
| 191 | |
| 192 | end PoincareMT.RicciFlow |