Theorem: EMetric.subset_countable_closure_of_almost_dense_set
File: Mathlib/Topology/MetricSpace/EMetricSpace.lean

tactic: rcases s.eq_empty_or_nonempty with (rfl | ⟨x₀, hx₀⟩)
state_before: α : Type u
β : Type v
X : Type ?u.273536
inst✝ : PseudoEMetricSpace α
x y z : α
ε ε₁ ε₂ : ℝ≥0∞
s✝ t s : Set α
hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε
⊢ ∃ t, t ⊆ s ∧ Set.Countable t ∧ s ⊆ closure t

tactic: choose! T hTc hsT using fun n : ℕ => hs n⁻¹ (by simp)
state_before: case inr.intro
α : Type u
β : Type v
X : Type ?u.273536
inst✝ : PseudoEMetricSpace α
x y z : α
ε ε₁ ε₂ : ℝ≥0∞
s✝ t s : Set α
hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
⊢ ∃ t, t ⊆ s ∧ Set.Countable t ∧ s ⊆ closure t

tactic: choose f hfs hf using this
state_before: case inr.intro
α : Type u
β : Type v
X : Type ?u.273536
inst✝ : PseudoEMetricSpace α
x y z : α
ε ε₁ ε₂ : ℝ≥0∞
s✝ t s : Set α
hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
T : ℕ → Set α
hTc : ∀ (n : ℕ), Set.Countable (T n)
hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : x ∈ T n), closedBall x (↑n)⁻¹
this : ∀ (r : ℝ≥0∞) (x : α), ∃ y, y ∈ s ∧ closedBall x r ∩ s ⊆ closedBall y (r * 2)
⊢ ∃ t, t ⊆ s ∧ Set.Countable t ∧ 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 _, _⟩
state_before: case inr.intro
α : Type u
β : Type v
X : Type ?u.273536
inst✝ : PseudoEMetricSpace α
x y z : α
ε ε₁ ε₂ : ℝ≥0∞
s✝ t s : Set α
hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
T : ℕ → Set α
hTc : ∀ (n : ℕ), Set.Countable (T n)
hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : 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, t ⊆ s ∧ Set.Countable t ∧ s ⊆ closure t

tactic: refine' fun x hx => mem_closure_iff.2 fun ε ε0 => _
state_before: case inr.intro
α : Type u
β : Type v
X : Type ?u.273536
inst✝ : PseudoEMetricSpace α
x y z : α
ε ε₁ ε₂ : ℝ≥0∞
s✝ t s : Set α
hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
T : ℕ → Set α
hTc : ∀ (n : ℕ), Set.Countable (T n)
hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : 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: rcases ENNReal.exists_inv_nat_lt (ENNReal.half_pos ε0.lt.ne').ne' with ⟨n, hn⟩
state_before: case inr.intro
α : Type u
β : Type v
X : Type ?u.273536
inst✝ : PseudoEMetricSpace α
x✝ y z : α
ε✝ ε₁ ε₂ : ℝ≥0∞
s✝ t s : Set α
hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
T : ℕ → Set α
hTc : ∀ (n : ℕ), Set.Countable (T n)
hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : 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, (y ∈ ⋃ (n : ℕ), f (↑n)⁻¹ '' T n) ∧ edist x y < ε

tactic: rcases mem_iUnion₂.1 (hsT n hx) with ⟨y, hyn, hyx⟩
state_before: case inr.intro.intro
α : Type u
β : Type v
X : Type ?u.273536
inst✝ : PseudoEMetricSpace α
x✝ y z : α
ε✝ ε₁ ε₂ : ℝ≥0∞
s✝ t s : Set α
hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
T : ℕ → Set α
hTc : ∀ (n : ℕ), Set.Countable (T n)
hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : 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, (y ∈ ⋃ (n : ℕ), f (↑n)⁻¹ '' T n) ∧ edist x y < ε

tactic: refine' ⟨f n⁻¹ y, mem_iUnion.2 ⟨n, mem_image_of_mem _ hyn⟩, _⟩
state_before: case inr.intro.intro.intro.intro
α : Type u
β : Type v
X : Type ?u.273536
inst✝ : PseudoEMetricSpace α
x✝ y✝ z : α
ε✝ ε₁ ε₂ : ℝ≥0∞
s✝ t s : Set α
hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
T : ℕ → Set α
hTc : ∀ (n : ℕ), Set.Countable (T n)
hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : 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 : α
hyn : y ∈ T n
hyx : x ∈ closedBall y (↑n)⁻¹
⊢ ∃ y, (y ∈ ⋃ (n : ℕ), f (↑n)⁻¹ '' T n) ∧ edist x y < ε

tactic: calc
  edist x (f n⁻¹ y) ≤ (n : ℝ≥0∞)⁻¹ * 2 := hf _ _ ⟨hyx, hx⟩
  _ < ε := ENNReal.mul_lt_of_lt_div hn
state_before: case inr.intro.intro.intro.intro
α : Type u
β : Type v
X : Type ?u.273536
inst✝ : PseudoEMetricSpace α
x✝ y✝ z : α
ε✝ ε₁ ε₂ : ℝ≥0∞
s✝ t s : Set α
hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
T : ℕ → Set α
hTc : ∀ (n : ℕ), Set.Countable (T n)
hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : 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 : α
hyn : y ∈ T n
hyx : x ∈ closedBall y (↑n)⁻¹
⊢ edist x (f (↑n)⁻¹ y) < ε

tactic: exact ⟨∅, empty_subset _, countable_empty, empty_subset _⟩
state_before: case inl
α : Type u
β : Type v
X : Type ?u.273536
inst✝ : PseudoEMetricSpace α
x y z : α
ε ε₁ ε₂ : ℝ≥0∞
s t : Set α
hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ ∅ ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε
⊢ ∃ t, t ⊆ ∅ ∧ Set.Countable t ∧ ∅ ⊆ closure t

tactic: simp
state_before: α : Type u
β : Type v
X : Type ?u.273536
inst✝ : PseudoEMetricSpace α
x y z : α
ε ε₁ ε₂ : ℝ≥0∞
s✝ t s : Set α
hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
n : ℕ
⊢ (↑n)⁻¹ > 0

tactic: rcases (closedBall x r ∩ s).eq_empty_or_nonempty with (he | ⟨y, hxy, hys⟩)
state_before: α : Type u
β : Type v
X : Type ?u.273536
inst✝ : PseudoEMetricSpace α
x✝ y z : α
ε ε₁ ε₂ : ℝ≥0∞
s✝ t s : Set α
hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
T : ℕ → Set α
hTc : ∀ (n : ℕ), Set.Countable (T n)
hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : x ∈ T n), closedBall x (↑n)⁻¹
r : ℝ≥0∞
x : α
⊢ ∃ y, y ∈ s ∧ closedBall x r ∩ s ⊆ closedBall y (r * 2)

tactic: refine' ⟨x₀, hx₀, _⟩
state_before: case inl
α : Type u
β : Type v
X : Type ?u.273536
inst✝ : PseudoEMetricSpace α
x✝ y z : α
ε ε₁ ε₂ : ℝ≥0∞
s✝ t s : Set α
hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
T : ℕ → Set α
hTc : ∀ (n : ℕ), Set.Countable (T n)
hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : x ∈ T n), closedBall x (↑n)⁻¹
r : ℝ≥0∞
x : α
he : closedBall x r ∩ s = ∅
⊢ ∃ y, y ∈ s ∧ closedBall x r ∩ s ⊆ closedBall y (r * 2)

tactic: rw [he]
state_before: case inl
α : Type u
β : Type v
X : Type ?u.273536
inst✝ : PseudoEMetricSpace α
x✝ y z : α
ε ε₁ ε₂ : ℝ≥0∞
s✝ t s : Set α
hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
T : ℕ → Set α
hTc : ∀ (n : ℕ), Set.Countable (T n)
hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : x ∈ T n), closedBall x (↑n)⁻¹
r : ℝ≥0∞
x : α
he : closedBall x r ∩ s = ∅
⊢ closedBall x r ∩ s ⊆ closedBall x₀ (r * 2)

tactic: exact empty_subset _
state_before: case inl
α : Type u
β : Type v
X : Type ?u.273536
inst✝ : PseudoEMetricSpace α
x✝ y z : α
ε ε₁ ε₂ : ℝ≥0∞
s✝ t s : Set α
hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
T : ℕ → Set α
hTc : ∀ (n : ℕ), Set.Countable (T n)
hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : x ∈ T n), closedBall x (↑n)⁻¹
r : ℝ≥0∞
x : α
he : closedBall x r ∩ s = ∅
⊢ ∅ ⊆ closedBall x₀ (r * 2)

tactic: refine' ⟨y, hys, fun z hz => _⟩
state_before: case inr.intro.intro
α : Type u
β : Type v
X : Type ?u.273536
inst✝ : PseudoEMetricSpace α
x✝ y✝ z : α
ε ε₁ ε₂ : ℝ≥0∞
s✝ t s : Set α
hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
T : ℕ → Set α
hTc : ∀ (n : ℕ), Set.Countable (T n)
hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : x ∈ T n), closedBall x (↑n)⁻¹
r : ℝ≥0∞
x y : α
hxy : y ∈ closedBall x r
hys : y ∈ s
⊢ ∃ y, y ∈ s ∧ closedBall x r ∩ s ⊆ closedBall y (r * 2)

tactic: calc
  edist z y ≤ edist z x + edist y x := edist_triangle_right _ _ _
  _ ≤ r + r := (add_le_add hz.1 hxy)
  _ = r * 2 := (mul_two r).symm
state_before: case inr.intro.intro
α : Type u
β : Type v
X : Type ?u.273536
inst✝ : PseudoEMetricSpace α
x✝ y✝ z✝ : α
ε ε₁ ε₂ : ℝ≥0∞
s✝ t s : Set α
hs : ∀ (ε : ℝ≥0∞), ε > 0 → ∃ t, Set.Countable t ∧ s ⊆ ⋃ (x : α) (_ : x ∈ t), closedBall x ε
x₀ : α
hx₀ : x₀ ∈ s
T : ℕ → Set α
hTc : ∀ (n : ℕ), Set.Countable (T n)
hsT : ∀ (n : ℕ), s ⊆ ⋃ (x : α) (_ : 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)