-- Mathlib/Topology/EMetricSpace/Defs.lean
theorem subset_countable_closure_of_almost_dense_set (s : Set α)
    (hs : ∀ ε > 0, ∃ t : Set α, t.Countable ∧ s ⊆ ⋃ x ∈ t, closedBall x ε) :
    ∃ t, t ⊆ s ∧ t.Countable ∧ s ⊆ closure t

Proof state:
case inr.intro.intro
α : Type u
inst✝ : PseudoEMetricSpace α
s : Set α
hs : ∀ ε > 0, ∃ t, t.Countable ∧ s ⊆ ⋃ x ∈ t, closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
T : ℕ → Set α
hTc : ∀ (n : ℕ), (T n).Countable
hsT : ∀ (n : ℕ), s ⊆ ⋃ x ∈ T n, closedBall x (↑n)⁻¹
r : ℝ≥0∞
x y : α
hxy : y ∈ closedBall x r
hys : y ∈ s
⊢ ∃ y ∈ s, closedBall x r ∩ s ⊆ closedBall y (r * 2)

Tactic:
refine ⟨y, hys, fun z hz => ?_⟩

Result:
case inr.intro.intro
α : Type u
inst✝ : PseudoEMetricSpace α
s : Set α
hs : ∀ ε > 0, ∃ t, t.Countable ∧ s ⊆ ⋃ x ∈ t, closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
T : ℕ → Set α
hTc : ∀ (n : ℕ), (T n).Countable
hsT : ∀ (n : ℕ), s ⊆ ⋃ x ∈ T n, closedBall x (↑n)⁻¹
r : ℝ≥0∞
x y : α
hxy : y ∈ closedBall x r
hys : y ∈ s
z : α
hz : z ∈ closedBall x r ∩ s
⊢ z ∈ closedBall y (r * 2)

Proof state:
case inr.intro
α : Type u
inst✝ : PseudoEMetricSpace α
s : Set α
hs : ∀ ε > 0, ∃ t, t.Countable ∧ s ⊆ ⋃ x ∈ t, closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
T : ℕ → Set α
hTc : ∀ (n : ℕ), (T n).Countable
hsT : ∀ (n : ℕ), s ⊆ ⋃ x ∈ T n, closedBall x (↑n)⁻¹
f : ℝ≥0∞ → α → α
hfs : ∀ (r : ℝ≥0∞) (x : α), f r x ∈ s
hf : ∀ (r : ℝ≥0∞) (x : α), closedBall x r ∩ s ⊆ closedBall (f r x) (r * 2)
⊢ ∃ t ⊆ s, t.Countable ∧ s ⊆ closure t

Tactic:
refine
  ⟨⋃ n : ℕ, f n⁻¹ '' T n, iUnion_subset fun n => image_subset_iff.2 fun z _ => hfs _ _,
    countable_iUnion fun n => (hTc n).image _, ?_⟩

Result:
case inr.intro
α : Type u
inst✝ : PseudoEMetricSpace α
s : Set α
hs : ∀ ε > 0, ∃ t, t.Countable ∧ s ⊆ ⋃ x ∈ t, closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
T : ℕ → Set α
hTc : ∀ (n : ℕ), (T n).Countable
hsT : ∀ (n : ℕ), s ⊆ ⋃ x ∈ T n, closedBall x (↑n)⁻¹
f : ℝ≥0∞ → α → α
hfs : ∀ (r : ℝ≥0∞) (x : α), f r x ∈ s
hf : ∀ (r : ℝ≥0∞) (x : α), closedBall x r ∩ s ⊆ closedBall (f r x) (r * 2)
⊢ s ⊆ closure (⋃ n, f (↑n)⁻¹ '' T n)

Proof state:
case inl
α : Type u
inst✝ : PseudoEMetricSpace α
hs : ∀ ε > 0, ∃ t, t.Countable ∧ ∅ ⊆ ⋃ x ∈ t, closedBall x ε
⊢ ∃ t ⊆ ∅, t.Countable ∧ ∅ ⊆ closure t

Tactic:
exact ⟨∅, empty_subset _, countable_empty, empty_subset _⟩

Result:
no goals

Proof state:
α : Type u
inst✝ : PseudoEMetricSpace α
s : Set α
hs : ∀ ε > 0, ∃ t, t.Countable ∧ s ⊆ ⋃ x ∈ t, closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
n : ℕ
⊢ (↑n)⁻¹ > 0

Tactic:
simp

Result:
no goals

Proof state:
α : Type u
inst✝ : PseudoEMetricSpace α
s : Set α
hs : ∀ ε > 0, ∃ t, t.Countable ∧ s ⊆ ⋃ x ∈ t, closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
T : ℕ → Set α
hTc : ∀ (n : ℕ), (T n).Countable
hsT : ∀ (n : ℕ), s ⊆ ⋃ x ∈ T n, closedBall x (↑n)⁻¹
r : ℝ≥0∞
x : α
⊢ ∃ y ∈ s, closedBall x r ∩ s ⊆ closedBall y (r * 2)

Tactic:
rcases (closedBall x r ∩ s).eq_empty_or_nonempty with (he | ⟨y, hxy, hys⟩)

Result:
case inl
α : Type u
inst✝ : PseudoEMetricSpace α
s : Set α
hs : ∀ ε > 0, ∃ t, t.Countable ∧ s ⊆ ⋃ x ∈ t, closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
T : ℕ → Set α
hTc : ∀ (n : ℕ), (T n).Countable
hsT : ∀ (n : ℕ), s ⊆ ⋃ x ∈ T n, closedBall x (↑n)⁻¹
r : ℝ≥0∞
x : α
he : closedBall x r ∩ s = ∅
⊢ ∃ y ∈ s, closedBall x r ∩ s ⊆ closedBall y (r * 2)

case inr.intro.intro
α : Type u
inst✝ : PseudoEMetricSpace α
s : Set α
hs : ∀ ε > 0, ∃ t, t.Countable ∧ s ⊆ ⋃ x ∈ t, closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
T : ℕ → Set α
hTc : ∀ (n : ℕ), (T n).Countable
hsT : ∀ (n : ℕ), s ⊆ ⋃ x ∈ T n, closedBall x (↑n)⁻¹
r : ℝ≥0∞
x y : α
hxy : y ∈ closedBall x r
hys : y ∈ s
⊢ ∃ y ∈ s, closedBall x r ∩ s ⊆ closedBall y (r * 2)

Proof state:
case inr.intro
α : Type u
inst✝ : PseudoEMetricSpace α
s : Set α
hs : ∀ ε > 0, ∃ t, t.Countable ∧ s ⊆ ⋃ x ∈ t, closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
T : ℕ → Set α
hTc : ∀ (n : ℕ), (T n).Countable
hsT : ∀ (n : ℕ), s ⊆ ⋃ x ∈ T n, closedBall x (↑n)⁻¹
f : ℝ≥0∞ → α → α
hfs : ∀ (r : ℝ≥0∞) (x : α), f r x ∈ s
hf : ∀ (r : ℝ≥0∞) (x : α), closedBall x r ∩ s ⊆ closedBall (f r x) (r * 2)
x : α
hx : x ∈ s
ε : ℝ≥0∞
ε0 : ε > 0
⊢ ∃ y ∈ ⋃ n, f (↑n)⁻¹ '' T n, edist x y < ε

Tactic:
rcases ENNReal.exists_inv_nat_lt (ENNReal.half_pos ε0.lt.ne').ne' with ⟨n, hn⟩

Result:
case inr.intro.intro
α : Type u
inst✝ : PseudoEMetricSpace α
s : Set α
hs : ∀ ε > 0, ∃ t, t.Countable ∧ s ⊆ ⋃ x ∈ t, closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
T : ℕ → Set α
hTc : ∀ (n : ℕ), (T n).Countable
hsT : ∀ (n : ℕ), s ⊆ ⋃ x ∈ T n, closedBall x (↑n)⁻¹
f : ℝ≥0∞ → α → α
hfs : ∀ (r : ℝ≥0∞) (x : α), f r x ∈ s
hf : ∀ (r : ℝ≥0∞) (x : α), closedBall x r ∩ s ⊆ closedBall (f r x) (r * 2)
x : α
hx : x ∈ s
ε : ℝ≥0∞
ε0 : ε > 0
n : ℕ
hn : (↑n)⁻¹ < ε / 2
⊢ ∃ y ∈ ⋃ n, f (↑n)⁻¹ '' T n, edist x y < ε

Proof state:
case inr.intro
α : Type u
inst✝ : PseudoEMetricSpace α
s : Set α
hs : ∀ ε > 0, ∃ t, t.Countable ∧ s ⊆ ⋃ x ∈ t, closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
T : ℕ → Set α
hTc : ∀ (n : ℕ), (T n).Countable
hsT : ∀ (n : ℕ), s ⊆ ⋃ x ∈ T n, closedBall x (↑n)⁻¹
f : ℝ≥0∞ → α → α
hfs : ∀ (r : ℝ≥0∞) (x : α), f r x ∈ s
hf : ∀ (r : ℝ≥0∞) (x : α), closedBall x r ∩ s ⊆ closedBall (f r x) (r * 2)
⊢ s ⊆ closure (⋃ n, f (↑n)⁻¹ '' T n)

Tactic:
refine fun x hx => mem_closure_iff.2 fun ε ε0 => ?_

Result:
case inr.intro
α : Type u
inst✝ : PseudoEMetricSpace α
s : Set α
hs : ∀ ε > 0, ∃ t, t.Countable ∧ s ⊆ ⋃ x ∈ t, closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
T : ℕ → Set α
hTc : ∀ (n : ℕ), (T n).Countable
hsT : ∀ (n : ℕ), s ⊆ ⋃ x ∈ T n, closedBall x (↑n)⁻¹
f : ℝ≥0∞ → α → α
hfs : ∀ (r : ℝ≥0∞) (x : α), f r x ∈ s
hf : ∀ (r : ℝ≥0∞) (x : α), closedBall x r ∩ s ⊆ closedBall (f r x) (r * 2)
x : α
hx : x ∈ s
ε : ℝ≥0∞
ε0 : ε > 0
⊢ ∃ y ∈ ⋃ n, f (↑n)⁻¹ '' T n, edist x y < ε