Lean library · module TopologyByExample.Spaces.NestedRectangles
Nested rectangles
For k ≥ 1 let Rₖ be the boundary of the rectangle centred at the origin of width
2k / (k + 1) and height 2k: the points (x, y) of the plane with |x| = k / (k + 1) and
|y| ≤ k, or with |y| = k and |x| ≤ k / (k + 1). The nested rectangles space is the union of
the rectangles Rₖ with the two lines x = 1 and x = -1, with the subspace topology of the
plane. In this file the rectangles are indexed from 0: rect n is R_{n + 1}.
The vertical sides of the rectangles accumulate only on the two lines, and the horizontal sides
escape to infinity, so the space is a closed subset of the plane. Hence it is completely
metrizable, σ-compact and locally compact. It is not compact, being unbounded, and not connected:
the first rectangle is open and closed in it. It is not locally connected at (1, 0): near that
point the abscissae of its points lie in the countable set of the numbers 1 and
(n + 1) / (n + 2), so a connected neighbourhood of (1, 0) would lie on the line x = 1, but
the vertical sides x = (n + 1) / (n + 2) come arbitrarily close.
Main definitions
Main statements
TopologyByExample.NestedRectangles.isClosed_nestedRectangles: the space is a closed subset of the plane.TopologyByExample.NestedRectangles.isCompletelyMetrizableSpace,TopologyByExample.NestedRectangles.sigmaCompactSpace,TopologyByExample.NestedRectangles.weaklyLocallyCompactSpace,TopologyByExample.NestedRectangles.not_compactSpace,TopologyByExample.NestedRectangles.not_preconnectedSpace,TopologyByExample.NestedRectangles.not_locallyConnectedSpace,TopologyByExample.NestedRectangles.not_totallyPathDisconnectedSpace.
Tags
nested rectangles, locally connected, closed subset of the plane
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
definition halfWidth
TopologyByExample.NestedRectangles.halfWidth
The half-width (n + 1) / (n + 2) of the n-th rectangle (the rectangle R_{n + 1}).
noncomputable def halfWidth (n : ℕ) : ℝ
:= ((n : ℝ) + 1) / ((n : ℝ) + 2)
definition rect
TopologyByExample.NestedRectangles.rect
The boundary of the n-th rectangle, R_{n + 1}: half-width (n + 1) / (n + 2), half-height
n + 1.
noncomputable def rect (n : ℕ) : Set (ℝ × ℝ)
:=
{p | (|p.1| = halfWidth n ∧ |p.2| ≤ (n : ℝ) + 1) ∨ (|p.2| = (n : ℝ) + 1 ∧ |p.1| ≤ halfWidth n)}
definition nestedRectangles
TopologyByExample.NestedRectangles.nestedRectangles
The nested rectangles: the lines x = ±1 together with all the rectangles.
noncomputable def nestedRectangles : Set (ℝ × ℝ)
:= {p | |p.1| = 1} ∪ ⋃ n, rect n
theorem halfWidth_pos
TopologyByExample.NestedRectangles.halfWidth_pos
theorem halfWidth_pos (n : ℕ) : 0 < halfWidth n
Proof
:= by unfold halfWidth; positivity
theorem halfWidth_lt_one
TopologyByExample.NestedRectangles.halfWidth_lt_one
theorem halfWidth_lt_one (n : ℕ) : halfWidth n < 1
Proof
:= by
unfold halfWidth; rw [div_lt_one (by positivity)]; linarith
theorem one_sub_halfWidth
TopologyByExample.NestedRectangles.one_sub_halfWidth
theorem one_sub_halfWidth (n : ℕ) : 1 - halfWidth n = 1 / ((n : ℝ) + 2)
Proof
:= by
unfold halfWidth; field_simp; ring
theorem two_thirds_le_halfWidth
TopologyByExample.NestedRectangles.two_thirds_le_halfWidth
The half-widths, n ≥ 1, are at least 2 / 3.
theorem two_thirds_le_halfWidth {n : ℕ} (hn : n ≠ 0) : 2 / 3 ≤ halfWidth n
Proof
:= by
have : (1 : ℝ) ≤ n := by exact_mod_cast Nat.one_le_iff_ne_zero.2 hn
unfold halfWidth; rw [div_le_div_iff₀ (by norm_num) (by positivity)]; linarith
theorem halfWidth_zero
TopologyByExample.NestedRectangles.halfWidth_zero
theorem halfWidth_zero : halfWidth 0 = 1 / 2
Proof
:= by norm_num [halfWidth]
theorem tendsto_halfWidth
TopologyByExample.NestedRectangles.tendsto_halfWidth
The half-widths converge to 1.
theorem tendsto_halfWidth : Tendsto halfWidth atTop (𝓝 1)
Proof
:= by
have h : halfWidth = fun n : ℕ ↦ 1 - 1 / ((n : ℝ) + 2) := by
ext n; rw [← one_sub_halfWidth]; ring
rw [h]
have h2 : Tendsto (fun n : ℕ ↦ 1 / ((n : ℝ) + 2)) atTop (𝓝 0) := by
have := (tendsto_one_div_add_atTop_nhds_zero_nat (𝕜 := ℝ)).comp (tendsto_add_atTop_nat 1)
refine this.congr fun n ↦ ?_
simp only [Function.comp_apply, Nat.cast_add, Nat.cast_one]; ring
simpa using h2.const_sub 1
definition widths
TopologyByExample.NestedRectangles.widths
The possible absolute values of abscissae of points on vertical sides or lines.
noncomputable def widths : Set ℝ
:= insert 1 (range halfWidth)
theorem isClosed_widths
TopologyByExample.NestedRectangles.isClosed_widths
theorem isClosed_widths : IsClosed widths
Proof
:= tendsto_halfWidth.isCompact_insert_range.isClosed
theorem countable_widths
TopologyByExample.NestedRectangles.countable_widths
theorem countable_widths : widths.Countable
Proof
:= (countable_range _).insert 1
theorem isClosed_range_succ
TopologyByExample.NestedRectangles.isClosed_range_succ
theorem isClosed_range_succ : IsClosed (range fun n : ℕ ↦ (n : ℝ) + 1)
Proof
:= by
have h : (range fun n : ℕ ↦ (n : ℝ) + 1) = (fun x : ℝ ↦ x + 1) '' range ((↑) : ℕ → ℝ) := by
rw [← range_comp]; rfl
rw [h]
exact (Homeomorph.addRight (1 : ℝ)).isClosedMap _ Nat.isClosedEmbedding_coe_real.isClosed_range
theorem nestedRectangles_eq
TopologyByExample.NestedRectangles.nestedRectangles_eq
The nested rectangles as the union of the "vertical" part (the lines and the vertical sides) and the "horizontal" part (the horizontal sides), each described by closed conditions.
theorem nestedRectangles_eq : nestedRectangles =
{p : ℝ × ℝ | |p.1| ∈ widths ∧ |p.2| * (1 - |p.1|) ≤ |p.1|} ∪
{p : ℝ × ℝ | |p.2| ∈ range (fun n : ℕ ↦ (n : ℝ) + 1) ∧ |p.1| * (|p.2| + 1) ≤ |p.2|}
Proof
:= by
ext p
simp only [nestedRectangles, rect, widths, mem_union, mem_ofPred_eq, mem_iUnion, mem_insert_iff,
mem_range]
constructor
· rintro (h | ⟨n, ⟨h1, h2⟩ | ⟨h1, h2⟩⟩)
· exact Or.inl ⟨Or.inl h, by rw [h]; simp⟩
· refine Or.inl ⟨Or.inr ⟨n, h1.symm⟩, ?_⟩
rw [h1, one_sub_halfWidth]
have : |p.2| * (1 / ((n : ℝ) + 2)) ≤ ((n : ℝ) + 1) * (1 / ((n : ℝ) + 2)) :=
mul_le_mul_of_nonneg_right h2 (by positivity)
simpa [halfWidth, div_eq_mul_one_div ((n : ℝ) + 1)] using this
· refine Or.inr ⟨⟨n, h1.symm⟩, ?_⟩
rw [h1]
have h3 : |p.1| * ((n : ℝ) + 2) ≤ halfWidth n * ((n : ℝ) + 2) :=
mul_le_mul_of_nonneg_right h2 (by positivity)
have h4 : halfWidth n * ((n : ℝ) + 2) = (n : ℝ) + 1 := by
unfold halfWidth; field_simp
linarith
· rintro (⟨h1 | ⟨n, hn⟩, h2⟩ | ⟨⟨n, hn⟩, h2⟩)
· exact Or.inl h1
· refine Or.inr ⟨n, Or.inl ⟨hn.symm, ?_⟩⟩
rw [← hn, one_sub_halfWidth] at h2
have h3 : |p.2| * (1 / ((n : ℝ) + 2)) * ((n : ℝ) + 2) ≤
halfWidth n * ((n : ℝ) + 2) := mul_le_mul_of_nonneg_right h2 (by positivity)
have h4 : halfWidth n * ((n : ℝ) + 2) = (n : ℝ) + 1 := by
unfold halfWidth; field_simp
have h5 : |p.2| * (1 / ((n : ℝ) + 2)) * ((n : ℝ) + 2) = |p.2| := by field_simp
linarith
· refine Or.inr ⟨n, Or.inr ⟨hn.symm, ?_⟩⟩
rw [← hn] at h2
unfold halfWidth
rw [le_div_iff₀ (by positivity)]
linarith
theorem isClosed_nestedRectangles
TopologyByExample.NestedRectangles.isClosed_nestedRectangles
The nested rectangles form a closed subset of the plane.
theorem isClosed_nestedRectangles : IsClosed nestedRectangles
Proof
:= by
rw [nestedRectangles_eq]
have ha1 : Continuous fun p : ℝ × ℝ ↦ |p.1| := continuous_fst.abs
have ha2 : Continuous fun p : ℝ × ℝ ↦ |p.2| := continuous_snd.abs
refine IsClosed.union ?_ ?_
· exact (isClosed_widths.preimage ha1).inter
(isClosed_le (ha2.mul (continuous_const.sub ha1)) ha1)
· exact (isClosed_range_succ.preimage ha2).inter
(isClosed_le (ha1.mul (ha2.add continuous_const)) ha2)
On this site: Nested rectangles: The nested rectangles form a closed subset of the plane
definition NestedRectangles
TopologyByExample.NestedRectangles
The nested rectangles: the subspace NestedRectangles.nestedRectangles of the plane.
abbrev NestedRectangles : Type
:= NestedRectangles.nestedRectangles
On this site: Space: Nested rectangles
theorem mk_mem_of_abs_mem
TopologyByExample.NestedRectangles.mk_mem_of_abs_mem
The point (x, 0) for |x| = 1 or |x| a half-width.
theorem mk_mem_of_abs_mem {x : ℝ} (hx : |x| = 1) : ((x, 0) : ℝ × ℝ) ∈ nestedRectangles
Proof
:=
Or.inl hx
theorem side_mem
TopologyByExample.NestedRectangles.side_mem
The point (halfWidth n, 0) on the right side of the n-th rectangle.
theorem side_mem (n : ℕ) : ((halfWidth n, 0) : ℝ × ℝ) ∈ nestedRectangles
Proof
:=
Or.inr (mem_iUnion.2 ⟨n, Or.inl ⟨abs_of_pos (halfWidth_pos n), by rw [abs_zero]; positivity⟩⟩)
definition one
TopologyByExample.NestedRectangles.one
The point (1, 0) of the space.
def one : NestedRectangles
:= ⟨(1, 0), Or.inl (by simp)⟩
instance
The space is nonempty.
instance : Nonempty NestedRectangles
Proof
:= ⟨one⟩
theorem isCompletelyMetrizableSpace
TopologyByExample.NestedRectangles.isCompletelyMetrizableSpace
The nested rectangles are completely metrizable: a closed subset of the plane.
theorem isCompletelyMetrizableSpace : IsCompletelyMetrizableSpace NestedRectangles
Proof
:=
isClosed_nestedRectangles.isCompletelyMetrizableSpace
On this site: Nested rectangles is completely metrizable
theorem sigmaCompactSpace
TopologyByExample.NestedRectangles.sigmaCompactSpace
The nested rectangles are σ-compact: a closed subset of the plane.
theorem sigmaCompactSpace : SigmaCompactSpace NestedRectangles
Proof
:=
isClosed_nestedRectangles.sigmaCompactSpace
On this site: Nested rectangles is σ-compact
theorem weaklyLocallyCompactSpace
TopologyByExample.NestedRectangles.weaklyLocallyCompactSpace
The nested rectangles are weakly locally compact: a closed subset of the plane is locally compact.
theorem weaklyLocallyCompactSpace : WeaklyLocallyCompactSpace NestedRectangles
Proof
:=
have := isClosed_nestedRectangles.locallyCompactSpace
inferInstance
On this site: Nested rectangles is weakly locally compact
theorem not_compactSpace
TopologyByExample.NestedRectangles.not_compactSpace
The nested rectangles are not compact: they contain the points (0, n + 1).
theorem not_compactSpace : ¬CompactSpace NestedRectangles
Proof
:= by
intro h
have hK : IsCompact nestedRectangles := isCompact_iff_compactSpace.2 h
obtain ⟨b, hb⟩ := (hK.image continuous_snd).bddAbove
obtain ⟨n, hn⟩ := exists_nat_gt b
have hmem : ((0, (n : ℝ) + 1) : ℝ × ℝ) ∈ nestedRectangles :=
Or.inr (mem_iUnion.2 ⟨n, Or.inr ⟨by rw [abs_of_pos (by positivity)],
by rw [abs_zero]; exact (halfWidth_pos n).le⟩⟩)
have := hb (mem_image_of_mem _ hmem)
simp only at this
linarith
On this site: Nested rectangles is not compact
theorem abs_le_of_abs_lt
TopologyByExample.NestedRectangles.abs_le_of_abs_lt
In the nested rectangles, the first rectangle is the set of points with |x| < 2 / 3 and
|y| < 2, and also the set of points with |x| ≤ 1 / 2 and |y| ≤ 1.
theorem abs_le_of_abs_lt {p : ℝ × ℝ} (hp : p ∈ nestedRectangles) (h1 : |p.1| < 2 / 3)
(h2 : |p.2| < 2) : |p.1| ≤ 1 / 2 ∧ |p.2| ≤ 1
Proof
:= by
rcases hp with hp | hp
· simp only [mem_ofPred_eq] at hp; linarith
obtain ⟨n, hn⟩ := mem_iUnion.1 hp
have hn0 : n = 0 := by
by_contra hne
rcases hn with ⟨h3, -⟩ | ⟨h3, -⟩
· linarith [two_thirds_le_halfWidth hne]
· have : (1 : ℝ) ≤ n := by exact_mod_cast Nat.one_le_iff_ne_zero.2 hne
linarith
subst hn0
rcases hn with ⟨h3, h4⟩ | ⟨h3, h4⟩
· rw [halfWidth_zero] at h3; simp only [CharP.cast_eq_zero, zero_add] at h4
exact ⟨h3.le, h4⟩
· rw [halfWidth_zero] at h4; simp only [CharP.cast_eq_zero, zero_add] at h3
exact ⟨h4, h3.le⟩
theorem not_preconnectedSpace
TopologyByExample.NestedRectangles.not_preconnectedSpace
The nested rectangles are not connected: the first rectangle is open and closed.
theorem not_preconnectedSpace : ¬PreconnectedSpace NestedRectangles
Proof
:= by
intro h
let s : Set NestedRectangles := {p | |(p : ℝ × ℝ).1| < 2 / 3 ∧ |(p : ℝ × ℝ).2| < 2}
have hs : s = {p : NestedRectangles | |(p : ℝ × ℝ).1| ≤ 1 / 2 ∧ |(p : ℝ × ℝ).2| ≤ 1} := by
ext ⟨p, hp⟩
constructor
· rintro ⟨h1, h2⟩; exact abs_le_of_abs_lt hp h1 h2
· rintro ⟨h1, h2⟩; exact ⟨by linarith, by linarith⟩
have ha1 : Continuous fun p : NestedRectangles ↦ |(p : ℝ × ℝ).1| :=
(continuous_fst.comp continuous_subtypeVal).abs
have ha2 : Continuous fun p : NestedRectangles ↦ |(p : ℝ × ℝ).2| :=
(continuous_snd.comp continuous_subtypeVal).abs
have hopen : IsOpen s :=
(isOpen_lt ha1 continuous_const).inter (isOpen_lt ha2 continuous_const)
have hclosed : IsClosed s := by
rw [hs]; exact (isClosed_le ha1 continuous_const).inter (isClosed_le ha2 continuous_const)
rcases isClopen_iff.1 ⟨hclosed, hopen⟩ with he | hu
· have hmem : (⟨(halfWidth 0, 0), side_mem 0⟩ : NestedRectangles) ∈ s := by
simp only [s, mem_ofPred_eq, halfWidth_zero, abs_zero]; norm_num
rw [he] at hmem; exact hmem
· have hmem : one ∈ s := hu ▸ mem_univ _
simp only [s, one, mem_ofPred_eq, abs_one] at hmem
norm_num at hmem
On this site: Nested rectangles is not connected
theorem not_locallyConnectedSpace
TopologyByExample.NestedRectangles.not_locallyConnectedSpace
The nested rectangles are not locally connected, at (1, 0). Near that point the abscissae of
the points of the space lie in the countable set of the numbers 1 and (n + 1) / (n + 2), so a
connected neighbourhood would lie on the line x = 1; but the points ((n + 1) / (n + 2), 0)
converge to (1, 0).
theorem not_locallyConnectedSpace : ¬LocallyConnectedSpace NestedRectangles
Proof
:= by
intro h
set U : Set NestedRectangles := {p | 3 / 4 < (p : ℝ × ℝ).1 ∧ |(p : ℝ × ℝ).2| < 1 / 2}
have hU : U ∈ 𝓝 one :=
((isOpen_lt continuous_const (continuous_fst.comp continuous_subtypeVal)).inter
(isOpen_lt (continuous_snd.comp continuous_subtypeVal).abs continuous_const)).mem_nhds
(by norm_num [U, one])
obtain ⟨V, hV, hVc, hVU⟩ := locallyConnectedSpace_iff_connected_subsets.1 h one U hU
-- the abscissae of points of `U` lie in `widths`
have hw : ∀ p ∈ U, (p : ℝ × ℝ).1 ∈ widths := by
rintro ⟨p, hp⟩ ⟨h1, h2⟩
simp only at h1 h2 ⊢
have hpos : 0 < p.1 := by linarith
rcases hp with hp | hp
· simp only [mem_ofPred_eq, abs_of_pos hpos] at hp
exact hp ▸ mem_insert _ _
obtain ⟨n, hn⟩ := mem_iUnion.1 hp
rcases hn with ⟨h3, -⟩ | ⟨h3, -⟩
· rw [abs_of_pos hpos] at h3; exact h3 ▸ mem_insert_of_mem _ (mem_range_self n)
· have : (1 : ℝ) ≤ (n : ℝ) + 1 := by linarith [n.cast_nonneg' (α := ℝ)]
linarith
have hconst : ∀ p ∈ V, (p : ℝ × ℝ).1 = 1 := by
intro p hp
have himg : (fun q : NestedRectangles ↦ (q : ℝ × ℝ).1) '' V ⊆ widths := by
rintro _ ⟨q, hq, rfl⟩; exact hw q (hVU hq)
exact countable_widths.isTotallyDisconnected _ himg
(hVc.image _ (continuous_fst.comp continuous_subtypeVal).continuousOn)
(mem_image_of_mem _ hp) (mem_image_of_mem _ (mem_of_mem_nhds hV))
have hq : Tendsto (fun n : ℕ ↦ (⟨_, side_mem n⟩ : NestedRectangles)) atTop (𝓝 one) :=
tendsto_subtype_rng.2 (tendsto_halfWidth.prodMk_nhds tendsto_const_nhds)
obtain ⟨n, hn⟩ := (hq.eventually hV).exists
exact (halfWidth_lt_one n).ne (hconst _ hn)
On this site: Nested rectangles is not locally connected
theorem not_totallyPathDisconnectedSpace
TopologyByExample.NestedRectangles.not_totallyPathDisconnectedSpace
The nested rectangles are not totally path disconnected: the line x = 1 contains distinct
points joined by a path.
theorem not_totallyPathDisconnectedSpace : ¬TotallyPathDisconnectedSpace NestedRectangles
Proof
:= by
intro h
have hS : IsPathConnected (({1} : Set ℝ) ×ˢ (univ : Set ℝ)) :=
((convex_singleton (1 : ℝ)).prod convex_univ).isPathConnected
⟨(1, 0), rfl, mem_univ _⟩
have hsub : ({1} : Set ℝ) ×ˢ (univ : Set ℝ) ⊆ nestedRectangles := by
rintro p ⟨hp, -⟩
exact Or.inl (show |p.1| = 1 by rw [mem_singleton_iff.1 hp, abs_one])
have hj := ((hS.joinedIn (1, 0) ⟨rfl, mem_univ _⟩ (1, 1) ⟨rfl, mem_univ _⟩).mono
hsub).joined_subtype
have := congrArg (fun p : NestedRectangles ↦ (p : ℝ × ℝ).2) (h.eq_of_joined _ _ hj)
norm_num at this
On this site: Nested rectangles is not totally path disconnected