Lean library · module TopologyByExample.Spaces.DuncanFiniteChanges

Finite changes to 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

theorem countBelow_le_add_of_agree_above

TopologyByExample.DuncanSpace.countBelow_le_add_of_agree_above

Altering membership only below M changes each counting function by at most M.

theorem countBelow_le_add_of_agree_above (x y : ℕ → ℕ) (M : ℕ)
    (h : ∀ k, M ≤ k → (k ∈ range x ↔ k ∈ range y)) (n : ℕ) :
    sequenceCountBelow x n ≤ sequenceCountBelow y n + M
Proof
:= by
  classical
  have hs : (Finset.range n).filter (fun k ↦ k ∈ range x) ⊆
      (Finset.range n).filter (fun k ↦ k ∈ range y) ∪ Finset.range M := by
    intro k hk
    obtain ⟨hkn, hkx⟩ := Finset.mem_filter.mp hk
    by_cases hMk : M ≤ k
    · exact Finset.mem_union_left _ (Finset.mem_filter.mpr ⟨hkn, (h k hMk).mp hkx⟩)
    · exact Finset.mem_union_right _ (Finset.mem_range.mpr (lt_of_not_ge hMk))
  have hc := Finset.card_union_le ((Finset.range n).filter (fun k ↦ k ∈ range y))
    (Finset.range M)
  exact (Finset.card_le_card hs).trans (by simpa [sequenceCountBelow] using hc)

theorem density_of_agree_above

TopologyByExample.DuncanSpace.density_of_agree_above

A finite change to the range of an integer sequence preserves asymptotic density.

theorem density_of_agree_above (x y : ℕ → ℕ) (M : ℕ)
    (h : ∀ k, M ≤ k → (k ∈ range x ↔ k ∈ range y)) (δ : ℝ)
    (hx : Tendsto (fun n : ℕ ↦ (sequenceCountBelow x n : ℝ) / n) atTop (𝓝 δ)) :
    Tendsto (fun n : ℕ ↦ (sequenceCountBelow y n : ℝ) / n) atTop (𝓝 δ)
Proof
:= by
  apply hx.congr_dist
  have hbound (n : ℕ) : |(sequenceCountBelow x n : ℝ) - sequenceCountBelow y n| ≤ M := by
    have h1 := countBelow_le_add_of_agree_above x y M h n
    have h2 := countBelow_le_add_of_agree_above y x M (fun k hk ↦ (h k hk).symm) n
    have h1' : (sequenceCountBelow x n : ℝ) ≤ sequenceCountBelow y n + M := by exact_mod_cast h1
    have h2' : (sequenceCountBelow y n : ℝ) ≤ sequenceCountBelow x n + M := by exact_mod_cast h2
    exact abs_le.mpr ⟨by linarith, by linarith⟩
  have hlim : Tendsto (fun n : ℕ ↦ (M : ℝ) / n) atTop (𝓝 0) := by
    simpa [div_eq_mul_inv] using tendsto_const_nhds.mul (tendsto_inv_atTop_nhds_zero_nat (𝕜 := ℝ))
  apply squeeze_zero (fun _ ↦ dist_nonneg) (fun n ↦ ?_) hlim
  rw [Real.dist_eq, ← sub_div, abs_div]
  simp only [abs_of_nonneg (show (0 : ℝ) ≤ n from Nat.cast_nonneg n)]
  exact div_le_div_of_nonneg_right (hbound n) (Nat.cast_nonneg n)

On this site: Duncan's space: Finite changes preserve density

definition skipTerm

TopologyByExample.DuncanSpace.skipTerm

Delete the Nth term of an increasing sequence.

def skipTerm (x : ℕ → ℕ) (N i : ℕ) : ℕ
:= x (if i < N then i else i + 1)

theorem strictMono_skipTerm

TopologyByExample.DuncanSpace.strictMono_skipTerm

Deleting a term preserves strict increase.

theorem strictMono_skipTerm {x : ℕ → ℕ} (hx : StrictMono x) (N : ℕ) :
    StrictMono (skipTerm x N)
Proof
:= by
  intro i j hij
  apply hx
  split_ifs <;> omega

theorem range_skipTerm

TopologyByExample.DuncanSpace.range_skipTerm

Deleting a term removes exactly that value from the range.

theorem range_skipTerm {x : ℕ → ℕ} (hx : StrictMono x) (N : ℕ) :
    range (skipTerm x N) = range x \ {x N}
Proof
:= by
  ext k
  constructor
  · rintro ⟨i, rfl⟩
    refine ⟨mem_range_self _, ?_⟩
    change x (if i < N then i else i + 1) ≠ x N
    intro he
    have hi := hx.injective he
    split_ifs at hi <;> omega
  · rintro ⟨⟨i, rfl⟩, hi⟩
    have hin : i ≠ N := fun h ↦ hi (by simp [h])
    by_cases h : i < N
    · exact ⟨i, by simp [skipTerm, h]⟩
    · refine ⟨i - 1, ?_⟩
      have h' : ¬i - 1 < N := by omega
      simp only [skipTerm, ite_eq_right h']
      congr 1
      omega

definition deleteTerm

TopologyByExample.DuncanSpace.deleteTerm

Deleting one term gives another point with the same density.

def deleteTerm (x : DuncanSpace) (N : ℕ) : DuncanSpace
Definition
:= by
  refine ⟨(skipTerm x.val.1 N, x.val.2), strictMono_skipTerm x.property.1 N,
    fun i ↦ x.property.2.1 _, ?_⟩
  apply density_of_agree_above x.val.1 (skipTerm x.val.1 N) (x.val.1 N + 1)
    (δ := x.val.2) ?_ x.property.2.2
  intro k hk
  rw [range_skipTerm x.property.1]
  simp only [Set.mem_sdiff, mem_singleton_iff]
  have hne : k ≠ x.val.1 N := by omega
  simp [hne]

theorem deleteTerm_ne

TopologyByExample.DuncanSpace.deleteTerm_ne

Deleting a term changes the point.

theorem deleteTerm_ne (x : DuncanSpace) (N : ℕ) : deleteTerm x N ≠ x
Proof
:= by
  intro h
  have he := congrArg (fun z : DuncanSpace ↦ z.val.1 N) h
  have hx := x.property.1 (Nat.lt_succ_self N)
  simp [deleteTerm, skipTerm] at he
  exact hx.ne he.symm

theorem tendsto_deleteTerm

TopologyByExample.DuncanSpace.tendsto_deleteTerm

Moving the deleted term to infinity converges to the original point.

theorem tendsto_deleteTerm (x : DuncanSpace) : Tendsto (deleteTerm x) atTop (𝓝 x)
Proof
:= by
  apply tendsto_subtype_rng.mpr
  apply Filter.Tendsto.prodMk_nhds
  · apply tendsto_pi_nhds.mpr
    intro i
    apply tendsto_const_nhds.congr'
    filter_upwards [eventually_gt_atTop i] with N hN
    simp [skipTerm, hN]
  · exact tendsto_const_nhds

instance

Duncan's space has no isolated points.

instance : PerfectSpace DuncanSpace
Proof
:= by
  apply perfectSpace_iff_forall_not_isolated.mpr
  intro x
  have h : Tendsto (deleteTerm x) atTop (𝓝[≠] x) :=
    tendsto_nhdsWithin_iff.mpr ⟨tendsto_deleteTerm x,
      Eventually.of_forall fun N ↦ deleteTerm_ne x N⟩
  exact h.neBot

definition skipBlock

TopologyByExample.DuncanSpace.skipBlock

Delete a finite block of K terms beginning at N.

def skipBlock (x : ℕ → ℕ) (N K i : ℕ) : ℕ
:= x (if i < N then i else i + K)

theorem strictMono_skipBlock

TopologyByExample.DuncanSpace.strictMono_skipBlock

Finite block deletion preserves strict increase.

theorem strictMono_skipBlock {x : ℕ → ℕ} (hx : StrictMono x) (N K : ℕ) :
    StrictMono (skipBlock x N K)
Proof
:= by
  intro i j hij
  apply hx
  split_ifs <;> omega

theorem range_skipBlock_agree_above

TopologyByExample.DuncanSpace.range_skipBlock_agree_above

Finite block deletion preserves every sufficiently large value.

theorem range_skipBlock_agree_above {x : ℕ → ℕ} (hx : StrictMono x) (N K k : ℕ)
    (hk : x (N + K) ≤ k) : k ∈ range x ↔ k ∈ range (skipBlock x N K)
Proof
:= by
  constructor
  · rintro ⟨i, rfl⟩
    have hi : N + K ≤ i := hx.le_iff_le.mp hk
    refine ⟨i - K, ?_⟩
    have hni : ¬i - K < N := by omega
    simp only [skipBlock, ite_eq_right hni]
    congr 1
    omega
  · rintro ⟨i, rfl⟩
    exact mem_range_self _

definition deleteBlock

TopologyByExample.DuncanSpace.deleteBlock

A point obtained by deleting a finite block, retaining the same density.

def deleteBlock (x : DuncanSpace) (N K : ℕ) : DuncanSpace
Definition
:= by
  refine ⟨(skipBlock x.val.1 N K, x.val.2), strictMono_skipBlock x.property.1 N K,
    fun i ↦ x.property.2.1 _, ?_⟩
  exact density_of_agree_above _ _ (x.val.1 (N + K))
    (range_skipBlock_agree_above x.property.1 N K) _ x.property.2.2

theorem tendsto_deleteBlock

TopologyByExample.DuncanSpace.tendsto_deleteBlock

Blocks deleted farther and farther out converge back, regardless of their lengths.

theorem tendsto_deleteBlock (x : DuncanSpace) (K : ℕ → ℕ) :
    Tendsto (fun N ↦ deleteBlock x N (K N)) atTop (𝓝 x)
Proof
:= by
  apply tendsto_subtype_rng.mpr
  apply Filter.Tendsto.prodMk_nhds
  · apply tendsto_pi_nhds.mpr
    intro i
    apply tendsto_const_nhds.congr'
    filter_upwards [eventually_gt_atTop i] with N hN
    simp [skipBlock, hN]
  · exact tendsto_const_nhds

theorem not_mem_nhds_of_isCompact

TopologyByExample.DuncanSpace.not_mem_nhds_of_isCompact

No compact subset of Duncan's space is a neighborhood of any point.

theorem not_mem_nhds_of_isCompact {C : Set DuncanSpace} (hC : IsCompact C) (x : DuncanSpace) :
    C ∉ 𝓝 x
Proof
:= by
  classical
  have hb (n : ℕ) : ∃ b : ℕ, ∀ z ∈ C, z.val.1 n ≤ b := by
    obtain ⟨b, hb⟩ :=
      (hC.image ((continuous_apply n).comp continuous_sequence)).finite_of_discrete.bddAbove
    exact ⟨b, fun z hz ↦ hb (mem_image_of_mem _ hz)⟩
  choose b hb using hb
  have hout (n : ℕ) : deleteBlock x n (b n + 1) ∉ C := by
    intro hn
    have hle := hb n _ hn
    change x.val.1 (if n < n then n else n + (b n + 1)) ≤ b n at hle
    simp only [lt_self_iff_false, ite_false] at hle
    have hlarge := x.property.1.id_le (n + (b n + 1))
    dsimp at hlarge
    omega
  intro hx
  have hmem : ∀ᶠ n in atTop, deleteBlock x n (b n + 1) ∈ C :=
    (tendsto_deleteBlock x (fun n ↦ b n + 1)) hx
  obtain ⟨n, hn⟩ := hmem.exists
  exact hout n hn

theorem not_weaklyLocallyCompactSpace

TopologyByExample.DuncanSpace.not_weaklyLocallyCompactSpace

Duncan's space is not weakly locally compact.

theorem not_weaklyLocallyCompactSpace : ¬WeaklyLocallyCompactSpace DuncanSpace
Proof
:= by
  intro h
  let := h
  obtain ⟨C, hC, hx⟩ := exists_compact_mem_nhds positiveIntegers
  exact not_mem_nhds_of_isCompact hC positiveIntegers hx

On this site: Duncan's space is not weakly locally compact