Theorem: exists_nat_nat_continuous_surjective_of_completeSpace
File: Mathlib/Topology/MetricSpace/PiNat.lean

tactic: letI : MetricSpace (ℕ → ℕ) := PiNat.metricSpaceNatNat
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
⊢ ∃ f, Continuous f ∧ Surjective f

tactic: have I0 : (0 : ℝ) < 1 / 2 := by norm_num
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
⊢ ∃ f, Continuous f ∧ Surjective f

tactic: have I1 : (1 / 2 : ℝ) < 1 := by norm_num
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
⊢ ∃ f, Continuous f ∧ Surjective f

tactic: rcases exists_dense_seq α with ⟨u, hu⟩
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
⊢ ∃ f, Continuous f ∧ Surjective f

tactic: let s : Set (ℕ → ℕ) := { x | (⋂ n : ℕ, closedBall (u (x n)) ((1 / 2) ^ n)).Nonempty }
state_before: case intro
E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
⊢ ∃ f, Continuous f ∧ Surjective f

tactic: let g : s → α := fun x => x.2.some
state_before: case intro
E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
⊢ ∃ f, Continuous f ∧ Surjective f

tactic: have A : ∀ (x : s) (n : ℕ), dist (g x) (u ((x : ℕ → ℕ) n)) ≤ (1 / 2) ^ n := fun x n =>
  (mem_iInter.1 x.2.some_mem n : _)
state_before: case intro
E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
⊢ ∃ f, Continuous f ∧ Surjective f

tactic: have g_surj : Surjective g := fun y ↦ by
  have : ∀ n : ℕ, ∃ j, y ∈ closedBall (u j) ((1 / 2) ^ n) := fun n ↦ by
    rcases hu.exists_dist_lt y (by simp : (0 : ℝ) < (1 / 2) ^ n) with ⟨j, hj⟩
    exact ⟨j, hj.le⟩
  choose x hx using this
  have I : (⋂ n : ℕ, closedBall (u (x n)) ((1 / 2) ^ n)).Nonempty := ⟨y, mem_iInter.2 hx⟩
  refine' ⟨⟨x, I⟩, _⟩
  refine' dist_le_zero.1 _
  have J : ∀ n : ℕ, dist (g ⟨x, I⟩) y ≤ (1 / 2) ^ n + (1 / 2) ^ n := fun n =>
    calc
      dist (g ⟨x, I⟩) y ≤ dist (g ⟨x, I⟩) (u (x n)) + dist y (u (x n)) :=
        dist_triangle_right _ _ _
      _ ≤ (1 / 2) ^ n + (1 / 2) ^ n := add_le_add (A ⟨x, I⟩ n) (hx n)
  have L : Tendsto (fun n : ℕ => (1 / 2 : ℝ) ^ n + (1 / 2) ^ n) atTop (𝓝 (0 + 0)) :=
    (tendsto_pow_atTop_nhds_0_of_lt_1 I0.le I1).add (tendsto_pow_atTop_nhds_0_of_lt_1 I0.le I1)
  rw [add_zero] at L
  exact ge_of_tendsto' L J
state_before: case intro
E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
⊢ ∃ f, Continuous f ∧ Surjective f

tactic: have s_closed : IsClosed s := by
  refine isClosed_iff_clusterPt.mpr fun x hx ↦ ?_
  have L : Tendsto (fun n : ℕ => diam (closedBall (u (x n)) ((1 / 2) ^ n))) atTop (𝓝 0) := by
    have : Tendsto (fun n : ℕ => (2 : ℝ) * (1 / 2) ^ n) atTop (𝓝 (2 * 0)) :=
      (tendsto_pow_atTop_nhds_0_of_lt_1 I0.le I1).const_mul _
    rw [MulZeroClass.mul_zero] at this
    exact
      squeeze_zero (fun n => diam_nonneg) (fun n => diam_closedBall (pow_nonneg I0.le _)) this
  refine nonempty_iInter_of_nonempty_biInter (fun n => isClosed_ball)
    (fun n => bounded_closedBall) (fun N ↦ ?_) L
  obtain ⟨y, hxy, ys⟩ : ∃ y, y ∈ ball x ((1 / 2) ^ N) ∩ s :=
    clusterPt_principal_iff.1 hx _ (ball_mem_nhds x (pow_pos I0 N))
  have E :
    (⋂ (n : ℕ) (H : n ≤ N), closedBall (u (x n)) ((1 / 2) ^ n)) =
      ⋂ (n : ℕ) (H : n ≤ N), closedBall (u (y n)) ((1 / 2) ^ n) := by
    refine iInter_congr fun n ↦ iInter_congr fun hn ↦ ?_
    have : x n = y n := apply_eq_of_dist_lt (mem_ball'.1 hxy) hn
    rw [this]
  rw [E]
  apply Nonempty.mono _ ys
  apply iInter_subset_iInter₂
state_before: case intro
E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
g_surj : Surjective g
⊢ ∃ f, Continuous f ∧ Surjective f

tactic: obtain ⟨f, -, f_surj, f_cont⟩ :
  ∃ f : (ℕ → ℕ) → s, (∀ x : s, f x = x) ∧ Surjective f ∧ Continuous f := by
  apply exists_retraction_subtype_of_isClosed s_closed
  simpa only [nonempty_coe_sort] using g_surj.nonempty
state_before: case intro
E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
g_surj : Surjective g
s_closed : IsClosed s
⊢ ∃ f, Continuous f ∧ Surjective f

tactic: exact ⟨g ∘ f, g_cont.comp f_cont, g_surj.comp f_surj⟩
state_before: case intro.intro.intro.intro
E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
g_surj : Surjective g
s_closed : IsClosed s
f : (ℕ → ℕ) → ↑s
f_surj : Surjective f
f_cont : Continuous f
⊢ ∃ f, Continuous f ∧ Surjective f

tactic: norm_num
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
⊢ 0 < 1 / 2

tactic: norm_num
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
⊢ 1 / 2 < 1

tactic: refine continuous_iff_continuousAt.2 fun y => ?_
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
⊢ Continuous g

tactic: refine continuousAt_of_locally_lipschitz zero_lt_one 4 fun x hxy => ?_
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
y : ↑s
⊢ ContinuousAt g y

tactic: rcases eq_or_ne x y with (rfl | hne)
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
y x : ↑s
hxy : dist x y < 1
⊢ dist (g x) (g y) ≤ 4 * dist x y

tactic: have hne' : x.1 ≠ y.1 := Subtype.coe_injective.ne hne
state_before: case inr
E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
y x : ↑s
hxy : dist x y < 1
hne : x ≠ y
⊢ dist (g x) (g y) ≤ 4 * dist x y

tactic: have dist' : dist x y = dist x.1 y.1 := rfl
state_before: case inr
E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
y x : ↑s
hxy : dist x y < 1
hne : x ≠ y
hne' : ↑x ≠ ↑y
⊢ dist (g x) (g y) ≤ 4 * dist x y

tactic: let n := firstDiff x.1 y.1 - 1
state_before: case inr
E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
y x : ↑s
hxy : dist x y < 1
hne : x ≠ y
hne' : ↑x ≠ ↑y
dist' : dist x y = dist ↑x ↑y
⊢ dist (g x) (g y) ≤ 4 * dist x y

tactic: have diff_pos : 0 < firstDiff x.1 y.1 := by
  by_contra' h
  apply apply_firstDiff_ne hne'
  rw [le_zero_iff.1 h]
  apply apply_eq_of_dist_lt _ le_rfl
  rw [pow_zero]
  exact hxy
state_before: case inr
E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
y x : ↑s
hxy : dist x y < 1
hne : x ≠ y
hne' : ↑x ≠ ↑y
dist' : dist x y = dist ↑x ↑y
n : ℕ := firstDiff ↑x ↑y - 1
⊢ dist (g x) (g y) ≤ 4 * dist x y

tactic: have hn : firstDiff x.1 y.1 = n + 1 := (Nat.succ_pred_eq_of_pos diff_pos).symm
state_before: case inr
E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
y x : ↑s
hxy : dist x y < 1
hne : x ≠ y
hne' : ↑x ≠ ↑y
dist' : dist x y = dist ↑x ↑y
n : ℕ := firstDiff ↑x ↑y - 1
diff_pos : 0 < firstDiff ↑x ↑y
⊢ dist (g x) (g y) ≤ 4 * dist x y

tactic: rw [dist', dist_eq_of_ne hne', hn]
state_before: case inr
E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
y x : ↑s
hxy : dist x y < 1
hne : x ≠ y
hne' : ↑x ≠ ↑y
dist' : dist x y = dist ↑x ↑y
n : ℕ := firstDiff ↑x ↑y - 1
diff_pos : 0 < firstDiff ↑x ↑y
hn : firstDiff ↑x ↑y = n + 1
⊢ dist (g x) (g y) ≤ 4 * dist x y

tactic: have B : x.1 n = y.1 n := mem_cylinder_firstDiff x.1 y.1 n (Nat.pred_lt diff_pos.ne')
state_before: case inr
E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
y x : ↑s
hxy : dist x y < 1
hne : x ≠ y
hne' : ↑x ≠ ↑y
dist' : dist x y = dist ↑x ↑y
n : ℕ := firstDiff ↑x ↑y - 1
diff_pos : 0 < firstDiff ↑x ↑y
hn : firstDiff ↑x ↑y = n + 1
⊢ dist (g x) (g y) ≤ 4 * (1 / 2) ^ (n + 1)

tactic: calc
  dist (g x) (g y) ≤ dist (g x) (u (x.1 n)) + dist (g y) (u (x.1 n)) :=
    dist_triangle_right _ _ _
  _ = dist (g x) (u (x.1 n)) + dist (g y) (u (y.1 n)) := by rw [← B]
  _ ≤ (1 / 2) ^ n + (1 / 2) ^ n := (add_le_add (A x n) (A y n))
  _ = 4 * (1 / 2) ^ (n + 1) := by ring
state_before: case inr
E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
y x : ↑s
hxy : dist x y < 1
hne : x ≠ y
hne' : ↑x ≠ ↑y
dist' : dist x y = dist ↑x ↑y
n : ℕ := firstDiff ↑x ↑y - 1
diff_pos : 0 < firstDiff ↑x ↑y
hn : firstDiff ↑x ↑y = n + 1
B : ↑x n = ↑y n
⊢ dist (g x) (g y) ≤ 4 * (1 / 2) ^ (n + 1)

tactic: simp
state_before: case inl
E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
x : ↑s
hxy : dist x x < 1
⊢ dist (g x) (g x) ≤ 4 * dist x x

tactic: by_contra' h
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
y x : ↑s
hxy : dist x y < 1
hne : x ≠ y
hne' : ↑x ≠ ↑y
dist' : dist x y = dist ↑x ↑y
n : ℕ := firstDiff ↑x ↑y - 1
⊢ 0 < firstDiff ↑x ↑y

tactic: apply apply_firstDiff_ne hne'
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
y x : ↑s
hxy : dist x y < 1
hne : x ≠ y
hne' : ↑x ≠ ↑y
dist' : dist x y = dist ↑x ↑y
n : ℕ := firstDiff ↑x ↑y - 1
h : firstDiff ↑x ↑y ≤ 0
⊢ False

tactic: rw [le_zero_iff.1 h]
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
y x : ↑s
hxy : dist x y < 1
hne : x ≠ y
hne' : ↑x ≠ ↑y
dist' : dist x y = dist ↑x ↑y
n : ℕ := firstDiff ↑x ↑y - 1
h : firstDiff ↑x ↑y ≤ 0
⊢ ↑x (firstDiff ↑x ↑y) = ↑y (firstDiff ↑x ↑y)

tactic: apply apply_eq_of_dist_lt _ le_rfl
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
y x : ↑s
hxy : dist x y < 1
hne : x ≠ y
hne' : ↑x ≠ ↑y
dist' : dist x y = dist ↑x ↑y
n : ℕ := firstDiff ↑x ↑y - 1
h : firstDiff ↑x ↑y ≤ 0
⊢ ↑x 0 = ↑y 0

tactic: rw [pow_zero]
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
y x : ↑s
hxy : dist x y < 1
hne : x ≠ y
hne' : ↑x ≠ ↑y
dist' : dist x y = dist ↑x ↑y
n : ℕ := firstDiff ↑x ↑y - 1
h : firstDiff ↑x ↑y ≤ 0
⊢ dist ↑x ↑y < (1 / 2) ^ 0

tactic: exact hxy
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
y x : ↑s
hxy : dist x y < 1
hne : x ≠ y
hne' : ↑x ≠ ↑y
dist' : dist x y = dist ↑x ↑y
n : ℕ := firstDiff ↑x ↑y - 1
h : firstDiff ↑x ↑y ≤ 0
⊢ dist ↑x ↑y < 1

tactic: rw [← B]
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
y x : ↑s
hxy : dist x y < 1
hne : x ≠ y
hne' : ↑x ≠ ↑y
dist' : dist x y = dist ↑x ↑y
n : ℕ := firstDiff ↑x ↑y - 1
diff_pos : 0 < firstDiff ↑x ↑y
hn : firstDiff ↑x ↑y = n + 1
B : ↑x n = ↑y n
⊢ dist (g x) (u (↑x n)) + dist (g y) (u (↑x n)) = dist (g x) (u (↑x n)) + dist (g y) (u (↑y n))

tactic: ring
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
y x : ↑s
hxy : dist x y < 1
hne : x ≠ y
hne' : ↑x ≠ ↑y
dist' : dist x y = dist ↑x ↑y
n : ℕ := firstDiff ↑x ↑y - 1
diff_pos : 0 < firstDiff ↑x ↑y
hn : firstDiff ↑x ↑y = n + 1
B : ↑x n = ↑y n
⊢ (1 / 2) ^ n + (1 / 2) ^ n = 4 * (1 / 2) ^ (n + 1)

tactic: have : ∀ n : ℕ, ∃ j, y ∈ closedBall (u j) ((1 / 2) ^ n) := fun n ↦ by
  rcases hu.exists_dist_lt y (by simp : (0 : ℝ) < (1 / 2) ^ n) with ⟨j, hj⟩
  exact ⟨j, hj.le⟩
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
y : α
⊢ ∃ a, g a = y

tactic: choose x hx using this
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this✝ : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
y : α
this : ∀ (n : ℕ), ∃ j, y ∈ closedBall (u j) ((1 / 2) ^ n)
⊢ ∃ a, g a = y

tactic: have I : (⋂ n : ℕ, closedBall (u (x n)) ((1 / 2) ^ n)).Nonempty := ⟨y, mem_iInter.2 hx⟩
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
y : α
x : ℕ → ℕ
hx : ∀ (n : ℕ), y ∈ closedBall (u (x n)) ((1 / 2) ^ n)
⊢ ∃ a, g a = y

tactic: refine' ⟨⟨x, I⟩, _⟩
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
y : α
x : ℕ → ℕ
hx : ∀ (n : ℕ), y ∈ closedBall (u (x n)) ((1 / 2) ^ n)
I : Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))
⊢ ∃ a, g a = y

tactic: refine' dist_le_zero.1 _
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
y : α
x : ℕ → ℕ
hx : ∀ (n : ℕ), y ∈ closedBall (u (x n)) ((1 / 2) ^ n)
I : Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))
⊢ g { val := x, property := I } = y

tactic: have J : ∀ n : ℕ, dist (g ⟨x, I⟩) y ≤ (1 / 2) ^ n + (1 / 2) ^ n := fun n =>
  calc
    dist (g ⟨x, I⟩) y ≤ dist (g ⟨x, I⟩) (u (x n)) + dist y (u (x n)) :=
      dist_triangle_right _ _ _
    _ ≤ (1 / 2) ^ n + (1 / 2) ^ n := add_le_add (A ⟨x, I⟩ n) (hx n)
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
y : α
x : ℕ → ℕ
hx : ∀ (n : ℕ), y ∈ closedBall (u (x n)) ((1 / 2) ^ n)
I : Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))
⊢ dist (g { val := x, property := I }) y ≤ 0

tactic: have L : Tendsto (fun n : ℕ => (1 / 2 : ℝ) ^ n + (1 / 2) ^ n) atTop (𝓝 (0 + 0)) :=
  (tendsto_pow_atTop_nhds_0_of_lt_1 I0.le I1).add (tendsto_pow_atTop_nhds_0_of_lt_1 I0.le I1)
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
y : α
x : ℕ → ℕ
hx : ∀ (n : ℕ), y ∈ closedBall (u (x n)) ((1 / 2) ^ n)
I : Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))
J : ∀ (n : ℕ), dist (g { val := x, property := I }) y ≤ (1 / 2) ^ n + (1 / 2) ^ n
⊢ dist (g { val := x, property := I }) y ≤ 0

tactic: rw [add_zero] at L
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
y : α
x : ℕ → ℕ
hx : ∀ (n : ℕ), y ∈ closedBall (u (x n)) ((1 / 2) ^ n)
I : Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))
J : ∀ (n : ℕ), dist (g { val := x, property := I }) y ≤ (1 / 2) ^ n + (1 / 2) ^ n
L : Tendsto (fun n => (1 / 2) ^ n + (1 / 2) ^ n) atTop (𝓝 (0 + 0))
⊢ dist (g { val := x, property := I }) y ≤ 0

tactic: exact ge_of_tendsto' L J
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
y : α
x : ℕ → ℕ
hx : ∀ (n : ℕ), y ∈ closedBall (u (x n)) ((1 / 2) ^ n)
I : Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))
J : ∀ (n : ℕ), dist (g { val := x, property := I }) y ≤ (1 / 2) ^ n + (1 / 2) ^ n
L : Tendsto (fun n => (1 / 2) ^ n + (1 / 2) ^ n) atTop (𝓝 0)
⊢ dist (g { val := x, property := I }) y ≤ 0

tactic: rcases hu.exists_dist_lt y (by simp : (0 : ℝ) < (1 / 2) ^ n) with ⟨j, hj⟩
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
y : α
n : ℕ
⊢ ∃ j, y ∈ closedBall (u j) ((1 / 2) ^ n)

tactic: exact ⟨j, hj.le⟩
state_before: case intro
E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
y : α
n j : ℕ
hj : dist y (u j) < (1 / 2) ^ n
⊢ ∃ j, y ∈ closedBall (u j) ((1 / 2) ^ n)

tactic: simp
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
y : α
n : ℕ
⊢ 0 < (1 / 2) ^ n

tactic: refine isClosed_iff_clusterPt.mpr fun x hx ↦ ?_
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
g_surj : Surjective g
⊢ IsClosed s

tactic: have L : Tendsto (fun n : ℕ => diam (closedBall (u (x n)) ((1 / 2) ^ n))) atTop (𝓝 0) := by
  have : Tendsto (fun n : ℕ => (2 : ℝ) * (1 / 2) ^ n) atTop (𝓝 (2 * 0)) :=
    (tendsto_pow_atTop_nhds_0_of_lt_1 I0.le I1).const_mul _
  rw [MulZeroClass.mul_zero] at this
  exact
    squeeze_zero (fun n => diam_nonneg) (fun n => diam_closedBall (pow_nonneg I0.le _)) this
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
g_surj : Surjective g
x : ℕ → ℕ
hx : ClusterPt x (𝓟 s)
⊢ x ∈ s

tactic: refine nonempty_iInter_of_nonempty_biInter (fun n => isClosed_ball)
  (fun n => bounded_closedBall) (fun N ↦ ?_) L
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
g_surj : Surjective g
x : ℕ → ℕ
hx : ClusterPt x (𝓟 s)
L : Tendsto (fun n => diam (closedBall (u (x n)) ((1 / 2) ^ n))) atTop (𝓝 0)
⊢ x ∈ s

tactic: obtain ⟨y, hxy, ys⟩ : ∃ y, y ∈ ball x ((1 / 2) ^ N) ∩ s :=
  clusterPt_principal_iff.1 hx _ (ball_mem_nhds x (pow_pos I0 N))
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
g_surj : Surjective g
x : ℕ → ℕ
hx : ClusterPt x (𝓟 s)
L : Tendsto (fun n => diam (closedBall (u (x n)) ((1 / 2) ^ n))) atTop (𝓝 0)
N : ℕ
⊢ Set.Nonempty (⋂ (n : ℕ) (_ : n ≤ N), closedBall (u (x n)) ((1 / 2) ^ n))

tactic: have E :
  (⋂ (n : ℕ) (H : n ≤ N), closedBall (u (x n)) ((1 / 2) ^ n)) =
    ⋂ (n : ℕ) (H : n ≤ N), closedBall (u (y n)) ((1 / 2) ^ n) := by
  refine iInter_congr fun n ↦ iInter_congr fun hn ↦ ?_
  have : x n = y n := apply_eq_of_dist_lt (mem_ball'.1 hxy) hn
  rw [this]
state_before: case intro.intro
E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
g_surj : Surjective g
x : ℕ → ℕ
hx : ClusterPt x (𝓟 s)
L : Tendsto (fun n => diam (closedBall (u (x n)) ((1 / 2) ^ n))) atTop (𝓝 0)
N : ℕ
y : ℕ → ℕ
hxy : y ∈ ball x ((1 / 2) ^ N)
ys : y ∈ s
⊢ Set.Nonempty (⋂ (n : ℕ) (_ : n ≤ N), closedBall (u (x n)) ((1 / 2) ^ n))

tactic: rw [E]
state_before: case intro.intro
E✝ : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
g_surj : Surjective g
x : ℕ → ℕ
hx : ClusterPt x (𝓟 s)
L : Tendsto (fun n => diam (closedBall (u (x n)) ((1 / 2) ^ n))) atTop (𝓝 0)
N : ℕ
y : ℕ → ℕ
hxy : y ∈ ball x ((1 / 2) ^ N)
ys : y ∈ s
E :
  (⋂ (n : ℕ) (_ : n ≤ N), closedBall (u (x n)) ((1 / 2) ^ n)) =
    ⋂ (n : ℕ) (_ : n ≤ N), closedBall (u (y n)) ((1 / 2) ^ n)
⊢ Set.Nonempty (⋂ (n : ℕ) (_ : n ≤ N), closedBall (u (x n)) ((1 / 2) ^ n))

tactic: apply Nonempty.mono _ ys
state_before: case intro.intro
E✝ : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
g_surj : Surjective g
x : ℕ → ℕ
hx : ClusterPt x (𝓟 s)
L : Tendsto (fun n => diam (closedBall (u (x n)) ((1 / 2) ^ n))) atTop (𝓝 0)
N : ℕ
y : ℕ → ℕ
hxy : y ∈ ball x ((1 / 2) ^ N)
ys : y ∈ s
E :
  (⋂ (n : ℕ) (_ : n ≤ N), closedBall (u (x n)) ((1 / 2) ^ n)) =
    ⋂ (n : ℕ) (_ : n ≤ N), closedBall (u (y n)) ((1 / 2) ^ n)
⊢ Set.Nonempty (⋂ (n : ℕ) (_ : n ≤ N), closedBall (u (y n)) ((1 / 2) ^ n))

tactic: apply iInter_subset_iInter₂
state_before: E✝ : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
g_surj : Surjective g
x : ℕ → ℕ
hx : ClusterPt x (𝓟 s)
L : Tendsto (fun n => diam (closedBall (u (x n)) ((1 / 2) ^ n))) atTop (𝓝 0)
N : ℕ
y : ℕ → ℕ
hxy : y ∈ ball x ((1 / 2) ^ N)
ys : y ∈ s
E :
  (⋂ (n : ℕ) (_ : n ≤ N), closedBall (u (x n)) ((1 / 2) ^ n)) =
    ⋂ (n : ℕ) (_ : n ≤ N), closedBall (u (y n)) ((1 / 2) ^ n)
⊢ (⋂ (n : ℕ), closedBall (u (y n)) ((1 / 2) ^ n)) ⊆ ⋂ (n : ℕ) (_ : n ≤ N), closedBall (u (y n)) ((1 / 2) ^ n)

tactic: have : Tendsto (fun n : ℕ => (2 : ℝ) * (1 / 2) ^ n) atTop (𝓝 (2 * 0)) :=
  (tendsto_pow_atTop_nhds_0_of_lt_1 I0.le I1).const_mul _
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
g_surj : Surjective g
x : ℕ → ℕ
hx : ClusterPt x (𝓟 s)
⊢ Tendsto (fun n => diam (closedBall (u (x n)) ((1 / 2) ^ n))) atTop (𝓝 0)

tactic: rw [MulZeroClass.mul_zero] at this
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this✝ : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
g_surj : Surjective g
x : ℕ → ℕ
hx : ClusterPt x (𝓟 s)
this : Tendsto (fun n => 2 * (1 / 2) ^ n) atTop (𝓝 (2 * 0))
⊢ Tendsto (fun n => diam (closedBall (u (x n)) ((1 / 2) ^ n))) atTop (𝓝 0)

tactic: exact
  squeeze_zero (fun n => diam_nonneg) (fun n => diam_closedBall (pow_nonneg I0.le _)) this
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this✝ : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
g_surj : Surjective g
x : ℕ → ℕ
hx : ClusterPt x (𝓟 s)
this : Tendsto (fun n => 2 * (1 / 2) ^ n) atTop (𝓝 0)
⊢ Tendsto (fun n => diam (closedBall (u (x n)) ((1 / 2) ^ n))) atTop (𝓝 0)

tactic: refine iInter_congr fun n ↦ iInter_congr fun hn ↦ ?_
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
g_surj : Surjective g
x : ℕ → ℕ
hx : ClusterPt x (𝓟 s)
L : Tendsto (fun n => diam (closedBall (u (x n)) ((1 / 2) ^ n))) atTop (𝓝 0)
N : ℕ
y : ℕ → ℕ
hxy : y ∈ ball x ((1 / 2) ^ N)
ys : y ∈ s
⊢ (⋂ (n : ℕ) (_ : n ≤ N), closedBall (u (x n)) ((1 / 2) ^ n)) =
    ⋂ (n : ℕ) (_ : n ≤ N), closedBall (u (y n)) ((1 / 2) ^ n)

tactic: have : x n = y n := apply_eq_of_dist_lt (mem_ball'.1 hxy) hn
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
g_surj : Surjective g
x : ℕ → ℕ
hx : ClusterPt x (𝓟 s)
L : Tendsto (fun n => diam (closedBall (u (x n)) ((1 / 2) ^ n))) atTop (𝓝 0)
N : ℕ
y : ℕ → ℕ
hxy : y ∈ ball x ((1 / 2) ^ N)
ys : y ∈ s
n : ℕ
hn : n ≤ N
⊢ closedBall (u (x n)) ((1 / 2) ^ n) = closedBall (u (y n)) ((1 / 2) ^ n)

tactic: rw [this]
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this✝ : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
g_surj : Surjective g
x : ℕ → ℕ
hx : ClusterPt x (𝓟 s)
L : Tendsto (fun n => diam (closedBall (u (x n)) ((1 / 2) ^ n))) atTop (𝓝 0)
N : ℕ
y : ℕ → ℕ
hxy : y ∈ ball x ((1 / 2) ^ N)
ys : y ∈ s
n : ℕ
hn : n ≤ N
this : x n = y n
⊢ closedBall (u (x n)) ((1 / 2) ^ n) = closedBall (u (y n)) ((1 / 2) ^ n)

tactic: apply exists_retraction_subtype_of_isClosed s_closed
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
g_surj : Surjective g
s_closed : IsClosed s
⊢ ∃ f, (∀ (x : ↑s), f ↑x = x) ∧ Surjective f ∧ Continuous f

tactic: simpa only [nonempty_coe_sort] using g_surj.nonempty
state_before: E : ℕ → Type ?u.233694
α : Type u_1
inst✝³ : MetricSpace α
inst✝² : CompleteSpace α
inst✝¹ : SecondCountableTopology α
inst✝ : Nonempty α
this : MetricSpace (ℕ → ℕ) := metricSpaceNatNat
I0 : 0 < 1 / 2
I1 : 1 / 2 < 1
u : ℕ → α
hu : DenseRange u
s : Set (ℕ → ℕ) := {x | Set.Nonempty (⋂ (n : ℕ), closedBall (u (x n)) ((1 / 2) ^ n))}
g : ↑s → α := fun x => Set.Nonempty.some (_ : ↑x ∈ s)
A : ∀ (x : ↑s) (n : ℕ), dist (g x) (u (↑x n)) ≤ (1 / 2) ^ n
g_cont : Continuous g
g_surj : Surjective g
s_closed : IsClosed s
⊢ Set.Nonempty s