Lean library · module TopologyByExample.Spaces.InfiniteCage

The infinite cage

Source file

For n ≥ 1 let Aₙ be the segment of points (1 / n, y, 0) of space with 0 ≤ y ≤ 3n, let Bₙ be the segment of points (0, y, 0) with 2n - 1 / 2 ≤ y ≤ 2n + 1 / 2, and let Cₙ be the arc of points (x, 2n, x (1 / n - x)) with 0 ≤ x ≤ 1 / n, which joins the point (0, 2n, 0) of Bₙ to the point (1 / n, 2n, 0) of Aₙ. The infinite cage is the union of all the sets Dₙ = Aₙ ∪ Bₙ ∪ Cₙ, with the subspace topology of ℝ³. In this file the pieces are indexed from 0: piece m is D_{m + 1}.

The pieces Dₙ are pairwise disjoint, compact and path connected. Every point (0, y, 0) of a segment Bₙ is the limit of the points (1 / k, y, 0) of the segments A_k along any infinite set of indices k. Hence a closed set containing infinitely many of the segments A_k contains every Bₙ, and the cage is connected. By Sierpiński's theorem a path, whose image is a continuum covered by the countably many disjoint closed pieces, stays in one piece, so the cage is not path connected. It is not locally connected: in the slab 7 / 4 < y < 2, which meets no arc Cₙ, the first coordinates of its points lie in the countable set of the numbers 0 and 1 / k. It is not weakly locally compact at the end (0, 5 / 2, 0) of B₁: a compact neighbourhood would contain the limits (0, y, 0) of points of the segments A_k, for some y just above 5 / 2, which are not in the cage. It is a Gδ subset of space, hence completely metrizable.

Main definitions

Main statements

Tags

infinite cage, connected, path connected, locally compact

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

theorem isClosed_setOf_exists_mem

TopologyByExample.InfiniteCage.isClosed_setOf_exists_mem

A projection along a compact set preserves closedness: if F ⊆ X × Y is closed and K ⊆ Y is compact, the set of x with (x, y) ∈ F for some y ∈ K is closed.

theorem isClosed_setOf_exists_mem {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y]
    {K : Set Y} (hK : IsCompact K) {F : Set (X × Y)} (hF : IsClosed F) :
    IsClosed {x | ∃ y ∈ K, (x, y) ∈ F}
Proof
:= by
  have : CompactSpace K := isCompact_iff_compactSpace.1 hK
  have hG : IsClosed ((Prod.map id ((↑) : K → Y)) ⁻¹' F) :=
    hF.preimage (continuous_id.prodMap continuous_subtypeVal)
  convert isClosedMap_fst_of_compactSpace _ hG using 1
  ext x
  constructor
  · rintro ⟨y, hy, h⟩
    exact ⟨(x, ⟨y, hy⟩), h, rfl⟩
  · rintro ⟨⟨x, y⟩, h, rfl⟩
    exact ⟨y, y.property, h⟩

definition segA

TopologyByExample.InfiniteCage.segA

The segment A_{m + 1}: the points (1 / (m + 1), y, 0) with 0 ≤ y ≤ 3 (m + 1).

noncomputable def segA (m : ℕ) : Set (ℝ × ℝ × ℝ)
:=
  {1 / ((m : ℝ) + 1)} ×ˢ (Icc 0 (3 * ((m : ℝ) + 1)) ×ˢ {0})

definition segB

TopologyByExample.InfiniteCage.segB

The segment B_{m + 1}: the points (0, y, 0) with |y - 2 (m + 1)| ≤ 1 / 2.

noncomputable def segB (m : ℕ) : Set (ℝ × ℝ × ℝ)
:=
  {0} ×ˢ (Icc (2 * ((m : ℝ) + 1) - 1 / 2) (2 * ((m : ℝ) + 1) + 1 / 2) ×ˢ {0})

definition arcC

TopologyByExample.InfiniteCage.arcC

The arc C_{m + 1}: the points (x, 2 (m + 1), x (1 / (m + 1) - x)) with 0 ≤ x ≤ 1 / (m + 1).

noncomputable def arcC (m : ℕ) : Set (ℝ × ℝ × ℝ)
:=
  (fun x : ℝ ↦ (x, 2 * ((m : ℝ) + 1), x * (1 / ((m : ℝ) + 1) - x))) '' Icc 0 (1 / ((m : ℝ) + 1))

definition piece

TopologyByExample.InfiniteCage.piece

The piece D_{m + 1} = A_{m + 1} ∪ B_{m + 1} ∪ C_{m + 1}.

noncomputable def piece (m : ℕ) : Set (ℝ × ℝ × ℝ)
:= segA m ∪ segB m ∪ arcC m

definition cage

TopologyByExample.InfiniteCage.cage

The infinite cage: the union of the pieces.

noncomputable def cage : Set (ℝ × ℝ × ℝ)
:= ⋃ m, piece m

theorem mem_segA

TopologyByExample.InfiniteCage.mem_segA

theorem mem_segA {m : ℕ} {p : ℝ × ℝ × ℝ} :
    p ∈ segA m ↔ p.1 = 1 / ((m : ℝ) + 1) ∧ 0 ≤ p.2.1 ∧ p.2.1 ≤ 3 * ((m : ℝ) + 1) ∧ p.2.2 = 0
Proof
:= by
  simp [segA, and_assoc]

theorem mem_segB

TopologyByExample.InfiniteCage.mem_segB

theorem mem_segB {m : ℕ} {p : ℝ × ℝ × ℝ} :
    p ∈ segB m ↔ p.1 = 0 ∧ 2 * ((m : ℝ) + 1) - 1 / 2 ≤ p.2.1 ∧
      p.2.1 ≤ 2 * ((m : ℝ) + 1) + 1 / 2 ∧ p.2.2 = 0
Proof
:= by
  simp [segB, and_assoc]

theorem mem_arcC

TopologyByExample.InfiniteCage.mem_arcC

theorem mem_arcC {m : ℕ} {p : ℝ × ℝ × ℝ} :
    p ∈ arcC m ↔ 0 ≤ p.1 ∧ p.1 ≤ 1 / ((m : ℝ) + 1) ∧ p.2.1 = 2 * ((m : ℝ) + 1) ∧
      p.2.2 = p.1 * (1 / ((m : ℝ) + 1) - p.1)
Proof
:= by
  obtain ⟨x, y, z⟩ := p
  simp only [arcC, mem_image, mem_Icc, Prod.mk.injEq]
  constructor
  · rintro ⟨t, ⟨h0, h1⟩, rfl, rfl, rfl⟩; exact ⟨h0, h1, rfl, rfl⟩
  · rintro ⟨h0, h1, rfl, rfl⟩; exact ⟨x, ⟨h0, h1⟩, rfl, rfl, rfl⟩

theorem isCompact_piece

TopologyByExample.InfiniteCage.isCompact_piece

theorem isCompact_piece (m : ℕ) : IsCompact (piece m)
Proof
:=
  ((isCompact_singleton.prod (isCompact_Icc.prod isCompact_singleton)).union
    (isCompact_singleton.prod (isCompact_Icc.prod isCompact_singleton))).union
    (isCompact_Icc.image (by fun_prop))

theorem isClosed_piece

TopologyByExample.InfiniteCage.isClosed_piece

theorem isClosed_piece (m : ℕ) : IsClosed (piece m)
Proof
:= (isCompact_piece m).isClosed

theorem mem_segA_inter_arcC

TopologyByExample.InfiniteCage.mem_segA_inter_arcC

The arc meets the segment A at (1 / (m + 1), 2 (m + 1), 0).

theorem mem_segA_inter_arcC (m : ℕ) :
    ((1 / ((m : ℝ) + 1), 2 * ((m : ℝ) + 1), 0) : ℝ × ℝ × ℝ) ∈ segA m ∩ arcC m
Proof
:= by
  refine ⟨mem_segA.2 ⟨rfl, by positivity, by linarith [m.cast_nonneg' (α := ℝ)], rfl⟩,
    mem_arcC.2 ⟨by positivity, le_rfl, rfl, by ring⟩⟩

theorem mem_segB_inter_arcC

TopologyByExample.InfiniteCage.mem_segB_inter_arcC

The arc meets the segment B at (0, 2 (m + 1), 0).

theorem mem_segB_inter_arcC (m : ℕ) :
    ((0, 2 * ((m : ℝ) + 1), 0) : ℝ × ℝ × ℝ) ∈ segB m ∩ arcC m
Proof
:=
  ⟨mem_segB.2 ⟨rfl, by linarith, by linarith, rfl⟩,
    mem_arcC.2 ⟨le_rfl, by positivity, rfl, by ring⟩⟩

theorem isPathConnected_segA

TopologyByExample.InfiniteCage.isPathConnected_segA

theorem isPathConnected_segA (m : ℕ) : IsPathConnected (segA m)
Proof
:=
  ((convex_singleton _).prod ((convex_Icc _ _).prod (convex_singleton _))).isPathConnected
    ⟨_, (mem_segA_inter_arcC m).1⟩

theorem isPathConnected_segB

TopologyByExample.InfiniteCage.isPathConnected_segB

theorem isPathConnected_segB (m : ℕ) : IsPathConnected (segB m)
Proof
:=
  ((convex_singleton _).prod ((convex_Icc _ _).prod (convex_singleton _))).isPathConnected
    ⟨_, (mem_segB_inter_arcC m).1⟩

theorem isPathConnected_arcC

TopologyByExample.InfiniteCage.isPathConnected_arcC

theorem isPathConnected_arcC (m : ℕ) : IsPathConnected (arcC m)
Proof
:=
  ((convex_Icc _ _).isPathConnected (nonempty_Icc.2 (by positivity))).image (by fun_prop)

theorem isPathConnected_piece

TopologyByExample.InfiniteCage.isPathConnected_piece

Each piece is path connected.

theorem isPathConnected_piece (m : ℕ) : IsPathConnected (piece m)
Proof
:= by
  have hAC := (isPathConnected_segA m).union (isPathConnected_arcC m) ⟨_, mem_segA_inter_arcC m⟩
  have := hAC.union (isPathConnected_segB m)
    ⟨_, Or.inr (mem_segB_inter_arcC m).2, (mem_segB_inter_arcC m).1⟩
  convert this using 1
  simp only [piece]
  ac_rfl

theorem pairwise_disjoint_piece

TopologyByExample.InfiniteCage.pairwise_disjoint_piece

The pieces are pairwise disjoint.

theorem pairwise_disjoint_piece : Pairwise (Disjoint on piece)
Proof
:= by
  intro m n hmn
  rw [Function.onFun, Set.disjoint_left]
  have hm : (0 : ℝ) < (m : ℝ) + 1 := by positivity
  have hn : (0 : ℝ) < (n : ℝ) + 1 := by positivity
  have hmn' : (m : ℝ) ≠ n := by exact_mod_cast hmn
  have hinv : 1 / ((m : ℝ) + 1) ≠ 1 / ((n : ℝ) + 1) := by
    intro h; rw [div_eq_div_iff hm.ne' hn.ne', one_mul, one_mul] at h; exact hmn' (by linarith)
  -- intervals around `2 (m + 1)` and `2 (n + 1)` are far apart
  have hfar : 2 ≤ |2 * ((m : ℝ) + 1) - 2 * ((n : ℝ) + 1)| := by
    rcases lt_or_gt_of_ne hmn with h | h
    · have : (m : ℝ) + 1 ≤ n := by exact_mod_cast h
      rw [abs_of_neg (by linarith)]; linarith
    · have : (n : ℝ) + 1 ≤ m := by exact_mod_cast h
      rw [abs_of_pos (by linarith)]; linarith
  rintro ⟨x, y, z⟩ hpm hpn
  -- the case analysis on the three parts of each piece
  rcases hpm with (hA | hB) | hC <;> rcases hpn with (hA' | hB') | hC'
  · exact hinv ((mem_segA.1 hA).1.symm.trans (mem_segA.1 hA').1)
  · have h1 := (mem_segA.1 hA).1; have h2 := (mem_segB.1 hB').1
    simp only at h1 h2; rw [h2] at h1; exact absurd h1.symm (by positivity)
  · obtain ⟨h1, -, -, h4⟩ := mem_segA.1 hA
    obtain ⟨-, -, -, h4'⟩ := mem_arcC.1 hC'
    simp only at h1 h4 h4'
    rw [h4, h1] at h4'
    have : 1 / ((n : ℝ) + 1) - 1 / ((m : ℝ) + 1) = 0 :=
      (mul_eq_zero.1 h4'.symm).resolve_left (by positivity)
    exact hinv (by linarith)
  · have h1 := (mem_segB.1 hB).1; have h2 := (mem_segA.1 hA').1
    simp only at h1 h2; rw [h1] at h2; exact absurd h2 (by positivity)
  · obtain ⟨-, h2, h3, -⟩ := mem_segB.1 hB
    obtain ⟨-, h2', h3', -⟩ := mem_segB.1 hB'
    simp only at h2 h3 h2' h3'
    have : |2 * ((m : ℝ) + 1) - 2 * ((n : ℝ) + 1)| ≤ 1 := by rw [abs_le]; constructor <;> linarith
    linarith
  · obtain ⟨h1, h2, h3, -⟩ := mem_segB.1 hB
    obtain ⟨-, -, h3', -⟩ := mem_arcC.1 hC'
    simp only at h2 h3 h3'
    rw [h3'] at h2 h3
    have : |2 * ((m : ℝ) + 1) - 2 * ((n : ℝ) + 1)| ≤ 1 / 2 := by
      rw [abs_le]; constructor <;> linarith
    linarith
  · obtain ⟨-, -, -, h4⟩ := mem_arcC.1 hC
    obtain ⟨h1, -, -, h4'⟩ := mem_segA.1 hA'
    simp only at h1 h4 h4'
    rw [h4', h1] at h4
    have : 1 / ((m : ℝ) + 1) - 1 / ((n : ℝ) + 1) = 0 :=
      (mul_eq_zero.1 h4.symm).resolve_left (by positivity)
    exact hinv (by linarith)
  · obtain ⟨-, -, h3, -⟩ := mem_arcC.1 hC
    obtain ⟨h1, h2, h3', -⟩ := mem_segB.1 hB'
    simp only at h3 h2 h3'
    rw [h3] at h2 h3'
    have : |2 * ((m : ℝ) + 1) - 2 * ((n : ℝ) + 1)| ≤ 1 / 2 := by
      rw [abs_le]; constructor <;> linarith
    linarith
  · have h1 := (mem_arcC.1 hC).2.2.1; have h2 := (mem_arcC.1 hC').2.2.1
    simp only at h1 h2
    exact hmn' (by linarith)

theorem pieces_spec

TopologyByExample.InfiniteCage.pieces_spec

The pieces are pairwise disjoint, compact and path connected.

theorem pieces_spec :
    Pairwise (Disjoint on piece) ∧ ∀ n, IsCompact (piece n) ∧ IsPathConnected (piece n)
Proof
:=
  ⟨pairwise_disjoint_piece, fun n ↦ ⟨isCompact_piece n, isPathConnected_piece n⟩⟩

On this site: Infinite cage: The pieces \(D_n\) are pairwise disjoint, compact and path connected

theorem segB_subset_of_frequently

TopologyByExample.InfiniteCage.segB_subset_of_frequently

The points (0, y, 0) of the segments B lie in every closed set containing infinitely many of the segments A: they are the limits of the points (1 / (k + 1), y, 0) of the segments A_{k + 1} along any infinite set of indices.

theorem segB_subset_of_frequently {F : Set (ℝ × ℝ × ℝ)} (hF : IsClosed F) {J : Set ℕ}
    (hJ : J.Infinite) (hJF : ∀ m ∈ J, segA m ⊆ F) (n : ℕ) : segB n ⊆ F
Proof
:= by
  rintro ⟨x, y, z⟩ hp
  obtain ⟨hx, hy0, -, hz⟩ := mem_segB.1 hp
  simp only at hx hy0 hz
  subst hx hz
  have hy : 0 ≤ y := by linarith [n.cast_nonneg' (α := ℝ)]
  have hlim : Tendsto (fun k : ℕ ↦ ((1 / ((k : ℝ) + 1), y, 0) : ℝ × ℝ × ℝ)) atTop
      (𝓝 (0, y, 0)) :=
    tendsto_one_div_add_atTop_nhds_zero_nat.prodMk_nhds tendsto_const_nhds
  refine hF.mem_of_frequently_of_tendsto ?_ hlim
  have hfreq : ∃ᶠ k in atTop, k ∈ J := Nat.frequently_atTop_iff_infinite.2 hJ
  have hev : ∀ᶠ k : ℕ in atTop, y ≤ 3 * ((k : ℝ) + 1) := by
    filter_upwards [eventually_ge_atTop ⌈y⌉₊] with k hk
    have : y ≤ k := (Nat.le_ceil y).trans (by exact_mod_cast hk)
    linarith
  refine (hfreq.and_eventually hev).mono fun k ⟨hk, hyk⟩ ↦ hJF k hk ?_
  exact mem_segA.2 ⟨rfl, hy, hyk, rfl⟩

theorem isPreconnected_cage

TopologyByExample.InfiniteCage.isPreconnected_cage

The cage is connected: in a cover of the cage by two closed sets disjoint on it, each piece lies in one of them, one of them contains infinitely many pieces and hence every segment B, and so every piece.

theorem isPreconnected_cage : IsPreconnected cage
Proof
:= by
  rw [isPreconnected_iff_subset_of_disjoint_closed]
  intro u v hu hv hcov hdisj
  have hpiece : ∀ m, piece m ⊆ u ∨ piece m ⊆ v := fun m ↦
    isPreconnected_iff_subset_of_disjoint_closed.1
      (isPathConnected_piece m).isConnected.isPreconnected u v hu hv
      ((subset_iUnion piece m).trans hcov)
      (eq_empty_of_subset_empty fun p ⟨hp, huv⟩ ↦
        hdisj ▸ (⟨mem_iUnion.2 ⟨m, hp⟩, huv⟩ : p ∈ cage ∩ (u ∩ v)))
  -- if infinitely many pieces lie in a closed set `w`, so does every piece
  have key : ∀ w w' : Set (ℝ × ℝ × ℝ), IsClosed w → (∀ m, piece m ⊆ w ∨ piece m ⊆ w') →
      cage ∩ (w ∩ w') = ∅ → {m | piece m ⊆ w}.Infinite → cage ⊆ w := by
    intro w w' hw hcases hdisj' hinf
    refine iUnion_subset fun n ↦ ?_
    rcases hcases n with h | h
    · exact h
    · exfalso
      have hB := segB_subset_of_frequently hw hinf
        (fun m hm ↦ (subset_union_left.trans subset_union_left).trans hm) n
      have hb := (mem_segB_inter_arcC n).1
      have : ((0, 2 * ((n : ℝ) + 1), 0) : ℝ × ℝ × ℝ) ∈ cage ∩ (w ∩ w') :=
        ⟨mem_iUnion.2 ⟨n, Or.inl (Or.inr hb)⟩, hB hb, h (Or.inl (Or.inr hb))⟩
      rw [hdisj'] at this
      exact this
  have hunion : {m | piece m ⊆ u} ∪ {m | piece m ⊆ v} = univ :=
    eq_univ_of_forall fun m ↦ hpiece m
  rcases infinite_union.1 (hunion ▸ infinite_univ : ({m | piece m ⊆ u} ∪
    {m | piece m ⊆ v}).Infinite) with h | h
  · exact Or.inl (key u v hu hpiece hdisj h)
  · refine Or.inr (key v u hv (fun m ↦ (hpiece m).symm) ?_ h)
    rw [inter_comm v u]; exact hdisj

theorem isSigmaCompact_cage

TopologyByExample.InfiniteCage.isSigmaCompact_cage

The cage is σ-compact: a countable union of compact pieces.

theorem isSigmaCompact_cage : IsSigmaCompact cage
Proof
:=
  isSigmaCompact_iUnion_of_isCompact _ isCompact_piece

definition params

TopologyByExample.InfiniteCage.params

The parameters 0 and 1 / (m + 1).

noncomputable def params : Set ℝ
:= insert 0 (range fun m : ℕ ↦ 1 / ((m : ℝ) + 1))

theorem isCompact_params

TopologyByExample.InfiniteCage.isCompact_params

theorem isCompact_params : IsCompact params
Proof
:=
  tendsto_one_div_add_atTop_nhds_zero_nat.isCompact_insert_range

theorem countable_params

TopologyByExample.InfiniteCage.countable_params

theorem countable_params : params.Countable
Proof
:= (countable_range _).insert 0

definition closedA

TopologyByExample.InfiniteCage.closedA

The closure of the segments A: the points (s, y, 0) with s ∈ params, y ≥ 0 and y s ≤ 3.

def closedA : Set (ℝ × ℝ × ℝ)
:=
  {p | p.1 ∈ params ∧ 0 ≤ p.2.1 ∧ p.2.1 * p.1 ≤ 3 ∧ p.2.2 = 0}

definition closedC

TopologyByExample.InfiniteCage.closedC

The union of the arcs.

def closedC : Set (ℝ × ℝ × ℝ)
:=
  {p | ∃ s ∈ params, (p, s) ∈ {q : (ℝ × ℝ × ℝ) × ℝ | q.1.2.1 * q.2 = 2 ∧ 0 ≤ q.1.1 ∧
    q.1.1 ≤ q.2 ∧ q.1.2.2 = q.1.1 * (q.2 - q.1.1)}}

definition closedB

TopologyByExample.InfiniteCage.closedB

The union of the segments B.

def closedB : Set (ℝ × ℝ × ℝ)
:=
  {p | ∃ s ∈ params, (p, s) ∈ {q : (ℝ × ℝ × ℝ) × ℝ | q.1.1 = 0 ∧ q.1.2.2 = 0 ∧
    |q.1.2.1 * q.2 - 2| ≤ q.2 / 2}}

theorem isClosed_closedA

TopologyByExample.InfiniteCage.isClosed_closedA

theorem isClosed_closedA : IsClosed closedA
Proof
:=
  (isCompact_params.isClosed.preimage continuous_fst).inter
    ((isClosed_le continuous_const (continuous_fst.comp continuous_snd)).inter
      ((isClosed_le ((continuous_fst.comp continuous_snd).mul continuous_fst)
        continuous_const).inter
        (isClosed_eq (continuous_snd.comp continuous_snd) continuous_const)))

theorem isClosed_closedC

TopologyByExample.InfiniteCage.isClosed_closedC

theorem isClosed_closedC : IsClosed closedC
Proof
:= by
  refine isClosed_setOf_exists_mem isCompact_params ?_
  have h1 : Continuous fun q : (ℝ × ℝ × ℝ) × ℝ ↦ q.1.1 := by fun_prop
  have h2 : Continuous fun q : (ℝ × ℝ × ℝ) × ℝ ↦ q.1.2.1 := by fun_prop
  have h3 : Continuous fun q : (ℝ × ℝ × ℝ) × ℝ ↦ q.1.2.2 := by fun_prop
  have hs : Continuous fun q : (ℝ × ℝ × ℝ) × ℝ ↦ q.2 := by fun_prop
  exact (isClosed_eq (h2.mul hs) continuous_const).inter ((isClosed_le continuous_const h1).inter
    ((isClosed_le h1 hs).inter (isClosed_eq h3 (h1.mul (hs.sub h1)))))

theorem isClosed_closedB

TopologyByExample.InfiniteCage.isClosed_closedB

theorem isClosed_closedB : IsClosed closedB
Proof
:= by
  refine isClosed_setOf_exists_mem isCompact_params ?_
  have h1 : Continuous fun q : (ℝ × ℝ × ℝ) × ℝ ↦ q.1.1 := by fun_prop
  have h2 : Continuous fun q : (ℝ × ℝ × ℝ) × ℝ ↦ q.1.2.1 := by fun_prop
  have h3 : Continuous fun q : (ℝ × ℝ × ℝ) × ℝ ↦ q.1.2.2 := by fun_prop
  have hs : Continuous fun q : (ℝ × ℝ × ℝ) × ℝ ↦ q.2 := by fun_prop
  exact (isClosed_eq h1 continuous_const).inter ((isClosed_eq h3 continuous_const).inter
    (isClosed_le ((h2.mul hs).sub continuous_const).abs (hs.div_const 2)))

theorem abs_mul_sub_le_iff

TopologyByExample.InfiniteCage.abs_mul_sub_le_iff

Membership in closedB for the parameter 1 / (m + 1).

theorem abs_mul_sub_le_iff (m : ℕ) (y : ℝ) :
Proof
    |y * (1 / ((m : ℝ) + 1)) - 2| ≤ 1 / ((m : ℝ) + 1) / 2 ↔
      2 * ((m : ℝ) + 1) - 1 / 2 ≤ y ∧ y ≤ 2 * ((m : ℝ) + 1) + 1 / 2 := by
  have hm : (0 : ℝ) < (m : ℝ) + 1 := by positivity
  have h : y * (1 / ((m : ℝ) + 1)) - 2 = (y - 2 * ((m : ℝ) + 1)) / ((m : ℝ) + 1) := by
    field_simp
  have e : 1 / ((m : ℝ) + 1) * ((m : ℝ) + 1) = 1 := by field_simp
  have key : |y - 2 * ((m : ℝ) + 1)| * 2 ≤ 1 ↔ |y - 2 * ((m : ℝ) + 1)| ≤ 1 / 2 := by
    constructor <;> intro h <;> linarith
  rw [h, abs_div, abs_of_pos hm, div_le_div_iff₀ hm (by positivity), e, key, abs_le]
  constructor <;> rintro ⟨h1, h2⟩ <;> exact ⟨by linarith, by linarith⟩

theorem cage_eq

TopologyByExample.InfiniteCage.cage_eq

The cage is the intersection of a closed set with a Gδ set.

theorem cage_eq : cage = (closedA ∪ closedC) ∩ ({p | p.1 ≠ 0} ∪ {p | p.2.2 ≠ 0} ∪ closedB)
Proof
:= by
  ext ⟨x, y, z⟩
  simp only [cage, piece, mem_iUnion, mem_union, mem_inter_iff, closedA, closedB, closedC,
    params, mem_ofPred_eq, mem_insert_iff, mem_range, exists_eq_or_imp, exists_exists_eq_and]
  constructor
  · rintro ⟨m, (hA | hB) | hC⟩
    · obtain ⟨h1, h2, h3, h4⟩ := mem_segA.1 hA
      simp only at h1 h2 h3 h4
      subst h1 h4
      refine ⟨Or.inl ⟨Or.inr ⟨m, rfl⟩, h2, ?_, rfl⟩, Or.inl (Or.inl (by positivity))⟩
      rw [mul_one_div, div_le_iff₀ (by positivity)]; linarith
    · obtain ⟨h1, h2, h3, h4⟩ := mem_segB.1 hB
      simp only at h1 h2 h3 h4
      subst h1 h4
      refine ⟨Or.inl ⟨Or.inl rfl, by linarith [m.cast_nonneg' (α := ℝ)], by simp, rfl⟩,
        Or.inr (Or.inr ⟨m, rfl, rfl, (abs_mul_sub_le_iff m y).2 ⟨h2, h3⟩⟩)⟩
    · obtain ⟨h1, h2, h3, h4⟩ := mem_arcC.1 hC
      simp only at h1 h2 h3 h4
      subst h3 h4
      refine ⟨Or.inr (Or.inr ⟨m, by field_simp, h1, h2, rfl⟩), ?_⟩
      rcases h1.lt_or_eq with h | h
      · exact Or.inl (Or.inl h.ne')
      · subst h
        exact Or.inr (Or.inr ⟨m, rfl, by ring,
          (abs_mul_sub_le_iff m _).2 ⟨by linarith, by linarith⟩⟩)
  · rintro ⟨(⟨hx | ⟨m, hx⟩, hy, hyx, hz⟩ | hC), hG⟩
    · subst hx hz
      rcases hG with (h | h) | hB
      · exact absurd rfl h
      · exact absurd rfl h
      · rcases hB with ⟨-, -, h⟩ | ⟨m, -, -, h⟩
        · norm_num at h
        · exact ⟨m, Or.inl (Or.inr (mem_segB.2 ⟨rfl, ((abs_mul_sub_le_iff m y).1 h).1,
            ((abs_mul_sub_le_iff m y).1 h).2, rfl⟩))⟩
    · subst hx hz
      refine ⟨m, Or.inl (Or.inl (mem_segA.2 ⟨rfl, hy, ?_, rfl⟩))⟩
      rwa [mul_one_div, div_le_iff₀ (by positivity)] at hyx
    · rcases hC with ⟨h, -⟩ | ⟨m, h1, h2, h3, h4⟩
      · norm_num at h
      · refine ⟨m, Or.inr (mem_arcC.2 ⟨h2, h3, ?_, h4⟩)⟩
        field_simp at h1; linarith

theorem isGδ_cage

TopologyByExample.InfiniteCage.isGδ_cage

The infinite cage is a Gδ subset of ℝ³.

theorem isGδ_cage : IsGδ cage
Proof
:= by
  rw [cage_eq]
  exact (isClosed_closedA.union isClosed_closedC).isGδ.inter
    (((isOpen_ne_fun continuous_fst continuous_const).isGδ.union
      (isOpen_ne_fun (continuous_snd.comp continuous_snd) continuous_const).isGδ).union
      isClosed_closedB.isGδ)

On this site: Infinite cage: The infinite cage is a \(G_\delta\) subset of space

definition InfiniteCage

TopologyByExample.InfiniteCage

The infinite cage: the subspace InfiniteCage.cage of ℝ³.

abbrev InfiniteCage : Type
:= InfiniteCage.cage

On this site: Space: Infinite cage

definition pointA

TopologyByExample.InfiniteCage.pointA

A point of the segment A_1.

noncomputable def pointA (y : ℝ) (hy0 : 0 ≤ y) (hy : y ≤ 3) : InfiniteCage
:=
  ⟨(1, y, 0), mem_iUnion.2 ⟨0, Or.inl (Or.inl (mem_segA.2 ⟨by simp, hy0, by simpa using hy, rfl⟩))⟩⟩

instance

The space is nonempty.

instance : Nonempty InfiniteCage
Proof
:= ⟨pointA 0 le_rfl (by norm_num)⟩

theorem isCompletelyMetrizableSpace

TopologyByExample.InfiniteCage.isCompletelyMetrizableSpace

The infinite cage is completely metrizable: a Gδ subset of ℝ³.

theorem isCompletelyMetrizableSpace : IsCompletelyMetrizableSpace InfiniteCage
Proof
:=
  isGδ_cage.isCompletelyMetrizableSpace

On this site: Infinite cage is completely metrizable

theorem sigmaCompactSpace

TopologyByExample.InfiniteCage.sigmaCompactSpace

The infinite cage is σ-compact: a countable union of compact pieces.

theorem sigmaCompactSpace : SigmaCompactSpace InfiniteCage
Proof
:=
  isSigmaCompact_iff_sigmaCompactSpace.1 isSigmaCompact_cage

On this site: Infinite cage is σ-compact

theorem preconnectedSpace

TopologyByExample.InfiniteCage.preconnectedSpace

The infinite cage is connected.

theorem preconnectedSpace : PreconnectedSpace InfiniteCage
Proof
:=
  Subtype.preconnectedSpace isPreconnected_cage

On this site: Infinite cage is connected

theorem eq_of_joined

TopologyByExample.InfiniteCage.eq_of_joined

A path in the cage stays in one piece (Sierpiński's theorem: its image is a continuum covered by the countably many pairwise disjoint closed pieces).

theorem eq_of_joined {m n : ℕ} {p q : InfiniteCage} (hp : (p : ℝ × ℝ × ℝ) ∈ piece m)
    (hq : (q : ℝ × ℝ × ℝ) ∈ piece n) (h : Joined p q) : m = n
Proof
:= by
  obtain ⟨γ⟩ := h
  set C : Set (ℝ × ℝ × ℝ) := range fun t ↦ (γ t : ℝ × ℝ × ℝ)
  have hcont : Continuous fun t ↦ (γ t : ℝ × ℝ × ℝ) := continuous_subtypeVal.comp γ.continuous
  have hsub := (isPreconnected_range hcont).subsingleton_setOf_inter_nonempty isClosed_piece
    pairwise_disjoint_piece (isCompact_range hcont)
    (by rintro _ ⟨t, rfl⟩; exact mem_iUnion.1 (γ t).property |>.choose_spec |> mem_iUnion_of_mem _)
  exact hsub ⟨_, ⟨0, by simp⟩, hp⟩ ⟨_, ⟨1, by simp⟩, hq⟩

theorem not_pathPreconnectedSpace

TopologyByExample.InfiniteCage.not_pathPreconnectedSpace

The infinite cage is not path connected: no path joins the first piece to the second.

theorem not_pathPreconnectedSpace : ¬PathPreconnectedSpace InfiniteCage
Proof
:= by
  intro h
  have hq : ((1 / 2, 0, 0) : ℝ × ℝ × ℝ) ∈ piece 1 :=
    Or.inl (Or.inl (mem_segA.2 ⟨by norm_num, le_rfl, by norm_num, rfl⟩))
  have hp : ((1, 0, 0) : ℝ × ℝ × ℝ) ∈ piece 0 :=
    Or.inl (Or.inl (mem_segA.2 ⟨by norm_num, le_rfl, by norm_num, rfl⟩))
  exact absurd (eq_of_joined (p := ⟨_, mem_iUnion.2 ⟨0, hp⟩⟩) (q := ⟨_, mem_iUnion.2 ⟨1, hq⟩⟩)
    hp hq (h.joined _ _)) (by norm_num)

On this site: Infinite cage is not path connected

theorem fst_mem_params

TopologyByExample.InfiniteCage.fst_mem_params

Below the plane y = 2, which contains the first arc, the first coordinates of points of the cage are 0 or 1 / (m + 1).

theorem fst_mem_params {p : ℝ × ℝ × ℝ} (hp : p ∈ cage) (h2 : p.2.1 < 2) :
    p.1 ∈ params
Proof
:= by
  obtain ⟨m, (hA | hB) | hC⟩ := mem_iUnion.1 hp
  · exact (mem_segA.1 hA).1 ▸ mem_insert_of_mem _ (mem_range_self m)
  · exact (mem_segB.1 hB).1 ▸ mem_insert _ _
  · have := (mem_arcC.1 hC).2.2.1
    linarith [m.cast_nonneg' (α := ℝ)]

theorem not_locallyConnectedSpace

TopologyByExample.InfiniteCage.not_locallyConnectedSpace

The infinite cage is not locally connected, at (0, 15 / 8, 0): in the slab 7 / 4 < y < 2 a connected set has constant first coordinate, but the points (1 / (k + 1), 15 / 8, 0) of the segments A converge to that point.

theorem not_locallyConnectedSpace : ¬LocallyConnectedSpace InfiniteCage
Proof
:= by
  intro h
  have hb : ((0, 15 / 8, 0) : ℝ × ℝ × ℝ) ∈ cage :=
    mem_iUnion.2 ⟨0, Or.inl (Or.inr (mem_segB.2 ⟨rfl, by norm_num, by norm_num, rfl⟩))⟩
  set b : InfiniteCage := ⟨_, hb⟩
  have hy : Continuous fun p : InfiniteCage ↦ (p : ℝ × ℝ × ℝ).2.1 := by fun_prop
  have hU : {p : InfiniteCage | 7 / 4 < (p : ℝ × ℝ × ℝ).2.1 ∧ (p : ℝ × ℝ × ℝ).2.1 < 2} ∈ 𝓝 b :=
    ((isOpen_lt continuous_const hy).inter (isOpen_lt hy continuous_const)).mem_nhds
      (by norm_num [b])
  obtain ⟨V, hV, hVc, hVU⟩ := locallyConnectedSpace_iff_connected_subsets.1 h b _ hU
  have hpt : ∀ k : ℕ, ((1 / ((k : ℝ) + 1), 15 / 8, 0) : ℝ × ℝ × ℝ) ∈ cage := fun k ↦
    mem_iUnion.2 ⟨k, Or.inl (Or.inl (mem_segA.2 ⟨rfl, by norm_num, by
      linarith [k.cast_nonneg' (α := ℝ)], rfl⟩))⟩
  have hq : Tendsto (fun k : ℕ ↦ (⟨_, hpt k⟩ : InfiniteCage)) atTop (𝓝 b) :=
    tendsto_subtype_rng.2 (tendsto_one_div_add_atTop_nhds_zero_nat.prodMk_nhds tendsto_const_nhds)
  obtain ⟨k, hk⟩ := (hq.eventually hV).exists
  have hx : Continuous fun p : InfiniteCage ↦ (p : ℝ × ℝ × ℝ).1 := by fun_prop
  have := countable_params.isTotallyDisconnected _
    (by rintro _ ⟨p, hp, rfl⟩; exact fst_mem_params p.property (hVU hp).2)
    (hVc.image _ hx.continuousOn) (mem_image_of_mem _ hk) (mem_image_of_mem _ (mem_of_mem_nhds hV))
  simp only [b] at this
  exact (by positivity : (1 : ℝ) / ((k : ℝ) + 1) ≠ 0) this

On this site: Infinite cage is not locally connected

definition corner

TopologyByExample.InfiniteCage.corner

The point (0, 5 / 2, 0) of the cage, the upper end of B_1.

noncomputable def corner : InfiniteCage
:=
  ⟨(0, 5 / 2, 0), mem_iUnion.2 ⟨0, Or.inl (Or.inr (mem_segB.2 ⟨rfl, by norm_num, by norm_num,
    rfl⟩))⟩⟩

theorem not_mem_cage

TopologyByExample.InfiniteCage.not_mem_cage

No point (0, y, 0) with 5 / 2 < y < 3 lies in the cage.

theorem not_mem_cage {y : ℝ} (h1 : 5 / 2 < y) (h2 : y < 3) : ((0, y, 0) : ℝ × ℝ × ℝ) ∉ cage
Proof
:= by
  intro hp
  obtain ⟨m, (hA | hB) | hC⟩ := mem_iUnion.1 hp
  · have := (mem_segA.1 hA).1
    simp only at this
    exact absurd this.symm (by positivity)
  · obtain ⟨-, h3, h4, -⟩ := mem_segB.1 hB
    simp only at h3 h4
    rcases Nat.eq_zero_or_pos m with rfl | hm
    · norm_num at h4; linarith
    · have : (1 : ℝ) ≤ m := by exact_mod_cast hm
      linarith
  · obtain ⟨-, -, h3, -⟩ := mem_arcC.1 hC
    simp only at h3
    rcases Nat.eq_zero_or_pos m with rfl | hm
    · norm_num at h3; linarith
    · have : (1 : ℝ) ≤ m := by exact_mod_cast hm
      linarith

theorem not_isCompact_of_mem_nhds_corner

TopologyByExample.InfiniteCage.not_isCompact_of_mem_nhds_corner

The point (0, 5 / 2, 0) has no compact neighbourhood: such a neighbourhood would contain the points (1 / (k + 1), 5 / 2 + δ, 0) of the segments A for some small δ > 0 and all large k, and, being closed in ℝ³, also their limit (0, 5 / 2 + δ, 0), which is not in the cage.

theorem not_isCompact_of_mem_nhds_corner {K : Set InfiniteCage} (hKn : K ∈ 𝓝 corner) :
    ¬IsCompact K
Proof
:= by
  intro hK
  obtain ⟨u, hu, huK⟩ := (mem_nhds_subtype _ _ _).1 hKn
  obtain ⟨ε, hε, hball⟩ := Metric.mem_nhds_iff.1 hu
  set δ : ℝ := min (ε / 2) (1 / 4) with hδ
  have hδ0 : 0 < δ := lt_min (half_pos hε) (by norm_num)
  have hδε : δ < ε := (min_le_left _ _).trans_lt (half_lt_self hε)
  have hδ4 : δ ≤ 1 / 4 := min_le_right _ _
  have hpt : ∀ k : ℕ, ((1 / ((k : ℝ) + 1), 5 / 2 + δ, 0) : ℝ × ℝ × ℝ) ∈ cage := fun k ↦
    mem_iUnion.2 ⟨k, Or.inl (Or.inl (mem_segA.2 ⟨rfl, by linarith, by
      linarith [k.cast_nonneg' (α := ℝ)], rfl⟩))⟩
  have hlim : Tendsto (fun k : ℕ ↦ ((1 / ((k : ℝ) + 1), 5 / 2 + δ, 0) : ℝ × ℝ × ℝ)) atTop
      (𝓝 (0, 5 / 2 + δ, 0)) :=
    tendsto_one_div_add_atTop_nhds_zero_nat.prodMk_nhds tendsto_const_nhds
  have hball' : ball ((0, 5 / 2, 0) : ℝ × ℝ × ℝ) ε ∈ 𝓝 ((0, 5 / 2 + δ, 0) : ℝ × ℝ × ℝ) := by
    refine isOpen_ball.mem_nhds ?_
    simp only [mem_ball, Prod.dist_eq, Real.dist_eq, sub_self, abs_zero]
    rw [show 5 / 2 + δ - 5 / 2 = δ by ring, abs_of_pos hδ0]
    simp [hδε, hε]
  have hK' : IsClosed (((↑) : InfiniteCage → ℝ × ℝ × ℝ) '' K) :=
    (hK.image continuous_subtypeVal).isClosed
  obtain ⟨p, -, hp⟩ := hK'.mem_of_tendsto hlim ((hlim.eventually hball').mono fun k hk ↦
    ⟨⟨_, hpt k⟩, huK (hball hk), rfl⟩)
  have := p.property
  rw [hp] at this
  exact not_mem_cage (by linarith) (by linarith) this

On this site: Infinite cage: The end \((0, 5/2, 0)\) of \(B_1\) has no compact neighbourhood

theorem not_weaklyLocallyCompactSpace

TopologyByExample.InfiniteCage.not_weaklyLocallyCompactSpace

The infinite cage is not weakly locally compact.

theorem not_weaklyLocallyCompactSpace : ¬WeaklyLocallyCompactSpace InfiniteCage
Proof
:= fun h ↦
  let ⟨_, hK, hKn⟩ := h.exists_compact_mem_nhds corner
  not_isCompact_of_mem_nhds_corner hKn hK

On this site: Infinite cage is not weakly locally compact

theorem not_totallyPathDisconnectedSpace

TopologyByExample.InfiniteCage.not_totallyPathDisconnectedSpace

The infinite cage is not totally path disconnected: the segment A_1 joins (1, 0, 0) to (1, 1, 0).

theorem not_totallyPathDisconnectedSpace : ¬TotallyPathDisconnectedSpace InfiniteCage
Proof
:= by
  intro h
  have h0 : ((1, 0, 0) : ℝ × ℝ × ℝ) ∈ segA 0 := mem_segA.2 ⟨by norm_num, le_rfl, by norm_num, rfl⟩
  have h1 : ((1, 1, 0) : ℝ × ℝ × ℝ) ∈ segA 0 := mem_segA.2 ⟨by norm_num, by norm_num, by norm_num,
    rfl⟩
  have hj := (((isPathConnected_segA 0).joinedIn _ h0 _ h1).mono fun p hp ↦
    show p ∈ cage from mem_iUnion.2 ⟨0, Or.inl (Or.inl hp)⟩).joined_subtype
  have := congrArg (fun p : InfiniteCage ↦ (p : ℝ × ℝ × ℝ).2.1) (h.eq_of_joined _ _ hj)
  norm_num at this

On this site: Infinite cage is not totally path disconnected