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.Tensor.TimeDerivative.Trace |
| 2 | import PoincareLib.Geometry.Riemannian.Hessian.Tensor |
| 3 | import PoincareLib.Geometry.Riemannian.ScalarOperators.GradientTime |
| 4 | import PoincareLib.Geometry.Riemannian.Curvature.Bilinear |
| 5 | |
| 6 | /-! |
| 7 | # Gradient energy under Ricci flow |
| 8 | |
| 9 | Tracing the tensor `df ⊗ df` gives its moving gradient norm. The inverse-metric |
| 10 | variation contributes twice Ricci evaluated on the gradient; the two scalar |
| 11 | differentials contribute twice the pairing with the gradient of the time |
| 12 | derivative. This is the gradient-energy term in Morgan--Tian, Lemma 9.1. |
| 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 BigOperators |
| 20 | |
| 21 | universe u |
| 22 | |
| 23 | namespace PoincareMT |
| 24 | |
| 25 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 26 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 27 | |
| 28 | private theorem differential_square_isSmooth {f : M → ℝ} |
| 29 | (hf : ContMDiff (𝓡 n) 𝓘(ℝ, ℝ) ∞ f) : |
| 30 | IsSmoothCovariantTensor (k := 2) |
| 31 | (fun x v ↦ mvfderiv (𝓡 n) f x (v 0) * mvfderiv (𝓡 n) f x (v 1)) := by |
| 32 | constructor |
| 33 | · intro x |
| 34 | refine ⟨{ |
| 35 | toFun := fun v ↦ mvfderiv (𝓡 n) f x (v 0) * mvfderiv (𝓡 n) f x (v 1) |
| 36 | map_update_add' := ?_ |
| 37 | map_update_smul' := ?_ }, fun _ ↦ rfl⟩ |
| 38 | · intro _ v i a b |
| 39 | fin_cases i <;> simp [map_add, add_mul, mul_add] |
| 40 | · intro _ v i c a |
| 41 | fin_cases i <;> simp [map_smul, mul_assoc, mul_left_comm] |
| 42 | · intro U hU X hX |
| 43 | exact ((differentialEvaluation_isSmooth hf).2 U hU |
| 44 | (fun _ ↦ X 0) (fun _ ↦ hX 0)).mul |
| 45 | ((differentialEvaluation_isSmooth hf).2 U hU |
| 46 | (fun _ ↦ X 1) (fun _ ↦ hX 1)) |
| 47 | |
| 48 | private theorem ricci_gradient_eq_sum {g : RiemannianMetric n M} |
| 49 | (D : LeviCivitaData g) (f : M → ℝ) (x : M) : |
| 50 | D.ricci x (D.gradient f x) (D.gradient f x) = |
| 51 | ∑ i, ∑ j, D.ricci x (g.orthonormalBasis x i) (g.orthonormalBasis x j) * |
| 52 | (mvfderiv (𝓡 n) f x (g.orthonormalBasis x i) * |
| 53 | mvfderiv (𝓡 n) f x (g.orthonormalBasis x j)) := by |
| 54 | classical |
| 55 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 56 | ⟨g.toRiemannianMetric⟩ |
| 57 | let b := g.orthonormalBasis x |
| 58 | let B := ∑ k, D.curvatureTensor_bilinear_first_third x (b k) (b k) |
| 59 | have hB (u v : TangentSpace (𝓡 n) x) : B u v = D.ricci x u v := by |
| 60 | simp only [B, LinearMap.sum_apply, |
| 61 | LeviCivitaData.curvatureTensor_bilinear_first_third_apply, LeviCivitaData.ricci, b] |
| 62 | have hgrad : (∑ i, mvfderiv (𝓡 n) f x (b i) • b i) = D.gradient f x := by |
| 63 | have hinner (i) : inner ℝ (b i) (D.gradient f x) = mvfderiv (𝓡 n) f x (b i) := by |
| 64 | change g.inner x (b i) (D.gradient f x) = _ |
| 65 | rw [g.symm, D.inner_gradient] |
| 66 | have h := b.sum_repr (D.gradient f x) |
| 67 | simpa only [OrthonormalBasis.repr_apply_apply, hinner] using h |
| 68 | rw [← hB, ← hgrad] |
| 69 | simp only [map_sum, map_smul, LinearMap.sum_apply, LinearMap.smul_apply, |
| 70 | smul_eq_mul, Finset.mul_sum, hB] |
| 71 | rw [Finset.sum_comm] |
| 72 | apply Finset.sum_congr rfl |
| 73 | intro i _ |
| 74 | apply Finset.sum_congr rfl |
| 75 | intro j _ |
| 76 | ring |
| 77 | |
| 78 | namespace RicciFlow |
| 79 | |
| 80 | variable {J : Set ℝ} |
| 81 | |
| 82 | /-- The variation of gradient energy for a smooth scalar with specified time derivative. -/ |
| 83 | theorem hasDerivAt_gradient_normSq_of_time_derivative |
| 84 | (F : RicciFlow n M J) {f : ℝ × M → ℝ} {df : M → ℝ} |
| 85 | {t : ℝ} (ht : t ∈ interior J) |
| 86 | (hspace : ∀ s, ContMDiff (𝓡 n) 𝓘(ℝ, ℝ) ∞ (fun y ↦ f (s, y))) |
| 87 | (hreg : ∀ y, ContMDiffAt (𝓘(ℝ, ℝ).prod (𝓡 n)) 𝓘(ℝ, ℝ) ∞ f (t, y)) |
| 88 | (hdf : ∀ y, HasDerivAt (fun s ↦ f (s, y)) (df y) t) (x : M) : |
| 89 | HasDerivAt |
| 90 | (fun s ↦ (F.metric s).inner x |
| 91 | ((F.connection s).gradient (fun y ↦ f (s, y)) x) |
| 92 | ((F.connection s).gradient (fun y ↦ f (s, y)) x)) |
| 93 | (2 * (F.connection t).ricci x |
| 94 | ((F.connection t).gradient (fun y ↦ f (t, y)) x) |
| 95 | ((F.connection t).gradient (fun y ↦ f (t, y)) x) + |
| 96 | 2 * (F.metric t).inner x |
| 97 | ((F.connection t).gradient (fun y ↦ f (t, y)) x) |
| 98 | ((F.connection t).gradient df x)) t := by |
| 99 | let T : ℝ → CovariantTensorEvaluation n M 2 := fun s y v ↦ |
| 100 | mvfderiv (𝓡 n) (fun z ↦ f (s, z)) y (v 0) * |
| 101 | mvfderiv (𝓡 n) (fun z ↦ f (s, z)) y (v 1) |
| 102 | let W : ℝ → CovariantTensorEvaluation n M 2 := fun _ y v ↦ |
| 103 | mvfderiv (𝓡 n) df y (v 0) * mvfderiv (𝓡 n) (fun z ↦ f (t, z)) y (v 1) + |
| 104 | mvfderiv (𝓡 n) (fun z ↦ f (t, z)) y (v 0) * mvfderiv (𝓡 n) df y (v 1) |
| 105 | have hW (v : Fin 2 → TangentSpace (𝓡 n) x) : |
| 106 | HasDerivAt (fun s ↦ T s x v) (W t x v) t := |
| 107 | (Poincare.Manifold.hasDerivAt_mvfderiv_time (hreg x) hdf (v 0)).mul |
| 108 | (Poincare.Manifold.hasDerivAt_mvfderiv_time (hreg x) hdf (v 1)) |
| 109 | have h := F.hasDerivAt_tensorTrace (T := T) (W := W) ht x |
| 110 | (fun s ↦ differential_square_isSmooth (hspace s)) hW (Fin.elim0) |
| 111 | have htrace (s : ℝ) : (F.metric s).tensorTrace (T s) x Fin.elim0 = |
| 112 | (F.metric s).inner x ((F.connection s).gradient (fun y ↦ f (s, y)) x) |
| 113 | ((F.connection s).gradient (fun y ↦ f (s, y)) x) := by |
| 114 | simpa only [RiemannianMetric.tensorTrace, T, Fin.cons_zero, Fin.cons_one, pow_two] using |
| 115 | ((F.connection s).gradient_normSq_eq_sum_mvfderiv_sq (fun y ↦ f (s, y)) x).symm |
| 116 | simp_rw [htrace] at h |
| 117 | apply h.congr_deriv |
| 118 | simp only [RiemannianMetric.tensorTrace, W, T, Fin.cons_zero, Fin.cons_one, |
| 119 | Finset.sum_add_distrib] |
| 120 | rw [(F.connection t).sum_mvfderiv_mul_eq_inner_gradient, |
| 121 | (F.connection t).sum_mvfderiv_mul_eq_inner_gradient, |
| 122 | ← ricci_gradient_eq_sum] |
| 123 | rw [(F.metric t).symm x ((F.connection t).gradient df x)] |
| 124 | ring |
| 125 | |
| 126 | /-- A jointly smooth potential on the flow's time strip has the moving |
| 127 | gradient-energy derivative, with no regularity required outside that strip. -/ |
| 128 | theorem hasDerivAt_gradient_normSq |
| 129 | (F : RicciFlow n M J) {f : M × ℝ → ℝ} {t : ℝ} |
| 130 | (ht : t ∈ interior J) |
| 131 | (hf : ContMDiffOn ((𝓡 n).prod 𝓘(ℝ, ℝ)) 𝓘(ℝ, ℝ) ∞ f (univ ×ˢ J)) |
| 132 | (x : M) : |
| 133 | HasDerivAt |
| 134 | (fun s ↦ (F.metric s).inner x |
| 135 | ((F.connection s).gradient (fun y ↦ f (y, s)) x) |
| 136 | ((F.connection s).gradient (fun y ↦ f (y, s)) x)) |
| 137 | (2 * (F.connection t).ricci x |
| 138 | ((F.connection t).gradient (fun y ↦ f (y, t)) x) |
| 139 | ((F.connection t).gradient (fun y ↦ f (y, t)) x) + |
| 140 | 2 * (F.metric t).inner x |
| 141 | ((F.connection t).gradient (fun y ↦ f (y, t)) x) |
| 142 | ((F.connection t).gradient (fun y ↦ deriv (fun s ↦ f (y, s)) t) x)) t := by |
| 143 | classical |
| 144 | let f' : ℝ × M → ℝ := fun p ↦ if p.1 ∈ J then f (p.2, p.1) else 0 |
| 145 | have hnear : J ∈ 𝓝 t := mem_interior_iff_mem_nhds.mp ht |
| 146 | have hsmooth (y : M) : ContMDiffAt ((𝓡 n).prod 𝓘(ℝ, ℝ)) 𝓘(ℝ, ℝ) ∞ f (y, t) := |
| 147 | hf.contMDiffAt (prod_mem_nhds Filter.univ_mem hnear) |
| 148 | have hspace (s : ℝ) : ContMDiff (𝓡 n) 𝓘(ℝ, ℝ) ∞ (fun y ↦ f' (s, y)) := by |
| 149 | by_cases hs : s ∈ J |
| 150 | · have hslice : ContMDiff (𝓡 n) 𝓘(ℝ, ℝ) ∞ (fun y ↦ f (y, s)) := |
| 151 | contMDiffOn_univ.mp (hf.comp |
| 152 | (contMDiffOn_id.prodMk contMDiffOn_const) (fun y _ ↦ ⟨mem_univ y, hs⟩)) |
| 153 | simpa only [f', if_pos hs] using hslice |
| 154 | · simpa only [f', if_neg hs] using |
| 155 | (contMDiff_const : ContMDiff (𝓡 n) 𝓘(ℝ, ℝ) ∞ (fun _ : M ↦ (0 : ℝ))) |
| 156 | have hreg (y : M) : ContMDiffAt (𝓘(ℝ, ℝ).prod (𝓡 n)) 𝓘(ℝ, ℝ) ∞ f' (t, y) := by |
| 157 | have hswap : ContMDiffAt (𝓘(ℝ, ℝ).prod (𝓡 n)) 𝓘(ℝ, ℝ) ∞ |
| 158 | (fun p : ℝ × M ↦ f (p.2, p.1)) (t, y) := |
| 159 | (hsmooth y).comp_of_eq (contMDiffAt_snd.prodMk contMDiffAt_fst) rfl |
| 160 | apply hswap.congr_of_eventuallyEq |
| 161 | filter_upwards [continuousAt_fst.tendsto.eventually hnear] with p hp |
| 162 | exact if_pos hp |
| 163 | have hdf (y : M) : HasDerivAt (fun s ↦ f' (s, y)) |
| 164 | (deriv (fun s ↦ f (y, s)) t) t := by |
| 165 | have hs : ContMDiffAt 𝓘(ℝ, ℝ) 𝓘(ℝ, ℝ) ∞ (fun s ↦ f (y, s)) t := |
| 166 | (hsmooth y).comp t (contMDiffAt_const.prodMk contMDiffAt_id) |
| 167 | apply (hs.contDiffAt.differentiableAt (by simp)).hasDerivAt.congr_of_eventuallyEq |
| 168 | filter_upwards [hnear] with s hs |
| 169 | exact if_pos hs |
| 170 | have h := F.hasDerivAt_gradient_normSq_of_time_derivative ht hspace hreg hdf x |
| 171 | have hft : (fun y ↦ f' (t, y)) = (fun y ↦ f (y, t)) := by |
| 172 | funext y |
| 173 | exact if_pos (interior_subset ht) |
| 174 | rw [hft] at h |
| 175 | apply h.congr_of_eventuallyEq |
| 176 | filter_upwards [hnear] with s hs |
| 177 | simp only [f', if_pos hs] |
| 178 | |
| 179 | end RicciFlow |
| 180 | |
| 181 | end PoincareMT |