Lean library · module TopologyByExample.Theorems.DenseCompleteGDelta

Dense completely metrizable subspaces are G-delta

Source file

This file was written by Codex (OpenAI's AI model) working under the direction of David R. MacIver, who reviews it and is responsible for it.

Imports

theorem isGδ_of_dense_of_completelyMetrizable

TopologyByExample.isGδ_of_dense_of_completelyMetrizable

A dense completely metrizable subspace of a Hausdorff space is G-delta.

theorem isGδ_of_dense_of_completelyMetrizable {X : Type*} [TopologicalSpace X] [T2Space X]
    {S : Set X} (hS : Dense S) [IsCompletelyMetrizableSpace S] : IsGδ S
Proof
:= by
  let := upgradeIsCompletelyMetrizable S
  have hU : ∀ (n : ℕ) (y : S), ∃ U : Set X, IsOpen U ∧
      ((↑) : S → X) ⁻¹' U = Metric.ball y (1 / (n + 1 : ℝ)) := by
    intro n y
    exact Topology.IsInducing.subtypeVal.isOpen_iff.mp Metric.isOpen_ball
  choose U hUopen hUeq using hU
  have he : S = ⋂ n, ⋃ y : S, U n y := by
    ext x
    constructor
    · intro hx
      apply mem_iInter.mpr
      intro n
      apply mem_iUnion.mpr
      refine ⟨⟨x, hx⟩, ?_⟩
      have hm : (⟨x, hx⟩ : S) ∈ Metric.ball ⟨x, hx⟩ (1 / (n + 1 : ℝ)) :=
        Metric.mem_ball_self (by positivity)
      rwa [← hUeq n ⟨x, hx⟩] at hm
    · intro hx
      let L : Filter S := comap ((↑) : S → X) (𝓝 x)
      have : L.NeBot := hS.comap_val_nhds_neBot x
      have hc : Cauchy L := by
        apply Metric.cauchy_iff.mpr
        refine ⟨inferInstance, ?_⟩
        intro ε hε
        obtain ⟨n, hn⟩ := exists_nat_one_div_lt (half_pos hε)
        obtain ⟨y, hy⟩ := mem_iUnion.mp (mem_iInter.mp hx n)
        refine ⟨((↑) : S → X) ⁻¹' U n y, ?_, ?_⟩
        · exact preimage_mem_comap ((hUopen n y).mem_nhds hy)
        · intro a ha b hb
          rw [hUeq n y] at ha hb
          have hab := dist_triangle a y b
          have ha' := Metric.mem_ball.mp ha
          have hb' := Metric.mem_ball.mp hb
          rw [dist_comm y b] at hab
          linarith
      obtain ⟨y, hy⟩ := cauchy_iff_exists_le_nhds.mp hc
      have he : (y : X) = x := tendsto_nhds_unique
        (continuous_subtypeVal.continuousAt.tendsto.mono_left hy) tendsto_comap
      exact he ▸ y.property
  rw [he]
  exact IsGδ.iInter_of_isOpen fun n ↦ isOpen_iUnion (hUopen n)

On this site: Theorem: Dense completely metrizable subspaces are G-delta