Lean library · module TopologyByExample.Theorems.SmallClasses

Alexandrov, almost discrete, hereditarily connected and anticompact spaces

Source file

This file introduces three small classes of spaces, uses Mathlib's fourth, and proves the implications between them and the other properties of spaces that the project needs:

It also proves that a sequentially discrete space is totally path disconnected: a continuous map from a first countable preconnected space to a sequentially discrete space is constant.

No separation axiom is assumed anywhere unless it is stated.

Main statements

Tags

Alexandrov topology, almost discrete, hereditarily connected, anticompact, sequentially discrete

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
variable {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y]

The classes

class AlmostDiscreteSpace

TopologyByExample.AlmostDiscreteSpace

A space is almost discrete if exactly one of its points is not isolated: some point p has {p} not open, and every other singleton is open. A discrete space is not almost discrete.

@[mk_iff]
class AlmostDiscreteSpace (X : Type*) [TopologicalSpace X] : Prop where
  /-- Some point is not isolated, and every other point is. -/
  exists_not_isOpen_singleton :
    ∃ p : X, ¬IsOpen ({p} : Set X) ∧ ∀ x, x ≠ p → IsOpen ({x} : Set X)

class HereditarilyConnectedSpace

TopologyByExample.HereditarilyConnectedSpace

A space is hereditarily connected if every subset of it is preconnected.

@[mk_iff]
class HereditarilyConnectedSpace (X : Type*) [TopologicalSpace X] : Prop where
  /-- Every subset is preconnected. -/
  isPreconnected : ∀ s : Set X, IsPreconnected s

class AnticompactSpace

TopologyByExample.AnticompactSpace

A space is anticompact if every compact subset of it is finite.

@[mk_iff]
class AnticompactSpace (X : Type*) [TopologicalSpace X] : Prop where
  /-- Every compact subset is finite. -/
  finite_of_isCompact : ∀ s : Set X, IsCompact s → s.Finite

Spaces with at most one point, and finite spaces

instance of_subsingleton

TopologyByExample.HereditarilyConnectedSpace.of_subsingleton

A space with at most one point is hereditarily connected: every subset has at most one point.

instance (priority := 100) HereditarilyConnectedSpace.of_subsingleton [Subsingleton X] :
    HereditarilyConnectedSpace X
Proof
:=
  ⟨fun s ↦ (subsingleton_of_subsingleton (s := s)).isPreconnected⟩

instance of_finite

TopologyByExample.AnticompactSpace.of_finite

A finite space is anticompact.

instance (priority := 100) AnticompactSpace.of_finite [Finite X] : AnticompactSpace X
Proof
:=
  ⟨fun s _ ↦ s.toFinite⟩

Hereditarily connected spaces

theorem hereditarilyConnectedSpace_iff_isChain_isOpen

TopologyByExample.hereditarilyConnectedSpace_iff_isChain_isOpen

A space is hereditarily connected if and only if its open sets form a chain under inclusion.

theorem hereditarilyConnectedSpace_iff_isChain_isOpen :
    HereditarilyConnectedSpace X ↔ IsChain (· ⊆ ·) {s : Set X | IsOpen s}
Proof
:= by
  refine ⟨fun h u hu v hv _ ↦ ?_, fun h ↦ ⟨fun s u v hu hv _ ⟨a, has, hau⟩ ⟨b, hbs, hbv⟩ ↦ ?_⟩⟩
  · by_contra huv
    simp only [not_or, not_subset] at huv
    obtain ⟨⟨x, hxu, hxv⟩, ⟨y, hyv, hyu⟩⟩ := huv
    obtain ⟨z, hz, hzu, hzv⟩ := h.isPreconnected {x, y} u v hu hv
      (insert_subset (Or.inl hxu) (singleton_subset_iff.2 (Or.inr hyv)))
      ⟨x, mem_insert x _, hxu⟩ ⟨y, mem_insert_of_mem x rfl, hyv⟩
    rcases hz with rfl | rfl
    exacts [hxv hzv, hyu hzu]
  · rcases h.total hu hv with huv | hvu
    exacts [⟨a, has, hau, huv hau⟩, ⟨b, hbs, hvu hbv, hbv⟩]
variable [HereditarilyConnectedSpace X]

theorem isChain_isOpen

TopologyByExample.HereditarilyConnectedSpace.isChain_isOpen

In a hereditarily connected space the open sets form a chain under inclusion.

theorem isChain_isOpen : IsChain (· ⊆ ·) {s : Set X | IsOpen s}
Proof
:=
  hereditarilyConnectedSpace_iff_isChain_isOpen.1 ‹_›

theorem subset_or_subset

TopologyByExample.HereditarilyConnectedSpace.subset_or_subset

Of two open sets of a hereditarily connected space, one contains the other.

theorem subset_or_subset {u v : Set X} (hu : IsOpen u) (hv : IsOpen v) : u ⊆ v ∨ v ⊆ u
Proof
:=
  isChain_isOpen.total hu hv

theorem specializes_or_specializes

TopologyByExample.HereditarilyConnectedSpace.specializes_or_specializes

In a hereditarily connected space any two points are related by specialization, one way or the other.

theorem specializes_or_specializes (x y : X) : x ⤳ y ∨ y ⤳ x
Proof
:= by
  by_contra h
  simp only [not_or, specializes_iff_forall_open, not_forall] at h
  obtain ⟨⟨u, hu, hyu, hxu⟩, ⟨v, hv, hxv, hyv⟩⟩ := h
  rcases subset_or_subset hu hv with huv | hvu
  exacts [hyv (huv hyu), hxu (hvu hxv)]

theorem joinedIn

TopologyByExample.HereditarilyConnectedSpace.joinedIn

Any two points of a hereditarily connected space lying in a set F are joined by a path in F.

theorem joinedIn {F : Set X} {x y : X} (hx : x ∈ F) (hy : y ∈ F) : JoinedIn F x y
Proof
:= by
  rcases specializes_or_specializes x y with h | h
  exacts [h.joinedIn hx hy, (h.joinedIn hy hx).symm]

instance preirreducibleSpace

TopologyByExample.HereditarilyConnectedSpace.preirreducibleSpace

A hereditarily connected space is hyperconnected: of two nonempty open sets, one contains the other, so they meet.

instance (priority := 100) preirreducibleSpace : PreirreducibleSpace X
Proof
:=
  ⟨fun u v hu hv ⟨a, _, hau⟩ ⟨b, _, hbv⟩ ↦ by
    rcases subset_or_subset hu hv with huv | hvu
    exacts [⟨a, trivial, hau, huv hau⟩, ⟨b, trivial, hvu hbv, hbv⟩]⟩

On this site: Theorem: Hereditarily connected spaces are hyperconnected

instance ultraconnectedSpace

TopologyByExample.HereditarilyConnectedSpace.ultraconnectedSpace

A hereditarily connected space is ultraconnected: of two points, one lies in the closure of the other.

instance (priority := 100) ultraconnectedSpace : UltraconnectedSpace X
Proof
:=
  ⟨fun x y ↦ by
    rcases specializes_or_specializes x y with h | h
    · exact ⟨y, specializes_iff_mem_closure.1 h, subset_closure rfl⟩
    · exact ⟨x, subset_closure rfl, specializes_iff_mem_closure.1 h⟩⟩

On this site: Theorem: Hereditarily connected spaces are ultraconnected

instance completelyNormalSpace

TopologyByExample.HereditarilyConnectedSpace.completelyNormalSpace

A hereditarily connected space is completely normal: of two separated sets one is empty, since otherwise the complements of their closures would be open sets neither of which contains the other.

instance (priority := 100) completelyNormalSpace : CompletelyNormalSpace X
Proof
:=
  ⟨fun s t hst hts ↦ by
    rcases s.eq_empty_or_nonempty with rfl | ⟨a, ha⟩
    · simp
    rcases t.eq_empty_or_nonempty with rfl | ⟨b, hb⟩
    · simp
    exfalso
    rcases subset_or_subset (isClosed_closure (s := t)).isOpen_compl
      (isClosed_closure (s := s)).isOpen_compl with h | h
    · exact h (disjoint_left.1 hts ha) (subset_closure ha)
    · exact h (disjoint_right.1 hst hb) (subset_closure hb)⟩

On this site: Theorem: Hereditarily connected spaces are completely normal

instance pathPreconnectedSpace

TopologyByExample.HereditarilyConnectedSpace.pathPreconnectedSpace

A hereditarily connected space is path connected: any two points are related by specialization, and a specialization gives a path.

instance (priority := 100) pathPreconnectedSpace : PathPreconnectedSpace X
Proof
:=
  ⟨fun _ _ ↦ (joinedIn (F := univ) (mem_univ _) (mem_univ _)).joined⟩

instance locallyPathConnectedSpace

TopologyByExample.HereditarilyConnectedSpace.locallyPathConnectedSpace

A hereditarily connected space is locally path connected: any two points of an open set are joined by a path inside it.

instance (priority := 100) locallyPathConnectedSpace : LocallyPathConnectedSpace X
Proof
:=
  .of_bases (fun x ↦ (𝓝 x).basis_sets) fun x _ hU ↦
    ⟨x, mem_of_mem_nhds hU, fun _ hy ↦ joinedIn (mem_of_mem_nhds hU) hy⟩

On this site: Theorem: Hereditarily connected spaces are locally path connected

Almost discrete spaces

theorem isOpen_of_forall_ne_isOpen_singleton

TopologyByExample.isOpen_of_forall_ne_isOpen_singleton

In a space in which every point other than p is isolated, every set not containing p is open.

theorem isOpen_of_forall_ne_isOpen_singleton {p : X} (h : ∀ x, x ≠ p → IsOpen ({x} : Set X))
    {s : Set X} (hs : p ∉ s) : IsOpen s
Proof
:= by
  rw [← biUnion_of_singleton s]
  exact isOpen_biUnion fun x hx ↦ h x fun hxp ↦ hs (hxp ▸ hx)

theorem completelyNormalSpace_of_forall_ne_isOpen_singleton

TopologyByExample.completelyNormalSpace_of_forall_ne_isOpen_singleton

A space in which every point other than p is isolated is completely normal: of two separated sets, one does not contain p, so is open, and the other lies in the complement of its closure.

theorem completelyNormalSpace_of_forall_ne_isOpen_singleton (p : X)
    (h : ∀ x, x ≠ p → IsOpen ({x} : Set X)) : CompletelyNormalSpace X
Proof
:=
  ⟨fun s t hst hts ↦ by
    by_cases hpt : p ∈ t
    · have hps : p ∉ s := fun hps ↦ disjoint_left.1 hts hps (subset_closure hpt)
      rw [(isOpen_of_forall_ne_isOpen_singleton h hps).nhdsSet_eq]
      exact disjoint_principal_nhdsSet.2 hst
    · rw [(isOpen_of_forall_ne_isOpen_singleton h hpt).nhdsSet_eq]
      exact disjoint_nhdsSet_principal.2 hts⟩
variable [AlmostDiscreteSpace X]

instance scatteredSpace

TopologyByExample.AlmostDiscreteSpace.scatteredSpace

An almost discrete space is scattered.

instance (priority := 100) scatteredSpace : ScatteredSpace X
Proof
:=
  let ⟨p, _, h⟩ := exists_not_isOpen_singleton (X := X)
  scatteredSpace_of_forall_ne_isOpen_singleton p h

On this site: Theorem: Almost discrete spaces are scattered

instance completelyNormalSpace

TopologyByExample.AlmostDiscreteSpace.completelyNormalSpace

An almost discrete space is completely normal.

instance (priority := 100) completelyNormalSpace : CompletelyNormalSpace X
Proof
:=
  let ⟨p, _, h⟩ := exists_not_isOpen_singleton (X := X)
  completelyNormalSpace_of_forall_ne_isOpen_singleton p h

On this site: Theorem: Almost discrete spaces are completely normal

theorem countable

TopologyByExample.AlmostDiscreteSpace.countable

An almost discrete space satisfying the countable chain condition is countable: the isolated points form a family of pairwise disjoint nonempty open sets.

theorem countable
    (hccc : ∀ S : Set (Set X), (∀ s ∈ S, IsOpen s ∧ s.Nonempty) → S.PairwiseDisjoint id →
      S.Countable) : Countable X
Proof
:= by
  obtain ⟨p, -, h⟩ := exists_not_isOpen_singleton (X := X)
  have hS := hccc ((fun x ↦ ({x} : Set X)) '' {p}ᶜ)
    (by rintro _ ⟨x, hx, rfl⟩; exact ⟨h x hx, singleton_nonempty x⟩)
    (by
      rintro _ ⟨x, -, rfl⟩ _ ⟨y, -, rfl⟩ hxy
      exact disjoint_singleton.2 fun h ↦ hxy (h ▸ rfl))
  rw [← countable_univ_iff, ← compl_union_self {p}]
  exact (countable_of_injective_of_countable_image singleton_injective.injOn hS).union
    (countable_singleton p)

On this site: Theorem: Almost discrete spaces satisfying the countable chain condition are countable

theorem nonempty

TopologyByExample.AlmostDiscreteSpace.nonempty

An almost discrete space is nonempty.

theorem nonempty : Nonempty X
Proof
:=
  let ⟨p, _⟩ := exists_not_isOpen_singleton (X := X)
  ⟨p⟩

theorem nontrivial

TopologyByExample.AlmostDiscreteSpace.nontrivial

An almost discrete space has at least two points: in a space with one point, that point is isolated.

theorem nontrivial : Nontrivial X
Proof
:= by
  obtain ⟨p, hp, -⟩ := exists_not_isOpen_singleton (X := X)
  by_contra h
  rw [not_nontrivial_iff_subsingleton] at h
  exact hp (by rw [Subsingleton.eq_univ_of_nonempty (singleton_nonempty p)]; exact isOpen_univ)

theorem not_discreteTopology

TopologyByExample.AlmostDiscreteSpace.not_discreteTopology

An almost discrete space is not discrete.

theorem not_discreteTopology : ¬DiscreteTopology X
Proof
:= fun _ ↦
  let ⟨_, hp, _⟩ := exists_not_isOpen_singleton (X := X)
  hp (isOpen_discrete _)
macro (name := nonemptyOfLiteral) "nonempty_of_literal " h:term : tactic =>
  `(tactic| first
    | (have := $h; exact TopologyByExample.AlmostDiscreteSpace.nonempty)
    | exact by_contra fun hc ↦ $h (by rw [not_nonempty_iff] at hc; subsingleton_space))
macro (name := nontrivialOfLiteral) "nontrivial_of_literal " h:term : tactic =>
  `(tactic| first
    | (have := $h; exact TopologyByExample.AlmostDiscreteSpace.nontrivial)
    | refine by_contra fun hc ↦ $h ?_
      rw [not_nontrivial_iff_subsingleton] at hc
      subsingleton_space)

Sequentially discrete spaces

theorem isLocallyConstant

TopologyByExample.SequentiallyDiscreteSpace.isLocallyConstant

A continuous map from a first countable space to a sequentially discrete space is locally constant: a sequence converging to a point is sent to a sequence converging to its image, which is eventually equal to it.

theorem isLocallyConstant [FirstCountableTopology Y] [SequentiallyDiscreteSpace X] {f : Y → X}
    (hf : Continuous f) : IsLocallyConstant f
Proof
:=
  (IsLocallyConstant.iff_eventually_eq f).2 fun y ↦ eventually_iff_seq_eventually.2 fun u hu ↦
    eventually_eq_of_tendsto (f ∘ u) (f y) ((hf.tendsto y).comp hu)

instance totallyPathDisconnectedSpace

TopologyByExample.SequentiallyDiscreteSpace.totallyPathDisconnectedSpace

A sequentially discrete space is totally path disconnected: a path is locally constant, and the unit interval is connected.

instance (priority := 100) totallyPathDisconnectedSpace [SequentiallyDiscreteSpace X] :
    TotallyPathDisconnectedSpace X
Proof
:=
  ⟨fun x y hxy ↦ by
    let γ := hxy.somePath
    simpa using (isLocallyConstant γ.continuous).apply_eq_of_preconnectedSpace 0 1⟩

On this site: Theorem: Sequentially discrete spaces are totally path disconnected

Anticompact spaces

variable [AnticompactSpace X]

theorem sequentiallyDiscreteSpace

TopologyByExample.AnticompactSpace.sequentiallyDiscreteSpace

An anticompact T₁ space is sequentially discrete: a convergent sequence together with its limit is compact, so finite, and the finitely many values other than the limit form a closed set missing it.

theorem sequentiallyDiscreteSpace [T1Space X] : SequentiallyDiscreteSpace X
Proof
:=
  ⟨fun u x hu ↦ by
    have hfin : (range u \ {x}).Finite :=
      ((finite_of_isCompact _ hu.isCompact_insert_range).subset
        (subset_insert x (range u))).sdiff
    filter_upwards [hu (hfin.isClosed.isOpen_compl.mem_nhds fun h ↦ h.2 rfl)] with n hn
    by_contra hne
    exact hn ⟨mem_range_self n, hne⟩⟩

On this site: Theorem: Anticompact T₁ spaces are sequentially discrete

instance totallyPathDisconnectedSpace

TopologyByExample.AnticompactSpace.totallyPathDisconnectedSpace

An anticompact T₁ space is totally path disconnected.

instance (priority := 100) totallyPathDisconnectedSpace [T1Space X] :
    TotallyPathDisconnectedSpace X
Proof
:=
  have := sequentiallyDiscreteSpace (X := X)
  inferInstance

theorem finite

TopologyByExample.AnticompactSpace.finite

An anticompact compact space is finite.

theorem finite [CompactSpace X] : Finite X
Proof
:=
  finite_univ_iff.1 (finite_of_isCompact univ isCompact_univ)

On this site: Theorem: Anticompact compact spaces are finite

theorem countable

TopologyByExample.AnticompactSpace.countable

An anticompact σ-compact space is countable: it is a countable union of compact, hence finite, sets.

theorem countable [SigmaCompactSpace X] : Countable X
Proof
:= by
  rw [← countable_univ_iff, ← iUnion_compactCovering]
  exact countable_iUnion fun n ↦ (finite_of_isCompact _ (isCompact_compactCovering X n)).countable

On this site: Theorem: Anticompact σ-compact spaces are countable

Invariance under homeomorphism

theorem alexandrovDiscrete_iff

TopologyByExample.Homeomorph.alexandrovDiscrete_iff

Being Alexandrov is invariant under homeomorphism.

theorem alexandrovDiscrete_iff (e : X ≃ₜ Y) : AlexandrovDiscrete X ↔ AlexandrovDiscrete Y
Proof
:=
  ⟨fun _ ↦ e.symm.isInducing.alexandrovDiscrete, fun _ ↦ e.isInducing.alexandrovDiscrete⟩

theorem almostDiscreteSpace_of

TopologyByExample.Homeomorph.almostDiscreteSpace_of

private theorem almostDiscreteSpace_of (e : X ≃ₜ Y) [AlmostDiscreteSpace X] :
    AlmostDiscreteSpace Y
Proof
:= by
  obtain ⟨p, hp, h⟩ := AlmostDiscreteSpace.exists_not_isOpen_singleton (X := X)
  refine ⟨⟨e p, fun hep ↦ hp ?_, fun y hy ↦ ?_⟩⟩
  · rwa [← e.isOpen_image, image_singleton]
  · have := h (e.symm y) fun h ↦ hy (by rw [← h, e.apply_symm_apply])
    rwa [← e.isOpen_image, image_singleton, e.apply_symm_apply] at this

theorem almostDiscreteSpace_iff

TopologyByExample.Homeomorph.almostDiscreteSpace_iff

Being almost discrete is invariant under homeomorphism.

theorem almostDiscreteSpace_iff (e : X ≃ₜ Y) : AlmostDiscreteSpace X ↔ AlmostDiscreteSpace Y
Proof
:=
  ⟨fun _ ↦ almostDiscreteSpace_of e, fun _ ↦ almostDiscreteSpace_of e.symm⟩

theorem hereditarilyConnectedSpace_of

TopologyByExample.Homeomorph.hereditarilyConnectedSpace_of

private theorem hereditarilyConnectedSpace_of (e : X ≃ₜ Y) [HereditarilyConnectedSpace X] :
    HereditarilyConnectedSpace Y
Proof
:=
  ⟨fun s ↦ e.image_preimage s ▸
    (HereditarilyConnectedSpace.isPreconnected _).image e e.continuous.continuousOn⟩

theorem hereditarilyConnectedSpace_iff

TopologyByExample.Homeomorph.hereditarilyConnectedSpace_iff

Being hereditarily connected is invariant under homeomorphism.

theorem hereditarilyConnectedSpace_iff (e : X ≃ₜ Y) :
    HereditarilyConnectedSpace X ↔ HereditarilyConnectedSpace Y
Proof
:=
  ⟨fun _ ↦ hereditarilyConnectedSpace_of e, fun _ ↦ hereditarilyConnectedSpace_of e.symm⟩

theorem anticompactSpace_of

TopologyByExample.Homeomorph.anticompactSpace_of

private theorem anticompactSpace_of (e : X ≃ₜ Y) [AnticompactSpace X] : AnticompactSpace Y
Proof
:=
  ⟨fun _ hs ↦ (AnticompactSpace.finite_of_isCompact _ (e.isCompact_preimage.2 hs)).of_preimage
    e.surjective⟩

theorem anticompactSpace_iff

TopologyByExample.Homeomorph.anticompactSpace_iff

Being anticompact is invariant under homeomorphism.

theorem anticompactSpace_iff (e : X ≃ₜ Y) : AnticompactSpace X ↔ AnticompactSpace Y
Proof
:=
  ⟨fun _ ↦ anticompactSpace_of e, fun _ ↦ anticompactSpace_of e.symm⟩

Almost discrete spaces

theorem isCompletelyMetrizableSpace_of_almostDiscreteSpace

TopologyByExample.isCompletelyMetrizableSpace_of_almostDiscreteSpace

A first countable almost discrete T₁ space is completely metrizable: it is a closed subspace of a countable product of discrete spaces.

theorem isCompletelyMetrizableSpace_of_almostDiscreteSpace [T1Space X] [FirstCountableTopology X]
    [AlmostDiscreteSpace X] : IsCompletelyMetrizableSpace X
Proof
:= by
  classical
  obtain ⟨p, -, hiso⟩ := AlmostDiscreteSpace.exists_not_isOpen_singleton (X := X)
  obtain ⟨V, hV⟩ := (𝓝 p).exists_antitone_basis
  have hpV : ∀ k, p ∈ V k := fun k ↦ mem_of_mem_nhds (hV.mem k)
  -- Every point other than `p` lies outside some `V k`.
  have hout : ∀ y, y ≠ p → ∃ k, y ∉ V k := fun y hy ↦ by
    obtain ⟨k, -, hk⟩ := hV.toHasBasis.mem_iff.1 (isOpen_compl_singleton.mem_nhds hy.symm)
    exact ⟨k, fun hyk ↦ hk hyk rfl⟩
  let _ : TopologicalSpace (Option X) := ⊥
  have : DiscreteTopology (Option X) := ⟨rfl⟩
  let g : X → ℕ → Option X := fun y k ↦ if y ∈ V k then none else some y
  have hgp : g p = fun _ ↦ none := funext fun k ↦ by simp [g, hpV k]
  have hg_some : ∀ y z k, g y k = some z → y = z ∧ y ∉ V k := fun y z k h ↦ by
    by_cases hy : y ∈ V k
    · simp [g, hy] at h
    · simp only [g, hy] at h
      exact ⟨Option.some_injective _ h, hy⟩
  have hg_none : ∀ y k, g y k = none ↔ y ∈ V k := fun y k ↦ by
    by_cases hy : y ∈ V k <;> simp [g, hy]
  have hcont : Continuous g := by
    refine continuous_pi fun k ↦ continuous_iff_continuousAt.2 fun y ↦ ?_
    by_cases hy : y = p
    · rw [hy]
      refine tendsto_const_nhds.congr' ?_
      filter_upwards [hV.mem k] with z hz
      rw [(hg_none p k).2 (hpV k), (hg_none z k).2 hz]
    · rw [ContinuousAt, (isOpen_singleton_iff_nhds_eq_pure y).1 (hiso y hy)]
      exact tendsto_pure_nhds _ _
  have hinj : Function.Injective g := by
    have key : ∀ y z, y ≠ p → g y = g z → y = z := fun y z hy h ↦ by
      obtain ⟨k, hk⟩ := hout y hy
      have hyk : g y k = some y := by simp [g, hk]
      exact ((hg_some z y k (h ▸ hyk)).1).symm
    intro y z h
    by_cases hy : y = p
    · by_cases hz : z = p
      · rw [hy, hz]
      · exact (key z y hz h.symm).symm
    · exact key y z hy h
  have hclosed : IsClosedMap g := by
    intro C hC
    refine isOpen_compl_iff.1 (isOpen_iff_mem_nhds.2 fun w hw ↦ ?_)
    by_cases hw' : ∃ k y, w k = some y
    · obtain ⟨k, y, hk⟩ := hw'
      have h₀ : ({some y} : Set (Option X)) ∈ 𝓝 (w k) :=
        hk ▸ (isOpen_discrete {some y}).mem_nhds rfl
      have h₁ : {w' : ℕ → Option X | w' k = some y} ∈ 𝓝 w :=
        (continuous_apply k).continuousAt.preimage_mem_nhds h₀
      by_cases hyC : y ∈ C
      · have h₂ : w ≠ g y := fun hwy ↦ hw ⟨y, hyC, hwy.symm⟩
        filter_upwards [h₁, isOpen_compl_singleton.mem_nhds h₂] with w' hw'k hw'y
        rintro ⟨c, -, rfl⟩
        obtain ⟨rfl, -⟩ := hg_some c y k hw'k
        exact hw'y rfl
      · filter_upwards [h₁] with w' hw'k
        rintro ⟨c, hc, rfl⟩
        obtain ⟨rfl, -⟩ := hg_some c y k hw'k
        exact hyC hc
    · push Not at hw'
      have hwp : w = g p := by
        rw [hgp]
        funext k
        exact Option.eq_none_iff_forall_ne_some.2 (hw' k)
      have hpC : p ∉ C := fun hp ↦ hw ⟨p, hp, hwp.symm⟩
      obtain ⟨k, -, hk⟩ := hV.toHasBasis.mem_iff.1 (hC.isOpen_compl.mem_nhds hpC)
      have h₀ : ({none} : Set (Option X)) ∈ 𝓝 (w k) := by
        rw [hwp, hgp]
        exact (isOpen_discrete {none}).mem_nhds rfl
      have h₁ : {w' : ℕ → Option X | w' k = none} ∈ 𝓝 w :=
        (continuous_apply k).continuousAt.preimage_mem_nhds h₀
      filter_upwards [h₁] with w' hw'k
      rintro ⟨c, hc, rfl⟩
      exact hk ((hg_none c k).1 hw'k) hc
  exact (Topology.IsClosedEmbedding.of_continuous_injective_isClosedMap hcont hinj
    hclosed).IsCompletelyMetrizableSpace

On this site: Theorem: First countable almost discrete T₁ spaces are completely metrizable

theorem extremallyDisconnected_of_almostDiscreteSpace_of_not_semiregularSpace

TopologyByExample.extremallyDisconnected_of_almostDiscreteSpace_of_not_semiregularSpace

An almost discrete space that is not semiregular is extremally disconnected. No separation axiom is assumed; a T₁ almost discrete space is always semiregular.

theorem extremallyDisconnected_of_almostDiscreteSpace_of_not_semiregularSpace
    [AlmostDiscreteSpace X] (h : ¬SemiregularSpace X) : ExtremallyDisconnected X
Proof
:= by
  obtain ⟨p, -, hiso⟩ := AlmostDiscreteSpace.exists_not_isOpen_singleton (X := X)
  -- A set is open as soon as it is a neighbourhood of `p` when it contains `p`.
  have hopen : ∀ s : Set X, (p ∈ s → s ∈ 𝓝 p) → IsOpen s := fun s hs ↦
    isOpen_iff_mem_nhds.2 fun y hy ↦ by
      by_cases hyp : y = p
      · rw [hyp] at hy ⊢
        exact hs hy
      · exact mem_of_superset ((hiso y hyp).mem_nhds rfl) (singleton_subset_iff.2 hy)
  -- Taking the closure of a set adds at most the point `p`.
  have hcl : ∀ s : Set X, closure s ⊆ insert p s := fun s y hy ↦ by
    by_cases hyp : y = p
    · exact .inl hyp
    · obtain ⟨z, hzy, hzs⟩ := mem_closure_iff.1 hy {y} (hiso y hyp) rfl
      rw [mem_singleton_iff.1 hzy] at hzs
      exact .inr hzs
  refine ⟨fun U hU ↦ ?_⟩
  by_contra hcU
  refine h ⟨isTopologicalBasis_of_isOpen_of_nhds (fun s hs ↦ ?_) fun a u hau hu ↦ ?_⟩
  · rw [← show interior (closure s) = s from hs]
    exact isOpen_interior
  by_cases hap : a = p
  · -- An open set containing `p` is closed, hence regular open.
    refine ⟨u, ?_, hau, subset_rfl⟩
    have hclu : closure u = u :=
      (subset_antisymm (fun y hy ↦ (hcl u hy).elim (fun hyp ↦ hyp ▸ hap ▸ hau) id)
        subset_closure)
    change interior (closure u) = u
    rw [hclu, hu.interior_eq]
  · -- The singleton of an isolated point is regular open, or else `closure U` would be open.
    refine ⟨{a}, ?_, rfl, singleton_subset_iff.2 hau⟩
    change interior (closure {a}) = {a}
    refine subset_antisymm (fun y hy ↦ ?_) (interior_maximal subset_closure (hiso a hap))
    rcases hcl {a} (interior_subset hy) with hyp | hya
    · exfalso
      refine hcU (hopen _ fun hpU ↦ ?_)
      have hW : interior (closure {a}) ∈ 𝓝 p := isOpen_interior.mem_nhds (hyp ▸ hy)
      obtain ⟨z, hzW, hzU⟩ := mem_closure_iff_nhds.1 hpU _ hW
      rcases hcl {a} (interior_subset hzW) with hzp | hza
      · exact mem_of_superset (hU.mem_nhds (hzp ▸ hzU)) subset_closure
      · refine mem_of_superset hW fun w hw ↦ ?_
        rcases hcl {a} (interior_subset hw) with hwp | hwa
        · exact hwp ▸ hpU
        · rw [mem_singleton_iff.1 hwa, ← mem_singleton_iff.1 hza]
          exact subset_closure hzU
    · exact hya

On this site: Theorem: Almost discrete spaces that are not semiregular are extremally disconnected

Hyperconnected spaces

theorem hereditarilyConnectedSpace_of_preirreducibleSpace_of_completelyNormalSpace

TopologyByExample.hereditarilyConnectedSpace_of_preirreducibleSpace_of_completelyNormalSpace

A completely normal hyperconnected space is hereditarily connected: two separated nonempty sets would have disjoint nonempty open neighbourhoods.

theorem hereditarilyConnectedSpace_of_preirreducibleSpace_of_completelyNormalSpace
    [PreirreducibleSpace X] [CompletelyNormalSpace X] : HereditarilyConnectedSpace X
Proof
:= by
  refine ⟨fun s u v hu hv _ hsu hsv ↦ ?_⟩
  by_contra hne
  have h₁ : Disjoint (closure (s ∩ u)) (s ∩ v) := by
    refine Set.disjoint_left.2 fun y hyc ⟨_, hyv⟩ ↦ ?_
    obtain ⟨z, hzv, hzs, hzu⟩ := mem_closure_iff.1 hyc v hv hyv
    exact hne ⟨z, hzs, hzu, hzv⟩
  have h₂ : Disjoint (s ∩ u) (closure (s ∩ v)) := by
    refine Set.disjoint_right.2 fun y hyc ⟨_, hyu⟩ ↦ ?_
    obtain ⟨z, hzu, hzs, hzv⟩ := mem_closure_iff.1 hyc u hu hyu
    exact hne ⟨z, hzs, hzu, hzv⟩
  obtain ⟨U, V, hU, hV, hAU, hBV, hUV⟩ :=
    separatedNhds_iff_disjoint.2 (CompletelyNormalSpace.completely_normal h₁ h₂)
  obtain ⟨y, hy⟩ := hsu
  obtain ⟨z, hz⟩ := hsv
  obtain ⟨w, -, hwU, hwV⟩ := PreirreducibleSpace.isPreirreducible_univ U V hU hV
    ⟨y, trivial, hAU hy⟩ ⟨z, trivial, hBV hz⟩
  exact Set.disjoint_left.1 hUV hwU hwV

On this site: Theorem: Completely normal hyperconnected spaces are hereditarily connected