Lean library · module TopologyByExample.Spaces.DeletedDiscs

Topologies on the plane given by discs with part of a horizontal diameter deleted

Source file

Let S be a set of real numbers not containing 0 whose complement is closed under addition. For a point p of the plane and r > 0, let DeletedDiscPlane.nbhd S p r be the open Euclidean disc of radius r centred at p, with the points (p.1 + a, p.2), a ∈ S, removed. These sets form the neighbourhood bases of a topology on the plane, DeletedDiscPlane S. For S = {a | a ≠ 0} this is the deleted diameter topology, and for S = {a | 0 < a} the deleted radius topology.

We prove the facts the two spaces share: the topology is finer than the Euclidean one (so the space is submetrizable, hence Hausdorff); every nonempty open set contains a nonempty Euclidean open set (so the space is separable and a Baire space); it is first countable; every line that is not horizontal carries its Euclidean topology, so the basic neighbourhoods are path connected (they are star-shaped about their centre) and the space is path connected and locally path connected; the closure of a basic neighbourhood contains the whole Euclidean disc, so the space is not semiregular when S has arbitrarily small elements; and the first coordinate is an unbounded continuous function, so the space is not pseudocompact.

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

definition DeletedDiscPlane

TopologyByExample.DeletedDiscPlane

The plane ℝ × ℝ with the topology in which a point p has the neighbourhood base of open discs centred at p from which the points (p.1 + a, p.2), a ∈ S, are removed. It is a topology when 0 ∉ S and the complement of S is closed under addition.

def DeletedDiscPlane (_S : Set ℝ) : Type
:= ℝ × ℝ
variable {S : Set ℝ}

Points and discs

definition toPlane

TopologyByExample.DeletedDiscPlane.toPlane

The point of the plane underlying a point of DeletedDiscPlane S.

def toPlane (p : DeletedDiscPlane S) : ℝ × ℝ
:= p

definition ofPlane

TopologyByExample.DeletedDiscPlane.ofPlane

The point of DeletedDiscPlane S over a point of the plane.

def ofPlane (q : ℝ × ℝ) : DeletedDiscPlane S
:= q

theorem toPlane_ofPlane

TopologyByExample.DeletedDiscPlane.toPlane_ofPlane

toPlane is a left inverse of ofPlane.

@[simp]
theorem toPlane_ofPlane (q : ℝ × ℝ) : toPlane (ofPlane q : DeletedDiscPlane S) = q
Proof
:= rfl

theorem ofPlane_toPlane

TopologyByExample.DeletedDiscPlane.ofPlane_toPlane

ofPlane is a left inverse of toPlane.

@[simp]
theorem ofPlane_toPlane (p : DeletedDiscPlane S) : ofPlane (toPlane p) = p
Proof
:= rfl

theorem toPlane_injective

TopologyByExample.DeletedDiscPlane.toPlane_injective

toPlane is injective.

theorem toPlane_injective : Injective (toPlane : DeletedDiscPlane S → ℝ × ℝ)
Proof
:=
  fun _ _ h ↦ h

instance

DeletedDiscPlane S is nonempty.

instance : Nonempty (DeletedDiscPlane S)
Proof
:= ⟨ofPlane (0, 0)⟩

definition disc

TopologyByExample.DeletedDiscPlane.disc

The open Euclidean disc of radius r centred at p.

def disc (p : ℝ × ℝ) (r : ℝ) : Set (ℝ × ℝ)
:= {z | (z.1 - p.1) ^ 2 + (z.2 - p.2) ^ 2 < r ^ 2}

definition deleted

TopologyByExample.DeletedDiscPlane.deleted

The deleted part of the horizontal diameter through p: the points (p.1 + a, p.2), a ∈ S.

def deleted (S : Set ℝ) (p : ℝ × ℝ) : Set (ℝ × ℝ)
:= {z | z.2 = p.2 ∧ z.1 - p.1 ∈ S}

definition nbhd

TopologyByExample.DeletedDiscPlane.nbhd

The basic neighbourhood of radius r at p: the open disc of radius r centred at p with the deleted part of its horizontal diameter removed.

def nbhd (S : Set ℝ) (p : ℝ × ℝ) (r : ℝ) : Set (ℝ × ℝ)
:= disc p r \ deleted S p

theorem mem_disc_self

TopologyByExample.DeletedDiscPlane.mem_disc_self

The centre lies in its disc of positive radius.

theorem mem_disc_self (p : ℝ × ℝ) {r : ℝ} (hr : 0 < r) : p ∈ disc p r
Proof
:= by
  have : 0 < r ^ 2 := by positivity
  simpa [disc] using this

theorem mem_nbhd_self

TopologyByExample.DeletedDiscPlane.mem_nbhd_self

The centre lies in its basic neighbourhoods.

theorem mem_nbhd_self (hS0 : (0 : ℝ) ∉ S) (p : ℝ × ℝ) {r : ℝ} (hr : 0 < r) : p ∈ nbhd S p r
Proof
:=
  ⟨mem_disc_self p hr, fun h ↦ hS0 (by simpa using h.2)⟩

theorem notMem_deleted_of_ne

TopologyByExample.DeletedDiscPlane.notMem_deleted_of_ne

A point off the horizontal line through p is not deleted.

theorem notMem_deleted_of_ne {p z : ℝ × ℝ} (h : z.2 ≠ p.2) : z ∉ deleted S p
Proof
:= fun h' ↦ h h'.1

theorem disc_mono

TopologyByExample.DeletedDiscPlane.disc_mono

Discs increase with the radius.

theorem disc_mono {p : ℝ × ℝ} {r s : ℝ} (hr : 0 ≤ r) (h : r ≤ s) : disc p r ⊆ disc p s
Proof
:=
  fun z hz ↦ by
    simp only [disc, mem_ofPred_eq] at hz ⊢
    nlinarith

theorem nbhd_mono

TopologyByExample.DeletedDiscPlane.nbhd_mono

Basic neighbourhoods increase with the radius.

theorem nbhd_mono {p : ℝ × ℝ} {r s : ℝ} (hr : 0 ≤ r) (h : r ≤ s) : nbhd S p r ⊆ nbhd S p s
Proof
:=
  sdiff_subset_sdiff_left (disc_mono hr h)

theorem isOpen_disc

TopologyByExample.DeletedDiscPlane.isOpen_disc

The disc is open in the Euclidean plane.

theorem isOpen_disc (p : ℝ × ℝ) (r : ℝ) : IsOpen (disc p r)
Proof
:=
  isOpen_lt (by fun_prop) continuous_const

theorem abs_lt_of_mem_disc

TopologyByExample.DeletedDiscPlane.abs_lt_of_mem_disc

A point of the disc of radius r centred at p has coordinates within r of those of p.

theorem abs_lt_of_mem_disc {p z : ℝ × ℝ} {r : ℝ} (hz : z ∈ disc p r) (hr : 0 ≤ r) :
Proof
    |z.1 - p.1| < r ∧ |z.2 - p.2| < r := by
  simp only [disc, mem_ofPred_eq] at hz
  exact ⟨abs_lt_of_sq_lt_sq (by nlinarith [sq_nonneg (z.2 - p.2)]) hr,
    abs_lt_of_sq_lt_sq (by nlinarith [sq_nonneg (z.1 - p.1)]) hr⟩

theorem disc_subset_ball

TopologyByExample.DeletedDiscPlane.disc_subset_ball

The disc of radius r lies in the ball of radius r for the maximum metric.

theorem disc_subset_ball (p : ℝ × ℝ) {r : ℝ} (hr : 0 ≤ r) : disc p r ⊆ Metric.ball p r
Proof
:= by
  intro z hz
  obtain ⟨h1, h2⟩ := abs_lt_of_mem_disc hz hr
  rw [Metric.mem_ball, Prod.dist_eq, Real.dist_eq, Real.dist_eq]
  exact max_lt h1 h2

theorem exists_disc_subset

TopologyByExample.DeletedDiscPlane.exists_disc_subset

A Euclidean open set contains a disc around each of its points.

theorem exists_disc_subset {V : Set (ℝ × ℝ)} (hV : IsOpen V) {q : ℝ × ℝ} (hq : q ∈ V) :
    ∃ s > 0, disc q s ⊆ V
Proof
:= by
  obtain ⟨s, hs, hsV⟩ := Metric.isOpen_iff.1 hV q hq
  exact ⟨s, hs, (disc_subset_ball q hs.le).trans hsV⟩

theorem exists_nbhd_subset_nbhd

TopologyByExample.DeletedDiscPlane.exists_nbhd_subset_nbhd

Around each point of a basic neighbourhood there is a basic neighbourhood inside it, when the complement of S is closed under addition.

theorem exists_nbhd_subset_nbhd (hS : ∀ a b, a ∉ S → b ∉ S → a + b ∉ S) {p q : ℝ × ℝ} {r : ℝ}
    (hq : q ∈ nbhd S p r) : ∃ s > 0, nbhd S q s ⊆ nbhd S p r
Proof
:= by
  by_cases hq2 : q.2 = p.2
  · obtain ⟨s, hs, hsub⟩ := exists_disc_subset (isOpen_disc p r) hq.1
    refine ⟨s, hs, fun z hz ↦ ⟨hsub hz.1, fun hzp ↦ ?_⟩⟩
    have hq1 : q.1 - p.1 ∉ S := fun h ↦ hq.2 ⟨hq2, h⟩
    have hz1 : z.1 - q.1 ∉ S := fun h ↦ hz.2 ⟨hzp.1.trans hq2.symm, h⟩
    have := hS _ _ hz1 hq1
    rw [sub_add_sub_cancel] at this
    exact this hzp.2
  · have hV : IsOpen (disc p r ∩ {z | z.2 ≠ p.2}) :=
      (isOpen_disc p r).inter (isOpen_ne_fun continuous_snd continuous_const)
    obtain ⟨s, hs, hsub⟩ := exists_disc_subset hV ⟨hq.1, hq2⟩
    exact ⟨s, hs, fun z hz ↦ ⟨(hsub hz.1).1, notMem_deleted_of_ne (hsub hz.1).2⟩⟩

The topology

instance

The topology: a set is open if it contains a basic neighbourhood of each of its points.

instance : TopologicalSpace (DeletedDiscPlane S)
Proof
where
  IsOpen U := ∀ p ∈ U, ∃ r > 0, ofPlane '' nbhd S (toPlane p) r ⊆ U
  isOpen_univ _ _ := ⟨1, one_pos, subset_univ _⟩
  isOpen_inter U V hU hV p hp := by
    obtain ⟨r, hr, hrU⟩ := hU p hp.1
    obtain ⟨s, hs, hsV⟩ := hV p hp.2
    exact ⟨min r s, lt_min hr hs, subset_inter
      ((image_mono (nbhd_mono (lt_min hr hs).le (min_le_left _ _))).trans hrU)
      ((image_mono (nbhd_mono (lt_min hr hs).le (min_le_right _ _))).trans hsV)⟩
  isOpen_sUnion F hF p hp := by
    obtain ⟨U, hUF, hpU⟩ := mem_sUnion.1 hp
    obtain ⟨r, hr, hrU⟩ := hF U hUF p hpU
    exact ⟨r, hr, hrU.trans (subset_sUnion_of_mem hUF)⟩

theorem isOpen_iff

TopologyByExample.DeletedDiscPlane.isOpen_iff

A set is open if and only if it contains a basic neighbourhood of each of its points.

theorem isOpen_iff {U : Set (DeletedDiscPlane S)} :
    IsOpen U ↔ ∀ p ∈ U, ∃ r > 0, ofPlane '' nbhd S (toPlane p) r ⊆ U
Proof
:= Iff.rfl

theorem isOpen_preimage_toPlane

TopologyByExample.DeletedDiscPlane.isOpen_preimage_toPlane

The preimage of a Euclidean open set is open.

theorem isOpen_preimage_toPlane {V : Set (ℝ × ℝ)} (hV : IsOpen V) :
    IsOpen (toPlane ⁻¹' V : Set (DeletedDiscPlane S))
Proof
:= by
  intro p hp
  obtain ⟨r, hr, hrV⟩ := exists_disc_subset hV hp
  exact ⟨r, hr, by rintro _ ⟨z, hz, rfl⟩; exact hrV hz.1⟩

theorem continuous_toPlane

TopologyByExample.DeletedDiscPlane.continuous_toPlane

The topology is finer than the Euclidean one.

theorem continuous_toPlane : Continuous (toPlane : DeletedDiscPlane S → ℝ × ℝ)
Proof
:= by
  refine ⟨fun V hV p hp ↦ ?_⟩
  obtain ⟨r, hr, hrV⟩ := exists_disc_subset hV hp
  exact ⟨r, hr, by rintro _ ⟨z, hz, rfl⟩; exact hrV hz.1⟩

instance t2Space

TopologyByExample.DeletedDiscPlane.t2Space

DeletedDiscPlane S is Hausdorff, since its topology is finer than the Euclidean one.

instance t2Space : T2Space (DeletedDiscPlane S)
Proof
:=
  .of_injective_continuous toPlane_injective continuous_toPlane

theorem le_euclidean

TopologyByExample.DeletedDiscPlane.le_euclidean

The topology is finer than the Euclidean topology, in the order on topologies.

theorem le_euclidean :
    (inferInstance : TopologicalSpace (DeletedDiscPlane S)) ≤
      (instTopologicalSpaceProd : TopologicalSpace (ℝ × ℝ))
Proof
:=
  continuous_id_iff_le.1 continuous_toPlane

theorem submetrizableSpace

TopologyByExample.DeletedDiscPlane.submetrizableSpace

DeletedDiscPlane S is submetrizable: its topology is finer than the Euclidean one.

theorem submetrizableSpace : SubmetrizableSpace (DeletedDiscPlane S)
Proof
:=
  @SubmetrizableSpace.of_le (DeletedDiscPlane S) _ _ le_euclidean
    (inferInstanceAs (SubmetrizableSpace (ℝ × ℝ)))

theorem not_pseudocompactSpace

TopologyByExample.DeletedDiscPlane.not_pseudocompactSpace

The first coordinate is unbounded, so DeletedDiscPlane S is not pseudocompact.

theorem not_pseudocompactSpace : ¬PseudocompactSpace (DeletedDiscPlane S)
Proof
:= by
  intro h
  obtain ⟨⟨M, hM⟩, -⟩ := h.bddAbove_and_bddBelow_range
    ⟨fun p ↦ (toPlane p).1, continuous_fst.comp continuous_toPlane⟩
  have := hM (mem_range_self (ofPlane (M + 1, 0)))
  simp only [ContinuousMap.coe_mk, toPlane_ofPlane] at this
  linarith

definition line

TopologyByExample.DeletedDiscPlane.line

The line through p in the direction v, as a map into DeletedDiscPlane S.

def line (p v : ℝ × ℝ) (t : ℝ) : DeletedDiscPlane S
:= ofPlane (p + t • v)

theorem toPlane_line

TopologyByExample.DeletedDiscPlane.toPlane_line

The point of the plane under a point of a line.

@[simp]
theorem toPlane_line (p v : ℝ × ℝ) (t : ℝ) : toPlane (line (S := S) p v t) = p + t • v
Proof
:= rfl

theorem exists_isOpen_subset

TopologyByExample.DeletedDiscPlane.exists_isOpen_subset

Every nonempty open set contains the image of a nonempty Euclidean open set: a basic neighbourhood of p contains the part of its disc above the horizontal line through p.

theorem exists_isOpen_subset {U : Set (DeletedDiscPlane S)} (hU : IsOpen U) (hne : U.Nonempty) :
    ∃ V : Set (ℝ × ℝ), IsOpen V ∧ V.Nonempty ∧ ofPlane '' V ⊆ U
Proof
:= by
  obtain ⟨p, hp⟩ := hne
  obtain ⟨r, hr, hrU⟩ := hU p hp
  refine ⟨disc (toPlane p) r ∩ {z | (toPlane p).2 < z.2},
    (isOpen_disc _ r).inter (isOpen_lt continuous_const continuous_snd),
    ⟨((toPlane p).1, (toPlane p).2 + r / 2), ?_, ?_⟩, ?_⟩
  · simp only [disc, mem_ofPred_eq, sub_self, add_sub_cancel_left]
    nlinarith
  · simp only [mem_ofPred_eq]
    linarith
  · rintro _ ⟨z, hz, rfl⟩
    exact hrU ⟨z, ⟨hz.1, notMem_deleted_of_ne hz.2.ne'⟩, rfl⟩

theorem separableSpace

TopologyByExample.DeletedDiscPlane.separableSpace

DeletedDiscPlane S is separable: the points with rational coordinates are dense.

theorem separableSpace : SeparableSpace (DeletedDiscPlane S)
Proof
:= by
  have hd : DenseRange (Prod.map ((↑) : ℚ → ℝ) ((↑) : ℚ → ℝ)) :=
    Rat.denseRange_cast.prodMap Rat.denseRange_cast
  refine ⟨⟨ofPlane '' range (Prod.map ((↑) : ℚ → ℝ) ((↑) : ℚ → ℝ)),
    (countable_range _).image _, dense_iff_inter_open.2 fun U hU hne ↦ ?_⟩⟩
  obtain ⟨V, hV, hVne, hVU⟩ := exists_isOpen_subset hU hne
  obtain ⟨q, hq⟩ := hd.exists_mem_open hV hVne
  exact ⟨ofPlane _, hVU ⟨_, hq, rfl⟩, _, ⟨q, rfl⟩, rfl⟩

theorem baireSpace

TopologyByExample.DeletedDiscPlane.baireSpace

DeletedDiscPlane S is a Baire space: its topology is finer than the Euclidean one, and every nonempty open set contains a nonempty Euclidean open set.

theorem baireSpace : BaireSpace (DeletedDiscPlane S)
Proof
:=
  @baireSpace_of_le (DeletedDiscPlane S) _ _ (inferInstanceAs (BaireSpace (ℝ × ℝ))) le_euclidean
    fun U hU hne ↦ by
      obtain ⟨V, hV, hVne, hVU⟩ := exists_isOpen_subset hU hne
      exact ⟨V, hV, hVne, fun z hz ↦ hVU ⟨z, hz, rfl⟩⟩
variable (hS0 : (0 : ℝ) ∉ S) (hS : ∀ a b, a ∉ S → b ∉ S → a + b ∉ S)
include hS

theorem isOpen_nbhd

TopologyByExample.DeletedDiscPlane.isOpen_nbhd

Every basic neighbourhood is open.

theorem isOpen_nbhd (p : ℝ × ℝ) (r : ℝ) :
    IsOpen (ofPlane '' nbhd S p r : Set (DeletedDiscPlane S))
Proof
:= by
  rintro _ ⟨q, hq, rfl⟩
  obtain ⟨s, hs, hsub⟩ := exists_nbhd_subset_nbhd hS hq
  exact ⟨s, hs, image_mono hsub⟩
include hS0

theorem hasBasis_nhds

TopologyByExample.DeletedDiscPlane.hasBasis_nhds

The neighbourhood bases: the basic neighbourhoods of positive radius at a point form a neighbourhood base there.

theorem hasBasis_nhds (p : DeletedDiscPlane S) :
    (𝓝 p).HasBasis (fun r : ℝ ↦ 0 < r) fun r ↦ ofPlane '' nbhd S (toPlane p) r
Proof
:= by
  refine ⟨fun U ↦ ⟨fun hU ↦ ?_, fun ⟨r, hr, hrU⟩ ↦ mem_of_superset ?_ hrU⟩⟩
  · obtain ⟨V, hVU, hV, hpV⟩ := mem_nhds_iff.1 hU
    obtain ⟨r, hr, hrV⟩ := hV p hpV
    exact ⟨r, hr, hrV.trans hVU⟩
  · exact (isOpen_nbhd hS _ r).mem_nhds ⟨toPlane p, mem_nbhd_self hS0 _ hr, rfl⟩

theorem firstCountableTopology

TopologyByExample.DeletedDiscPlane.firstCountableTopology

DeletedDiscPlane S is first countable: the basic neighbourhoods of radius 1 / (n + 1) form a neighbourhood base.

theorem firstCountableTopology : FirstCountableTopology (DeletedDiscPlane S)
Proof
:= by
  refine ⟨fun p ↦ ((hasBasis_nhds hS0 hS p).to_hasBasis (p' := fun _ : ℕ ↦ True)
    (s' := fun n ↦ ofPlane '' nbhd S (toPlane p) (1 / (n + 1))) ?_ ?_).isCountablyGenerated⟩
  · intro r hr
    obtain ⟨n, hn⟩ := exists_nat_one_div_lt hr
    exact ⟨n, trivial, image_mono (nbhd_mono (by positivity) hn.le)⟩
  · exact fun n _ ↦ ⟨1 / (n + 1), Nat.one_div_pos_of_nat, subset_rfl⟩

theorem continuous_line

TopologyByExample.DeletedDiscPlane.continuous_line

Lines that are not horizontal are continuous: if v.2 ≠ 0, then t ↦ p + t • v is continuous into DeletedDiscPlane S, since a point of the line near p + t₀ • v lies in the disc around it and, unless it is that point, off its horizontal line.

theorem continuous_line (p : ℝ × ℝ) {v : ℝ × ℝ} (hv : v.2 ≠ 0) :
    Continuous (line (S := S) p v)
Proof
:= by
  refine continuous_iff_continuousAt.2 fun t₀ ↦ ?_
  refine ((hasBasis_nhds hS0 hS _).tendsto_right_iff).2 fun r hr ↦ ?_
  have hc : Continuous fun t : ℝ ↦ p + t • v := by fun_prop
  have hmem : (fun t : ℝ ↦ p + t • v) ⁻¹' disc (p + t₀ • v) r ∈ 𝓝 t₀ :=
    ((isOpen_disc _ r).preimage hc).mem_nhds (mem_disc_self _ hr)
  filter_upwards [hmem] with t ht
  refine ⟨p + t • v, ⟨ht, ?_⟩, rfl⟩
  rintro ⟨h2, h1⟩
  simp only [toPlane_line, Prod.snd_add, Prod.smul_snd, smul_eq_mul, add_right_inj] at h2
  rcases eq_or_ne t t₀ with rfl | htt
  · rw [toPlane_line, sub_self] at h1
    exact hS0 h1
  · exact hv (by
      have : (t - t₀) * v.2 = 0 := by rw [sub_mul, h2, sub_self]
      exact (mul_eq_zero.1 this).resolve_left (sub_ne_zero.2 htt))

theorem joinedIn_segment

TopologyByExample.DeletedDiscPlane.joinedIn_segment

Two points at different heights are joined by the segment between them.

theorem joinedIn_segment {F : Set (DeletedDiscPlane S)} {q q' : ℝ × ℝ} (h : q.2 ≠ q'.2)
    (hF : ∀ t ∈ unitInterval, ofPlane (q + t • (q' - q)) ∈ F) :
    JoinedIn F (ofPlane q) (ofPlane q')
Proof
:= by
  refine JoinedIn.ofLine (f := line q (q' - q))
    (continuous_line hS0 hS q (sub_ne_zero.2 h.symm)).continuousOn ?_ ?_ ?_
  · simp [line]
  · simp [line]
  · rintro _ ⟨t, ht, rfl⟩
    exact hF t ht

theorem joinedIn_center_of_ne

TopologyByExample.DeletedDiscPlane.joinedIn_center_of_ne

Every point of a basic neighbourhood off the horizontal line through its centre is joined to the centre inside the neighbourhood, by a segment.

theorem joinedIn_center_of_ne {p z : ℝ × ℝ} {r : ℝ} (hz : z ∈ disc p r)
    (hz2 : z.2 ≠ p.2) :
    JoinedIn (ofPlane '' nbhd S p r : Set (DeletedDiscPlane S)) (ofPlane z) (ofPlane p)
Proof
:= by
  refine joinedIn_segment hS0 hS hz2 fun t ⟨ht0, ht1⟩ ↦ ⟨z + t • (p - z), ⟨?_, ?_⟩, rfl⟩
  · simp only [disc, mem_ofPred_eq, Prod.fst_add, Prod.smul_fst, Prod.fst_sub, smul_eq_mul,
      Prod.snd_add, Prod.smul_snd, Prod.snd_sub] at hz ⊢
    have e1 : z.1 + t * (p.1 - z.1) - p.1 = (1 - t) * (z.1 - p.1) := by ring
    have e2 : z.2 + t * (p.2 - z.2) - p.2 = (1 - t) * (z.2 - p.2) := by ring
    rw [e1, e2]
    have h1t : (1 - t) ^ 2 ≤ 1 := by nlinarith
    nlinarith [sq_nonneg (z.1 - p.1), sq_nonneg (z.2 - p.2)]
  · rintro ⟨h2, h1⟩
    simp only [Prod.fst_add, Prod.smul_fst, Prod.fst_sub, smul_eq_mul, Prod.snd_add,
      Prod.smul_snd, Prod.snd_sub] at h1 h2
    have ht : 1 - t = 0 := by
      have : (1 - t) * (z.2 - p.2) = 0 := by linear_combination h2
      exact (mul_eq_zero.1 this).resolve_right (sub_ne_zero.2 hz2)
    have : z.1 + t * (p.1 - z.1) - p.1 = 0 := by linear_combination (z.1 - p.1) * ht
    rw [this] at h1
    exact hS0 h1

theorem isPathConnected_nbhd

TopologyByExample.DeletedDiscPlane.isPathConnected_nbhd

The basic neighbourhoods are path connected: each point is joined to the centre by a segment, or, if it lies on the horizontal line through the centre, by a vertical segment followed by a segment.

theorem isPathConnected_nbhd (p : ℝ × ℝ) {r : ℝ} (hr : 0 < r) :
    IsPathConnected (ofPlane '' nbhd S p r : Set (DeletedDiscPlane S))
Proof
:= by
  refine ⟨ofPlane p, ⟨p, mem_nbhd_self hS0 p hr, rfl⟩, ?_⟩
  rintro _ ⟨z, hz, rfl⟩
  refine JoinedIn.symm ?_
  by_cases hz2 : z.2 = p.2
  · -- go up vertically to `z' = (z.1, z.2 + h)`, then straight to the centre
    have hd : 0 < r ^ 2 - (z.1 - p.1) ^ 2 := by
      have := hz.1
      simp only [disc, mem_ofPred_eq, hz2, sub_self] at this
      linarith
    set h := min 1 ((r ^ 2 - (z.1 - p.1) ^ 2) / 2)
    have hh : 0 < h := lt_min one_pos (half_pos hd)
    have hh1 : h ≤ 1 := min_le_left _ _
    have hh2 : h ≤ (r ^ 2 - (z.1 - p.1) ^ 2) / 2 := min_le_right _ _
    have hsq : (z.1 - p.1) ^ 2 + h ^ 2 < r ^ 2 := by nlinarith
    set z' : ℝ × ℝ := (z.1, z.2 + h)
    have hz'2 : z'.2 ≠ p.2 := by simp [z', hz2, hh.ne']
    have hz' : z' ∈ disc p r := by
      simp only [disc, mem_ofPred_eq, z', hz2, add_sub_cancel_left]
      exact hsq
    refine JoinedIn.trans ?_ (joinedIn_center_of_ne hS0 hS hz' hz'2)
    refine joinedIn_segment hS0 hS (by simp [z', hh.ne']) fun t ⟨ht0, ht1⟩ ↦
      ⟨z + t • (z' - z), ⟨?_, ?_⟩, rfl⟩
    · simp only [disc, mem_ofPred_eq, Prod.fst_add, Prod.smul_fst, Prod.fst_sub, smul_eq_mul,
        Prod.snd_add, Prod.smul_snd, Prod.snd_sub, z', sub_self, mul_zero, add_zero, hz2,
        add_sub_cancel_left]
      have h1 : t * h ≤ h := mul_le_of_le_one_left hh.le ht1
      have h2 : 0 ≤ t * h := mul_nonneg ht0 hh.le
      nlinarith
    · rintro ⟨h2, h1⟩
      simp only [Prod.snd_add, Prod.smul_snd, Prod.snd_sub, smul_eq_mul, z', hz2,
        add_sub_cancel_left, add_eq_left, mul_eq_zero, hh.ne', or_false] at h2
      subst h2
      exact hz.2 ⟨hz2, by simpa using h1⟩
  · exact joinedIn_center_of_ne hS0 hS hz.1 hz2

theorem locallyPathConnectedSpace

TopologyByExample.DeletedDiscPlane.locallyPathConnectedSpace

DeletedDiscPlane S is locally path connected: the basic neighbourhoods are path connected.

theorem locallyPathConnectedSpace : LocallyPathConnectedSpace (DeletedDiscPlane S)
Proof
:=
  .of_bases (hasBasis_nhds hS0 hS) fun _ _ hr ↦ isPathConnected_nbhd hS0 hS _ hr

theorem joined_of_ne

TopologyByExample.DeletedDiscPlane.joined_of_ne

Two points at different heights are joined by a path.

theorem joined_of_ne {q q' : ℝ × ℝ} (h : q.2 ≠ q'.2) :
    Joined (ofPlane q : DeletedDiscPlane S) (ofPlane q')
Proof
:=
  (joinedIn_segment (F := univ) hS0 hS h fun _ _ ↦ mem_univ _).joined

theorem pathPreconnectedSpace

TopologyByExample.DeletedDiscPlane.pathPreconnectedSpace

DeletedDiscPlane S is path connected: every point is joined to the origin, by a segment or, from a point of the horizontal axis, by a vertical segment followed by a segment.

theorem pathPreconnectedSpace : PathPreconnectedSpace (DeletedDiscPlane S)
Proof
:= by
  have key : ∀ q : ℝ × ℝ, Joined (ofPlane q : DeletedDiscPlane S) (ofPlane (0, 0)) := by
    intro q
    by_cases hq : q.2 = 0
    · exact (joined_of_ne hS0 hS (q' := (q.1, 1)) (by simp [hq])).trans
        (joined_of_ne hS0 hS (by simp))
    · exact joined_of_ne hS0 hS (by simpa using hq)
  exact ⟨fun p q ↦ (key (toPlane p)).trans (key (toPlane q)).symm⟩

theorem subset_closure_nbhd

TopologyByExample.DeletedDiscPlane.subset_closure_nbhd

The closure of a basic neighbourhood contains its whole disc: a point of the disc is the limit, along the vertical line through it, of points of the disc off the horizontal line through the centre.

theorem subset_closure_nbhd (p : ℝ × ℝ) (r : ℝ) :
    (ofPlane '' disc p r : Set (DeletedDiscPlane S)) ⊆ closure (ofPlane '' nbhd S p r)
Proof
:= by
  rintro _ ⟨z, hz, rfl⟩
  have hc := continuous_line (S := S) hS0 hS z (v := (0, 1)) one_ne_zero
  have hmem : (fun t : ℝ ↦ z + t • ((0 : ℝ), (1 : ℝ))) ⁻¹' disc p r ∈ 𝓝 (0 : ℝ) :=
    ((isOpen_disc p r).preimage (by fun_prop)).mem_nhds
      (by simp only [mem_preimage, zero_smul, add_zero]; exact hz)
  have hz0 : line (S := S) z (0, 1) 0 = ofPlane z := by simp [line]
  have hin : ∀ t : ℝ, t ≠ 0 → (z + t • ((0 : ℝ), (1 : ℝ))) ∈ disc p r →
      (z + t • ((0 : ℝ), (1 : ℝ))).2 ≠ p.2 → line (S := S) z (0, 1) t ∈ ofPlane '' nbhd S p r :=
    fun t _ hd hne ↦ ⟨_, ⟨hd, notMem_deleted_of_ne hne⟩, rfl⟩
  have h2 : ∀ t : ℝ, (z + t • ((0 : ℝ), (1 : ℝ))).2 = z.2 + t := fun t ↦ by simp
  rcases le_or_gt p.2 z.2 with hle | hlt
  · rw [← hz0]
    refine mem_closure_of_tendsto ((hc.tendsto 0).mono_left (nhdsWithin_le_nhds (s := Ioi 0))) ?_
    filter_upwards [nhdsWithin_le_nhds hmem, self_mem_nhdsWithin] with t hd (ht : 0 < t)
    refine hin t ht.ne' hd ?_
    rw [h2]
    exact ne_of_gt (by linarith)
  · rw [← hz0]
    refine mem_closure_of_tendsto ((hc.tendsto 0).mono_left (nhdsWithin_le_nhds (s := Iio 0))) ?_
    filter_upwards [nhdsWithin_le_nhds hmem, self_mem_nhdsWithin] with t hd (ht : t < 0)
    refine hin t ht.ne hd ?_
    rw [h2]
    exact ne_of_lt (by linarith)

theorem not_semiregularSpace

TopologyByExample.DeletedDiscPlane.not_semiregularSpace

DeletedDiscPlane S is not semiregular when S has arbitrarily small elements: a regular open set containing a point contains the closure-interior of a basic neighbourhood, hence a whole disc around it, so it is not contained in the basic neighbourhood of radius 1.

theorem not_semiregularSpace (hSsmall : ∀ ε > 0, ∃ a ∈ S, |a| < ε) :
    ¬SemiregularSpace (DeletedDiscPlane S)
Proof
:= by
  intro h
  set p : ℝ × ℝ := (0, 0)
  have hW : IsOpen (ofPlane '' nbhd S p 1 : Set (DeletedDiscPlane S)) := isOpen_nbhd hS _ 1
  have hpW : (ofPlane p : DeletedDiscPlane S) ∈ ofPlane '' nbhd S p 1 :=
    ⟨p, mem_nbhd_self hS0 p one_pos, rfl⟩
  obtain ⟨V, hVreg, hpV, hVW⟩ := h.isTopologicalBasis.exists_subset_of_mem_open hpW hW
  have hVreg' : interior (closure V) = V := hVreg
  have hVo : IsOpen V := hVreg' ▸ isOpen_interior
  obtain ⟨r, hr, hrV⟩ :=
    (hasBasis_nhds hS0 hS (ofPlane p : DeletedDiscPlane S)).mem_iff.1 (hVo.mem_nhds hpV)
  have hdisc : (ofPlane '' disc p r : Set (DeletedDiscPlane S)) ⊆ V := by
    rw [← hVreg']
    refine interior_maximal ((subset_closure_nbhd hS0 hS p r).trans (closure_mono hrV)) ?_
    convert isOpen_preimage_toPlane (S := S) (isOpen_disc p r) using 1
    ext q
    exact ⟨by rintro ⟨z, hz, rfl⟩; exact hz, fun hq ↦ ⟨q, hq, rfl⟩⟩
  obtain ⟨a, haS, ha⟩ := hSsmall (min r 1) (lt_min hr one_pos)
  have hz : ((a, 0) : ℝ × ℝ) ∈ disc p r := by
    have := (abs_lt.1 (ha.trans_le (min_le_left _ _)))
    simp only [disc, mem_ofPred_eq, p, sub_zero]
    nlinarith
  obtain ⟨w, hw, hw'⟩ := hVW (hdisc ⟨_, hz, rfl⟩)
  have hw'' : w = (a, 0) := hw'
  subst hw''
  exact hw.2 ⟨rfl, show a - 0 ∈ S by rwa [sub_zero]⟩