Lean library · module TopologyByExample.Spaces.DuncanSpace

Duncan's space of integer sequences with asymptotic density

Source file

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

Imports

definition sequenceCountBelow

TopologyByExample.sequenceCountBelow

The number of values of a sequence below a given natural number.

def sequenceCountBelow (x : ℕ → ℕ) (n : ℕ) : ℕ
:= by
  classical
  exact ((Finset.range n).filter fun k ↦ k ∈ range x).card

definition DuncanSpace

TopologyByExample.DuncanSpace

Duncan's space, realized as the graph of asymptotic density over strictly increasing sequences of positive integers, with the induced product topology.

abbrev DuncanSpace
:= ↥({p : (ℕ → ℕ) × ℝ | StrictMono p.1 ∧ (∀ i, 0 < p.1 i) ∧
  Tendsto (fun n : ℕ ↦ (sequenceCountBelow p.1 n : ℝ) / n) atTop (𝓝 p.2)})

On this site: Space: Duncan's space

check

example : SecondCountableTopology DuncanSpace
Proof
:= inferInstance

check

example : MetrizableSpace DuncanSpace
Proof
:= inferInstance

theorem continuous_sequence

TopologyByExample.DuncanSpace.continuous_sequence

Forgetting the density coordinate is continuous.

theorem continuous_sequence : Continuous (fun x : DuncanSpace ↦ x.val.1)
Proof
:=
  continuous_fst.comp continuous_subtypeVal

theorem continuous_density

TopologyByExample.DuncanSpace.continuous_density

Asymptotic density is continuous on Duncan's space.

theorem continuous_density : Continuous (fun x : DuncanSpace ↦ x.val.2)
Proof
:=
  continuous_snd.comp continuous_subtypeVal

theorem sequence_injective

TopologyByExample.DuncanSpace.sequence_injective

A sequence determines its density, so forgetting that coordinate is injective.

theorem sequence_injective : Function.Injective (fun x : DuncanSpace ↦ x.val.1)
Proof
:= by
  intro x y h
  apply Subtype.ext
  apply Prod.ext h
  exact tendsto_nhds_unique x.property.2.2 (by simpa only [h] using y.property.2.2)

instance

Duncan's space is totally separated, since its sequence coordinates separate points.

instance : TotallySeparatedSpace DuncanSpace
Proof
:= by
  apply totallySeparatedSpace_iff_exists_isClopen.mpr
  intro x y hxy
  obtain ⟨U, hU, hx, hy⟩ := exists_isClopen_of_totally_separated
    (show x.val.1 ≠ y.val.1 from fun h ↦ hxy (sequence_injective h))
  exact ⟨(fun z : DuncanSpace ↦ z.val.1) ⁻¹' U, hU.preimage continuous_sequence, hx, hy⟩

theorem countBelow_successor

TopologyByExample.DuncanSpace.countBelow_successor

The first n positive integers are precisely the values below n+1.

theorem countBelow_successor (n : ℕ) : sequenceCountBelow (fun i ↦ i + 1) (n + 1) = n
Proof
:= by
  classical
  have heq : (Finset.range (n + 1)).filter (fun k ↦ k ∈ range (fun i : ℕ ↦ i + 1)) =
      (Finset.range (n + 1)).erase 0 := by
    ext k
    simp only [Finset.mem_filter, Finset.mem_range, mem_range, Finset.mem_erase]
    constructor
    · rintro ⟨hk, i, rfl⟩
      exact ⟨by omega, hk⟩
    · rintro ⟨hk, hkn⟩
      exact ⟨hkn, k - 1, by omega⟩
  unfold sequenceCountBelow
  rw [heq]
  simp

theorem density_successor

TopologyByExample.DuncanSpace.density_successor

The sequence of all positive integers has density one.

theorem density_successor :
    Tendsto (fun n : ℕ ↦ (sequenceCountBelow (fun i ↦ i + 1) n : ℝ) / n) atTop (𝓝 1)
Proof
:= by
  apply (tendsto_add_atTop_iff_nat 1).mp
  simpa only [countBelow_successor, Nat.cast_add, Nat.cast_one] using
    (tendsto_natCast_div_add_atTop (1 : ℝ))

definition positiveIntegers

TopologyByExample.DuncanSpace.positiveIntegers

The sequence of all positive integers is a point of Duncan's space.

def positiveIntegers : DuncanSpace
:=
  ⟨(fun i ↦ i + 1, 1), fun _ _ h ↦ by dsimp; omega, fun _ ↦ by dsimp; omega, density_successor⟩

instance

instance : Nonempty DuncanSpace
Proof
:= ⟨positiveIntegers⟩