module public import Mathlib.NumberTheory.Padics.RingHoms import Mathlib.NumberTheory.Padics.ProperSpace import Mathlib.RingTheory.RegularLocalRing.Defs import Mathlib.RingTheory.ZMod.UnitsCyclic import Mathlib.Topology.Algebra.ClopenNhdofOne import Mathlib.Topology.Algebra.Module.Compact import Mathlib.Topology.Compactness.Paracompact import Mathlib.Topology.Connected.Separation import Mathlib.Topology.MetricSpace.Ultra.TotallySeparated import Mathlib.Topology.Separation.Connected import TauCeti.NumberTheory.Padics.PrincipalUnits public import Lib.Speed /-! # Open subgroups, a tube lemma, and procyclic images of ℓ-adic characters This file collects auxiliary facts from topology and algebra. It characterises congruence modulo a principal ideal `(a)` by divisibility of the difference by `a`. ## Main definitions and results * `New.exists_openNormalSubgroup_apply_eq`: a continuous map on a product of a compact topological group and a compact space is constant in the first variable on some open normal subgroup, when the target is discrete. * `IsCompact.eventually_forall_mem`: a form of the tube lemma for a jointly continuous map of two variables, with the continuity hypothesis discharged by `fun_prop` by default. * `New.Selmer.exists_procyclic_generator`: a continuous character of a compact group with values in 1 + 4ℤ_ℓ has procyclic image. * `MonoidHom.IsGeneratorModKer`: an element generates a topological group modulo the kernel of a homomorphism; `New.Selmer.exists_isGeneratorModKer` gives one for such a character of a profinite group. -/ @[expose] public section open Set Topology in /-- The image of a closed discrete set under a closed map is discrete. -/ lemma New.isDiscrete_image_of_isClosedMap {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] {f : X → Y} {S : Set X} (hS : IsDiscrete S) (h_closed : IsClosed S) (hf : IsClosedMap f) : IsDiscrete (f '' S) := by -- Each subset of the image is the image of a closed subset of S. refine isDiscrete_iff_forall_mem_exists_isClosed.2 fun t ht ↦ ⟨t, ?_, inter_eq_left.2 ht⟩ rw [← inter_eq_right.mpr ht, ← image_inter_preimage] exact hf _ (isClosed_of_subset_discrete_closed inter_subset_left hS h_closed) /-! ## Open subgroups, a tube lemma, and congruence modulo a principal ideal -/ /-- The subgroup U of G is an open subset of G. -/ @[to_additive /-- The additive subgroup U of G is an open subset of G. -/] protected abbrev Subgroup.IsOpen {G : Type*} [Group G] [TopologicalSpace G] (U : Subgroup G) : Prop := IsOpen (X := G) U /-- Tube lemma for a jointly continuous f: if W is a neighbourhood of f(x₀, y) for each y in a compact set K, then f(x, y) ∈ W for all y in K and all x near x₀. -/ lemma IsCompact.eventually_forall_mem {X Y Z : Type*} [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] {K : Set Y} {x₀ : X} (hK : IsCompact K) (f : X → Y → Z) (W : Set Z) (h_nhds : ∀ y ∈ K, W ∈ nhds (f x₀ y)) (hf : Continuous f.uncurry := by fun_prop) : ∀ᶠ x : X in nhds x₀, ∀ y ∈ K, f x y ∈ W := hK.eventually_forall_of_forall_eventually fun y hy ↦ hf.continuousAt (h_nhds y hy) /-- For a compact topological group `Γ`, a compact space `Y`, and a discrete space `X`, a continuous map `f : Γ × Y → X` satisfies `f (u, y) = f (1, y)` for all `y` on some open normal subgroup of `Γ`. -/ lemma New.exists_openNormalSubgroup_apply_eq {Γ Y X : Type*} [Group Γ] [TopologicalSpace Γ] [IsTopologicalGroup Γ] [CompactSpace Γ] [TopologicalSpace Y] [CompactSpace Y] [TopologicalSpace X] [DiscreteTopology X] {f : Γ × Y → X} (hf : Continuous f) : ∃ U : OpenNormalSubgroup Γ, ∀ u ∈ U, ∀ y : Y, f (u, y) = f (1, y) := by -- Project the clopen set of failures to `Γ`. The projection is open and, since `Y` is compact, -- closed, so its complement is a clopen neighbourhood of `1`. have h_bad : IsClopen {p : Γ × Y | f p ≠ f (1, p.snd)} := (isClopen_discrete {x : X × X | x.fst ≠ x.snd}).preimage (hf.prodMk (by fun_prop)) have h_good : IsClopen (Prod.fst '' {p : Γ × Y | f p ≠ f (1, p.snd)})ᶜ := ⟨(isOpenMap_fst _ h_bad.isOpen).isClosed_compl, (isClosedMap_fst_of_compactSpace _ h_bad.isClosed).isOpen_compl⟩ simpa [Set.subset_def] using IsTopologicalGroup.exist_openNormalSubgroup_sub_clopen_nhds_of_one h_good (by simp) /-- Two elements x and y have the same class modulo the principal ideal (a) if and only if a divides x − y. -/ lemma Ideal.mk_span_eq_iff_dvd_sub {R : Type*} [CommRing R] {a x y : R} : Quotient.mk (span {a}) x = Quotient.mk (span {a}) y ↔ a ∣ x - y := Quotient.eq.trans mem_span_singleton /-! ## Procyclic images of ℓ-adic characters of compact groups -/ section ProcyclicImage open PadicInt Filter Subgroup ZMod Nat Units /-- A character with values in `1 + 4ℤ_ℓ` has cyclic image modulo every `ℓ^(k+2)`. -/ lemma New.Selmer.isCyclic_range_toZModPow {ℓ : ℕ} {Γ : Type*} [Fact ℓ.Prime] [Group Γ] (κ : Γ →* ℤ_[ℓ]ˣ) (hκ_four : ∀ g : Γ, 4 ∣ (κ g).val - 1) (k : ℕ) : IsCyclic ((Units.map (toZModPow (k + 2) : ℤ_[ℓ] →+* ZMod (ℓ ^ (k + 2))).toMonoidHom).comp κ).range := by obtain hℓ | rfl := em' (ℓ = 2) · have : IsCyclic (ZMod (ℓ ^ (k + 2)))ˣ := isCyclic_units_of_prime_pow ℓ Fact.out hℓ _ infer_instance obtain ⟨u, hu, hu'⟩ := TauCeti.exists_mem_unitsPrincipal_and_notMem_succ_of_pos 2 two_pos let f : ℤ_[2]ˣ →* (ZMod (2 ^ (k + 2)))ˣ := Units.map (toZModPow (k + 2) : ℤ_[2] →+* ZMod (2 ^ (k + 2))).toMonoidHom refine isCyclic_of_le (H' := zpowers (f u)) ?_ rintro _ ⟨g, rfl⟩ have hg : κ g ∈ TauCeti.unitsPrincipal 2 2 := TauCeti.mem_unitsPrincipal_iff.2 <| by simpa only [Nat.cast_ofNat, show (2 : ℤ_[2]) ^ 2 = 4 by norm_num] using hκ_four g obtain ⟨n, hn⟩ := TauCeti.exists_zpow_inv_mul_mem_unitsPrincipal two_pos (fun _ ↦ le_rfl) hu hu' hg k have h1 : f ((u ^ n)⁻¹ * κ g) = 1 := Units.ext (TauCeti.mem_unitsPrincipal_iff_toZModPow.1 (Nat.add_comm 2 k ▸ hn)) rw [map_mul, map_inv, map_zpow, _root_.inv_mul_eq_one] at h1 exact ⟨n, h1⟩ /-- Let ℓ be a prime and κ a continuous homomorphism from a compact group Γ to ℤ_ℓ^× with values in 1 + 4ℤ_ℓ (for odd ℓ this is no condition, as 4 is a unit of ℤ_ℓ; for ℓ = 2 it keeps κ away from −1). Then κ has procyclic image: for some γ, every open subgroup S that contains γ and ker κ is all of Γ. -/ lemma New.Selmer.exists_procyclic_generator {ℓ : ℕ} {Γ : Type*} [Fact ℓ.Prime] [Group Γ] [TopologicalSpace Γ] [CompactSpace Γ] (κ : Γ →* ℤ_[ℓ]ˣ) (hκ : Continuous κ) (hκ_four : ∀ g : Γ, 4 ∣ (κ g).val - 1) : ∃ γ : Γ, ∀ S : Subgroup Γ, κ.ker ≤ S → S.IsOpen → γ ∈ S → ∀ g : Γ, g ∈ S := by -- The image of κ modulo every ℓ^(k+2) is cyclic, generated by -- κ(γ k). A cluster point δ of the γ k works: an open S ∋ δ holds γ k for arbitrarily large k, -- and an open S ≥ ker κ holds the kernel of κ modulo ℓ^(k+2) for large k. let red (k : ℕ) : ℤ_[ℓ]ˣ →* (ZMod (ℓ ^ (k + 2)))ˣ := Units.map (toZModPow (k + 2) : ℤ_[ℓ] →+* ZMod (ℓ ^ (k + 2))).toMonoidHom have exists_gen (k : ℕ) : ∃ γ : Γ, ∀ g : Γ, ∃ n : ℤ, (red k).comp κ γ ^ n = (red k).comp κ g := by obtain ⟨⟨_, γ, rfl⟩, hγ⟩ := (isCyclic_range_toZModPow κ hκ_four k).exists_generator exact ⟨γ, fun g ↦ (mem_zpowers_iff.mp (hγ ⟨_, g, rfl⟩)).imp fun n hn ↦ Subtype.ext_iff.mp hn⟩ choose γ hγ using exists_gen obtain ⟨δ, hδ⟩ : ∃ δ : Γ, ClusterPt δ (atTop.map γ) := exists_clusterPt_of_compactSpace _ refine ⟨δ, fun S S_ker S_open hδS g ↦ ?_⟩ -- As Γ is compact, κ is a closed map, so S contains the fibre of some principal unit group. have near_one : ∀ᶠ y : ℤ_[ℓ]ˣ in nhds 1, ∀ x ∈ κ ⁻¹' {y}, x ∈ S := hκ.isClosedMap.eventually_nhds_fiber 1 fun x hx ↦ S_open.mem_nhds (S_ker hx) obtain ⟨j, -, hj⟩ := (TauCeti.hasBasis_nhds_one_unitsPrincipal ℓ).eventually_iff.mp near_one obtain ⟨k, hjk, hγS⟩ : ∃ k : ℕ, j ≤ k ∧ γ k ∈ S := frequently_atTop.mp (hδ.frequently (S_open.mem_nhds hδS)) j -- κ(x) ≡ 1 modulo ℓ^(k+2), with j ≤ k, puts κ(x) in `unitsPrincipal ℓ j`. have ker_le : ((red k).comp κ).ker ≤ S := fun x hx ↦ by have hx_mem : κ x ∈ TauCeti.unitsPrincipal ℓ (k + 2) := TauCeti.mem_unitsPrincipal_iff_toZModPow.2 (by simpa [red, Units.ext_iff] using hx) exact hj (TauCeti.unitsPrincipal_antitone ℓ (le_add_right hjk) hx_mem) x rfl -- Modulo that kernel, g is a power of γ k. obtain ⟨n, hn⟩ := hγ k g have h_mem : (γ k ^ n)⁻¹ * g ∈ S := ker_le (by simp [-MonoidHom.coe_comp, hn]) simpa using S.mul_mem (S.zpow_mem hγS n) h_mem /-- The element γ generates Γ modulo the kernel of κ: the only closed subgroup that contains γ and ker κ is Γ. -/ def MonoidHom.IsGeneratorModKer {Γ A : Type*} [Group Γ] [TopologicalSpace Γ] [Group A] (κ : Γ →* A) (γ : Γ) : Prop := ∀ S : Subgroup Γ, IsClosed (S : Set Γ) → κ.ker ≤ S → γ ∈ S → S = ⊤ /-- If γ generates Γ modulo the kernel of κ, then so does γ⁻¹. -/ lemma MonoidHom.IsGeneratorModKer.inv {Γ A : Type*} [Group Γ] [TopologicalSpace Γ] [Group A] {κ : Γ →* A} {γ : Γ} (hγ : κ.IsGeneratorModKer γ) : κ.IsGeneratorModKer γ⁻¹ := fun S S_closed S_ker h_mem ↦ hγ S S_closed S_ker (inv_mem_iff.1 h_mem) /-- Let γ generate the compact group Γ modulo the closed kernel of κ. Then every g is a product h q with h in ker κ and q in the closure of the powers of γ. -/ lemma MonoidHom.IsGeneratorModKer.exists_mul_eq {Γ A : Type*} [Group Γ] [TopologicalSpace Γ] [IsTopologicalGroup Γ] [CompactSpace Γ] [Group A] {κ : Γ →* A} {γ : Γ} (hγ : κ.IsGeneratorModKer γ) (h_ker : IsClosed (κ.ker : Set Γ)) (g : Γ) : ∃ h ∈ κ.ker, ∃ q ∈ (zpowers γ).topologicalClosure, h * q = g := by have h_closed : IsClosed (↑(κ.ker ⊔ (zpowers γ).topologicalClosure) : Set Γ) := by simpa [normal_mul] using h_ker.mul_right_of_isCompact (isClosed_topologicalClosure _).isCompact have h_top : κ.ker ⊔ (zpowers γ).topologicalClosure = ⊤ := hγ _ h_closed le_sup_left (mem_sup_right (le_topologicalClosure _ (mem_zpowers γ))) exact mem_sup_of_normal_left.1 (h_top.ge (mem_top g)) /-- If γ generates Γ modulo the kernel of a continuous character κ with values in ℤ_ℓ^×, then κ(γ)^a − 1 divides κ(g)^a − 1 for every g. -/ lemma MonoidHom.IsGeneratorModKer.pow_sub_one_dvd {ℓ : ℕ} {Γ : Type*} [Fact ℓ.Prime] [Group Γ] [TopologicalSpace Γ] {κ : Γ →* ℤ_[ℓ]ˣ} {γ : Γ} (hγ : κ.IsGeneratorModKer γ) (hκ : Continuous κ) (a : ℕ) (g : Γ) : (κ γ ^ a).val - 1 ∣ (κ g ^ a).val - 1 := by -- The g with this property form the kernel S of κ^a modulo the closed ideal (κ(γ)^a − 1). let I : Ideal ℤ_[ℓ] := .span {(κ γ ^ a).val - 1} let S : Subgroup Γ := ((Units.map (Ideal.Quotient.mk I).toMonoidHom).comp (κ ^ a)).ker have mem_S (x : Γ) : x ∈ S ↔ (κ x ^ a).val - 1 ∈ I := by simp [S, Units.ext_iff, ← Ideal.Quotient.eq] have S_closed : IsClosed (S : Set Γ) := by rw [show (S : Set Γ) = (fun x ↦ (κ x ^ a).val - 1) ⁻¹' I from Set.ext mem_S] exact (IsNoetherianRing.isClosed_ideal I).preimage (by fun_prop) have ker_le : κ.ker ≤ S := fun x hx ↦ by simp [mem_S, mem_ker.1 hx] have h_top : S = ⊤ := hγ S S_closed ker_le ((mem_S γ).2 (Ideal.mem_span_singleton_self _)) exact Ideal.mem_span_singleton.1 ((mem_S g).1 (h_top.ge (mem_top g))) /-- A profinite group has a generator modulo the kernel of a continuous character with values in 1 + 4ℤ_ℓ. -/ lemma New.Selmer.exists_isGeneratorModKer {ℓ : ℕ} {Γ : Type*} [Fact ℓ.Prime] [Group Γ] [TopologicalSpace Γ] [IsTopologicalGroup Γ] [CompactSpace Γ] [TotallyDisconnectedSpace Γ] {κ : Γ →* ℤ_[ℓ]ˣ} (hκ : Continuous κ) (hκ_four : ∀ g : Γ, 4 ∣ (κ g).val - 1) : ∃ γ : Γ, κ.IsGeneratorModKer γ := by obtain ⟨γ, hγ⟩ := exists_procyclic_generator κ hκ hκ_four refine ⟨γ, fun S S_closed S_ker hγS ↦ ?_⟩ -- A closed subgroup is the intersection of the open subgroups that contain it. have h_inf : S = sInf {N : Subgroup Γ | IsOpen (N : Set Γ) ∧ S ≤ N} := ProfiniteGrp.closedSubgroup_eq_sInf_open ⟨S, S_closed⟩ rw [h_inf, sInf_eq_top] exact fun N ⟨N_open, hSN⟩ ↦ (eq_top_iff' N).2 (hγ N (S_ker.trans hSN) N_open (hSN hγS)) end ProcyclicImage