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.Spacetime.Horizontal.Regularity.Curvature |
| 2 | import PoincareLib.Geometry.Riemannian.Tensor.Trace |
| 3 | import Mathlib.Geometry.Manifold.VectorBundle.LocalFrame |
| 4 | import Mathlib.Geometry.Manifold.Algebra.Structures |
| 5 | import Mathlib.Analysis.InnerProductSpace.GramMatrix |
| 6 | |
| 7 | /-! |
| 8 | # Smooth metric traces of horizontal tensors |
| 9 | |
| 10 | A smooth local frame and its inverse Gram matrix express contraction without |
| 11 | requiring a smoothly chosen slice orthonormal frame. |
| 12 | -/ |
| 13 | |
| 14 | set_option autoImplicit false |
| 15 | set_option backward.isDefEq.respectTransparency false |
| 16 | set_option synthInstance.maxHeartbeats 100000 |
| 17 | |
| 18 | open scoped Manifold ContDiff Bundle BigOperators Topology |
| 19 | open Bundle Filter Set |
| 20 | |
| 21 | universe u |
| 22 | |
| 23 | namespace PoincareMT |
| 24 | |
| 25 | variable {n : ℕ} {X : Type u} [TopologicalSpace X] {time : X → ℝ} |
| 26 | {I : SpacetimeInterval} {F : GeneralizedFlowSpacetime n X time I} |
| 27 | {S : ∀ t : ℝ, SpacetimeSliceGeometry F t} |
| 28 | |
| 29 | private lemma contMDiffAt_matrix_det {ι : Type} [Fintype ι] [DecidableEq ι] |
| 30 | (G : F.Point → Matrix ι ι ℝ) (x : F.Point) |
| 31 | (hG : ∀ i j, ContMDiffAt (spacetimeModel n) 𝓘(ℝ) ∞ (fun y => G y i j) x) : |
| 32 | ContMDiffAt (spacetimeModel n) 𝓘(ℝ) ∞ (fun y => (G y).det) x := by |
| 33 | simp only [Matrix.det_apply'] |
| 34 | apply ContMDiffAt.sum |
| 35 | intro σ _ |
| 36 | exact contMDiffAt_const.mul (ContMDiffAt.prod fun i _ => hG (σ i) i) |
| 37 | |
| 38 | private lemma contMDiffAt_matrix_inv_entry {ι : Type} [Fintype ι] [DecidableEq ι] |
| 39 | (G : F.Point → Matrix ι ι ℝ) (x : F.Point) |
| 40 | (hG : ∀ i j, ContMDiffAt (spacetimeModel n) 𝓘(ℝ) ∞ (fun y => G y i j) x) |
| 41 | (hx : (G x).det ≠ 0) (i j : ι) : |
| 42 | ContMDiffAt (spacetimeModel n) 𝓘(ℝ) ∞ (fun y => (G y)⁻¹ i j) x := by |
| 43 | simp only [Matrix.inv_def, Ring.inverse_eq_inv, Matrix.smul_apply, smul_eq_mul, |
| 44 | Matrix.adjugate_apply] |
| 45 | apply ((contMDiffAt_matrix_det G x hG).inv₀ hx).mul |
| 46 | apply contMDiffAt_matrix_det |
| 47 | intro a b |
| 48 | by_cases ha : a = j |
| 49 | · subst a |
| 50 | simpa using (contMDiffAt_const (I := spacetimeModel n) (x := x) (n := ∞) |
| 51 | (c := (Pi.single i (1 : ℝ) : ι → ℝ) b)) |
| 52 | · simpa [Matrix.updateRow_apply, ha] using hG a b |
| 53 | |
| 54 | /-- Trace in the transported orthonormal frame of the actual slice. -/ |
| 55 | noncomputable def horizontalTensorTrace |
| 56 | (S : ∀ t : ℝ, SpacetimeSliceGeometry F t) {k : ℕ} |
| 57 | (T : HorizontalCovariantTensorEvaluation F (k + 2)) : |
| 58 | HorizontalCovariantTensorEvaluation F k := fun p v => |
| 59 | let x := spacetimeSlicePoint S p |
| 60 | let j := (S (F.timeFunction p)).tangentEquiv x |
| 61 | let b := (S (F.timeFunction p)).metricOnPoints.orthonormalBasis x |
| 62 | ∑ i, T p (Fin.cons (j (b i)) (Fin.cons (j (b i)) v)) |
| 63 | |
| 64 | /-- Metric contraction preserves joint horizontal tensor regularity. -/ |
| 65 | theorem IsSmoothHorizontalCovariantTensor.tensorTrace {k : ℕ} |
| 66 | {T : HorizontalCovariantTensorEvaluation F (k + 2)} |
| 67 | (hT : IsSmoothHorizontalCovariantTensor F T) : |
| 68 | IsSmoothHorizontalCovariantTensor F (horizontalTensorTrace S T) := by |
| 69 | classical |
| 70 | constructor |
| 71 | · intro p |
| 72 | obtain ⟨A, hA⟩ := hT.1 p |
| 73 | let x := spacetimeSlicePoint S p |
| 74 | let j := (S (F.timeFunction p)).tangentEquiv x |
| 75 | let b := (S (F.timeFunction p)).metricOnPoints.orthonormalBasis x |
| 76 | refine ⟨∑ i, (A.curryLeft (j (b i))).curryLeft (j (b i)), fun v => ?_⟩ |
| 77 | simp only [horizontalTensorTrace, sum_apply, hA, MultilinearMap.curryLeft_apply] |
| 78 | rfl |
| 79 | · intro U hU V hV p hp |
| 80 | let E := EuclideanSpace ℝ (Fin n) |
| 81 | let e := trivializationAt E F.Horizontal p |
| 82 | let b := (EuclideanSpace.basisFun (Fin n) ℝ).toBasis |
| 83 | let W := e.localFrame b |
| 84 | have hep : p ∈ e.baseSet := FiberBundle.mem_baseSet_trivializationAt E F.Horizontal p |
| 85 | let G : F.Point → Matrix (Fin n) (Fin n) ℝ := |
| 86 | fun q i j => F.horizontalMetric.inner q (W i q) (W j q) |
| 87 | let A : F.Point → Matrix (Fin n) (Fin n) ℝ := fun q i j => |
| 88 | T q (Fin.cons (W i q) (Fin.cons (W j q) (fun a => V a q))) |
| 89 | have hW i : IsSmoothHorizontalSectionOn F (W i) e.baseSet := |
| 90 | e.contMDiffOn_localFrame_baseSet ∞ b i |
| 91 | have hG i j : ContMDiffAt (spacetimeModel n) 𝓘(ℝ) ∞ (fun q => G q i j) p := |
| 92 | (contMDiffAt_totalSpace.mp ((F.horizontalMetric.contMDiff p).clm_bundle_apply₂ |
| 93 | (F₃ := ℝ) (E₃ := Bundle.Trivial F.Point ℝ) |
| 94 | ((hW i).contMDiffAt (e.open_baseSet.mem_nhds hep)) |
| 95 | ((hW j).contMDiffAt (e.open_baseSet.mem_nhds hep)))).2 |
| 96 | have hA i j : ContMDiffAt (spacetimeModel n) 𝓘(ℝ) ∞ (fun q => A q i j) p := by |
| 97 | let VV : Fin (k + 2) → HorizontalSection F := fun a q => |
| 98 | Fin.cons (α := fun _ : Fin (k + 2) => F.Horizontal q) (W i q) |
| 99 | (Fin.cons (α := fun _ : Fin (k + 1) => F.Horizontal q) (W j q) |
| 100 | (fun a => V a q)) a |
| 101 | have hh : ∀ a : Fin (k + 2), IsSmoothHorizontalSectionOn F (VV a) |
| 102 | (U ∩ e.baseSet) := by |
| 103 | intro a |
| 104 | refine Fin.cases ((hW i).mono inter_subset_right) |
| 105 | (fun a => Fin.cases ((hW j).mono inter_subset_right) |
| 106 | (fun a => (hV a).mono inter_subset_left) a) a |
| 107 | exact (hT.2 (U ∩ e.baseSet) (hU.inter e.open_baseSet) VV hh).contMDiffAt |
| 108 | ((hU.inter e.open_baseSet).mem_nhds ⟨hp, hep⟩) |
| 109 | let : RiemannianBundle F.Horizontal := ⟨F.horizontalMetric.toRiemannianMetric⟩ |
| 110 | have hdet : (G p).det ≠ 0 := by |
| 111 | have h := Matrix.det_gram_ne_zero_iff_linearIndependent.mpr |
| 112 | (e.basisAt b hep).linearIndependent |
| 113 | change (Matrix.gram ℝ (fun i => W i p)).det ≠ 0 |
| 114 | simpa only [W, e.localFrame_apply_of_mem_baseSet b hep] using h |
| 115 | have hinv := contMDiffAt_matrix_inv_entry G p hG hdet |
| 116 | have hs : ContMDiffAt (spacetimeModel n) 𝓘(ℝ) ∞ |
| 117 | (fun q => ∑ i, ∑ j, (G q)⁻¹ i j * A q i j) p := |
| 118 | ContMDiffAt.sum fun i _ => ContMDiffAt.sum fun j _ => (hinv i j).mul (hA i j) |
| 119 | apply ContMDiffAt.contMDiffWithinAt |
| 120 | apply hs.congr_of_eventuallyEq |
| 121 | filter_upwards [e.open_baseSet.mem_nhds hep] with q hq |
| 122 | let t := F.timeFunction q |
| 123 | let : ChartedSpace (EuclideanSpace ℝ (Fin n)) (S t).Point := (S t).chartedSpace |
| 124 | let x := spacetimeSlicePoint S q |
| 125 | let j := (S t).tangentEquiv x |
| 126 | let : RiemannianBundle (TangentSpace (𝓡 n) : (S t).Point → Type _) := |
| 127 | ⟨(S t).metricOnPoints.toRiemannianMetric⟩ |
| 128 | let c := (e.basisAt b hq).map j.symm.toLinearEquiv |
| 129 | obtain ⟨B, hB⟩ := hT.1 q |
| 130 | let C := (bilinearOfTensorCons B (fun a => V a q)).compl₁₂ j.toLinearMap j.toLinearMap |
| 131 | have h := bilinear_sum_basis_eq_inverse_gram C c |
| 132 | ((S t).metricOnPoints.orthonormalBasis x) |
| 133 | have hj (v : F.Horizontal q) : j (j.symm v) = v := j.apply_symm_apply v |
| 134 | have hc i : j (c i) = W i q := by |
| 135 | change j (j.symm ((e.basisAt b hq) i)) = _ |
| 136 | rw [hj] |
| 137 | exact (e.localFrame_apply_of_mem_baseSet b hq).symm |
| 138 | have hg : Matrix.of (fun i l => (S t).metricOnPoints.inner x (c i) (c l)) = G q := by |
| 139 | ext i l |
| 140 | change (S t).metricOnPoints.inner x (c i) (c l) = G q i l |
| 141 | rw [(S t).metric_eq] |
| 142 | change F.horizontalMetric.inner q (j (c i)) (j (c l)) = G q i l |
| 143 | rw [hc, hc] |
| 144 | change (∑ i, B (Fin.cons (j ((S t).metricOnPoints.orthonormalBasis x i)) |
| 145 | (Fin.cons (j ((S t).metricOnPoints.orthonormalBasis x i)) (fun a => V a q)))) = |
| 146 | ∑ i, ∑ l, (Matrix.of (fun i l => (S t).metricOnPoints.inner x (c i) (c l)))⁻¹ i l * |
| 147 | B (Fin.cons (j (c i)) (Fin.cons (j (c l)) (fun a => V a q))) at h |
| 148 | rw [hg] at h |
| 149 | simp only [← hB, hc] at h |
| 150 | simpa only [horizontalTensorTrace, A, t, x, j] using h |
| 151 | |
| 152 | /-- Permuting the covariant slots preserves smoothness. -/ |
| 153 | theorem IsSmoothHorizontalCovariantTensor.perm {k : ℕ} |
| 154 | {T : HorizontalCovariantTensorEvaluation F k} |
| 155 | (hT : IsSmoothHorizontalCovariantTensor F T) (σ : Equiv.Perm (Fin k)) : |
| 156 | IsSmoothHorizontalCovariantTensor F (fun p v => T p (v ∘ σ)) := by |
| 157 | constructor |
| 158 | · intro p |
| 159 | obtain ⟨A, hA⟩ := hT.1 p |
| 160 | exact ⟨A.domDomCongr σ, fun v => hA _⟩ |
| 161 | · intro U hU V hV |
| 162 | exact hT.2 U hU (fun i => V (σ i)) (fun i => hV (σ i)) |
| 163 | |
| 164 | /-- Ricci curvature is a smooth contraction of the horizontal Riemann tensor. -/ |
| 165 | theorem horizontalRicci_tensor_of_riemann |
| 166 | (D : LeafwiseLeviCivitaFamily F S) |
| 167 | (hR : IsSmoothHorizontalCovariantTensor F (k := 4) |
| 168 | (fun p v => horizontalRiemann D p (v 0) (v 1) (v 2) (v 3))) : |
| 169 | IsSmoothHorizontalCovariantTensor F (k := 2) |
| 170 | (fun p v => horizontalRicci D p (v 0) (v 1)) := by |
| 171 | let σ : Equiv.Perm (Fin 4) := Equiv.ofBijective ![2, 0, 3, 1] (by decide) |
| 172 | have h := (hR.perm σ).tensorTrace (S := S) |
| 173 | convert h using 1 |
| 174 | funext p v |
| 175 | let x := spacetimeSlicePoint S p |
| 176 | let j := (S (F.timeFunction p)).tangentEquiv x |
| 177 | let b := (S (F.timeFunction p)).metricOnPoints.orthonormalBasis x |
| 178 | change (∑ i, (D.sliceConnection (F.timeFunction p)).curvatureTensor x |
| 179 | (j.symm (v 0)) (b i) (j.symm (v 1)) (b i)) = |
| 180 | ∑ i, (D.sliceConnection (F.timeFunction p)).curvatureTensor x |
| 181 | (j.symm (v 0)) (j.symm (j (b i))) (j.symm (v 1)) (j.symm (j (b i))) |
| 182 | simp only [ContinuousLinearEquiv.symm_apply_apply] |
| 183 | |
| 184 | /-- The scalar curvature is the smooth metric trace of horizontal Ricci. -/ |
| 185 | theorem horizontalScalarCurvature_smooth_of_ricci |
| 186 | (D : LeafwiseLeviCivitaFamily F S) |
| 187 | (hRic : IsSmoothHorizontalCovariantTensor F (k := 2) |
| 188 | (fun p v => horizontalRicci D p (v 0) (v 1))) : |
| 189 | ContMDiff (spacetimeModel n) 𝓘(ℝ) ∞ (horizontalScalarCurvature D) := by |
| 190 | have h := hRic.tensorTrace (S := S) (k := 0) |
| 191 | have hs := h.2 Set.univ isOpen_univ (fun i => Fin.elim0 i) (fun i => Fin.elim0 i) |
| 192 | rw [contMDiffOn_univ] at hs |
| 193 | convert hs using 1 |
| 194 | funext p |
| 195 | let x := spacetimeSlicePoint S p |
| 196 | let j := (S (F.timeFunction p)).tangentEquiv x |
| 197 | let b := (S (F.timeFunction p)).metricOnPoints.orthonormalBasis x |
| 198 | change (∑ i, (D.sliceConnection (F.timeFunction p)).ricci x (b i) (b i)) = |
| 199 | ∑ i, (D.sliceConnection (F.timeFunction p)).ricci x |
| 200 | (j.symm (j (b i))) (j.symm (j (b i))) |
| 201 | simp only [ContinuousLinearEquiv.symm_apply_apply] |
| 202 | |
| 203 | end PoincareMT |