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.Matrix |
| 3 | import PoincareLib.Geometry.Riemannian.Tensor.Trace |
| 4 | |
| 5 | /-! |
| 6 | # Time differentiation of metric traces |
| 7 | |
| 8 | The inverse metric contributes twice the Ricci contraction under Ricci flow. |
| 9 | A fixed basis gives the identity without differentiating the selected |
| 10 | orthonormal basis. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | set_option backward.isDefEq.respectTransparency false |
| 15 | |
| 16 | open scoped Manifold ContDiff Bundle Topology BigOperators |
| 17 | open Filter Set |
| 18 | |
| 19 | universe u |
| 20 | |
| 21 | namespace PoincareMT.RicciFlow |
| 22 | |
| 23 | private lemma hasDerivAt_matrix_inv_entry_at_one |
| 24 | {ι : Type*} [Fintype ι] [DecidableEq ι] |
| 25 | (G : ℝ → Matrix ι ι ℝ) (G' : Matrix ι ι ℝ) {t : ℝ} |
| 26 | (hG : ∀ i j, ContDiffAt ℝ ∞ (fun s => G s i j) t) |
| 27 | (hd : ∀ i j, HasDerivAt (fun s => G s i j) (G' i j) t) |
| 28 | (hx : G t = 1) (i j : ι) : |
| 29 | HasDerivAt (fun s => (G s)⁻¹ i j) (-G' i j) t := by |
| 30 | have hdet : (G t).det ≠ 0 := by simp [hx] |
| 31 | have hs (a b : ι) := (Poincare.Manifold.contMDiffAt_matrix_inv_entry G t |
| 32 | (fun a b => (hG a b).contMDiffAt) hdet a b).contDiffAt |
| 33 | have hi (a b : ι) := ((hs a b).differentiableAt (by simp)).hasDerivAt |
| 34 | have hnear : ∀ᶠ s in 𝓝 t, (G s).det ≠ 0 := |
| 35 | (Poincare.Manifold.contMDiffAt_matrix_det G t |
| 36 | (fun a b => (hG a b).contMDiffAt)).continuousAt.eventually_ne hdet |
| 37 | have heq : (fun s => ∑ a, (G s)⁻¹ i a * G s a j) =ᶠ[𝓝 t] |
| 38 | (fun _ => (1 : Matrix ι ι ℝ) i j) := by |
| 39 | filter_upwards [hnear] with s hs |
| 40 | exact congrArg (fun A : Matrix ι ι ℝ => A i j) |
| 41 | (Matrix.nonsing_inv_mul _ (isUnit_iff_ne_zero.mpr hs)) |
| 42 | have hsum := HasDerivAt.sum (u := Finset.univ) fun a _ => (hi i a).mul (hd a j) |
| 43 | have hz := hsum.unique ((hasDerivAt_const t ((1 : Matrix ι ι ℝ) i j)).congr_of_eventuallyEq |
| 44 | (by |
| 45 | convert heq using 1 |
| 46 | ext s |
| 47 | simp only [Finset.sum_apply, Pi.mul_apply])) |
| 48 | simp only [hx, inv_one, Matrix.one_apply, Finset.sum_add_distrib] at hz |
| 49 | simp at hz |
| 50 | exact (hi i j).congr_deriv (by linarith) |
| 51 | |
| 52 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 53 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 54 | {J : Set ℝ} |
| 55 | |
| 56 | /-- Differentiating a metric trace adds twice the Ricci contraction. -/ |
| 57 | lemma hasDerivAt_tensorTrace |
| 58 | (F : RicciFlow n M J) {k : ℕ} {T W : ℝ → CovariantTensorEvaluation n M (k + 2)} |
| 59 | {t : ℝ} (ht : t ∈ interior J) (x : M) |
| 60 | (hT : ∀ s, IsSmoothCovariantTensor (T s)) |
| 61 | (hW : ∀ z : Fin (k + 2) → TangentSpace (𝓡 n) x, |
| 62 | HasDerivAt (fun s => T s x z) (W t x z) t) |
| 63 | (v : Fin k → TangentSpace (𝓡 n) x) : |
| 64 | let b := (F.metric t).orthonormalBasis x |
| 65 | HasDerivAt (fun s => (F.metric s).tensorTrace (T s) x v) |
| 66 | ((F.metric t).tensorTrace (W t) x v + |
| 67 | 2 * ∑ i, ∑ j, (F.connection t).ricci x (b i) (b j) * |
| 68 | T t x (Fin.cons (b i) (Fin.cons (b j) v))) t := by |
| 69 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 70 | ⟨(F.metric t).toRiemannianMetric⟩ |
| 71 | let b := (F.metric t).orthonormalBasis x |
| 72 | let c := b.toBasis |
| 73 | let G : ℝ → Matrix _ _ ℝ := fun s i j => (F.metric s).inner x (b i) (b j) |
| 74 | have hGx : G t = 1 := by ext i j; exact b.inner_eq_ite i j |
| 75 | have hG (i j) := F.contDiffAt_inner_time ht x (b i) (b j) |
| 76 | have hd (i j) := (F.equation t (interior_subset ht) x (b i) (b j)).hasDerivAt |
| 77 | (mem_interior_iff_mem_nhds.mp ht) |
| 78 | have hi (i j) := hasDerivAt_matrix_inv_entry_at_one G |
| 79 | (fun i j => -2 * (F.connection t).ricci x (b i) (b j)) hG hd hGx i j |
| 80 | have hsum := HasDerivAt.sum (u := Finset.univ) fun i _ => |
| 81 | HasDerivAt.sum (u := Finset.univ) fun j _ => |
| 82 | (hi i j).mul (hW (Fin.cons (b i) (Fin.cons (b j) v))) |
| 83 | have heq (s : ℝ) : (F.metric s).tensorTrace (T s) x v = |
| 84 | ∑ i, ∑ j, (G s)⁻¹ i j * T s x (Fin.cons (b i) (Fin.cons (b j) v)) := by |
| 85 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 86 | ⟨(F.metric s).toRiemannianMetric⟩ |
| 87 | obtain ⟨A, hA⟩ := (hT s).1 x |
| 88 | have h := bilinear_sum_basis_eq_inverse_gram (bilinearOfTensorCons A v) |
| 89 | c ((F.metric s).orthonormalBasis x) |
| 90 | change (∑ i, A (Fin.cons ((F.metric s).orthonormalBasis x i) |
| 91 | (Fin.cons ((F.metric s).orthonormalBasis x i) v))) = |
| 92 | ∑ i, ∑ j, (Matrix.of (fun i j => (F.metric s).inner x (b i) (b j)))⁻¹ i j * |
| 93 | A (Fin.cons (b i) (Fin.cons (b j) v)) at h |
| 94 | simp only [← hA] at h |
| 95 | exact h |
| 96 | have h := hsum.congr_of_eventuallyEq |
| 97 | (Eventually.of_forall fun s => by |
| 98 | convert heq s using 1 |
| 99 | simp only [Finset.sum_apply, Pi.mul_apply]) |
| 100 | apply h.congr_deriv |
| 101 | simp only [hGx, inv_one, Matrix.one_apply, Finset.sum_add_distrib, |
| 102 | RiemannianMetric.tensorTrace, neg_mul, neg_neg, ite_mul, one_mul, zero_mul] |
| 103 | simp only [mul_assoc, ← Finset.mul_sum, Finset.sum_ite_eq, |
| 104 | Finset.mem_univ, if_true] |
| 105 | exact add_comm _ _ |
| 106 | |
| 107 | end PoincareMT.RicciFlow |