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.Adelic.Unitary.ComponentsAndBlockSums |
| 4 | import Lib.Adelic.Adeles.StrongApproximation |
| 5 | import Lib.Adelic.Unitary.WeakApproximation |
| 6 | import Lib.Adelic.Witt.WittTheorem |
| 7 | import Lib.Base |
| 8 | |
| 9 | /-! |
| 10 | # Rational points and vectors of spaces under sums, moves and block embeddings |
| 11 | |
| 12 | Elementary facts on adelic unitary groups and hermitian spaces. |
| 13 | |
| 14 | * `New.U.mem_range_sum_left`, `New.U.mem_range_sum_right`: which unitary matrices for a block |
| 15 | diagonal form come from one block. |
| 16 | * `New.Space.mem_Gamma_iff_range`: `g` is a rational point iff `x g x⁻¹` has rational entries. |
| 17 | * `New.Space.witt`: Witt's theorem for the form of a space. |
| 18 | * `New.Space.stdForm_vecAtPoint`: in the coordinates of the point, the form `J` becomes |
| 19 | `New.stdForm`. |
| 20 | |
| 21 | A space `V` (`New.Space`) is a rational matrix `J` with an adelic point `x` such that `xᴴ J x` is |
| 22 | the standard form of signs `s`; `New.G E s` is the adelic unitary group of that form. Rational |
| 23 | unitary matrices and rational vectors are read in these coordinates by `V.ratEmbed γ = x⁻¹ γ x`, |
| 24 | with image `V.Γ`, and `V.vecAtPoint y = x⁻¹ y`. |
| 25 | |
| 26 | Notions from other files: |
| 27 | * `New.G`: The adelic unitary group G = G_∞ × G_f for signs s at the infinite places and the |
| 28 | identity matrix at the finite places; `g.adeleMatrix` is the adelic matrix of `g`. |
| 29 | * `New.Space.sum`, `New.Space.reindex`, `New.Space.move`: the block diagonal sum of two spaces, the |
| 30 | relabelling of the indices, and the space `(J, x a)` for `a` in G. |
| 31 | * `New.signedSpace`: the standard space with matrix diag(s), defined when E has a primitive 5040th |
| 32 | root of unity (`New.HasPrimitiveRoot5040`). |
| 33 | |
| 34 | ## Relation to the literature |
| 35 | |
| 36 | Witt's extension theorem for hermitian forms is classical; `New.Space.witt` is its matrix form |
| 37 | `New.witt` applied to the matrix of a space. |
| 38 | -/ |
| 39 | |
| 40 | @[expose] public section |
| 41 | |
| 42 | open Matrix Topology |
| 43 | |
| 44 | namespace New |
| 45 | |
| 46 | variable {E : Type*} [Field E] [NumberField E] [NumberField.IsCMField E] |
| 47 | {n m : Type*} [Fintype n] [DecidableEq n] [Fintype m] [DecidableEq m] {s : n → ℤˣ} {t : m → ℤˣ} |
| 48 | |
| 49 | /-! ### Block embeddings and continuity -/ |
| 50 | |
| 51 | /-- Let `J''` be the block diagonal sum of `J` and `J'` with `J'` invertible. An element `g` of the |
| 52 | unitary group `U J''` of the matrices that preserve the form `J''` is `diag(a, 1)` with `a` in |
| 53 | `U J` if and only if its second block of columns is that of the identity matrix. Here `U.sum h` is |
| 54 | the map `(a, b) ↦ diag(a, b)`. -/ |
| 55 | lemma U.mem_range_sum_left {R : Type*} [CommRing R] [StarRing R] {J : Matrix n n R} |
| 56 | {J' : Matrix m m R} {J'' : Matrix (n ⊕ m) (n ⊕ m) R} (h : fromBlocks J 0 0 J' = J'') |
| 57 | {g : U J''} (hJ' : IsUnit J') : |
| 58 | (∃ a : U J, sum h (a, 1) = g) ↔ |
| 59 | (g : Matrix (n ⊕ m) (n ⊕ m) R).toCols₂ = fromRows 0 1 := by |
| 60 | subst h |
| 61 | refine ⟨?_, fun h_cols ↦ ?_⟩ |
| 62 | · rintro ⟨a, rfl⟩ |
| 63 | simp [sum, ← fromCols_fromRows_eq_fromBlocks] |
| 64 | -- For `g = (A 0; C 1)`, an off-diagonal block of `gᴴ J'' g = J''` says `J' C = 0`, so `C = 0`. |
| 65 | obtain ⟨A, B, C, D, hg⟩ : ∃ A B C D, g.val.val = fromBlocks A B C D := |
| 66 | ⟨_, _, _, _, (fromBlocks_toBlocks _).symm⟩ |
| 67 | obtain ⟨rfl, rfl⟩ : B = 0 ∧ D = 1 := by |
| 68 | simpa [hg, ← fromCols_fromRows_eq_fromBlocks, fromRows_ext_iff] using h_cols |
| 69 | obtain ⟨hA, -, hC⟩ : Aᴴ * J * A + Cᴴ * J' * C = J ∧ Cᴴ * J' = 0 ∧ J' * C = 0 := by |
| 70 | simpa [hg, fromBlocks_conjTranspose, fromBlocks_multiply, star_eq_conjTranspose] using |
| 71 | mem_unitaryGroupOf_iff.1 g.property |
| 72 | obtain rfl : C = 0 := by |
| 73 | rw [← nonsing_inv_mul_cancel_left J' C ((isUnit_iff_isUnit_det _).1 hJ'), hC, Matrix.mul_zero] |
| 74 | lift A to GL n R using by simpa [hg] using g.val.isUnit |
| 75 | exact ⟨⟨A, mem_unitaryGroupOf_iff.2 (by simpa [star_eq_conjTranspose] using hA)⟩, |
| 76 | Subtype.ext (Units.ext (by simp [sum, hg]))⟩ |
| 77 | |
| 78 | /-- Let `J''` be the block diagonal sum of `J` and `J'` with `J` invertible. An element `g` of the |
| 79 | unitary group `U J''` is `diag(1, a)` with `a` in `U J'` if and only if its first block of columns |
| 80 | is that of the identity matrix. Here `U.sum h` is the map `(a, b) ↦ diag(a, b)`. -/ |
| 81 | lemma U.mem_range_sum_right {R : Type*} [CommRing R] [StarRing R] {J : Matrix n n R} |
| 82 | {J' : Matrix m m R} {J'' : Matrix (n ⊕ m) (n ⊕ m) R} (h : fromBlocks J 0 0 J' = J'') |
| 83 | {g : U J''} (hJ : IsUnit J) : |
| 84 | (∃ a : U J', sum h (1, a) = g) ↔ |
| 85 | (g : Matrix (n ⊕ m) (n ⊕ m) R).toCols₁ = fromRows 1 0 := by |
| 86 | subst h |
| 87 | refine ⟨?_, fun h_cols ↦ ?_⟩ |
| 88 | · rintro ⟨a, rfl⟩ |
| 89 | simp [sum, ← fromCols_fromRows_eq_fromBlocks] |
| 90 | -- Exchange the summands and apply the left-block characterization. |
| 91 | let swap := reindex (Equiv.sumComm n m) (fromBlocks_submatrix_sum_swap_sum_swap J 0 0 J') |
| 92 | have hc : ((swap g).val.val).toCols₂ = fromRows 0 1 := by |
| 93 | ext i j |
| 94 | cases i with |
| 95 | | inl i => exact congrFun (congrFun h_cols (.inr i)) j |
| 96 | | inr i => exact congrFun (congrFun h_cols (.inl i)) j |
| 97 | obtain ⟨a, ha⟩ := (mem_range_sum_left (g := swap g) rfl hJ).2 hc |
| 98 | refine ⟨a, swap.injective (Eq.trans ?_ ha)⟩ |
| 99 | exact Subtype.ext (Units.ext (fromBlocks_submatrix_sum_swap_sum_swap _ _ _ _)) |
| 100 | |
| 101 | /-- The block diagonal embedding of the product of the adelic unitary groups for signs `s` and `t` |
| 102 | into the one for the concatenated signs is a closed embedding. -/ |
| 103 | @[fun_prop] |
| 104 | lemma G.isClosedEmbedding_sum : IsClosedEmbedding (sum : G E s × G E t → G E (s ⊕ᵥ t)) := by |
| 105 | -- Pass to matrices: there the map is `(A, B) ↦ fromBlocks A 0 0 B`, which is continuous |
| 106 | -- with the continuous left inverse that extracts the two diagonal blocks. |
| 107 | have h_blocks : |
| 108 | IsClosedEmbedding fun M : Matrix n n (𝔸 E) × Matrix m m (𝔸 E) ↦ fromBlocks M.1 0 0 M.2 := |
| 109 | Function.LeftInverse.isClosedEmbedding (f := fun M ↦ (M.toBlocks₁₁, M.toBlocks₂₂)) |
| 110 | (fun M ↦ by simp) (by fun_prop [toBlocks₁₁, toBlocks₂₂]) (by fun_prop) |
| 111 | simp only [← isClosedEmbedding_adeleMatrix.of_comp_iff, Function.comp_def, adeleMatrix_sum] |
| 112 | exact h_blocks.comp (isClosedEmbedding_adeleMatrix.prodMap isClosedEmbedding_adeleMatrix) |
| 113 | |
| 114 | /-- Relabelling the indices along a bijection that carries the signs `s` to `t` is continuous on |
| 115 | the adelic unitary groups. -/ |
| 116 | @[fun_prop] |
| 117 | lemma G.continuous_reindex (e : n ≃ m) (h : s ∘ e.symm = t) : |
| 118 | Continuous (reindex e h : G E s → G E t) := by |
| 119 | simp only [continuous_iff, adeleMatrix_reindex] |
| 120 | fun_prop |
| 121 | |
| 122 | /-- The isomorphism of adelic unitary groups for signs `s` and `-s` that is the identity on |
| 123 | matrices is continuous. -/ |
| 124 | @[fun_prop] |
| 125 | lemma G.continuous_neg : Continuous (neg : G E s → G E (-s)) := |
| 126 | continuous_iff.2 continuous_adeleMatrix |
| 127 | |
| 128 | namespace Space |
| 129 | |
| 130 | variable {E : Type*} [Field E] [CMType E] (V : Space E n s) (W : Space E m t) |
| 131 | |
| 132 | /-! ### Rational points and vectors of a space -/ |
| 133 | |
| 134 | /-- Two spaces with the same signs and the same point are equal: the point determines the |
| 135 | matrix. -/ |
| 136 | @[ext] |
| 137 | lemma ext {V V' : Space E n s} (h : V.x = V'.x) : V = V' := by |
| 138 | -- `map_J` expresses the image of `J` over the adeles by the point alone. |
| 139 | have hJ : V.J = V'.J := Matrix.map_injective toAdele.injective (by simp only [map_J, h]) |
| 140 | cases V |
| 141 | congr |
| 142 | |
| 143 | /-- `g` is a rational point of `V` (an element of `V.Γ`) if and only if all entries of the adelic |
| 144 | matrix `x g x⁻¹`, for the point `x` of `V`, are images of elements of `E` under the diagonal |
| 145 | embedding `toAdele` of `E` in its adeles. -/ |
| 146 | @[local simp] |
| 147 | lemma mem_Gamma_iff_range {g : G E s} : |
| 148 | g ∈ V.Γ ↔ ∀ i j : n, (V.x * g.adeleMatrix * V.x⁻¹) i j ∈ toAdele.range := by |
| 149 | refine ⟨fun hg ↦ mem_ratMatrices.1 (ratCoordMatrix_mem_ratMatrices hg), fun h_rat ↦ ?_⟩ |
| 150 | obtain ⟨γ, hγ⟩ := U.exists_map_eq_of_entries (by simp) (toAdele (E := E)).injective |
| 151 | V.isUnit_J rfl (V.toRatCoords g) h_rat |
| 152 | exact ⟨γ, V.toRatCoords.symm_apply_eq.2 hγ⟩ |
| 153 | |
| 154 | /-- Witt's theorem. Let `J` be the matrix of `V`, and let `X` and `Y` be left invertible `n × m` |
| 155 | matrices over `E` with `Xᴴ J X = Yᴴ J Y`. Then `g X = Y` for some `g` in the unitary group of `J` |
| 156 | over `E`. -/ |
| 157 | protected lemma witt {X Y : Matrix n m E} (hX : HasLeftInv X) (hY : HasLeftInv Y) |
| 158 | (h_gram : Xᴴ * V.J * X = Yᴴ * V.J * Y) : |
| 159 | ∃ g : U V.J, (g : Matrix n n E) * X = Y := |
| 160 | witt exists_isUnit_sub_star V.conjTranspose_J (by simp) hX hY h_gram |
| 161 | |
| 162 | /-- A rational unitary matrix `γ` acts in the coordinates of the point as it does on rational |
| 163 | vectors. -/ |
| 164 | lemma ratEmbed_mulVec_vecAtPoint (γ : U V.J) (y : n → E) : |
| 165 | (V.ratEmbed γ).adeleMatrix *ᵥ V.vecAtPoint y = V.vecAtPoint (γ *ᵥ y) := by |
| 166 | simp [adeleMatrix_ratEmbed, vecAtPoint, Function.comp_def, RingHom.map_mulVec] |
| 167 | |
| 168 | /-- The standard form on the coordinates `x⁻¹ y`, `x⁻¹ z` of rational vectors `y`, `z` at the point |
| 169 | `x` of `V` is the image of `yᴴ J z` in the adeles. -/ |
| 170 | lemma stdForm_vecAtPoint (y z : n → E) : |
| 171 | star (V.vecAtPoint y) ⬝ᵥ stdForm E s *ᵥ V.vecAtPoint z = |
| 172 | toAdele (star y ⬝ᵥ V.J *ᵥ z) := by |
| 173 | have h_star : star (toAdele ∘ y) = toAdele ∘ star y := funext fun i ↦ by simp |
| 174 | calc _ = star (toAdele ∘ y) ⬝ᵥ V.J.map toAdele *ᵥ (toAdele ∘ z) := by |
| 175 | simp [star_mulVec_dotProduct, vecAtPoint, map_J, mul_assoc] |
| 176 | _ = _ := by rw [h_star]; simp [RingHom.map_dotProduct, RingHom.map_mulVec, Function.comp_def] |
| 177 | |
| 178 | /-- A rational vector is determined by its coordinates at the point of the space. -/ |
| 179 | lemma vecAtPoint_injective : Function.Injective V.vecAtPoint := fun y z h ↦ |
| 180 | (toAdele (E := E)).injective.comp_left |
| 181 | (Matrix.mulVec_injective_of_isUnit V.x⁻¹.isUnit (by simpa [vecAtPoint] using h)) |
| 182 | |
| 183 | /-! ### Sums, relabelling and moves -/ |
| 184 | |
| 185 | /-- The rational embedding of a block sum of spaces sends `diag(γ₁, γ₂)` to the block diagonal sum |
| 186 | of the images of `γ₁` and `γ₂`. -/ |
| 187 | lemma sum_ratEmbed (γ : U V.J × U W.J) : |
| 188 | (V.sum W).ratEmbed (U.sum rfl γ) = G.sum (V.ratEmbed γ.1, W.ratEmbed γ.2) := by |
| 189 | apply G.ext_adeleMatrix |
| 190 | -- The ascription identifies `(V.sum W).J` with the block diagonal matrix of `V.J` and `W.J`. |
| 191 | calc _ = (V.sum W).x⁻¹ * (U.sum rfl γ : U (V.sum W).J).val.val.map toAdele * (V.sum W).x := |
| 192 | adeleMatrix_ratEmbed _ _ |
| 193 | _ = _ := by simp [sum, blockGL, U.sum, fromBlocks_map, fromBlocks_multiply, |
| 194 | adeleMatrix_ratEmbed] |
| 195 | |
| 196 | /-- The coordinates of a concatenated rational vector at the point of a sum of two spaces are the |
| 197 | concatenated coordinates. -/ |
| 198 | lemma sum_vecAtPoint (y : n → E) (z : m → E) : |
| 199 | (V.sum W).vecAtPoint (y ⊕ᵥ z) = V.vecAtPoint y ⊕ᵥ W.vecAtPoint z := by |
| 200 | simp [vecAtPoint, sum, blockGL, Function.comp_def, fromBlocks_mulVec] |
| 201 | |
| 202 | /-- A block diagonal pair is a rational point of the sum of two spaces if and only if each |
| 203 | component is a rational point of its space. -/ |
| 204 | lemma sum_mem_Gamma {g : G E s × G E t} : G.sum g ∈ (V.sum W).Γ ↔ g.1 ∈ V.Γ ∧ g.2 ∈ W.Γ := by |
| 205 | simp [sum, blockGL, fromBlocks_multiply] |
| 206 | |
| 207 | /-- Let `E` contain a primitive 5040th root of unity and let `e` be a bijection of indices that |
| 208 | carries the signs `s` to `t`. If the space `V` has the same point as the standard space |
| 209 | `New.signedSpace E s` of matrix `diag(s)`, then relabelling `V` along `e` gives the standard space |
| 210 | `New.signedSpace E t`. -/ |
| 211 | lemma signedSpace_eq_reindex [HasPrimitiveRoot5040 E] {e : n ≃ m} {h : s ∘ e.symm = t} |
| 212 | (hV : V.x = (signedSpace E s).x) : signedSpace E t = V.reindex e h := by |
| 213 | -- A space is determined by its point (`ext`), and the two points have the same entries. |
| 214 | subst h |
| 215 | ext : 2 |
| 216 | simp [signedSpace, reindex, hV] |
| 217 | |
| 218 | /-- `g` is a rational point of the space moved by `a` if and only if `a g a⁻¹` is a rational |
| 219 | point of the space. -/ |
| 220 | lemma mem_move_Gamma (a : G E s) {g : G E s} : g ∈ (V.move a).Γ ↔ a * g * a⁻¹ ∈ V.Γ := by |
| 221 | simp [move, G.adeleMatrix, mul_assoc] |
| 222 | |
| 223 | end Space |
| 224 | |
| 225 | end New |