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 Mathlib.NumberTheory.Padics.RingHoms |
| 4 | import Mathlib.NumberTheory.Padics.ProperSpace |
| 5 | import Mathlib.RingTheory.RegularLocalRing.Defs |
| 6 | import Mathlib.RingTheory.ZMod.UnitsCyclic |
| 7 | import Mathlib.Topology.Algebra.ClopenNhdofOne |
| 8 | import Mathlib.Topology.Algebra.Module.Compact |
| 9 | import Mathlib.Topology.Compactness.Paracompact |
| 10 | import Mathlib.Topology.Connected.Separation |
| 11 | import Mathlib.Topology.MetricSpace.Ultra.TotallySeparated |
| 12 | import Mathlib.Topology.Separation.Connected |
| 13 | import TauCeti.NumberTheory.Padics.PrincipalUnits |
| 14 | public import Lib.Speed |
| 15 | |
| 16 | /-! |
| 17 | # Open subgroups, a tube lemma, and procyclic images of ℓ-adic characters |
| 18 | |
| 19 | This file collects auxiliary facts from topology and algebra. It characterises congruence modulo a |
| 20 | principal ideal `(a)` by divisibility of the difference by `a`. |
| 21 | |
| 22 | ## Main definitions and results |
| 23 | |
| 24 | * `New.exists_openNormalSubgroup_apply_eq`: a continuous map on a product of a compact |
| 25 | topological group and a compact space is constant in the first variable on some open |
| 26 | normal subgroup, when the target is discrete. |
| 27 | * `IsCompact.eventually_forall_mem`: a form of the tube lemma for a jointly continuous map of two |
| 28 | variables, with the continuity hypothesis discharged by `fun_prop` by default. |
| 29 | * `New.Selmer.exists_procyclic_generator`: a continuous character of a compact group with values in |
| 30 | 1 + 4ℤ_ℓ has procyclic image. |
| 31 | * `MonoidHom.IsGeneratorModKer`: an element generates a topological group modulo the kernel of a |
| 32 | homomorphism; `New.Selmer.exists_isGeneratorModKer` gives one for such a character of a profinite |
| 33 | group. |
| 34 | -/ |
| 35 | |
| 36 | @[expose] public section |
| 37 | |
| 38 | open Set Topology in |
| 39 | /-- The image of a closed discrete set under a closed map is discrete. -/ |
| 40 | lemma New.isDiscrete_image_of_isClosedMap {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] |
| 41 | {f : X → Y} {S : Set X} (hS : IsDiscrete S) (h_closed : IsClosed S) (hf : IsClosedMap f) : |
| 42 | IsDiscrete (f '' S) := by |
| 43 | -- Each subset of the image is the image of a closed subset of S. |
| 44 | refine isDiscrete_iff_forall_mem_exists_isClosed.2 fun t ht ↦ ⟨t, ?_, inter_eq_left.2 ht⟩ |
| 45 | rw [← inter_eq_right.mpr ht, ← image_inter_preimage] |
| 46 | exact hf _ (isClosed_of_subset_discrete_closed inter_subset_left hS h_closed) |
| 47 | |
| 48 | /-! ## Open subgroups, a tube lemma, and congruence modulo a principal ideal -/ |
| 49 | |
| 50 | /-- The subgroup U of G is an open subset of G. -/ |
| 51 | @[to_additive /-- The additive subgroup U of G is an open subset of G. -/] |
| 52 | protected abbrev Subgroup.IsOpen {G : Type*} [Group G] [TopologicalSpace G] (U : Subgroup G) : |
| 53 | Prop := IsOpen (X := G) U |
| 54 | |
| 55 | /-- Tube lemma for a jointly continuous f: if W is a neighbourhood of f(x₀, y) for each y in a |
| 56 | compact set K, then f(x, y) ∈ W for all y in K and all x near x₀. -/ |
| 57 | lemma IsCompact.eventually_forall_mem {X Y Z : Type*} [TopologicalSpace X] [TopologicalSpace Y] |
| 58 | [TopologicalSpace Z] {K : Set Y} {x₀ : X} (hK : IsCompact K) (f : X → Y → Z) (W : Set Z) |
| 59 | (h_nhds : ∀ y ∈ K, W ∈ nhds (f x₀ y)) (hf : Continuous f.uncurry := by fun_prop) : |
| 60 | ∀ᶠ x : X in nhds x₀, ∀ y ∈ K, f x y ∈ W := |
| 61 | hK.eventually_forall_of_forall_eventually fun y hy ↦ hf.continuousAt (h_nhds y hy) |
| 62 | |
| 63 | /-- For a compact topological group `Γ`, a compact space `Y`, and a discrete space `X`, |
| 64 | a continuous map `f : Γ × Y → X` satisfies `f (u, y) = f (1, y)` for all `y` on some open |
| 65 | normal subgroup of `Γ`. -/ |
| 66 | lemma New.exists_openNormalSubgroup_apply_eq {Γ Y X : Type*} [Group Γ] [TopologicalSpace Γ] |
| 67 | [IsTopologicalGroup Γ] [CompactSpace Γ] [TopologicalSpace Y] |
| 68 | [CompactSpace Y] [TopologicalSpace X] [DiscreteTopology X] {f : Γ × Y → X} (hf : Continuous f) : |
| 69 | ∃ U : OpenNormalSubgroup Γ, ∀ u ∈ U, ∀ y : Y, f (u, y) = f (1, y) := by |
| 70 | -- Project the clopen set of failures to `Γ`. The projection is open and, since `Y` is compact, |
| 71 | -- closed, so its complement is a clopen neighbourhood of `1`. |
| 72 | have h_bad : IsClopen {p : Γ × Y | f p ≠ f (1, p.snd)} := |
| 73 | (isClopen_discrete {x : X × X | x.fst ≠ x.snd}).preimage (hf.prodMk (by fun_prop)) |
| 74 | have h_good : IsClopen (Prod.fst '' {p : Γ × Y | f p ≠ f (1, p.snd)})ᶜ := |
| 75 | ⟨(isOpenMap_fst _ h_bad.isOpen).isClosed_compl, |
| 76 | (isClosedMap_fst_of_compactSpace _ h_bad.isClosed).isOpen_compl⟩ |
| 77 | simpa [Set.subset_def] using |
| 78 | IsTopologicalGroup.exist_openNormalSubgroup_sub_clopen_nhds_of_one h_good (by simp) |
| 79 | |
| 80 | /-- Two elements x and y have the same class modulo the principal ideal (a) if and only if a divides |
| 81 | x − y. -/ |
| 82 | lemma Ideal.mk_span_eq_iff_dvd_sub {R : Type*} [CommRing R] {a x y : R} : |
| 83 | Quotient.mk (span {a}) x = Quotient.mk (span {a}) y ↔ a ∣ x - y := |
| 84 | Quotient.eq.trans mem_span_singleton |
| 85 | |
| 86 | /-! ## Procyclic images of ℓ-adic characters of compact groups -/ |
| 87 | |
| 88 | section ProcyclicImage |
| 89 | |
| 90 | open PadicInt Filter Subgroup ZMod Nat Units |
| 91 | |
| 92 | /-- A character with values in `1 + 4ℤ_ℓ` has cyclic image modulo every `ℓ^(k+2)`. -/ |
| 93 | lemma New.Selmer.isCyclic_range_toZModPow {ℓ : ℕ} {Γ : Type*} [Fact ℓ.Prime] [Group Γ] |
| 94 | (κ : Γ →* ℤ_[ℓ]ˣ) (hκ_four : ∀ g : Γ, 4 ∣ (κ g).val - 1) (k : ℕ) : |
| 95 | IsCyclic ((Units.map |
| 96 | (toZModPow (k + 2) : ℤ_[ℓ] →+* ZMod (ℓ ^ (k + 2))).toMonoidHom).comp κ).range := by |
| 97 | obtain hℓ | rfl := em' (ℓ = 2) |
| 98 | · have : IsCyclic (ZMod (ℓ ^ (k + 2)))ˣ := isCyclic_units_of_prime_pow ℓ Fact.out hℓ _ |
| 99 | infer_instance |
| 100 | obtain ⟨u, hu, hu'⟩ := TauCeti.exists_mem_unitsPrincipal_and_notMem_succ_of_pos 2 two_pos |
| 101 | let f : ℤ_[2]ˣ →* (ZMod (2 ^ (k + 2)))ˣ := |
| 102 | Units.map (toZModPow (k + 2) : ℤ_[2] →+* ZMod (2 ^ (k + 2))).toMonoidHom |
| 103 | refine isCyclic_of_le (H' := zpowers (f u)) ?_ |
| 104 | rintro _ ⟨g, rfl⟩ |
| 105 | have hg : κ g ∈ TauCeti.unitsPrincipal 2 2 := TauCeti.mem_unitsPrincipal_iff.2 <| by |
| 106 | simpa only [Nat.cast_ofNat, show (2 : ℤ_[2]) ^ 2 = 4 by norm_num] using hκ_four g |
| 107 | obtain ⟨n, hn⟩ := |
| 108 | TauCeti.exists_zpow_inv_mul_mem_unitsPrincipal two_pos (fun _ ↦ le_rfl) hu hu' hg k |
| 109 | have h1 : f ((u ^ n)⁻¹ * κ g) = 1 := |
| 110 | Units.ext (TauCeti.mem_unitsPrincipal_iff_toZModPow.1 (Nat.add_comm 2 k ▸ hn)) |
| 111 | rw [map_mul, map_inv, map_zpow, _root_.inv_mul_eq_one] at h1 |
| 112 | exact ⟨n, h1⟩ |
| 113 | |
| 114 | /-- Let ℓ be a prime and κ a continuous homomorphism from a compact group Γ to ℤ_ℓ^× with values in |
| 115 | 1 + 4ℤ_ℓ (for odd ℓ this is no condition, as 4 is a unit of ℤ_ℓ; for ℓ = 2 it keeps κ away from |
| 116 | −1). Then κ has procyclic image: for some γ, every open subgroup S that contains γ and ker κ is all |
| 117 | of Γ. -/ |
| 118 | lemma New.Selmer.exists_procyclic_generator {ℓ : ℕ} {Γ : Type*} [Fact ℓ.Prime] [Group Γ] |
| 119 | [TopologicalSpace Γ] [CompactSpace Γ] (κ : Γ →* ℤ_[ℓ]ˣ) (hκ : Continuous κ) |
| 120 | (hκ_four : ∀ g : Γ, 4 ∣ (κ g).val - 1) : |
| 121 | ∃ γ : Γ, ∀ S : Subgroup Γ, κ.ker ≤ S → S.IsOpen → γ ∈ S → ∀ g : Γ, g ∈ S := by |
| 122 | -- The image of κ modulo every ℓ^(k+2) is cyclic, generated by |
| 123 | -- κ(γ k). A cluster point δ of the γ k works: an open S ∋ δ holds γ k for arbitrarily large k, |
| 124 | -- and an open S ≥ ker κ holds the kernel of κ modulo ℓ^(k+2) for large k. |
| 125 | let red (k : ℕ) : ℤ_[ℓ]ˣ →* (ZMod (ℓ ^ (k + 2)))ˣ := |
| 126 | Units.map (toZModPow (k + 2) : ℤ_[ℓ] →+* ZMod (ℓ ^ (k + 2))).toMonoidHom |
| 127 | have exists_gen (k : ℕ) : ∃ γ : Γ, ∀ g : Γ, |
| 128 | ∃ n : ℤ, (red k).comp κ γ ^ n = (red k).comp κ g := by |
| 129 | obtain ⟨⟨_, γ, rfl⟩, hγ⟩ := (isCyclic_range_toZModPow κ hκ_four k).exists_generator |
| 130 | exact ⟨γ, fun g ↦ (mem_zpowers_iff.mp (hγ ⟨_, g, rfl⟩)).imp fun n hn ↦ Subtype.ext_iff.mp hn⟩ |
| 131 | choose γ hγ using exists_gen |
| 132 | obtain ⟨δ, hδ⟩ : ∃ δ : Γ, ClusterPt δ (atTop.map γ) := exists_clusterPt_of_compactSpace _ |
| 133 | refine ⟨δ, fun S S_ker S_open hδS g ↦ ?_⟩ |
| 134 | -- As Γ is compact, κ is a closed map, so S contains the fibre of some principal unit group. |
| 135 | have near_one : ∀ᶠ y : ℤ_[ℓ]ˣ in nhds 1, ∀ x ∈ κ ⁻¹' {y}, x ∈ S := |
| 136 | hκ.isClosedMap.eventually_nhds_fiber 1 fun x hx ↦ S_open.mem_nhds (S_ker hx) |
| 137 | obtain ⟨j, -, hj⟩ := (TauCeti.hasBasis_nhds_one_unitsPrincipal ℓ).eventually_iff.mp near_one |
| 138 | obtain ⟨k, hjk, hγS⟩ : ∃ k : ℕ, j ≤ k ∧ γ k ∈ S := |
| 139 | frequently_atTop.mp (hδ.frequently (S_open.mem_nhds hδS)) j |
| 140 | -- κ(x) ≡ 1 modulo ℓ^(k+2), with j ≤ k, puts κ(x) in `unitsPrincipal ℓ j`. |
| 141 | have ker_le : ((red k).comp κ).ker ≤ S := fun x hx ↦ by |
| 142 | have hx_mem : κ x ∈ TauCeti.unitsPrincipal ℓ (k + 2) := |
| 143 | TauCeti.mem_unitsPrincipal_iff_toZModPow.2 (by simpa [red, Units.ext_iff] using hx) |
| 144 | exact hj (TauCeti.unitsPrincipal_antitone ℓ (le_add_right hjk) hx_mem) x rfl |
| 145 | -- Modulo that kernel, g is a power of γ k. |
| 146 | obtain ⟨n, hn⟩ := hγ k g |
| 147 | have h_mem : (γ k ^ n)⁻¹ * g ∈ S := ker_le (by simp [-MonoidHom.coe_comp, hn]) |
| 148 | simpa using S.mul_mem (S.zpow_mem hγS n) h_mem |
| 149 | |
| 150 | /-- The element γ generates Γ modulo the kernel of κ: the only closed subgroup that contains γ and |
| 151 | ker κ is Γ. -/ |
| 152 | def MonoidHom.IsGeneratorModKer {Γ A : Type*} [Group Γ] [TopologicalSpace Γ] [Group A] |
| 153 | (κ : Γ →* A) (γ : Γ) : Prop := |
| 154 | ∀ S : Subgroup Γ, IsClosed (S : Set Γ) → κ.ker ≤ S → γ ∈ S → S = ⊤ |
| 155 | |
| 156 | /-- If γ generates Γ modulo the kernel of κ, then so does γ⁻¹. -/ |
| 157 | lemma MonoidHom.IsGeneratorModKer.inv {Γ A : Type*} [Group Γ] [TopologicalSpace Γ] [Group A] |
| 158 | {κ : Γ →* A} {γ : Γ} (hγ : κ.IsGeneratorModKer γ) : κ.IsGeneratorModKer γ⁻¹ := |
| 159 | fun S S_closed S_ker h_mem ↦ hγ S S_closed S_ker (inv_mem_iff.1 h_mem) |
| 160 | |
| 161 | /-- Let γ generate the compact group Γ modulo the closed kernel of κ. Then every g is a product |
| 162 | h q with h in ker κ and q in the closure of the powers of γ. -/ |
| 163 | lemma MonoidHom.IsGeneratorModKer.exists_mul_eq {Γ A : Type*} [Group Γ] [TopologicalSpace Γ] |
| 164 | [IsTopologicalGroup Γ] [CompactSpace Γ] [Group A] {κ : Γ →* A} {γ : Γ} |
| 165 | (hγ : κ.IsGeneratorModKer γ) (h_ker : IsClosed (κ.ker : Set Γ)) (g : Γ) : |
| 166 | ∃ h ∈ κ.ker, ∃ q ∈ (zpowers γ).topologicalClosure, h * q = g := by |
| 167 | have h_closed : IsClosed (↑(κ.ker ⊔ (zpowers γ).topologicalClosure) : Set Γ) := by |
| 168 | simpa [normal_mul] using h_ker.mul_right_of_isCompact (isClosed_topologicalClosure _).isCompact |
| 169 | have h_top : κ.ker ⊔ (zpowers γ).topologicalClosure = ⊤ := |
| 170 | hγ _ h_closed le_sup_left (mem_sup_right (le_topologicalClosure _ (mem_zpowers γ))) |
| 171 | exact mem_sup_of_normal_left.1 (h_top.ge (mem_top g)) |
| 172 | |
| 173 | /-- If γ generates Γ modulo the kernel of a continuous character κ with values in ℤ_ℓ^×, then |
| 174 | κ(γ)^a − 1 divides κ(g)^a − 1 for every g. -/ |
| 175 | lemma MonoidHom.IsGeneratorModKer.pow_sub_one_dvd {ℓ : ℕ} {Γ : Type*} [Fact ℓ.Prime] [Group Γ] |
| 176 | [TopologicalSpace Γ] {κ : Γ →* ℤ_[ℓ]ˣ} {γ : Γ} (hγ : κ.IsGeneratorModKer γ) |
| 177 | (hκ : Continuous κ) (a : ℕ) (g : Γ) : (κ γ ^ a).val - 1 ∣ (κ g ^ a).val - 1 := by |
| 178 | -- The g with this property form the kernel S of κ^a modulo the closed ideal (κ(γ)^a − 1). |
| 179 | let I : Ideal ℤ_[ℓ] := .span {(κ γ ^ a).val - 1} |
| 180 | let S : Subgroup Γ := ((Units.map (Ideal.Quotient.mk I).toMonoidHom).comp (κ ^ a)).ker |
| 181 | have mem_S (x : Γ) : x ∈ S ↔ (κ x ^ a).val - 1 ∈ I := by |
| 182 | simp [S, Units.ext_iff, ← Ideal.Quotient.eq] |
| 183 | have S_closed : IsClosed (S : Set Γ) := by |
| 184 | rw [show (S : Set Γ) = (fun x ↦ (κ x ^ a).val - 1) ⁻¹' I from Set.ext mem_S] |
| 185 | exact (IsNoetherianRing.isClosed_ideal I).preimage (by fun_prop) |
| 186 | have ker_le : κ.ker ≤ S := fun x hx ↦ by simp [mem_S, mem_ker.1 hx] |
| 187 | have h_top : S = ⊤ := hγ S S_closed ker_le ((mem_S γ).2 (Ideal.mem_span_singleton_self _)) |
| 188 | exact Ideal.mem_span_singleton.1 ((mem_S g).1 (h_top.ge (mem_top g))) |
| 189 | |
| 190 | /-- A profinite group has a generator modulo the kernel of a continuous character with values in |
| 191 | 1 + 4ℤ_ℓ. -/ |
| 192 | lemma New.Selmer.exists_isGeneratorModKer {ℓ : ℕ} {Γ : Type*} [Fact ℓ.Prime] [Group Γ] |
| 193 | [TopologicalSpace Γ] [IsTopologicalGroup Γ] [CompactSpace Γ] [TotallyDisconnectedSpace Γ] |
| 194 | {κ : Γ →* ℤ_[ℓ]ˣ} (hκ : Continuous κ) (hκ_four : ∀ g : Γ, 4 ∣ (κ g).val - 1) : |
| 195 | ∃ γ : Γ, κ.IsGeneratorModKer γ := by |
| 196 | obtain ⟨γ, hγ⟩ := exists_procyclic_generator κ hκ hκ_four |
| 197 | refine ⟨γ, fun S S_closed S_ker hγS ↦ ?_⟩ |
| 198 | -- A closed subgroup is the intersection of the open subgroups that contain it. |
| 199 | have h_inf : S = sInf {N : Subgroup Γ | IsOpen (N : Set Γ) ∧ S ≤ N} := |
| 200 | ProfiniteGrp.closedSubgroup_eq_sInf_open ⟨S, S_closed⟩ |
| 201 | rw [h_inf, sInf_eq_top] |
| 202 | exact fun N ⟨N_open, hSN⟩ ↦ (eq_top_iff' N).2 (hγ N (S_ker.trans hSN) N_open (hSN hγS)) |
| 203 | |
| 204 | end ProcyclicImage |