Lean library · module TopologyByExample.Spaces.CountableComplementExtension

The countable complement extension topology

Source file

The countable complement extension topology on ℝ is the coarsest topology finer than both the usual topology and the cocountable topology (their join; in Mathlib's order on topologies, where finer is smaller, their infimum). Its open sets are exactly the sets U \ C with U open in the usual topology and C countable: these sets are closed under unions because ℝ is hereditarily Lindelöf.

Countable sets are closed and discrete, so compact sets are finite and the space is not separable, while it stays Lindelöf and connected. A set is regular open only if it is open in the usual topology, so the space is not semiregular, and it is not locally connected: an open set containing 0 and avoiding K = {1 / n} is split at a point of K. It is a Baire space: the dense open sets are the sets U \ C with U dense, and countably many of them still meet every nonempty open set, by the Baire category theorem for ℝ.

Main definitions

Main statements

References

  • L. A. Steen and J. A. Seebach, Counterexamples in Topology, Example 63.

Tags

countable complement extension, cocountable topology, Baire space, counterexample

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 CountableComplementExtension

TopologyByExample.CountableComplementExtension

The real line with the countable complement extension topology: the coarsest topology finer than both the usual topology and the cocountable topology.

def CountableComplementExtension : Type
:= ℝ

On this site: Space: Countable complement extension topology

definition toReal

TopologyByExample.CountableComplementExtension.toReal

The identity map from the space to ℝ.

def toReal : CountableComplementExtension ≃ ℝ
:= Equiv.refl ℝ

instance

The space is nonempty.

instance : Nonempty CountableComplementExtension
Proof
:= ⟨toReal.symm 0⟩

instance

The countable complement extension topology: the join of the usual and the cocountable topologies (their infimum in Mathlib's order on topologies).

instance : TopologicalSpace CountableComplementExtension
Proof
:=
  induced toReal ((inferInstance : TopologicalSpace ℝ) ⊓ cocountableTopology ℝ)

The open sets

theorem eq_empty_of_isOpen_of_subset_countable

TopologyByExample.CountableComplementExtension.eq_empty_of_isOpen_of_subset_countable

A nonempty open set of reals is not contained in a countable set.

theorem eq_empty_of_isOpen_of_subset_countable {U C : Set ℝ} (hU : IsOpen U) (hC : C.Countable)
    (hUC : U ⊆ C) : U = ∅
Proof
:= by
  refine eq_empty_of_forall_notMem fun x hx ↦ ?_
  obtain ⟨y, hyU, hyC⟩ := (hC.dense_compl ℝ).inter_open_nonempty U hU ⟨x, hx⟩
  exact hyC (hUC hyU)

definition extensionTopology

TopologyByExample.CountableComplementExtension.extensionTopology

The topology on ℝ whose open sets are the sets U \ C, U open, C countable. Unions of such sets are again of this form because ℝ is hereditarily Lindelöf.

@[instance_reducible]
def extensionTopology : TopologicalSpace ℝ
Definition
where
  IsOpen s := ∃ U : Set ℝ, IsOpen U ∧ ∃ C : Set ℝ, C.Countable ∧ s = U \ C
  isOpen_univ := ⟨univ, isOpen_univ, ∅, countable_empty, by simp⟩
  isOpen_inter := by
    rintro _ _ ⟨U, hU, C, hC, rfl⟩ ⟨V, hV, D, hD, rfl⟩
    exact ⟨U ∩ V, hU.inter hV, C ∪ D, hC.union hD, by ext; simp; tauto⟩
  isOpen_sUnion S hS := by
    choose U hU C hC hs using hS
    obtain ⟨T, hTc, hTU⟩ :=
      isOpen_iUnion_countable (fun s : S ↦ U s s.property) fun s ↦ hU s s.property
    refine ⟨⋃ s : S, U s s.property, isOpen_iUnion fun s ↦ hU s s.property,
      (⋃ s : S, U s s.property) \ ⋃₀ S, ((hTc.biUnion fun s _ ↦ hC s s.property).mono ?_), ?_⟩
    · rintro x ⟨hxU, hxS⟩
      rw [← hTU] at hxU
      obtain ⟨s, hsT, hxs⟩ := mem_iUnion₂.1 hxU
      refine mem_iUnion₂.2 ⟨s, hsT, by_contra fun hxC ↦ hxS ⟨s, s.property, ?_⟩⟩
      rw [hs s s.property]
      exact ⟨hxs, hxC⟩
    · ext x
      refine ⟨fun hx ↦ ⟨?_, fun h ↦ h.2 hx⟩, fun hx ↦ by_contra fun h ↦ hx.2 ⟨hx.1, h⟩⟩
      obtain ⟨s, hsS, hxs⟩ := hx
      rw [hs s hsS] at hxs
      exact mem_iUnion.2 ⟨⟨s, hsS⟩, hxs.1⟩

theorem inf_eq_extensionTopology

TopologyByExample.CountableComplementExtension.inf_eq_extensionTopology

The open sets. The join of the usual and the cocountable topologies is the topology whose open sets are the sets U \ C with U open in the usual topology and C countable.

theorem inf_eq_extensionTopology :
    (inferInstance : TopologicalSpace ℝ) ⊓ cocountableTopology ℝ = extensionTopology
Proof
:= by
  refine le_antisymm (TopologicalSpace.le_def.2 fun s hs ↦ ?_)
    (le_inf (TopologicalSpace.le_def.2 fun U hU ↦ ⟨U, hU, ∅, countable_empty, by simp⟩)
      (TopologicalSpace.le_def.2 fun s hs ↦ ?_))
  · obtain ⟨U, hU, C, hC, rfl⟩ := hs
    have hC' : IsOpen[cocountableTopology ℝ] Cᶜ := fun _ ↦ by rwa [compl_compl]
    rw [sdiff_eq]
    exact @IsOpen.inter ℝ (_ ⊓ _) _ _ (TopologicalSpace.le_def.1 inf_le_left U hU)
      (TopologicalSpace.le_def.1 inf_le_right _ hC')
  · rcases s.eq_empty_or_nonempty with rfl | hne
    · exact ⟨∅, isOpen_empty, ∅, countable_empty, by simp⟩
    · exact ⟨univ, isOpen_univ, sᶜ, hs hne, by simp⟩

theorem isOpen_iff

TopologyByExample.CountableComplementExtension.isOpen_iff

The open sets of the countable complement extension topology are the sets U \ C with U open in ℝ and C countable.

theorem isOpen_iff {s : Set CountableComplementExtension} :
    IsOpen s ↔ ∃ U : Set ℝ, IsOpen U ∧ ∃ C : Set ℝ, C.Countable ∧ s = toReal ⁻¹' (U \ C)
Proof
:= by
  have h : IsOpen s ↔ ∃ t, IsOpen[extensionTopology] t ∧ toReal ⁻¹' t = s := by
    change IsOpen[induced toReal (_ ⊓ _)] s ↔ _
    rw [inf_eq_extensionTopology]
    rfl
  rw [h]
  constructor
  · rintro ⟨t, ⟨U, hU, C, hC, rfl⟩, rfl⟩
    exact ⟨U, hU, C, hC, rfl⟩
  · rintro ⟨U, hU, C, hC, rfl⟩
    exact ⟨_, ⟨U, hU, C, hC, rfl⟩, rfl⟩

On this site: Countable complement extension topology: The open sets are the sets \(U \setminus C\)

theorem isOpen_preimage_diff

TopologyByExample.CountableComplementExtension.isOpen_preimage_diff

theorem isOpen_preimage_diff {U C : Set ℝ} (hU : IsOpen U) (hC : C.Countable) :
    IsOpen (toReal ⁻¹' (U \ C))
Proof
:=
  isOpen_iff.2 ⟨U, hU, C, hC, rfl⟩

theorem continuous_toReal

TopologyByExample.CountableComplementExtension.continuous_toReal

The topology is finer than the usual topology.

theorem continuous_toReal : Continuous toReal
Proof
:=
  continuous_def.2 fun U hU ↦ by simpa using isOpen_preimage_diff hU countable_empty

theorem isOpen_preimage_toReal

TopologyByExample.CountableComplementExtension.isOpen_preimage_toReal

theorem isOpen_preimage_toReal {U : Set ℝ} (hU : IsOpen U) : IsOpen (toReal ⁻¹' U)
Proof
:=
  hU.preimage continuous_toReal

theorem isClosed_preimage_of_countable

TopologyByExample.CountableComplementExtension.isClosed_preimage_of_countable

Countable sets are closed.

theorem isClosed_preimage_of_countable {C : Set ℝ} (hC : C.Countable) :
    IsClosed (toReal ⁻¹' C)
Proof
:= by
  rw [← isOpen_compl_iff, ← preimage_compl, compl_eq_univ_sdiff]
  exact isOpen_preimage_diff isOpen_univ hC

theorem subset_closure_diff

TopologyByExample.CountableComplementExtension.subset_closure_diff

An open set is contained in the closure of each of its cocountable subsets that are open: the closure of U \ C contains U.

theorem subset_closure_diff {U C : Set ℝ} (hU : IsOpen U) (hC : C.Countable) :
    toReal ⁻¹' U ⊆ closure (toReal ⁻¹' (U \ C))
Proof
:= by
  intro x hx
  refine mem_closure_iff.2 fun o ho hxo ↦ ?_
  obtain ⟨V, hV, D, hD, rfl⟩ := isOpen_iff.1 ho
  obtain ⟨y, ⟨hyU, hyV⟩, hyCD⟩ := ((hC.union hD).dense_compl ℝ).inter_open_nonempty (U ∩ V)
    (hU.inter hV) ⟨toReal x, hx, hxo.1⟩
  refine ⟨toReal.symm y, ?_, ?_⟩ <;> simp only [mem_preimage, Equiv.apply_symm_apply]
  · exact ⟨hyV, fun h ↦ hyCD (.inr h)⟩
  · exact ⟨hyU, fun h ↦ hyCD (.inl h)⟩

Values

theorem lindelofSpace

TopologyByExample.CountableComplementExtension.lindelofSpace

The space is Lindelöf. From an open cover by sets Uᵢ \ Cᵢ, countably many Uᵢ cover ℝ, and countably many more members cover the countably many points of the corresponding Cᵢ.

theorem lindelofSpace : LindelofSpace CountableComplementExtension
Proof
:= by
  refine ⟨isLindelof_iff_countable_subcover.2 fun {ι} W hW hcov ↦ ?_⟩
  choose U hU C hC hWUC using fun i ↦ isOpen_iff.1 (hW i)
  obtain ⟨T, hTc, hTU⟩ := isOpen_iUnion_countable U hU
  have hUuniv : ⋃ i, U i = univ := eq_univ_of_forall fun x ↦ by
    obtain ⟨i, hi⟩ := mem_iUnion.1 (hcov (mem_univ (toReal.symm x)))
    rw [hWUC i] at hi
    exact mem_iUnion.2 ⟨i, by simpa using hi.1⟩
  have hpt (x : CountableComplementExtension) : ∃ i, x ∈ W i := mem_iUnion.1 (hcov (mem_univ x))
  choose j hj using hpt
  refine ⟨T ∪ (fun y ↦ j (toReal.symm y)) '' ⋃ i ∈ T, C i,
    hTc.union ((hTc.biUnion fun i _ ↦ hC i).image _), fun x _ ↦ ?_⟩
  have hx : toReal x ∈ ⋃ i ∈ T, U i := by rw [hTU, hUuniv]; trivial
  obtain ⟨i, hiT, hxi⟩ := mem_iUnion₂.1 hx
  by_cases hxC : toReal x ∈ C i
  · refine mem_iUnion₂.2 ⟨j x, .inr ⟨toReal x, mem_iUnion₂.2 ⟨i, hiT, hxC⟩, ?_⟩, hj x⟩
    simp
  · refine mem_iUnion₂.2 ⟨i, .inl hiT, ?_⟩
    rw [hWUC i]
    exact ⟨hxi, hxC⟩

On this site: The countable complement extension topology is Lindelöf

theorem isDiscrete_of_countable

TopologyByExample.CountableComplementExtension.isDiscrete_of_countable

Every subset of a countable set of the space is closed, so countable sets are discrete.

theorem isDiscrete_of_countable {s : Set CountableComplementExtension} (hs : s.Countable) :
    IsDiscrete s
Proof
:= by
  refine isDiscrete_iff_forall_mem_exists_isOpen.2 fun y hy ↦ ?_
  refine ⟨(toReal ⁻¹' (toReal '' (s \ {y})))ᶜ, (isClosed_preimage_of_countable
    ((hs.mono sdiff_subset).image _)).isOpen_compl, ?_⟩
  ext z
  simp only [mem_inter_iff, mem_compl_iff, mem_preimage, mem_image, Set.mem_sdiff,
    mem_singleton_iff, EmbeddingLike.apply_eq_iff_eq, exists_eq_right, not_and, not_not]
  constructor
  · rintro ⟨hz, hzs⟩
    exact hz hzs
  · rintro rfl
    exact ⟨fun _ ↦ rfl, hy⟩

theorem anticompactSpace

TopologyByExample.CountableComplementExtension.anticompactSpace

The space is anticompact: its compact sets are finite. An infinite set contains a countably infinite set, which is closed and discrete.

theorem anticompactSpace : AnticompactSpace CountableComplementExtension
Proof
:= by
  refine ⟨fun s hs ↦ by_contra fun hinf ↦ ?_⟩
  set e := Set.Infinite.natEmbedding s hinf
  set t : Set CountableComplementExtension := range fun n ↦ (e n : CountableComplementExtension)
  have htc : t.Countable := countable_range _
  have hts : t ⊆ s := by rintro _ ⟨n, rfl⟩; exact (e n).property
  have htcl : IsClosed t := by
    simpa using isClosed_preimage_of_countable (htc.image toReal)
  have hfin : t.Finite := (hs.of_isClosed_subset htcl hts).finite (isDiscrete_of_countable htc)
  exact infinite_range_of_injective (fun m n h ↦ e.injective (Subtype.ext h)) hfin

On this site: The countable complement extension topology is anticompact

theorem countableChainCondition

TopologyByExample.CountableComplementExtension.countableChainCondition

The space has the countable chain condition: disjoint nonempty open sets Uᵢ \ Cᵢ have disjoint Uᵢ, since a countable open set of reals is empty.

theorem countableChainCondition : ∀ S : Set (Set CountableComplementExtension),
    (∀ s ∈ S, IsOpen s ∧ s.Nonempty) → S.PairwiseDisjoint id → S.Countable
Proof
:= by
  intro S hS hdisj
  have hrep (s : Set CountableComplementExtension) :
      ∃ U : Set ℝ, (s ∈ S → IsOpen U) ∧
        ∃ C : Set ℝ, (s ∈ S → C.Countable ∧ s = toReal ⁻¹' (U \ C)) := by
    by_cases hs : s ∈ S
    · obtain ⟨U, hU, C, hC, h⟩ := isOpen_iff.1 (hS s hs).1
      exact ⟨U, fun _ ↦ hU, C, fun _ ↦ ⟨hC, h⟩⟩
    · exact ⟨∅, fun h ↦ absurd h hs, ∅, fun h ↦ absurd h hs⟩
  choose U hU C hC using hrep
  refine Set.PairwiseDisjoint.countable_of_isOpen (s := U) ?_ (fun s hs ↦ hU s hs) fun s hs ↦ ?_
  · intro s hs t ht hst
    refine Set.disjoint_left.2 fun x hxs hxt ↦ ?_
    have hemp := eq_empty_of_isOpen_of_subset_countable ((hU s hs).inter (hU t ht))
      (((hC s hs).1).union (hC t ht).1) fun y ⟨hys, hyt⟩ ↦ by
        by_contra hy
        simp only [mem_union, not_or] at hy
        have h1 : toReal.symm y ∈ s := by
          rw [(hC s hs).2, mem_preimage, Equiv.apply_symm_apply]; exact ⟨hys, hy.1⟩
        have h2 : toReal.symm y ∈ t := by
          rw [(hC t ht).2, mem_preimage, Equiv.apply_symm_apply]; exact ⟨hyt, hy.2⟩
        exact Set.disjoint_left.1 (hdisj hs ht hst) h1 h2
    exact (eq_empty_iff_forall_notMem.1 hemp x) ⟨hxs, hxt⟩
  · obtain ⟨x, hx⟩ := (hS s hs).2
    rw [(hC s hs).2] at hx
    exact ⟨_, hx.1⟩

On this site: The countable complement extension topology satisfies the countable chain condition

theorem not_separableSpace

TopologyByExample.CountableComplementExtension.not_separableSpace

The space is not separable: countable sets are closed, and ℝ is uncountable.

theorem not_separableSpace : ¬SeparableSpace CountableComplementExtension
Proof
:= fun h ↦ by
  obtain ⟨D, hDc, hD⟩ := h.exists_countable_dense
  have hcl : IsClosed D := by simpa using isClosed_preimage_of_countable (hDc.image toReal)
  have : (univ : Set ℝ).Countable := by
    rw [← image_univ_of_surjective toReal.surjective, ← hD.closure_eq, hcl.closure_eq]
    exact hDc.image _
  exact not_countable_univ this

On this site: The countable complement extension topology is not separable

theorem preconnectedSpace

TopologyByExample.CountableComplementExtension.preconnectedSpace

The space is connected. If a set is open and closed, write it as U \ C and its complement as V \ D; then U ∩ V is a countable open set of reals, so empty, and U ∪ V = ℝ, so U is open and closed in ℝ.

theorem preconnectedSpace : PreconnectedSpace CountableComplementExtension
Proof
:= by
  refine preconnectedSpace_iff_clopen.2 fun s hs ↦ ?_
  obtain ⟨U, hU, C, hC, rfl⟩ := isOpen_iff.1 hs.2
  obtain ⟨V, hV, D, hD, hVD⟩ := isOpen_iff.1 hs.1.isOpen_compl
  have hUV : U ∩ V = ∅ := eq_empty_of_isOpen_of_subset_countable (hU.inter hV) (hC.union hD)
    fun y ⟨hyU, hyV⟩ ↦ by
      by_contra hy
      simp only [mem_union, not_or] at hy
      have h1 : toReal.symm y ∈ toReal ⁻¹' (U \ C) := by
        rw [mem_preimage, Equiv.apply_symm_apply]; exact ⟨hyU, hy.1⟩
      have h2 : toReal.symm y ∈ (toReal ⁻¹' (U \ C))ᶜ := by
        rw [hVD, mem_preimage, Equiv.apply_symm_apply]; exact ⟨hyV, hy.2⟩
      exact h2 h1
  have hcov : U ∪ V = univ := eq_univ_of_forall fun y ↦ by
    by_cases h : toReal.symm y ∈ toReal ⁻¹' (U \ C)
    · exact .inl (by simpa using h.1)
    · have h' : toReal.symm y ∈ toReal ⁻¹' (V \ D) := hVD ▸ h
      exact .inr (by simpa using h'.1)
  have hUV' : Uᶜ = V := by
    ext y
    constructor
    · intro hy
      exact (hcov.symm ▸ mem_univ y : y ∈ U ∪ V).resolve_left hy
    · intro hy hyU
      exact (eq_empty_iff_forall_notMem.1 hUV y) ⟨hyU, hy⟩
  have hUc : IsClopen U := ⟨by rw [← isOpen_compl_iff, hUV']; exact hV, hU⟩
  rcases isClopen_iff.1 hUc with rfl | rfl
  · exact .inl (by simp)
  · refine .inr (eq_univ_of_forall fun x ↦ ?_)
    have hVe : V = ∅ := by simpa using hUV
    by_contra hx
    have : x ∈ toReal ⁻¹' (V \ D) := hVD ▸ hx
    simp [hVe] at this

On this site: The countable complement extension topology is connected

theorem exists_pos_mem_of_mem_nhds

TopologyByExample.CountableComplementExtension.exists_pos_mem_of_mem_nhds

Every neighbourhood of 0 contains a positive point outside K = {1 / n}.

theorem exists_pos_mem_of_mem_nhds {N : Set CountableComplementExtension}
    (hN : N ∈ 𝓝 (toReal.symm 0)) : ∃ p : ℝ, 0 < p ∧ toReal.symm p ∈ N
Proof
:= by
  obtain ⟨o, hoN, ho, h0o⟩ := mem_nhds_iff.1 hN
  obtain ⟨U, hU, C, hC, rfl⟩ := isOpen_iff.1 ho
  have h0U : (0 : ℝ) ∈ U := by simpa using h0o.1
  obtain ⟨ε, hε, hεU⟩ := Metric.isOpen_iff.1 hU 0 h0U
  obtain ⟨p, ⟨hp0, hpε⟩, hpC⟩ := (hC.dense_compl ℝ).inter_open_nonempty (Ioo 0 ε) isOpen_Ioo
    (nonempty_Ioo.2 hε)
  refine ⟨p, hp0, hoN ?_⟩
  simp only [mem_preimage, Equiv.apply_symm_apply]
  exact ⟨hεU (by rw [Metric.mem_ball, Real.dist_eq, sub_zero, abs_lt]; constructor <;> linarith),
    hpC⟩

theorem compl_kSet_mem_nhds

TopologyByExample.CountableComplementExtension.compl_kSet_mem_nhds

The set K = {1 / n} is countable, so ℝ \ K is a neighbourhood of 0.

theorem compl_kSet_mem_nhds : toReal ⁻¹' KTopology.kSetᶜ ∈ 𝓝 (toReal.symm 0)
Proof
:=
  (isClosed_preimage_of_countable KTopology.countable_kSet).isOpen_compl.mem_nhds
    (by simpa using KTopology.zero_notMem_kSet)

theorem not_locallyConnectedSpace

TopologyByExample.CountableComplementExtension.not_locallyConnectedSpace

The space is not locally connected at 0. An open set V with 0 ∈ V ⊆ ℝ \ K contains a positive point p; choosing 1 / n < p in K, the open sets (-∞, 1 / n) and (1 / n, ∞) split V.

theorem not_locallyConnectedSpace : ¬LocallyConnectedSpace CountableComplementExtension
Proof
:=
  fun h ↦ by
  obtain ⟨V, hVU, hVo, h0V, hVc⟩ := locallyConnectedSpace_iff_subsets_isOpen_isConnected.1 h
    (toReal.symm 0) _ compl_kSet_mem_nhds
  obtain ⟨p, hp, hpV⟩ := exists_pos_mem_of_mem_nhds (hVo.mem_nhds h0V)
  obtain ⟨n, hn⟩ := exists_nat_one_div_lt hp
  rw [one_div] at hn
  have hk : ((n : ℝ) + 1)⁻¹ ∈ KTopology.kSet := KTopology.inv_natCast_add_one_mem_kSet n
  have hk0 : (0 : ℝ) < ((n : ℝ) + 1)⁻¹ := inv_pos.2 n.cast_add_one_pos
  obtain ⟨z, -, hz₁, hz₂⟩ := hVc.isPreconnected _ _ (isOpen_preimage_toReal isOpen_Iio)
    (isOpen_preimage_toReal isOpen_Ioi) (fun x hx ↦ by
      rcases lt_trichotomy (toReal x) ((n : ℝ) + 1)⁻¹ with h | h | h
      · exact .inl h
      · exact absurd (h ▸ hk) (hVU hx)
      · exact .inr h)
    ⟨_, h0V, by simpa using hk0⟩ ⟨toReal.symm p, hpV, by simpa using hn⟩
  exact lt_asymm (show toReal z < _ from hz₁) hz₂

On this site: The countable complement extension topology is not locally connected

theorem not_semiregularSpace

TopologyByExample.CountableComplementExtension.not_semiregularSpace

The space is not semiregular. A regular open set V = U \ C containing 0 contains U, which lies in the closure of V; so it contains points 1 / n, and does not lie in the neighbourhood ℝ \ K of 0.

theorem not_semiregularSpace : ¬SemiregularSpace CountableComplementExtension
Proof
:= by
  intro ⟨h⟩
  obtain ⟨V, hVreg, h0V, hVK⟩ :=
    h.isOpen_iff.1 (isClosed_preimage_of_countable KTopology.countable_kSet).isOpen_compl
      (toReal.symm 0) (by simpa using KTopology.zero_notMem_kSet)
  have hVo : IsOpen V := hVreg ▸ isOpen_interior
  obtain ⟨U, hU, C, hC, rfl⟩ := isOpen_iff.1 hVo
  have hsub : toReal ⁻¹' U ⊆ toReal ⁻¹' (U \ C) := by
    rw [← show interior (closure (toReal ⁻¹' (U \ C))) = toReal ⁻¹' (U \ C) from hVreg]
    exact interior_maximal (subset_closure_diff hU hC) (isOpen_preimage_toReal hU)
  have h0U : (0 : ℝ) ∈ U := by simpa using h0V.1
  obtain ⟨ε, hε, hεU⟩ := Metric.isOpen_iff.1 hU 0 h0U
  obtain ⟨n, hn⟩ := exists_nat_one_div_lt hε
  rw [one_div] at hn
  have hk0 : (0 : ℝ) < ((n : ℝ) + 1)⁻¹ := inv_pos.2 n.cast_add_one_pos
  have hmem : toReal.symm ((n : ℝ) + 1)⁻¹ ∈ toReal ⁻¹' U := by
    simp only [mem_preimage, Equiv.apply_symm_apply]
    exact hεU (by rw [Metric.mem_ball, Real.dist_eq, sub_zero, abs_lt]; constructor <;> linarith)
  have := hVK (hsub hmem)
  simp only [mem_preimage, Equiv.apply_symm_apply, mem_compl_iff] at this
  exact this (KTopology.inv_natCast_add_one_mem_kSet n)

On this site: The countable complement extension topology is not semiregular

theorem not_pseudocompactSpace

TopologyByExample.CountableComplementExtension.not_pseudocompactSpace

The space is not pseudocompact: the identity to ℝ is an unbounded continuous real function.

theorem not_pseudocompactSpace : ¬PseudocompactSpace CountableComplementExtension
Proof
:= by
  intro ⟨h⟩
  obtain ⟨⟨b, hb⟩, -⟩ := h ⟨toReal, continuous_toReal⟩
  obtain ⟨x, hx⟩ := exists_gt b
  exact (hb ⟨toReal.symm x, by simp⟩).not_gt hx

On this site: The countable complement extension topology is not pseudocompact

theorem submetrizableSpace

TopologyByExample.CountableComplementExtension.submetrizableSpace

The space is submetrizable: the usual topology of ℝ, carried over by the identity, is a coarser metrizable topology.

theorem submetrizableSpace : SubmetrizableSpace CountableComplementExtension
Proof
:= by
  refine ⟨⟨induced toReal inferInstance, continuous_iff_le_induced.1 continuous_toReal, ?_⟩⟩
  let _ : TopologicalSpace CountableComplementExtension := induced toReal inferInstance
  exact (Topology.IsEmbedding.mk ⟨rfl⟩ toReal.injective).metrizableSpace

On this site: The countable complement extension topology is submetrizable

theorem dense_of_dense_diff

TopologyByExample.CountableComplementExtension.dense_of_dense_diff

A dense open set U \ C has U dense in ℝ.

theorem dense_of_dense_diff {U C : Set ℝ} (hd : Dense (toReal ⁻¹' (U \ C))) : Dense U
Proof
:=
  dense_iff_inter_open.2 fun W hW ⟨x, hx⟩ ↦ by
    obtain ⟨y, hyW, hyUC⟩ := dense_iff_inter_open.1 hd _ (isOpen_preimage_toReal hW)
      ⟨toReal.symm x, by simpa using hx⟩
    exact ⟨toReal y, hyW, hyUC.1⟩

theorem baireSpace

TopologyByExample.CountableComplementExtension.baireSpace

The space is a Baire space. If Uₙ \ Cₙ are dense open sets, each Uₙ is dense in ℝ, and a nonempty open set V \ D meets ⋂ₙ Uₙ outside the countable set D ∪ ⋃ₙ Cₙ, by the Baire category theorem for ℝ.

theorem baireSpace : BaireSpace CountableComplementExtension
Proof
:= by
  refine ⟨fun f hfo hfd ↦ ?_⟩
  choose U hU C hC hf using fun n ↦ isOpen_iff.1 (hfo n)
  have hUd (n : ℕ) : Dense (U n) := dense_of_dense_diff (hf n ▸ hfd n)
  refine dense_iff_inter_open.2 fun o ho ⟨x, hx⟩ ↦ ?_
  obtain ⟨V, hV, D, hD, rfl⟩ := isOpen_iff.1 ho
  have hE : (D ∪ ⋃ n, C n).Countable := hD.union (countable_iUnion hC)
  have hG : Dense ((⋂ n, U n) ∩ (D ∪ ⋃ n, C n)ᶜ) :=
    (dense_iInter_of_isOpen hU hUd).inter_of_Gδ (IsGδ.iInter_of_isOpen hU) hE.isGδ_compl
      (hE.dense_compl ℝ)
  obtain ⟨y, hyV, hyU, hyE⟩ := hG.inter_open_nonempty V hV ⟨toReal x, hx.1⟩
  simp only [mem_compl_iff, mem_union, mem_iUnion, not_or, not_exists] at hyE
  refine ⟨toReal.symm y, by simpa using ⟨hyV, hyE.1⟩, mem_iInter.2 fun n ↦ ?_⟩
  rw [hf n]
  simpa using ⟨mem_iInter.1 hyU n, hyE.2 n⟩

On this site: The countable complement extension topology is a Baire space

Meagre sets

theorem isMeagre_of_countable_real

TopologyByExample.CountableComplementExtension.isMeagre_of_countable_real

A countable set of reals is meagre in ℝ.

theorem isMeagre_of_countable_real {C : Set ℝ} (hC : C.Countable) : IsMeagre C
Proof
:= by
  rw [← biUnion_of_singleton C]
  exact isMeagre_biUnion hC fun x _ ↦
    (isClosed_singleton.isNowhereDense_iff.2 (interior_singleton x)).isMeagre

theorem isMeagre_image_of_isNowhereDense

TopologyByExample.CountableComplementExtension.isMeagre_image_of_isNowhereDense

A nowhere dense set of the space is meagre in ℝ: the complement of its closure is a set U \ C, so the set lies in the union of the closed set ℝ \ U, which has empty interior, and the countable set C.

theorem isMeagre_image_of_isNowhereDense {t : Set CountableComplementExtension}
    (ht : IsNowhereDense t) : IsMeagre (toReal '' t)
Proof
:= by
  obtain ⟨U, hU, C, hC, hF⟩ := isOpen_iff.1 (isClosed_closure (s := t)).isOpen_compl
  have hsub : toReal ⁻¹' Uᶜ ⊆ closure t := fun x hx ↦ by
    by_contra h
    have : x ∈ (closure t)ᶜ := h
    rw [hF] at this
    exact hx this.1
  have hK : IsNowhereDense Uᶜ := by
    refine hU.isClosed_compl.isNowhereDense_iff.2 (eq_empty_of_forall_notMem fun y hy ↦ ?_)
    have hW : toReal ⁻¹' interior Uᶜ ⊆ interior (closure t) :=
      interior_maximal ((preimage_mono interior_subset).trans hsub)
        (isOpen_preimage_toReal isOpen_interior)
    rw [ht] at hW
    exact hW (show toReal.symm y ∈ toReal ⁻¹' interior Uᶜ by simpa using hy)
  refine (hK.isMeagre.union (isMeagre_of_countable_real hC)).mono ?_
  rintro _ ⟨x, hx, rfl⟩
  by_contra h
  simp only [mem_union, mem_compl_iff, not_or, not_not] at h
  have : x ∈ (closure t)ᶜ := by rw [hF]; exact ⟨h.1, h.2⟩
  exact this (subset_closure hx)

theorem isNowhereDense_preimage

TopologyByExample.CountableComplementExtension.isNowhereDense_preimage

A set that is nowhere dense in ℝ is nowhere dense in the space: the interior of the closure of its closure K would be a set U \ C inside K, so U \ K would be a countable open set of reals, hence empty, and U would lie in the interior of K.

theorem isNowhereDense_preimage {t : Set ℝ} (ht : IsNowhereDense t) :
    IsNowhereDense (toReal ⁻¹' t)
Proof
:= by
  have hK : IsClosed (toReal ⁻¹' closure t) := isClosed_closure.preimage continuous_toReal
  refine (IsNowhereDense.mono (preimage_mono subset_closure) ?_)
  rw [hK.isNowhereDense_iff]
  obtain ⟨U, hU, C, hC, hUC⟩ := isOpen_iff.1 (isOpen_interior (s := toReal ⁻¹' closure t))
  have hsub : U \ C ⊆ closure t := fun y hy ↦ by
    have : toReal.symm y ∈ interior (toReal ⁻¹' closure t) := by rw [hUC]; simpa using hy
    simpa using interior_subset this
  have hUK : U \ closure t = ∅ := eq_empty_of_isOpen_of_subset_countable
    (hU.sdiff isClosed_closure) hC fun y hy ↦ by_contra fun h ↦ hy.2 (hsub ⟨hy.1, h⟩)
  have hUe : U = ∅ := by
    have : U ⊆ interior (closure t) :=
      interior_maximal (fun y hy ↦ by_contra fun h ↦ (hUK ▸ ⟨hy, h⟩ : y ∈ (∅ : Set ℝ))) hU
    rw [ht] at this
    exact subset_empty_iff.1 this
  rw [hUC, hUe]
  simp

theorem isMeagre_iff

TopologyByExample.CountableComplementExtension.isMeagre_iff

The meagre sets of the countable complement extension topology are the sets that are meagre in ℝ.

theorem isMeagre_iff {s : Set CountableComplementExtension} :
    IsMeagre s ↔ IsMeagre (toReal '' s)
Proof
:= by
  constructor
  · intro h
    obtain ⟨S, hS, hSc, hsS⟩ := isMeagre_iff_countable_union_isNowhereDense.1 h
    refine (isMeagre_biUnion hSc fun t ht ↦ isMeagre_image_of_isNowhereDense (hS t ht)).mono ?_
    rintro _ ⟨x, hx, rfl⟩
    obtain ⟨t, htS, hxt⟩ := mem_sUnion.1 (hsS hx)
    exact mem_iUnion₂.2 ⟨t, htS, x, hxt, rfl⟩
  · intro h
    obtain ⟨S, hS, hSc, hsS⟩ := isMeagre_iff_countable_union_isNowhereDense.1 h
    refine (isMeagre_biUnion hSc fun t ht ↦ (isNowhereDense_preimage (hS t ht)).isMeagre).mono ?_
    intro x hx
    obtain ⟨t, htS, hxt⟩ := mem_sUnion.1 (hsS ⟨x, hx, rfl⟩)
    exact mem_iUnion₂.2 ⟨t, htS, hxt⟩

On this site: Countable complement extension topology: The meagre sets are the Euclidean meagre sets