Lean library · module TopologyByExample.Theorems.CollapseQuotient

Collapsing a closed set to a point

Source file

For a subset A of a space X, the quotient X / A identifies all points of A with each other and nothing else. We show that collapsing a closed set preserves the T₁ property, normality, perfect normality and paracompactness (for paracompact normal spaces), and the Baire property when A has empty interior; and that collapsing a closed subset of a metrizable space that contains an infinite closed discrete set of non-interior points gives a space that is not first countable.

Main definitions

  • TopologyByExample.collapseSetoid A: the equivalence relation identifying the points of A.
  • TopologyByExample.Collapse A: the quotient space X / A.
  • TopologyByExample.Collapse.mk A: the quotient map.

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

definition collapseSetoid

TopologyByExample.collapseSetoid

The equivalence relation on X identifying all points of A with each other, and nothing else.

def collapseSetoid (A : Set X) : Setoid X
Definition
where
  r x y := x = y ∨ (x ∈ A ∧ y ∈ A)
  iseqv :=
    { refl := fun _ ↦ Or.inl rfl
      symm := fun h ↦ h.elim (fun h ↦ Or.inl h.symm) fun h ↦ Or.inr ⟨h.2, h.1⟩
      trans := by
        rintro x y z (rfl | ⟨hx, hy⟩) (rfl | ⟨hy', hz⟩)
        · exact Or.inl rfl
        · exact Or.inr ⟨hy', hz⟩
        · exact Or.inr ⟨hx, hy⟩
        · exact Or.inr ⟨hx, hz⟩ }

definition Collapse

TopologyByExample.Collapse

The space X / A obtained from X by collapsing A to a point, with the quotient topology.

abbrev Collapse (A : Set X) : Type u
:= Quotient (collapseSetoid A)
variable {A : Set X}

definition mk

TopologyByExample.Collapse.mk

The quotient map X → X / A.

def mk (A : Set X) : X → Collapse A
:= Quotient.mk (collapseSetoid A)
omit [TopologicalSpace X] in

theorem mk_eq_mk_iff

TopologyByExample.Collapse.mk_eq_mk_iff

theorem mk_eq_mk_iff {x y : X} : mk A x = mk A y ↔ x = y ∨ (x ∈ A ∧ y ∈ A)
Proof
:=
  Quotient.eq (r := collapseSetoid A)
omit [TopologicalSpace X] in

theorem mk_eq_mk_of_mem

TopologyByExample.Collapse.mk_eq_mk_of_mem

theorem mk_eq_mk_of_mem {x y : X} (hx : x ∈ A) (hy : y ∈ A) : mk A x = mk A y
Proof
:=
  mk_eq_mk_iff.2 (Or.inr ⟨hx, hy⟩)
omit [TopologicalSpace X] in

theorem eq_of_mk_eq_mk_of_notMem

TopologyByExample.Collapse.eq_of_mk_eq_mk_of_notMem

theorem eq_of_mk_eq_mk_of_notMem {x y : X} (h : mk A x = mk A y) (hx : x ∉ A) : x = y
Proof
:=
  (mk_eq_mk_iff.1 h).resolve_right fun h ↦ hx h.1
omit [TopologicalSpace X] in

theorem mem_of_mk_eq_mk_of_mem

TopologyByExample.Collapse.mem_of_mk_eq_mk_of_mem

theorem mem_of_mk_eq_mk_of_mem {x y : X} (h : mk A x = mk A y) (hy : y ∈ A) : x ∈ A
Proof
:= by
  rcases mk_eq_mk_iff.1 h with rfl | h
  · exact hy
  · exact h.1
omit [TopologicalSpace X] in

theorem surjective_mk

TopologyByExample.Collapse.surjective_mk

theorem surjective_mk : Function.Surjective (mk A)
Proof
:= Quotient.mk_surjective

theorem isQuotientMap_mk

TopologyByExample.Collapse.isQuotientMap_mk

theorem isQuotientMap_mk : IsQuotientMap (mk A)
Proof
:= isQuotientMap_quotient_mk'

theorem continuous_mk

TopologyByExample.Collapse.continuous_mk

@[continuity, fun_prop]
theorem continuous_mk : Continuous (mk A)
Proof
:= continuous_quotient_mk'
omit [TopologicalSpace X] in

theorem preimage_image_mk

TopologyByExample.Collapse.preimage_image_mk

A set is saturated if, whenever it meets A, it contains A; then it is the preimage of its image.

theorem preimage_image_mk {s : Set X} (hs : ∀ x ∈ s, x ∈ A → A ⊆ s) :
    mk A ⁻¹' (mk A '' s) = s
Proof
:= by
  ext y
  refine ⟨?_, fun hy ↦ ⟨y, hy, rfl⟩⟩
  rintro ⟨x, hx, hxy⟩
  rcases mk_eq_mk_iff.1 hxy with rfl | ⟨hxA, hyA⟩
  · exact hx
  · exact hs x hx hxA hyA
omit [TopologicalSpace X] in

theorem preimage_image_mk_of_disjoint

TopologyByExample.Collapse.preimage_image_mk_of_disjoint

theorem preimage_image_mk_of_disjoint {s : Set X} (hs : Disjoint s A) :
    mk A ⁻¹' (mk A '' s) = s
Proof
:=
  preimage_image_mk fun _ hx hxA ↦ absurd hxA (hs.notMem_of_mem_left hx)
omit [TopologicalSpace X] in

theorem preimage_image_mk_of_subset

TopologyByExample.Collapse.preimage_image_mk_of_subset

theorem preimage_image_mk_of_subset {s : Set X} (hs : A ⊆ s) : mk A ⁻¹' (mk A '' s) = s
Proof
:=
  preimage_image_mk fun _ _ _ ↦ hs

theorem isOpen_image_mk

TopologyByExample.Collapse.isOpen_image_mk

The image of a saturated open set is open.

theorem isOpen_image_mk {s : Set X} (ho : IsOpen s) (hs : ∀ x ∈ s, x ∈ A → A ⊆ s) :
    IsOpen (mk A '' s)
Proof
:= by
  rw [← isQuotientMap_mk.isOpen_preimage, preimage_image_mk hs]
  exact ho
omit [TopologicalSpace X] in

theorem saturated_preimage

TopologyByExample.Collapse.saturated_preimage

A preimage is saturated.

theorem saturated_preimage (t : Set (Collapse A)) :
    ∀ x ∈ mk A ⁻¹' t, x ∈ A → A ⊆ mk A ⁻¹' t
Proof
:= fun x hx hxA _ hy ↦ by
  rw [mem_preimage, mk_eq_mk_of_mem hy hxA]
  exact hx

theorem isClosed_diff_preimage

TopologyByExample.Collapse.isClosed_diff_preimage

For a preimage F of a set, A \ F is either empty or A; in particular it is closed when A is.

theorem isClosed_diff_preimage (hA : IsClosed A) (t : Set (Collapse A)) :
    IsClosed (A \ mk A ⁻¹' t)
Proof
:= by
  by_cases h : ∃ a ∈ A, a ∈ mk A ⁻¹' t
  · obtain ⟨a, ha, hat⟩ := h
    rw [sdiff_eq_empty.2 (saturated_preimage t a hat ha)]
    exact isClosed_empty
  · push Not at h
    rw [sdiff_eq_left.2 (disjoint_left.2 fun x hx hxt ↦ h x hx hxt)]
    exact hA

theorem saturate_open

TopologyByExample.Collapse.saturate_open

Shrinking an open set W ⊇ F, where F is a preimage, to an open saturated set that still contains F.

theorem saturate_open (hA : IsClosed A) (t : Set (Collapse A)) {W : Set X} (hW : IsOpen W)
    (hFW : mk A ⁻¹' t ⊆ W) :
    IsOpen (W \ (A \ mk A ⁻¹' t)) ∧ (∀ x ∈ W \ (A \ mk A ⁻¹' t), x ∈ A → A ⊆ W \ (A \ mk A ⁻¹' t))
      ∧ mk A ⁻¹' t ⊆ W \ (A \ mk A ⁻¹' t)
Proof
:= by
  refine ⟨hW.sdiff (isClosed_diff_preimage hA t), ?_, fun x hx ↦ ⟨hFW hx, fun h ↦ h.2 hx⟩⟩
  rintro x ⟨-, hx⟩ hxA y hy
  have hxt : x ∈ mk A ⁻¹' t := by
    by_contra hxt
    exact hx ⟨hxA, hxt⟩
  have hyt := saturated_preimage t x hxt hxA hy
  exact ⟨hFW hyt, fun h ↦ h.2 hyt⟩

theorem isClosedMap_mk

TopologyByExample.Collapse.isClosedMap_mk

For closed A, the quotient map X → X / A is closed.

theorem isClosedMap_mk (hA : IsClosed A) : IsClosedMap (mk A)
Proof
:= by
  intro F hF
  rw [← isQuotientMap_mk.isClosed_preimage]
  by_cases h : (F ∩ A).Nonempty
  · obtain ⟨a, haF, haA⟩ := h
    have : mk A ⁻¹' (mk A '' F) = F ∪ A := by
      ext y
      refine ⟨?_, ?_⟩
      · rintro ⟨x, hx, hxy⟩
        rcases mk_eq_mk_iff.1 hxy with rfl | ⟨_, hy⟩
        · exact Or.inl hx
        · exact Or.inr hy
      · rintro (hy | hy)
        · exact ⟨y, hy, rfl⟩
        · exact ⟨a, haF, mk_eq_mk_of_mem haA hy⟩
    rw [this]
    exact hF.union hA
  · rw [preimage_image_mk_of_disjoint (disjoint_iff_inter_eq_empty.2
      (not_nonempty_iff_eq_empty.1 h))]
    exact hF

theorem t1Space

TopologyByExample.Collapse.t1Space

Collapsing a closed subset of a T₁ space gives a T₁ space.

theorem t1Space [T1Space X] (hA : IsClosed A) : T1Space (Collapse A)
Proof
:= by
  refine ⟨fun q ↦ ?_⟩
  obtain ⟨x, rfl⟩ := surjective_mk q
  rw [← image_singleton]
  exact isClosedMap_mk hA _ isClosed_singleton

theorem normalSpace

TopologyByExample.Collapse.normalSpace

Collapsing a closed subset of a normal space gives a normal space.

theorem normalSpace [NormalSpace X] (hA : IsClosed A) : NormalSpace (Collapse A)
Proof
:= by
  refine ⟨fun F G hF hG hFG ↦ ?_⟩
  have hF' : IsClosed (mk A ⁻¹' F) := hF.preimage continuous_mk
  have hG' : IsClosed (mk A ⁻¹' G) := hG.preimage continuous_mk
  obtain ⟨U, V, hU, hV, hFU, hGV, hUV⟩ := normal_separation hF' hG' (hFG.preimage _)
  obtain ⟨hU', hUs, hFU'⟩ := saturate_open hA F hU hFU
  obtain ⟨hV', hVs, hGV'⟩ := saturate_open hA G hV hGV
  refine ⟨_, _, isOpen_image_mk hU' hUs, isOpen_image_mk hV' hVs, ?_, ?_, ?_⟩
  · intro q hq
    obtain ⟨x, rfl⟩ := surjective_mk q
    exact ⟨x, hFU' hq, rfl⟩
  · intro q hq
    obtain ⟨x, rfl⟩ := surjective_mk q
    exact ⟨x, hGV' hq, rfl⟩
  · rw [disjoint_iff_inter_eq_empty, eq_empty_iff_forall_notMem]
    rintro q ⟨hqU, hqV⟩
    obtain ⟨x, rfl⟩ := surjective_mk q
    have hxU : x ∈ U \ (A \ mk A ⁻¹' F) := by
      rw [← preimage_image_mk hUs]
      exact hqU
    have hxV : x ∈ V \ (A \ mk A ⁻¹' G) := by
      rw [← preimage_image_mk hVs]
      exact hqV
    exact hUV.notMem_of_mem_left hxU.1 hxV.1

theorem perfectlyNormalSpace

TopologyByExample.Collapse.perfectlyNormalSpace

Collapsing a closed subset of a perfectly normal space gives a perfectly normal space.

theorem perfectlyNormalSpace [PerfectlyNormalSpace X] (hA : IsClosed A) :
    PerfectlyNormalSpace (Collapse A)
Proof
:= by
  have := normalSpace hA
  refine ⟨fun F hF ↦ ?_⟩
  have hF' : IsClosed (mk A ⁻¹' F) := hF.preimage continuous_mk
  obtain ⟨W, hWo, hWeq⟩ := (PerfectlyNormalSpace.closed_gdelta hF').eq_iInter_nat
  have hFW : ∀ n, mk A ⁻¹' F ⊆ W n := fun n ↦ hWeq ▸ iInter_subset _ n
  have key := fun n ↦ saturate_open hA F (hWo n) (hFW n)
  have : F = ⋂ n, mk A '' (W n \ (A \ mk A ⁻¹' F)) := by
    ext q
    obtain ⟨x, rfl⟩ := surjective_mk q
    simp only [mem_iInter]
    refine ⟨fun hx n ↦ ⟨x, (key n).2.2 hx, rfl⟩, fun h ↦ ?_⟩
    have hx : ∀ n, x ∈ W n := fun n ↦ by
      have := h n
      rw [← mem_preimage, preimage_image_mk (key n).2.1] at this
      exact this.1
    have : x ∈ mk A ⁻¹' F := by
      rw [hWeq]
      exact mem_iInter.2 hx
    exact this
  rw [this]
  exact IsGδ.iInter_of_isOpen fun n ↦ isOpen_image_mk (key n).1 (key n).2.1

theorem paracompactSpace

TopologyByExample.Collapse.paracompactSpace

Collapsing a closed subset of a paracompact normal space gives a paracompact space.

theorem paracompactSpace [ParacompactSpace X] [NormalSpace X] (hA : IsClosed A) :
    ParacompactSpace (Collapse A)
Proof
:= by
  classical
  refine ⟨fun α s hso hsu ↦ ?_⟩
  have hso' : ∀ a, IsOpen (mk A ⁻¹' s a) := fun a ↦ (hso a).preimage continuous_mk
  have hsu' : ⋃ a, mk A ⁻¹' s a = univ := by rw [← preimage_iUnion, hsu, preimage_univ]
  obtain ⟨t, hto, htu, htlf, hts⟩ := precise_refinement _ hso' hsu'
  rcases A.eq_empty_or_nonempty with rfl | ⟨a, ha⟩
  · have hsat : ∀ (u : Set X), ∀ x ∈ u, x ∈ (∅ : Set X) → (∅ : Set X) ⊆ u :=
      fun _ _ _ h ↦ absurd h (notMem_empty _)
    refine ⟨α, fun b ↦ mk ∅ '' t b, fun b ↦ isOpen_image_mk (hto b) (hsat _), ?_, ?_,
      fun b ↦ ⟨b, by rw [image_subset_iff]; exact hts b⟩⟩
    · rw [← image_iUnion, htu, image_univ_of_surjective surjective_mk]
    · intro q
      obtain ⟨x, rfl⟩ := surjective_mk q
      obtain ⟨N, hN, hNf⟩ := htlf x
      obtain ⟨V, hVN, hVo, hxV⟩ := mem_nhds_iff.1 hN
      refine ⟨mk ∅ '' V, (isOpen_image_mk hVo (hsat _)).mem_nhds ⟨x, hxV, rfl⟩, hNf.subset ?_⟩
      rintro b ⟨_, ⟨y, hy, rfl⟩, ⟨z, hz, hzy⟩⟩
      obtain rfl := eq_of_mk_eq_mk_of_notMem hzy (notMem_empty z)
      exact ⟨z, hy, hVN hz⟩
  · obtain ⟨a₀, ha₀⟩ := mem_iUnion.1 (hsu ▸ mem_univ (mk A a))
    have hAs : A ⊆ mk A ⁻¹' s a₀ := fun y hy ↦ by
      rw [mem_preimage, mk_eq_mk_of_mem hy ha]
      exact ha₀
    obtain ⟨O, hOo, hAO, hOc⟩ := normal_exists_closure_subset hA (hso' a₀) hAs
    have hdisj : ∀ b, Disjoint (t b \ closure O) A := fun b ↦
      disjoint_left.2 fun x hx hxA ↦ hx.2 (subset_closure (hAO hxA))
    let u : α → Set (Collapse A) :=
      Function.update (fun b ↦ mk A '' (t b \ closure O)) a₀ (s a₀)
    have hu : ∀ b, b ≠ a₀ → u b = mk A '' (t b \ closure O) := fun b hb ↦ by simp [u, hb]
    have hua : u a₀ = s a₀ := by simp [u]
    refine ⟨α, u, fun b ↦ ?_, ?_, ?_, fun b ↦ ⟨b, ?_⟩⟩
    · by_cases hb : b = a₀
      · rw [hb, hua]
        exact hso a₀
      · rw [hu b hb]
        exact isOpen_image_mk ((hto b).sdiff isClosed_closure)
          fun x hx hxA ↦ absurd hxA ((hdisj b).notMem_of_mem_left hx)
    · refine eq_univ_of_forall fun q ↦ ?_
      obtain ⟨x, rfl⟩ := surjective_mk q
      rw [mem_iUnion]
      by_cases hx : x ∈ closure O
      · exact ⟨a₀, hua ▸ hOc hx⟩
      · obtain ⟨b, hb⟩ := mem_iUnion.1 (htu ▸ mem_univ x)
        by_cases hba : b = a₀
        · subst hba
          exact ⟨b, hua ▸ hts b hb⟩
        · exact ⟨b, (hu b hba).symm ▸ ⟨x, ⟨hb, hx⟩, rfl⟩⟩
    · intro q
      obtain ⟨x, rfl⟩ := surjective_mk q
      by_cases hxA : x ∈ A
      · refine ⟨mk A '' O, (isOpen_image_mk hOo fun _ _ _ ↦ hAO).mem_nhds ⟨x, hAO hxA, rfl⟩,
          (finite_singleton a₀).subset ?_⟩
        rintro b ⟨_, hbu, ⟨y, hyO, rfl⟩⟩
        by_contra hb
        rw [hu b hb] at hbu
        obtain ⟨z, hz, hzy⟩ := hbu
        have hzA : z ∉ A := (hdisj b).notMem_of_mem_left hz
        obtain rfl := eq_of_mk_eq_mk_of_notMem hzy hzA
        exact hz.2 (subset_closure hyO)
      · obtain ⟨N, hN, hNf⟩ := htlf x
        obtain ⟨V, hVN, hVo, hxV⟩ := mem_nhds_iff.1 hN
        have hVA : Disjoint (V \ A) A := disjoint_sdiff_left
        refine ⟨mk A '' (V \ A), (isOpen_image_mk (hVo.sdiff hA)
          fun y hy hyA ↦ absurd hyA (hVA.notMem_of_mem_left hy)).mem_nhds ⟨x, ⟨hxV, hxA⟩, rfl⟩,
          (hNf.insert a₀).subset ?_⟩
        rintro b ⟨_, hbu, ⟨y, hyV, rfl⟩⟩
        by_cases hb : b = a₀
        · exact Or.inl hb
        · right
          rw [hu b hb] at hbu
          obtain ⟨z, hz, hzy⟩ := hbu
          obtain rfl := eq_of_mk_eq_mk_of_notMem hzy ((hdisj b).notMem_of_mem_left hz)
          exact ⟨z, hz.1, hVN hyV.1⟩
    · by_cases hb : b = a₀
      · rw [hb, hua]
      · rw [hu b hb, image_subset_iff]
        exact sdiff_subset.trans (hts b)

theorem baireSpace

TopologyByExample.Collapse.baireSpace

Collapsing a closed subset with empty interior of a Baire space gives a Baire space.

theorem baireSpace [BaireSpace X] (hA : IsClosed A) (hAi : interior A = ∅) :
    BaireSpace (Collapse A)
Proof
:= by
  refine ⟨fun G hGo hGd ↦ ?_⟩
  have hd : ∀ n, Dense (mk A ⁻¹' G n) := fun n ↦ by
    rw [dense_iff_inter_open]
    rintro V hVo ⟨x, hxV⟩
    have hVA : (V \ A).Nonempty := by
      by_contra h
      rw [not_nonempty_iff_eq_empty, sdiff_eq_empty] at h
      have := interior_maximal h hVo hxV
      rw [hAi] at this
      exact this
    have hVsat : ∀ y ∈ V \ A, y ∈ A → A ⊆ V \ A := fun y hy hyA ↦ absurd hyA hy.2
    obtain ⟨q, hqV, hqG⟩ := (hGd n).inter_open_nonempty _ (isOpen_image_mk (hVo.sdiff hA) hVsat)
      (hVA.image _)
    obtain ⟨y, hy, rfl⟩ := hqV
    exact ⟨y, hy.1, hqG⟩
  have := dense_iInter_of_isOpen_nat (fun n ↦ (hGo n).preimage continuous_mk) hd
  refine (surjective_mk.denseRange.dense_image continuous_mk this).mono ?_
  rintro _ ⟨x, hx, rfl⟩
  exact mem_iInter.2 fun n ↦ mem_iInter.1 hx n

On this site: Theorem: Collapsing a closed set with empty interior in a Baire space gives a Baire space

theorem metrizable_collapse

TopologyByExample.Collapse.metrizable_collapse

Collapsing a closed subset of a metrizable space. If X is metrizable and A ⊆ X is closed, then X / A is T₁, perfectly normal and paracompact.

theorem metrizable_collapse [MetrizableSpace X] (hA : IsClosed A) :
    T1Space (Collapse A) ∧ PerfectlyNormalSpace (Collapse A) ∧ ParacompactSpace (Collapse A)
Proof
:= by
  let _ := TopologicalSpace.metrizableSpaceMetric X
  exact ⟨t1Space hA, perfectlyNormalSpace hA, paracompactSpace hA⟩

On this site: Theorem: Collapsing a closed subset of a metrizable space gives a T₁, perfectly normal, paracompact space

theorem not_firstCountableTopology

TopologyByExample.Collapse.not_firstCountableTopology

The collapsed point has no countable neighbourhood base. If X is metrizable, A ⊆ X is closed, and A contains an infinite set D, closed and discrete in X, none of whose points is interior to A, then X / A is not first countable.

theorem not_firstCountableTopology [MetrizableSpace X] (hA : IsClosed A) {D : Set X}
    (hDA : D ⊆ A) (hD : D.Infinite) (hDc : IsClosed D) (hDd : IsDiscrete D)
    (hDi : Disjoint D (interior A)) : ¬FirstCountableTopology (Collapse A)
Proof
:= by
  let _ := TopologicalSpace.metrizableSpaceMetric X
  intro hfc
  obtain ⟨a, haD⟩ := hD.nonempty
  set p := mk A a
  obtain ⟨W, hW⟩ := (𝓝 p).exists_antitone_basis
  let e := hD.natEmbedding
  have he : ∀ n, (e n : X) ∈ A := fun n ↦ hDA (e n).property
  have hpe : ∀ n, mk A (e n) = p := fun n ↦ mk_eq_mk_of_mem (he n) (hDA haD)
  -- choose `x n` near `e n`, in the preimage of `W n`, outside `A`
  have hx : ∀ n : ℕ, ∃ x, x ∈ mk A ⁻¹' W n ∧ dist x (e n) < 1 / (n + 1) ∧ x ∉ A := by
    intro n
    have hN : mk A ⁻¹' W n ∩ Metric.ball (e n : X) (1 / (n + 1)) ∈ 𝓝 (e n : X) := by
      refine inter_mem (continuous_mk.continuousAt.preimage_mem_nhds ?_)
        (Metric.ball_mem_nhds _ (by positivity))
      rw [hpe n]
      exact hW.mem n
    by_contra h
    push Not at h
    have hsub : mk A ⁻¹' W n ∩ Metric.ball (e n : X) (1 / (n + 1)) ⊆ A :=
      fun x hx' ↦ h x hx'.1 hx'.2
    exact hDi.notMem_of_mem_left (e n).property
      (interior_mono hsub (mem_interior_iff_mem_nhds.2 hN))
  choose x hxW hxd hxA using hx
  -- the points `x n` form a closed set
  have hlf : LocallyFinite fun n ↦ ({x n} : Set X) := by
    intro y
    have : ∃ r > 0, ∀ z ∈ D, dist z y < r → z = y := by
      by_cases hy : y ∈ D
      · have : IsOpen ({(⟨y, hy⟩ : D)} : Set D) := by
          have := hDd.to_subtype
          exact isOpen_discrete _
        obtain ⟨U, hUo, hU⟩ := isOpen_induced_iff.1 this
        have hyU : y ∈ U := by
          have : (⟨y, hy⟩ : D) ∈ ((↑) : D → X) ⁻¹' U := by rw [hU]; rfl
          exact this
        obtain ⟨r, hr, hrU⟩ := Metric.isOpen_iff.1 hUo y hyU
        refine ⟨r, hr, fun z hz hzr ↦ ?_⟩
        have : (⟨z, hz⟩ : D) ∈ ((↑) : D → X) ⁻¹' U := hrU hzr
        rw [hU] at this
        exact congrArg Subtype.val this
      · obtain ⟨r, hr, hrD⟩ := Metric.isOpen_iff.1 hDc.isOpen_compl y hy
        exact ⟨r, hr, fun z hz hzr ↦ absurd hz (hrD hzr)⟩
    obtain ⟨r, hr, hrD⟩ := this
    obtain ⟨N, hN⟩ := exists_nat_one_div_lt (half_pos hr)
    refine ⟨Metric.ball y (r / 2), Metric.ball_mem_nhds _ (half_pos hr), ?_⟩
    have hsub : {n | (e n : X) = y}.Subsingleton := fun n hn m hm ↦
      e.injective (Subtype.ext (hn.trans hm.symm))
    refine ((finite_lt_nat N).union hsub.finite).subset ?_
    rintro n ⟨_, rfl, hxn⟩
    by_cases hnN : n < N
    · exact Or.inl hnN
    · right
      have hNn : (N : ℝ) ≤ n := by exact_mod_cast not_lt.1 hnN
      have h1 : 1 / ((n : ℝ) + 1) ≤ 1 / ((N : ℝ) + 1) :=
        one_div_le_one_div_of_le (by positivity) (by linarith)
      refine hrD _ (e n).property ?_
      calc dist (e n : X) y ≤ dist (e n : X) (x n) + dist (x n) y := dist_triangle _ _ _
        _ < r / 2 + r / 2 := by
          refine add_lt_add ?_ (Metric.mem_ball.1 hxn)
          rw [dist_comm]
          exact (hxd n).trans_le (h1.trans hN.le)
        _ = r := add_halves r
  have hF : IsClosed (⋃ n, ({x n} : Set X)) := hlf.isClosed_iUnion fun _ ↦ isClosed_singleton
  have hFA : Disjoint (⋃ n, ({x n} : Set X)) A := by
    refine disjoint_left.2 fun z hz hzA ↦ ?_
    obtain ⟨n, hn⟩ := mem_iUnion.1 hz
    rw [mem_singleton_iff] at hn
    exact hxA n (hn ▸ hzA)
  have hp : (mk A '' ⋃ n, ({x n} : Set X))ᶜ ∈ 𝓝 p := by
    refine (isClosedMap_mk hA _ hF).isOpen_compl.mem_nhds ?_
    rintro ⟨z, hz, hzp⟩
    exact hFA.notMem_of_mem_left hz (mem_of_mk_eq_mk_of_mem hzp (hDA haD))
  obtain ⟨n, -, hn⟩ := hW.toHasBasis.mem_iff.1 hp
  exact hn (hxW n) ⟨x n, mem_iUnion.2 ⟨n, rfl⟩, rfl⟩

On this site: Theorem: Collapsing a set containing an infinite closed discrete set of non-interior points destroys first countability