Riemann hypothesis: the Lean proof, cleaned up together
The 2026 Lean proof of the Riemann hypothesis and GRH, machine-checked by others, not refereed, no word from Clay; cleaned up together: more readable, faster to build, the theorems unchanged

| 1 | module |
| 2 | |
| 3 | public import Lib.Shimura.HeckeTower.HeckeData |
| 4 | import Lib.General.LinearAlgebra.Eigenvalues |
| 5 | import TauCeti.LinearAlgebra.Matrix.Diagonal |
| 6 | |
| 7 | /-! |
| 8 | # Eigenline reflections of a separable matrix, and the term of the count at a marked triple |
| 9 | |
| 10 | Invariance properties of the terms of the point count `New.Variety.countTerm`, a function on |
| 11 | GL_n(E)-orbits of triples (coset xK, rational matrix y, index μ of a root), the type |
| 12 | `MarkedTriple (levelGU n 𝔑) n`. |
| 13 | |
| 14 | * `New.Variety.isReflection_markedReflection` and |
| 15 | `New.Variety.exists_eq_markedReflection_iff_of_ratConj_eq` (bundled as |
| 16 | `New.Variety.isReflection_markedReflection_and_exists_eq_iff`): for y with separable |
| 17 | characteristic polynomial, the matrices `New.Variety.markedReflection y i` are reflections, and |
| 18 | each reflection that commutes with y equals exactly one of them. |
| 19 | * `New.Variety.countTerm_mk`: the term of an orbit may be computed at any representative. |
| 20 | * `New.Variety.finsum_countTerm_eq_sum`: the weighted count as a finite sum over the support of the |
| 21 | count of weight 1. |
| 22 | |
| 23 | `New.Variety.IsReflection J` says J = u wᵀ - 1 with w · u = 2. `New.Variety.ratConj z` conjugates by |
| 24 | Φ_{v₀}(z), the image of z in GL_n(ℂ) under the fixed embedding Φ v₀ : E → ℂ used throughout. |
| 25 | `New.Variety.IsSignedFrame x J` says that x is a frame for a rational form whose signature is given |
| 26 | by J. |
| 27 | |
| 28 | Notions from other files: |
| 29 | * `New.Variety.heckeAlgebra`: the Hecke algebra of level K(𝔑): the subalgebra of elements ∑ a_g [g] |
| 30 | of ℂ[GL_n(𝔸_f)] that are supported on `GUPlus E n` and whose function ∑ a_g 1_{gK} is left |
| 31 | K(𝔑)-invariant. |
| 32 | * `New.Variety.levelGU`: the principal level K(𝔑), the similitudes in `GL_n(Ô E)` that are congruent |
| 33 | to `1` modulo `𝔑`. |
| 34 | * `New.Variety.toFinGL`: The diagonal embedding of GL_n(E) in GL_n of the finite adeles of E. |
| 35 | * `New.Variety.heckeCosetFn f`: for f = ∑ a_g [g] in the Hecke algebra, the function ∑ a_g 1_{gK} on |
| 36 | the cosets of the level `K`. |
| 37 | * `New.Variety.eigenReflection ε y μ`: if `ε` holds, the matrix `New.Variety.markedReflection y μ`, |
| 38 | a polynomial in Φ_{v₀}(y) that is `1` on the eigenline of the `μ`-th listed root of the |
| 39 | characteristic polynomial and `-1` on the other eigenlines; if `ε` fails, the identity. |
| 40 | |
| 41 | ## Relation to the literature |
| 42 | |
| 43 | Known; see `Lib.Shimura.Transfer.WeightOccurs` and `Lib.Shimura.TraceFormula.MarkedDefiniteSums` for |
| 44 | sources. |
| 45 | -/ |
| 46 | |
| 47 | @[expose] public section |
| 48 | |
| 49 | open NumberField Finset Matrix Polynomial Lagrange MulAction Quotient ConjAct |
| 50 | |
| 51 | namespace New.Variety |
| 52 | |
| 53 | variable {E n : Type} [Field E] [CMBase E] [Fintype n] [DecidableEq n] {x g : GL n (𝔸f E)} |
| 54 | {ℓ : Matrix n n ℂ} {y : GL n E} {𝔑 : 𝓞 E} {f : heckeAlgebra n ℂ 𝔑} |
| 55 | |
| 56 | /-- For y, z in GL_n(E), conjugating the eigenline reflection `New.Variety.eigenReflection` of y by |
| 57 | Φ_{v₀}(z) gives the eigenline reflection of zyz⁻¹. -/ |
| 58 | lemma ratConj_eigenReflection {ε : Prop} {μ : n} (z : GL n E) : |
| 59 | ratConj z (eigenReflection ε y μ) = eigenReflection ε (z * y * z⁻¹) μ := by |
| 60 | simp [eigenReflection, ratConj, ← aeval_smul, units_smul_def, ← map_inv] |
| 61 | |
| 62 | /-- The signature condition is unchanged when `x` is multiplied by a similitude `g` (an element of |
| 63 | `GU E n`) on the right, or by a rational `z` on the left with `ℓ` conjugated by `z`. -/ |
| 64 | lemma isSignedFrame_mul_iff (z : GL n E) (hg_GU : g ∈ GU E n) : |
| 65 | IsSignedFrame (x * g) ℓ ↔ IsSignedFrame (toFinGL z * x) (ratConj z ℓ) := |
| 66 | ⟨fun hx ↦ by simpa [mul_assoc] using hx.mul z (inv_mem hg_GU), |
| 67 | fun hx ↦ by simpa [ratConj] using hx.mul z⁻¹ hg_GU⟩ |
| 68 | |
| 69 | /-- If the unweighted count `countTerm ε f 1` has finite support, the count with weight `w` is a |
| 70 | finite sum over that support. For the chosen representative `(xK, y, μ)` of an orbit, the weight is |
| 71 | read at the characteristic polynomial of `y` and at the mark `μ`. -/ |
| 72 | lemma finsum_countTerm_eq_sum {ε : Prop} (w : E[X] → n → ℂ) |
| 73 | (h_fin : (countTerm ε f 1).support.Finite) : |
| 74 | ∑ᶠ c : orbitRel.Quotient (GL n E) (MarkedTriple (levelGU n 𝔑) n), countTerm ε f w c = |
| 75 | ∑ c ∈ h_fin.toFinset, countTerm ε f 1 c * w c.out.2.1.val.charpoly c.out.2.2 := by |
| 76 | -- The weight `w` factors out of each term, so the terms vanish off the support of |
| 77 | -- `countTerm ε f 1`. |
| 78 | have h_term (c : orbitRel.Quotient (GL n E) (MarkedTriple (levelGU n 𝔑) n)) : |
| 79 | countTerm ε f w c = countTerm ε f 1 c * w c.out.2.1.val.charpoly c.out.2.2 := by |
| 80 | rcases h_out : c.out with ⟨q, z, μ⟩ |
| 81 | simp [countTerm, h_out, ite_mul] |
| 82 | rw [funext h_term, finsum_eq_sum_of_support_subset] |
| 83 | -- The remaining goal: the support of the weighted term lies in that of `countTerm ε f 1`. |
| 84 | simp |
| 85 | |
| 86 | /-- For `y` with separable characteristic polynomial, some `k` conjugates the diagonal matrix of |
| 87 | the listed roots `numberedRoots (Φ v₀) _` of that polynomial to Φ_{v₀}(y), and the diagonal matrix |
| 88 | with `1` at `i` and `-1` elsewhere to `markedReflection y i`, for every `i`. -/ |
| 89 | private lemma exists_conj_diagonal_markedReflection (hy_sep : y.val.charpoly.Separable) : |
| 90 | ∃ k : GL n ℂ, |
| 91 | y.val.map (Φ v₀) = toConjAct k • diagonalAlgHom ℂ (numberedRoots (Φ v₀) y.val.charpoly) ∧ |
| 92 | ∀ i : n, markedReflection y i = toConjAct k • (diagonal (Pi.single i 2) - 1) := by |
| 93 | set ρ : n ↪ ℂ := numberedRoots (Φ v₀) y.val.charpoly |
| 94 | obtain ⟨k, hk⟩ : IsConj (diagonal ρ) (y.val.map (Φ v₀)) := |
| 95 | isConj_diagonal_of_isRoot_charpoly (isRoot_numberedRoots hy_sep _) |
| 96 | have hy_diag : y.val.map (Φ v₀) = toConjAct k • diagonalAlgHom ℂ ρ := by |
| 97 | simp [units_smul_def, hk.eq] |
| 98 | refine ⟨k, hy_diag, fun i ↦ ?_⟩ |
| 99 | -- The Lagrange polynomial takes the value `±1` at each listed root. |
| 100 | have h_eval : aeval (ρ : n → ℂ) (interpolate univ ρ fun j : n ↦ if j = i then 1 else -1) = |
| 101 | fun j : n ↦ Pi.single i (2 : ℂ) j - 1 := by |
| 102 | ext j |
| 103 | simp only [aeval_pi_apply, coe_aeval_eq_eval, eval_interpolate_univ_node] |
| 104 | grind |
| 105 | rw [markedReflection_eq_aeval, hy_diag, aeval_smul, aeval_algHom_apply, h_eval, |
| 106 | diagonalAlgHom_apply, ← diagonal_one, diagonal_sub] |
| 107 | |
| 108 | /-- For `y` with separable characteristic polynomial, `markedReflection y i` is a reflection (a |
| 109 | matrix `u wᵀ - 1` with `w ⬝ᵥ u = 2`). It is the polynomial in Φ_{v₀}(y) that is `1` on the |
| 110 | eigenline of the `i`-th listed root `numberedRoots (Φ v₀) _ i` of the characteristic polynomial and |
| 111 | `-1` on the other eigenlines. -/ |
| 112 | lemma isReflection_markedReflection (hy_sep : y.val.charpoly.Separable) (i : n) : |
| 113 | IsReflection (markedReflection y i) := by |
| 114 | obtain ⟨k, h_eig⟩ : ∃ k : GL n ℂ, |
| 115 | markedReflection y i = toConjAct k • (diagonal (Pi.single i 2) - 1) := |
| 116 | (exists_conj_diagonal_markedReflection hy_sep).imp fun k ⟨_, h_eig⟩ ↦ h_eig i |
| 117 | -- Take for `u` the `i`-th basis vector and for `w` twice that vector. |
| 118 | have h_uw : diagonal (Pi.single i 2) = vecMulVec (Pi.single i (1 : ℂ)) (Pi.single i 2) := by |
| 119 | ext a b |
| 120 | grind [vecMulVec_apply, diagonal_apply] |
| 121 | rw [h_eig, h_uw, units_smul_def, ofConjAct_toConjAct] |
| 122 | exact IsReflection.conj k ⟨Pi.single i 1, Pi.single i 2, by simp, rfl⟩ |
| 123 | |
| 124 | /-- Let `y` have separable characteristic polynomial, and let `J` be a reflection fixed by |
| 125 | conjugation with Φ_{v₀}(y). Then `J` equals `markedReflection y i` for exactly one `i`, and |
| 126 | Φ_{v₀}(y) acts on the image of `J + 1` by the `i`-th listed root `numberedRoots (Φ v₀) _ i` of its |
| 127 | characteristic polynomial. -/ |
| 128 | lemma exists_eq_markedReflection_iff_of_ratConj_eq (hy_sep : y.val.charpoly.Separable) |
| 129 | {J : Matrix n n ℂ} (hJ : IsReflection J) (h_fix : ratConj y J = J) : |
| 130 | ∃ i : n, y.val.map (Φ v₀) * (J + 1) = numberedRoots (Φ v₀) y.val.charpoly i • (J + 1) ∧ |
| 131 | ∀ j : n, J = markedReflection y j ↔ i = j := by |
| 132 | -- Diagonalise: Φ_{v₀}(y) = k • diagonal ρ with distinct `ρ i`; then `markedReflection y i` is |
| 133 | -- `k • (2 e_i e_iᵀ - 1)`. A reflection `k • (u wᵀ - 1)` that commutes with `k • diagonal ρ` has |
| 134 | -- `u wᵀ` diagonal, so `u wᵀ = 2 e_i e_iᵀ` for one `i`. |
| 135 | set ρ : n ↪ ℂ := numberedRoots (Φ v₀) y.val.charpoly |
| 136 | obtain ⟨k, hy_diag, h_eig⟩ : ∃ k : GL n ℂ, y.val.map (Φ v₀) = toConjAct k • diagonalAlgHom ℂ ρ ∧ |
| 137 | ∀ i : n, markedReflection y i = toConjAct k • (diagonal (Pi.single i 2) - 1) := |
| 138 | exists_conj_diagonal_markedReflection hy_sep |
| 139 | -- In the basis `k` the reflection `J` is `u wᵀ - 1` with `w ⬝ᵥ u = 2`. |
| 140 | obtain ⟨u, w, h_dot, hJ_uw⟩ : IsReflection ((toConjAct k)⁻¹ • J) := by |
| 141 | simpa [units_smul_def] using hJ.conj k⁻¹ |
| 142 | obtain rfl : J = toConjAct k • (vecMulVec u w - 1) := inv_smul_eq_iff.mp hJ_uw |
| 143 | -- As `J` is fixed, `diagonal ρ` commutes with `u wᵀ`; so `u a * w b = 0` for `a ≠ b`. |
| 144 | have h_comm : diagonal ρ * vecMulVec u w = vecMulVec u w * diagonal ρ := by |
| 145 | rw [ratConj, units_smul_def, ofConjAct_toConjAct, Units.mul_inv_eq_iff_eq_mul] at h_fix |
| 146 | simpa [hy_diag, ← smul_mul', mul_sub, sub_mul, smul_left_cancel_iff] using h_fix |
| 147 | have h_diag (a b : n) : a = b ∨ u a = 0 ∨ w b = 0 := by |
| 148 | exact or_iff_not_imp_left.mpr fun hab ↦ |
| 149 | mul_eq_zero.mp (TauCeti.apply_eq_zero_of_commute_diagonal h_comm (ρ.injective.ne hab)) |
| 150 | -- Some term `w i * u i` of `w ⬝ᵥ u = 2` is not zero; by `h_diag`, `u` and `w` vanish off `i`. |
| 151 | obtain ⟨i, -, h_wu_ne⟩ := exists_ne_zero_of_sum_ne_zero (h_dot.trans_ne two_ne_zero) |
| 152 | have h_off (b : n) (hb : b ≠ i) : w b * u b = 0 := by grind [h_diag b i] |
| 153 | have h_wu_two : w i * u i = 2 := by rw [← h_dot, dotProduct, Fintype.sum_eq_single i h_off] |
| 154 | have h_uw : vecMulVec u w = diagonal (Pi.single i 2) := by |
| 155 | ext a b |
| 156 | grind [vecMulVec_apply, diagonal_apply] |
| 157 | rw [h_uw] |
| 158 | refine ⟨i, ?_, fun j ↦ ?_⟩ |
| 159 | · -- `J + 1 = k • diagonal (Pi.single i 2)`, on which Φ_{v₀}(y) acts by `ρ i`. |
| 160 | have h_ρ : diagonal ρ * diagonal (Pi.single i (2 : ℂ)) = ρ i • diagonal (Pi.single i 2) := by |
| 161 | simp +contextual [← diagonal_smul, Pi.single_apply] |
| 162 | simp [smul_sub, hy_diag, ← smul_mul', h_ρ, smul_comm (ρ i)] |
| 163 | · rw [h_eig, smul_left_cancel_iff, sub_left_inj, diagonal_injective.eq_iff] |
| 164 | exact ⟨fun h ↦ by simpa [Pi.single_apply] using congrFun h i, fun h ↦ by rw [h]⟩ |
| 165 | |
| 166 | /-- For `y` with separable characteristic polynomial, each `markedReflection y i` is a reflection |
| 167 | (`isReflection_markedReflection`), and a reflection `J` fixed by conjugation with Φ_{v₀}(y) equals |
| 168 | `markedReflection y i` for exactly one `i`, whose eigenline contains the image of `J + 1` |
| 169 | (`exists_eq_markedReflection_iff_of_ratConj_eq`). -/ |
| 170 | lemma isReflection_markedReflection_and_exists_eq_iff (hy_sep : y.val.charpoly.Separable) : |
| 171 | (∀ i : n, IsReflection (markedReflection y i)) ∧ |
| 172 | ∀ J : Matrix n n ℂ, IsReflection J → ratConj y J = J → |
| 173 | ∃ i : n, y.val.map (Φ v₀) * (J + 1) = numberedRoots (Φ v₀) y.val.charpoly i • (J + 1) ∧ |
| 174 | ∀ j : n, J = markedReflection y j ↔ i = j := |
| 175 | ⟨isReflection_markedReflection hy_sep, fun _ hJ h_fix ↦ |
| 176 | exists_eq_markedReflection_iff_of_ratConj_eq hy_sep hJ h_fix⟩ |
| 177 | |
| 178 | /-- For `x` in the level `K = levelGU n 𝔑`, the function `heckeCosetFn f` of an element `f` of the |
| 179 | Hecke algebra takes the same value at the cosets of `x⁻¹ g x` and of `g`. -/ |
| 180 | lemma heckeAlgebra.heckeCosetFn_conj (hx_level : x ∈ levelGU n 𝔑) : |
| 181 | heckeCosetFn f (x⁻¹ * g * x) = heckeCosetFn f g := by |
| 182 | -- `f` sends the basis vector of the coset `K` to the vector `v` whose coefficients are the values |
| 183 | -- of `heckeCosetFn f`; as `f` lies in the Hecke algebra, `v` is fixed by `x ∈ K`. |
| 184 | set π := Representation.ofMulAction ℂ (GL n (𝔸f E)) (GL n (𝔸f E) ⧸ levelGU n 𝔑) |
| 185 | set v : MonoidAlgebra ℂ (GL n (𝔸f E) ⧸ levelGU n 𝔑) := |
| 186 | π.asAlgebraHom f.val (MonoidAlgebra.single ⟦1⟧ 1) |
| 187 | have h_fixed : π x v = v := by simpa using f.property.2 single_one_mem_levelSpace ⟨x, hx_level⟩ |
| 188 | calc heckeCosetFn f ↑(x⁻¹ * g * x) = v.coeff (x⁻¹ • ↑g) := by |
| 189 | simp [v, π, cosetFn, QuotientGroup.mk_mul_of_mem _ hx_level] |
| 190 | _ = (π x v).coeff ↑g := (Representation.coeff_ofMulAction x v _).symm |
| 191 | _ = heckeCosetFn f ↑g := by rw [h_fixed, heckeCosetFn, cosetFn] |
| 192 | |
| 193 | /-- If the function `heckeCosetFn f` of an element `f` of the Hecke algebra does not vanish at the |
| 194 | coset of `g`, then `g` lies in `GUPlus E n`, the similitudes whose inverse has integral |
| 195 | entries. -/ |
| 196 | lemma heckeAlgebra.mem_GUPlus_of_ne_zero (hg_ne : heckeCosetFn f g ≠ 0) : g ∈ GUPlus E n := by |
| 197 | -- `g` lies in the coset of some `d` in `GUPlus E n`, and the level is contained in `GUPlus E n`. |
| 198 | obtain ⟨d, hd_mem, hd_coset⟩ : ∃ d ∈ GUPlus E n, (d : GL n (𝔸f E) ⧸ levelGU n 𝔑) = g := |
| 199 | spanOn.exists_mem_of_cosetFn_ne_zero f.property.1 hg_ne |
| 200 | simpa using mul_mem hd_mem (mem_GUPlus_of_mem_levelGU (QuotientGroup.eq.mp hd_coset)) |
| 201 | |
| 202 | open scoped Classical in |
| 203 | /-- The term `countTerm ε f w` of the orbit of the triple `(xK, y, μ)` may be computed at this |
| 204 | triple: if `x` is a signed frame for `eigenReflection ε y μ`, it is |
| 205 | `heckeCosetFn f (invAutInFrame y x) * w (charpoly y) μ` with `invAutInFrame y x = x⁻¹ y⁻¹ x`, and |
| 206 | otherwise it is `0`. (`countTerm` itself reads a chosen representative.) -/ |
| 207 | lemma countTerm_mk {ε : Prop} {μ : n} {w : E[X] → n → ℂ} : |
| 208 | countTerm ε f w ⟦(x, y, μ)⟧ = |
| 209 | if IsSignedFrame x (eigenReflection ε y μ) then |
| 210 | heckeCosetFn f (invAutInFrame y x) * w y.val.charpoly μ |
| 211 | else 0 := by |
| 212 | -- The chosen representative of the orbit is the translate of `(x, y, μ)` by some `z`. |
| 213 | obtain ⟨z, hz : (⟦toFinGL z * x⟧, z * y * z⁻¹, μ) = _⟩ := |
| 214 | mk_out (s := orbitRel (GL n E) (MarkedTriple (levelGU n 𝔑) n)) (⟦x⟧, y, μ) |
| 215 | -- The chosen representative of the coset of `toFinGL z * x` is `toFinGL z * x * k`, `k` in the |
| 216 | -- level. |
| 217 | obtain ⟨⟨k, hk_level⟩, hk_out⟩ := QuotientGroup.mk_out_eq_mul (levelGU n 𝔑) (toFinGL z * x) |
| 218 | have h_charpoly : (z * y * z⁻¹).val.charpoly = y.val.charpoly := by simp |
| 219 | have h_aut : invAutInFrame (z * y * z⁻¹) (toFinGL z * x * k) = k⁻¹ * invAutInFrame y x * k := by |
| 220 | simp [invAutInFrame, mul_assoc] |
| 221 | -- Conjugation by `k` does not change the value of `f`. |
| 222 | rw [← heckeAlgebra.heckeCosetFn_conj hk_level, countTerm, ← hz] |
| 223 | -- Neither the signature condition nor the characteristic polynomial sees `z` and `k`. |
| 224 | dsimp only |
| 225 | rw [hk_out, h_aut, h_charpoly, ← ratConj_eigenReflection, mul_assoc, |
| 226 | ← isSignedFrame_mul_iff z (inv_mem (Subgroup.mem_inf.mp hk_level).left), mul_inv_cancel_right] |
| 227 | |
| 228 | end New.Variety |