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 Mathlib.Analysis.InnerProductSpace.Positive |
| 2 | import Mathlib.Analysis.InnerProductSpace.PiL2 |
| 3 | import Mathlib.Topology.Order.Compact |
| 4 | import Mathlib.Algebra.QuadraticDiscriminant |
| 5 | |
| 6 | /-! |
| 7 | # Variational partial traces |
| 8 | |
| 9 | The minimum trace on orthonormal `k`-frames detects every kernel-dimension |
| 10 | threshold of a positive operator. This is the finite-dimensional scalar |
| 11 | carrier for the tensor maximum-principle route to Ricci-flow splitting. |
| 12 | -/ |
| 13 | |
| 14 | set_option autoImplicit false |
| 15 | |
| 16 | noncomputable section |
| 17 | |
| 18 | open Set |
| 19 | open scoped RealInnerProductSpace |
| 20 | |
| 21 | namespace Poincare.RicciFlow.Splitting |
| 22 | |
| 23 | variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] |
| 24 | [FiniteDimensional ℝ E] |
| 25 | |
| 26 | /-- The trace of an operator on an indexed orthonormal frame. -/ |
| 27 | def frameTrace {k : ℕ} (A : E →L[ℝ] E) (v : Fin k → E) : ℝ := |
| 28 | ∑ i, inner ℝ (A (v i)) (v i) |
| 29 | |
| 30 | /-- The least trace on an orthonormal `k`-frame. The useful range is |
| 31 | `k ≤ Module.finrank ℝ E`. -/ |
| 32 | def partialTrace (k : ℕ) (A : E →L[ℝ] E) : ℝ := |
| 33 | sInf (frameTrace A '' {v : Fin k → E | Orthonormal ℝ v}) |
| 34 | |
| 35 | theorem isCompact_orthonormal_frames (k : ℕ) : |
| 36 | IsCompact {v : Fin k → E | Orthonormal ℝ v} := by |
| 37 | have hclosed : IsClosed {v : Fin k → E | Orthonormal ℝ v} := by |
| 38 | simp_rw [orthonormal_iff_ite, Set.ofPred_forall] |
| 39 | exact isClosed_iInter fun i => isClosed_iInter fun j => |
| 40 | isClosed_eq ((continuous_apply i).inner (continuous_apply j)) continuous_const |
| 41 | apply (isCompact_univ_pi fun _ : Fin k => isCompact_closedBall (0 : E) 1).of_isClosed_subset |
| 42 | hclosed |
| 43 | intro v hv i _ |
| 44 | simp [Metric.mem_closedBall, dist_zero_right, hv.norm_eq_one i] |
| 45 | |
| 46 | theorem exists_orthonormal_frame {k : ℕ} (hk : k ≤ Module.finrank ℝ E) : |
| 47 | ∃ v : Fin k → E, Orthonormal ℝ v := by |
| 48 | exact ⟨(stdOrthonormalBasis ℝ E) ∘ Fin.castLE hk, |
| 49 | (stdOrthonormalBasis ℝ E).orthonormal.comp _ (Fin.castLE_injective hk)⟩ |
| 50 | |
| 51 | omit [FiniteDimensional ℝ E] in |
| 52 | theorem continuous_frameTrace {k : ℕ} (A : E →L[ℝ] E) : |
| 53 | Continuous (frameTrace (k := k) A) := by |
| 54 | unfold frameTrace |
| 55 | exact continuous_finsetSum _ fun i _ => |
| 56 | (A.continuous.comp (continuous_apply i)).inner (continuous_apply i) |
| 57 | |
| 58 | theorem exists_minimizing_frame {k : ℕ} (hk : k ≤ Module.finrank ℝ E) |
| 59 | (A : E →L[ℝ] E) : |
| 60 | ∃ v : Fin k → E, Orthonormal ℝ v ∧ |
| 61 | frameTrace A v = partialTrace k A := by |
| 62 | obtain ⟨v, hv, hmin⟩ := (isCompact_orthonormal_frames (E := E) k).exists_isMinOn |
| 63 | (exists_orthonormal_frame hk) (continuous_frameTrace A).continuousOn |
| 64 | refine ⟨v, hv, ?_⟩ |
| 65 | apply le_antisymm |
| 66 | · exact le_csInf ⟨_, mem_image_of_mem _ hv⟩ (by |
| 67 | rintro _ ⟨w, hw, rfl⟩ |
| 68 | exact hmin hw) |
| 69 | · exact csInf_le |
| 70 | ((isCompact_orthonormal_frames (E := E) k).image (continuous_frameTrace A)).bddBelow |
| 71 | (mem_image_of_mem _ hv) |
| 72 | |
| 73 | theorem partialTrace_le_frameTrace {k : ℕ} (A : E →L[ℝ] E) |
| 74 | {v : Fin k → E} (hv : Orthonormal ℝ v) : |
| 75 | partialTrace k A ≤ frameTrace A v := by |
| 76 | exact csInf_le |
| 77 | ((isCompact_orthonormal_frames (E := E) k).image (continuous_frameTrace A)).bddBelow |
| 78 | (mem_image_of_mem _ hv) |
| 79 | |
| 80 | omit [FiniteDimensional ℝ E] in |
| 81 | theorem frameTrace_sub_bound {k : ℕ} (A B : E →L[ℝ] E) |
| 82 | {v : Fin k → E} (hv : Orthonormal ℝ v) : |
| 83 | |frameTrace A v - frameTrace B v| ≤ k * ‖A - B‖ := by |
| 84 | have hterm (i : Fin k) : |inner ℝ ((A - B) (v i)) (v i)| ≤ ‖A - B‖ := by |
| 85 | calc |
| 86 | _ ≤ ‖(A - B) (v i)‖ * ‖v i‖ := abs_real_inner_le_norm _ _ |
| 87 | _ = ‖(A - B) (v i)‖ := by rw [hv.norm_eq_one, mul_one] |
| 88 | _ ≤ ‖A - B‖ := by simpa [hv.norm_eq_one] using (A - B).le_opNorm (v i) |
| 89 | calc |
| 90 | _ = |∑ i, inner ℝ ((A - B) (v i)) (v i)| := by |
| 91 | simp only [frameTrace, sub_apply, inner_sub_left, |
| 92 | Finset.sum_sub_distrib] |
| 93 | _ ≤ ∑ i, |inner ℝ ((A - B) (v i)) (v i)| := Finset.abs_sum_le_sum_abs _ _ |
| 94 | _ ≤ ∑ _ : Fin k, ‖A - B‖ := Finset.sum_le_sum fun i _ => hterm i |
| 95 | _ = k * ‖A - B‖ := by simp |
| 96 | |
| 97 | theorem partialTrace_sub_bound {k : ℕ} (hk : k ≤ Module.finrank ℝ E) |
| 98 | (A B : E →L[ℝ] E) : |
| 99 | |partialTrace k A - partialTrace k B| ≤ k * ‖A - B‖ := by |
| 100 | obtain ⟨v, hv, hvmin⟩ := exists_minimizing_frame hk A |
| 101 | obtain ⟨w, hw, hwmin⟩ := exists_minimizing_frame hk B |
| 102 | have hAw := partialTrace_le_frameTrace A hw |
| 103 | have hBv := partialTrace_le_frameTrace B hv |
| 104 | have hvbound := frameTrace_sub_bound A B hv |
| 105 | have hwbound := frameTrace_sub_bound A B hw |
| 106 | rw [hvmin] at hvbound |
| 107 | rw [hwmin] at hwbound |
| 108 | rw [abs_le] at hvbound hwbound ⊢ |
| 109 | constructor <;> linarith |
| 110 | |
| 111 | theorem lipschitzWith_partialTrace {k : ℕ} (hk : k ≤ Module.finrank ℝ E) : |
| 112 | LipschitzWith k (partialTrace (E := E) k) := by |
| 113 | apply LipschitzWith.of_dist_le_mul |
| 114 | intro A B |
| 115 | simpa only [dist_eq_norm, Real.norm_eq_abs, NNReal.coe_natCast] using |
| 116 | partialTrace_sub_bound hk A B |
| 117 | |
| 118 | theorem continuous_partialTrace {k : ℕ} (hk : k ≤ Module.finrank ℝ E) : |
| 119 | Continuous (partialTrace (E := E) k) := |
| 120 | (lipschitzWith_partialTrace hk).continuous |
| 121 | |
| 122 | omit [FiniteDimensional ℝ E] in |
| 123 | theorem positive_inner_self_eq_zero_iff {A : E →L[ℝ] E} (hA : A.IsPositive) |
| 124 | (x : E) : inner ℝ (A x) x = 0 ↔ A x = 0 := by |
| 125 | constructor |
| 126 | · intro hx |
| 127 | have hpoly (t : ℝ) : |
| 128 | 0 ≤ inner ℝ (A (A x)) (A x) * (t * t) + |
| 129 | (2 * inner ℝ (A x) (A x)) * t + 0 := by |
| 130 | have hpos := hA.inner_nonneg_left (t • A x + x) |
| 131 | simp only [map_add, map_smul, inner_add_left, inner_add_right, |
| 132 | real_inner_smul_left, real_inner_smul_right, hx, |
| 133 | hA.inner_left_eq_inner_right (A x) x] at hpos |
| 134 | nlinarith |
| 135 | have hd := discrim_le_zero hpoly |
| 136 | simp only [discrim, mul_zero, sub_zero] at hd |
| 137 | apply (inner_self_eq_zero (𝕜 := ℝ)).mp |
| 138 | nlinarith [sq_nonneg (inner ℝ (A x) (A x))] |
| 139 | · intro hx |
| 140 | simp [hx] |
| 141 | |
| 142 | theorem partialTrace_nonneg {k : ℕ} (hk : k ≤ Module.finrank ℝ E) |
| 143 | {A : E →L[ℝ] E} (hA : A.IsPositive) : 0 ≤ partialTrace k A := by |
| 144 | obtain ⟨v, _, hmin⟩ := exists_minimizing_frame hk A |
| 145 | rw [← hmin] |
| 146 | exact Finset.sum_nonneg fun i _ => hA.inner_nonneg_left (v i) |
| 147 | |
| 148 | /-- A zero partial trace of a positive operator produces an entire orthonormal |
| 149 | frame in its kernel. -/ |
| 150 | theorem partialTrace_eq_zero_iff_kernel_frame {k : ℕ} |
| 151 | (hk : k ≤ Module.finrank ℝ E) {A : E →L[ℝ] E} (hA : A.IsPositive) : |
| 152 | partialTrace k A = 0 ↔ |
| 153 | ∃ v : Fin k → E, Orthonormal ℝ v ∧ ∀ i, A (v i) = 0 := by |
| 154 | constructor |
| 155 | · intro hzero |
| 156 | obtain ⟨v, hv, hmin⟩ := exists_minimizing_frame hk A |
| 157 | refine ⟨v, hv, fun i => (positive_inner_self_eq_zero_iff hA (v i)).mp ?_⟩ |
| 158 | have hsum : ∑ j, inner ℝ (A (v j)) (v j) = 0 := hmin.trans hzero |
| 159 | exact (Finset.sum_eq_zero_iff_of_nonneg |
| 160 | (fun j _ => hA.inner_nonneg_left (v j))).mp hsum i (Finset.mem_univ i) |
| 161 | · rintro ⟨v, hv, hker⟩ |
| 162 | apply le_antisymm _ (partialTrace_nonneg hk hA) |
| 163 | have hframe : frameTrace A v = 0 := by simp [frameTrace, hker] |
| 164 | simpa only [hframe] using partialTrace_le_frameTrace A hv |
| 165 | |
| 166 | /-- The variational partial trace detects every kernel-dimension threshold. -/ |
| 167 | theorem partialTrace_eq_zero_iff {k : ℕ} (hk : k ≤ Module.finrank ℝ E) |
| 168 | {A : E →L[ℝ] E} (hA : A.IsPositive) : |
| 169 | partialTrace k A = 0 ↔ k ≤ Module.finrank ℝ A.ker := by |
| 170 | rw [partialTrace_eq_zero_iff_kernel_frame hk hA] |
| 171 | constructor |
| 172 | · rintro ⟨v, hv, hker⟩ |
| 173 | let w : Fin k → A.ker := fun i => ⟨v i, hker i⟩ |
| 174 | have hw : Orthonormal ℝ w := |
| 175 | A.ker.subtypeₗᵢ.orthonormal_comp_iff.mp hv |
| 176 | simpa using hw.linearIndependent.fintype_card_le_finrank |
| 177 | · intro hdim |
| 178 | obtain ⟨w, hw⟩ := exists_orthonormal_frame hdim |
| 179 | exact ⟨fun i => (w i : E), A.ker.subtypeₗᵢ.orthonormal_comp_iff.mpr hw, |
| 180 | fun i => (w i).property⟩ |
| 181 | |
| 182 | end Poincare.RicciFlow.Splitting |