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.SpecialFunctions.Pow.Real |
| 2 | import Mathlib.Analysis.SpecialFunctions.Sqrt |
| 3 | import Mathlib.Algebra.Order.BigOperators.Ring.Finset |
| 4 | import Mathlib.Tactic |
| 5 | |
| 6 | /-! |
| 7 | # Absorbing the approximation error in spectral counting |
| 8 | |
| 9 | Balancing an error of order `ε² w` with a trace bound of order `ε⁻ⁿ` |
| 10 | gives a counting bound of order `w^(n/2)`. |
| 11 | -/ |
| 12 | |
| 13 | namespace Poincare.Analysis.Spectral.Counting |
| 14 | |
| 15 | theorem sqrt_pow_eq_rpow {x : ℝ} (hx : 0 ≤ x) (n : ℕ) : |
| 16 | (Real.sqrt x) ^ n = x ^ ((n : ℝ) / 2) := by |
| 17 | rw [Real.sqrt_eq_rpow, ← Real.rpow_natCast, ← Real.rpow_mul hx] |
| 18 | congr 1 |
| 19 | ring |
| 20 | |
| 21 | /-- The constants in a small-radius error bound give the sharp dimensional |
| 22 | exponent after the error is absorbed. -/ |
| 23 | theorem le_rpow_of_le_error_add_inverse_pow {N A B w : ℝ} (n : ℕ) |
| 24 | (hN : 0 ≤ N) (hA : 0 ≤ A) (hw : 1 ≤ w) |
| 25 | (hbound : ∀ ε : ℝ, 0 < ε → ε ≤ 1 → |
| 26 | N ≤ A * ε ^ 2 * w * N + B / ε ^ n) : |
| 27 | N ≤ (2 * B * (2 * (A + 1)) ^ ((n : ℝ) / 2)) * w ^ ((n : ℝ) / 2) := by |
| 28 | let r : ℝ := Real.sqrt (2 * (A + 1) * w) |
| 29 | have hwpos : 0 < w := lt_of_lt_of_le zero_lt_one hw |
| 30 | have hx : 0 < 2 * (A + 1) * w := by positivity |
| 31 | have hr : 0 < r := Real.sqrt_pos.mpr hx |
| 32 | have hrsq : r ^ 2 = 2 * (A + 1) * w := Real.sq_sqrt hx.le |
| 33 | have hrone : 1 ≤ r := by |
| 34 | have : 1 ≤ 2 * (A + 1) * w := by nlinarith |
| 35 | dsimp [r] |
| 36 | exact (Real.le_sqrt (by norm_num) hx.le).mpr (by simpa using this) |
| 37 | have he : 0 < r⁻¹ := inv_pos.mpr hr |
| 38 | have heone : r⁻¹ ≤ 1 := (inv_le_one₀ hr).mpr hrone |
| 39 | have herr : A * (r⁻¹) ^ 2 * w ≤ 1 / 2 := by |
| 40 | rw [inv_pow, ← div_eq_mul_inv, div_mul_eq_mul_div, hrsq] |
| 41 | apply (div_le_iff₀ hx).mpr |
| 42 | nlinarith |
| 43 | have hb := hbound r⁻¹ he heone |
| 44 | have hn : N ≤ 2 * B * r ^ n := by |
| 45 | have heN := mul_le_mul_of_nonneg_right herr hN |
| 46 | simp only [inv_pow, div_inv_eq_mul] at hb heN |
| 47 | nlinarith |
| 48 | refine hn.trans_eq ?_ |
| 49 | dsimp [r] |
| 50 | rw [sqrt_pow_eq_rpow hx.le, |
| 51 | Real.mul_rpow (by positivity : 0 ≤ 2 * (A + 1)) hwpos.le] |
| 52 | ring |
| 53 | |
| 54 | /-- Finite Cauchy--Schwarz turns a lower bound on a sum of chart norms into |
| 55 | a lower bound on their squared norms. -/ |
| 56 | theorem one_le_four_mul_weighted_sq_sum {ι : Type*} (s : Finset ι) |
| 57 | (a b : ι → ℝ) (h : 1 / 2 ≤ ∑ i ∈ s, a i * b i) : |
| 58 | 1 ≤ 4 * (∑ i ∈ s, a i ^ 2) * ∑ i ∈ s, b i ^ 2 := by |
| 59 | have hcs := Finset.sum_mul_sq_le_sq_mul_sq s a b |
| 60 | nlinarith |
| 61 | |
| 62 | theorem norm_sq_le_two_mul_sub_sq_add (K : Type*) [SeminormedAddCommGroup K] |
| 63 | (x y : K) : ‖x‖ ^ 2 ≤ 2 * ‖x - y‖ ^ 2 + 2 * ‖y‖ ^ 2 := by |
| 64 | have h' : ‖x‖ ≤ ‖x - y‖ + ‖y‖ := norm_le_norm_sub_add x y |
| 65 | nlinarith [sq_nonneg (‖x - y‖ - ‖y‖), norm_nonneg (x - y), norm_nonneg x, |
| 66 | norm_nonneg y] |
| 67 | |
| 68 | /-- Sum the localization reconstruction bound and absorb the approximation |
| 69 | errors into one scalar inequality. -/ |
| 70 | theorem card_le_error_add_trace {ι J K : Type*} [Fintype J] |
| 71 | [SeminormedAddCommGroup K] (s : Finset ι) (v z : ι → J → K) |
| 72 | {C A B : ℝ} (hC : 0 ≤ C) |
| 73 | (hrec : ∀ i ∈ s, 1 ≤ C * ∑ j, ‖v i j‖ ^ 2) |
| 74 | (herr : ∀ i ∈ s, ∑ j, ‖v i j - z i j‖ ^ 2 ≤ A) |
| 75 | (htrace : ∑ j, ∑ i ∈ s, ‖z i j‖ ^ 2 ≤ B) : |
| 76 | (s.card : ℝ) ≤ 2 * C * A * s.card + 2 * C * B := by |
| 77 | have hpoint (i : ι) (hi : i ∈ s) : |
| 78 | 1 ≤ 2 * C * A + 2 * C * ∑ j, ‖z i j‖ ^ 2 := by |
| 79 | have hb := Finset.sum_le_sum (s := Finset.univ) fun j hj => |
| 80 | norm_sq_le_two_mul_sub_sq_add K (v i j) (z i j) |
| 81 | rw [Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.mul_sum] at hb |
| 82 | have h := (hrec i hi).trans (mul_le_mul_of_nonneg_left hb hC) |
| 83 | have he := mul_le_mul_of_nonneg_left (herr i hi) (by positivity : 0 ≤ 2 * C) |
| 84 | nlinarith |
| 85 | have hsum := Finset.sum_le_sum hpoint |
| 86 | simp only [Finset.sum_const, nsmul_eq_mul, Finset.sum_add_distrib, |
| 87 | ← Finset.mul_sum] at hsum |
| 88 | rw [Finset.sum_comm] at hsum |
| 89 | have ht := mul_le_mul_of_nonneg_left htrace (by positivity : 0 ≤ 2 * C) |
| 90 | nlinarith |
| 91 | |
| 92 | /-- A bound on all finite subsets bounds the cardinality of the whole set. -/ |
| 93 | theorem finite_ncard_le_of_finset_card_le {ι : Type*} (S : Set ι) {C : ℝ} |
| 94 | (h : ∀ s : Finset ι, (↑s : Set ι) ⊆ S → (s.card : ℝ) ≤ C) : |
| 95 | S.Finite ∧ (S.ncard : ℝ) ≤ C := by |
| 96 | classical |
| 97 | have hfin : S.Finite := by |
| 98 | by_contra hfin |
| 99 | obtain ⟨n, hn⟩ := exists_nat_gt C |
| 100 | obtain ⟨s, hs, hcard⟩ := Set.Infinite.exists_subset_card_eq hfin n |
| 101 | have hb := h s hs |
| 102 | rw [hcard] at hb |
| 103 | exact (not_le_of_gt hn) hb |
| 104 | refine ⟨hfin, ?_⟩ |
| 105 | rw [Set.ncard_eq_toFinset_card S hfin] |
| 106 | exact h hfin.toFinset (by simp) |
| 107 | |
| 108 | end Poincare.Analysis.Spectral.Counting |