Lean library · module TopologyByExample.Spaces.ArithmeticProgression

Arithmetic progression topologies on the positive integers

Source file

The Golomb space and the Kirch space are the positive integers with a topology whose basic open sets are arithmetic progressions {y | y ≡ b [MOD a]} with a coprime to b, where the modulus a ranges over all positive integers (Golomb) or over the squarefree ones (Kirch). In this file we treat both at once: a ModulusSet is a set of positive moduli containing 1 and every prime and closed under least common multiples, and ArithProgSpace M is the positive integers with the topology in which a set is open when each of its points x lies in it together with a progression {y | y ≡ x [MOD a]}, with a ∈ M coprime to x.

Main definitions

Main statements

This file was written by Claude (Anthropic's AI model) working under the direction of David R. MacIver, who reviews it and is responsible for it.

Imports

structure ModulusSet

TopologyByExample.ModulusSet

An admissible set of moduli for an arithmetic progression topology on the positive integers: positive, containing 1 and every prime, and closed under least common multiples.

structure ModulusSet where
  /-- The admissible moduli. -/
  Mem : ℕ → Prop
  /-- Admissible moduli are positive. -/
  pos : ∀ {a}, Mem a → 0 < a
  /-- `1` is admissible. -/
  one_mem : Mem 1
  /-- The least common multiple of two admissible moduli is admissible. -/
  lcm_mem : ∀ {a b}, Mem a → Mem b → Mem (Nat.lcm a b)
  /-- Every prime is admissible. -/
  prime_mem : ∀ {p}, p.Prime → Mem p

Arithmetic facts

theorem exists_pos_modEq_modEq

TopologyByExample.exists_pos_modEq_modEq

A solution of two congruences, positive, when the residues agree modulo the gcd of the moduli.

theorem exists_pos_modEq_modEq {c a u v : ℕ} (hc : 0 < c) (ha : 0 < a)
    (h : u ≡ v [MOD Nat.gcd c a]) : ∃ z, 0 < z ∧ z ≡ u [MOD c] ∧ z ≡ v [MOD a]
Proof
:= by
  obtain ⟨k, hk1, hk2⟩ := Nat.chineseRemainder' h
  refine ⟨k + c * a, by positivity, ?_, ?_⟩
  · exact (show k + c * a ≡ k [MOD c] by simp [Nat.ModEq, Nat.add_mul_mod_self_left]).trans hk1
  · exact (show k + c * a ≡ k [MOD a] by simp [Nat.ModEq, Nat.add_mul_mod_self_right]).trans hk2

theorem coprime_iff_of_modEq

TopologyByExample.coprime_iff_of_modEq

Two numbers congruent modulo a are coprime to a together.

theorem coprime_iff_of_modEq {a x y : ℕ} (h : y ≡ x [MOD a]) :
    Nat.Coprime a y ↔ Nat.Coprime a x
Proof
:= by
  simp only [Nat.Coprime, Nat.gcd_comm a, h.gcd_eq]

definition ArithProgSpace

TopologyByExample.ArithProgSpace

The positive integers with an arithmetic progression topology. The topology is given by the instance below; the type is a copy of ℕ+, so as not to inherit its discrete topology.

def ArithProgSpace (_M : ModulusSet) : Type
:= ℕ+
variable {M : ModulusSet}

definition val

TopologyByExample.ArithProgSpace.val

The positive integer underlying a point.

def val (x : ArithProgSpace M) : ℕ
:= PNat.val x

definition mk

TopologyByExample.ArithProgSpace.mk

The point given by a positive integer.

def mk (n : ℕ) (hn : 0 < n) : ArithProgSpace M
:= (⟨n, hn⟩ : ℕ+)

theorem val_mk

TopologyByExample.ArithProgSpace.val_mk

@[simp] theorem val_mk (n : ℕ) (hn : 0 < n) : (mk n hn : ArithProgSpace M).val = n
Proof
:= rfl

theorem val_pos

TopologyByExample.ArithProgSpace.val_pos

theorem val_pos (x : ArithProgSpace M) : 0 < x.val
Proof
:= PNat.pos x

theorem val_injective

TopologyByExample.ArithProgSpace.val_injective

theorem val_injective : Function.Injective (val : ArithProgSpace M → ℕ)
Proof
:= PNat.coe_injective

theorem val_inj

TopologyByExample.ArithProgSpace.val_inj

@[simp] theorem val_inj {x y : ArithProgSpace M} : x.val = y.val ↔ x = y
Proof
:= val_injective.eq_iff

instance

The space is countable.

instance : Countable (ArithProgSpace M)
Proof
:= inferInstanceAs (Countable ℕ+)

instance

The space is nonempty.

instance : Nonempty (ArithProgSpace M)
Proof
:= ⟨mk 1 one_pos⟩

definition prog

TopologyByExample.ArithProgSpace.prog

The arithmetic progression of the points congruent to x modulo a.

def prog (a : ℕ) (x : ArithProgSpace M) : Set (ArithProgSpace M)
:= {y | y.val ≡ x.val [MOD a]}

theorem mem_prog

TopologyByExample.ArithProgSpace.mem_prog

@[simp] theorem mem_prog {a : ℕ} {x y : ArithProgSpace M} : y ∈ prog a x ↔ y.val ≡ x.val [MOD a]
Proof
:=
  Iff.rfl

theorem mem_prog_self

TopologyByExample.ArithProgSpace.mem_prog_self

theorem mem_prog_self (a : ℕ) (x : ArithProgSpace M) : x ∈ prog a x
Proof
:= Nat.ModEq.refl _

theorem prog_eq_of_mem

TopologyByExample.ArithProgSpace.prog_eq_of_mem

theorem prog_eq_of_mem {a : ℕ} {x y : ArithProgSpace M} (h : y ∈ prog a x) : prog a y = prog a x
Proof
:=
  ext fun _ ↦ ⟨fun hz ↦ Nat.ModEq.trans hz h, fun hz ↦ Nat.ModEq.trans hz h.symm⟩

theorem prog_subset_prog

TopologyByExample.ArithProgSpace.prog_subset_prog

theorem prog_subset_prog {a c : ℕ} (h : a ∣ c) (x : ArithProgSpace M) : prog c x ⊆ prog a x
Proof
:=
  fun _ hy ↦ Nat.ModEq.of_dvd h hy

theorem prog_lcm

TopologyByExample.ArithProgSpace.prog_lcm

theorem prog_lcm (a c : ℕ) (x : ArithProgSpace M) : prog (Nat.lcm a c) x = prog a x ∩ prog c x
Proof
:=
  ext fun _ ↦ Nat.modEq_and_modEq_iff_modEq_lcm.symm

theorem coprime_of_mem_prog

TopologyByExample.ArithProgSpace.coprime_of_mem_prog

theorem coprime_of_mem_prog {a : ℕ} {x y : ArithProgSpace M} (h : y ∈ prog a x)
    (hx : Nat.Coprime a x.val) : Nat.Coprime a y.val
Proof
:=
  (coprime_iff_of_modEq h).2 hx

instance instTopologicalSpace

TopologyByExample.ArithProgSpace.instTopologicalSpace

A set is open if each of its points x lies in it together with a progression modulo some admissible a coprime to x.

instance instTopologicalSpace : TopologicalSpace (ArithProgSpace M)
Proof
where
  IsOpen U := ∀ x ∈ U, ∃ a, M.Mem a ∧ Nat.Coprime a x.val ∧ prog a x ⊆ U
  isOpen_univ x _ := ⟨1, M.one_mem, Nat.coprime_one_left _, subset_univ _⟩
  isOpen_inter s t hs ht x hx := by
    obtain ⟨a, ha, hax, has⟩ := hs x hx.1
    obtain ⟨c, hc, hcx, hct⟩ := ht x hx.2
    refine ⟨Nat.lcm a c, M.lcm_mem ha hc,
      Nat.Coprime.coprime_dvd_left (Nat.lcm_dvd_mul a c) (Nat.Coprime.mul_left hax hcx), ?_⟩
    rw [prog_lcm]
    exact inter_subset_inter has hct
  isOpen_sUnion S hS x := by
    rintro ⟨t, ht, hx⟩
    obtain ⟨a, ha, hax, hat⟩ := hS t ht x hx
    exact ⟨a, ha, hax, hat.trans (subset_sUnion_of_mem ht)⟩

theorem isOpen_iff

TopologyByExample.ArithProgSpace.isOpen_iff

theorem isOpen_iff {U : Set (ArithProgSpace M)} :
    IsOpen U ↔ ∀ x ∈ U, ∃ a, M.Mem a ∧ Nat.Coprime a x.val ∧ prog a x ⊆ U
Proof
:=
  Iff.rfl

theorem isOpen_prog

TopologyByExample.ArithProgSpace.isOpen_prog

A basic progression is open.

theorem isOpen_prog {a : ℕ} (ha : M.Mem a) {x : ArithProgSpace M} (hx : Nat.Coprime a x.val) :
    IsOpen (prog a x)
Proof
:= fun _ hy ↦
  ⟨a, ha, coprime_of_mem_prog hy hx, (prog_eq_of_mem hy).subset⟩

theorem hasBasis_nhds

TopologyByExample.ArithProgSpace.hasBasis_nhds

The basic progressions through x form a neighbourhood base at x.

theorem hasBasis_nhds (x : ArithProgSpace M) :
    (𝓝 x).HasBasis (fun a ↦ M.Mem a ∧ Nat.Coprime a x.val) (prog · x)
Proof
:= by
  refine ⟨fun t ↦ ⟨fun ht ↦ ?_, fun ⟨a, ⟨ha, hax⟩, hat⟩ ↦
    mem_of_superset ((isOpen_prog ha hax).mem_nhds (mem_prog_self a x)) hat⟩⟩
  obtain ⟨U, hUt, hU, hxU⟩ := mem_nhds_iff.1 ht
  obtain ⟨a, ha, hax, haU⟩ := hU x hxU
  exact ⟨a, ⟨ha, hax⟩, haU.trans hUt⟩

instance

The space is first countable.

instance : FirstCountableTopology (ArithProgSpace M)
Proof
:=
  ⟨fun x ↦ (hasBasis_nhds x).isCountablyGenerated⟩

instance

The space is second countable.

instance : SecondCountableTopology (ArithProgSpace M)
Proof
:= inferInstance

instance

Two distinct points lie in disjoint progressions modulo a prime larger than both.

instance : T2Space (ArithProgSpace M)
Proof
:= by
  refine ⟨fun x y hxy ↦ ?_⟩
  obtain ⟨p, hp, hpp⟩ := Nat.exists_infinite_primes (x.val + y.val + 1)
  have hxp : x.val < p := by have := y.val_pos; omega
  have hyp : y.val < p := by have := x.val_pos; omega
  have hcop : ∀ z : ArithProgSpace M, z.val < p → Nat.Coprime p z.val := fun z hz ↦
    (Nat.Prime.coprime_iff_not_dvd hpp).2 fun hd ↦
      absurd (Nat.le_of_dvd z.val_pos hd) (not_le.2 hz)
  refine ⟨prog p x, prog p y, isOpen_prog (M.prime_mem hpp) (hcop x hxp),
    isOpen_prog (M.prime_mem hpp) (hcop y hyp), mem_prog_self _ _, mem_prog_self _ _, ?_⟩
  refine disjoint_left.2 fun z hzx hzy ↦ hxy ?_
  have h : x.val ≡ y.val [MOD p] := (Nat.ModEq.symm hzx).trans hzy
  rw [← val_inj]
  simpa [Nat.ModEq, Nat.mod_eq_of_lt hxp, Nat.mod_eq_of_lt hyp] using h

Closures of progressions

theorem mem_closure_prog_of_dvd

TopologyByExample.ArithProgSpace.mem_closure_prog_of_dvd

The closure of a basic progression of modulus a contains every multiple of a.

theorem mem_closure_prog_of_dvd {a : ℕ} (ha : 0 < a) (b : ArithProgSpace M)
    {x : ArithProgSpace M} (hx : a ∣ x.val) : x ∈ closure (prog a b)
Proof
:= by
  refine (mem_closure_iff_nhds_basis' (hasBasis_nhds x)).2 fun c ⟨hc, hcx⟩ ↦ ?_
  have hca : Nat.Coprime c a := Nat.Coprime.coprime_dvd_right hx hcx
  obtain ⟨z, hz, hzc, hza⟩ := exists_pos_modEq_modEq (u := x.val) (v := b.val) (M.pos hc) ha
    (by rw [hca.gcd_eq_one]; exact Nat.modEq_one)
  exact ⟨mk z hz, hzc, hza⟩

theorem closure_inter_closure_nonempty

TopologyByExample.ArithProgSpace.closure_inter_closure_nonempty

The closures of any two nonempty open sets meet: both contain a common multiple of the moduli of basic progressions inside them.

theorem closure_inter_closure_nonempty (U V : Set (ArithProgSpace M)) (hU : IsOpen U)
    (hV : IsOpen V) (hU' : U.Nonempty) (hV' : V.Nonempty) : (closure U ∩ closure V).Nonempty
Proof
:= by
  obtain ⟨x, hx⟩ := hU'
  obtain ⟨y, hy⟩ := hV'
  obtain ⟨a, ha, -, haU⟩ := hU x hx
  obtain ⟨c, hc, -, hcV⟩ := hV y hy
  have hpos : 0 < a * c := Nat.mul_pos (M.pos ha) (M.pos hc)
  exact ⟨mk (a * c) hpos,
    closure_mono haU (mem_closure_prog_of_dvd (M.pos ha) x (by simp)),
    closure_mono hcV (mem_closure_prog_of_dvd (M.pos hc) y (by simp))⟩

instance

The space is preconnected.

instance : PreconnectedSpace (ArithProgSpace M)
Proof
:=
  (preconnectedSpace_and_not_t25_of_closure_inter_closure closure_inter_closure_nonempty).1

theorem not_t25Space

TopologyByExample.ArithProgSpace.not_t25Space

The space is not Urysohn: 1 and 2 have no neighbourhoods with disjoint closures.

theorem not_t25Space : ¬T25Space (ArithProgSpace M)
Proof
:= fun h ↦ by
  have := (preconnectedSpace_and_not_t25_of_closure_inter_closure
    (closure_inter_closure_nonempty (M := M))).2.2 h
  have h12 := Subsingleton.elim (mk 1 one_pos : ArithProgSpace M) (mk 2 two_pos)
  simpa using congrArg val h12

theorem exists_ne_mem_prog

TopologyByExample.ArithProgSpace.exists_ne_mem_prog

Every progression through x with a positive modulus contains a point other than x.

theorem exists_ne_mem_prog {a : ℕ} (ha : 0 < a) (x : ArithProgSpace M) :
    ∃ y ∈ prog a x, y ≠ x
Proof
:= by
  refine ⟨mk (x.val + a) (by have := x.val_pos; omega), ?_, fun h ↦ ?_⟩
  · simp [Nat.ModEq]
  · have := congrArg val h
    simp at this
    omega

theorem not_hasIsolatedPoint

TopologyByExample.ArithProgSpace.not_hasIsolatedPoint

No point is isolated.

theorem not_hasIsolatedPoint : ¬HasIsolatedPoint (ArithProgSpace M)
Proof
:= by
  rintro ⟨x, hx⟩
  obtain ⟨a, ha, -, hax⟩ := hx x rfl
  obtain ⟨y, hy, hyx⟩ := exists_ne_mem_prog (M.pos ha) x
  exact hyx (hax hy)