-- Mathlib/Order/Filter/AtTopBot/CountablyGenerated.lean
theorem tendsto_of_subseq_tendsto {ι : Type*} {x : ι → α} {f : Filter α} {l : Filter ι}
    [l.IsCountablyGenerated]
    (hxy : ∀ ns : ℕ → ι, Tendsto ns atTop l →
      ∃ ms : ℕ → ℕ, Tendsto (fun n => x (ns <| ms n)) atTop f) :
    Tendsto x l f

Proof state:
α : Type u_1
ι : Type u_3
x : ι → α
f : Filter α
l : Filter ι
inst✝ : l.IsCountablyGenerated
hxy : ∀ (ns : ℕ → ι), Tendsto ns atTop l → ∃ ms, Tendsto (fun n => x (ns (ms n))) atTop f
⊢ Tendsto x l f

Tactic:
contrapose! hxy

Result:
α : Type u_1
ι : Type u_3
x : ι → α
f : Filter α
l : Filter ι
inst✝ : l.IsCountablyGenerated
hxy : ¬Tendsto x l f
⊢ ∃ ns, Tendsto ns atTop l ∧ ∀ (ms : ℕ → ℕ), ¬Tendsto (fun n => x (ns (ms n))) atTop f

Proof state:
case intro.intro.intro.intro
α : Type u_1
ι : Type u_3
x : ι → α
f : Filter α
l : Filter ι
inst✝ : l.IsCountablyGenerated
hxy : ¬Tendsto x l f
s : Set α
hs : s ∈ f
hfreq : ∃ᶠ (n : ι) in l, x n ∉ s
y : ℕ → ι
hy_tendsto : Tendsto y atTop l
hy_freq : ∀ (n : ℕ), x (y n) ∉ s
ms : ℕ → ℕ
hms_tendsto : Tendsto (fun n => x (y (ms n))) atTop f
⊢ False

Tactic:
rcases (hms_tendsto.eventually_mem hs).exists with ⟨n, hn⟩

Result:
case intro.intro.intro.intro.intro
α : Type u_1
ι : Type u_3
x : ι → α
f : Filter α
l : Filter ι
inst✝ : l.IsCountablyGenerated
hxy : ¬Tendsto x l f
s : Set α
hs : s ∈ f
hfreq : ∃ᶠ (n : ι) in l, x n ∉ s
y : ℕ → ι
hy_tendsto : Tendsto y atTop l
hy_freq : ∀ (n : ℕ), x (y n) ∉ s
ms : ℕ → ℕ
hms_tendsto : Tendsto (fun n => x (y (ms n))) atTop f
n : ℕ
hn : x (y (ms n)) ∈ s
⊢ False

Proof state:
α : Type u_1
ι : Type u_3
x : ι → α
f : Filter α
l : Filter ι
inst✝ : l.IsCountablyGenerated
hxy : ¬Tendsto x l f
⊢ ∃ ns, Tendsto ns atTop l ∧ ∀ (ms : ℕ → ℕ), ¬Tendsto (fun n => x (ns (ms n))) atTop f

Tactic:
obtain ⟨s, hs, hfreq⟩ : ∃ s ∈ f, ∃ᶠ n in l, x n ∉ s := by
  rwa [not_tendsto_iff_exists_frequently_nmem] at hxy

Result:
case intro.intro
α : Type u_1
ι : Type u_3
x : ι → α
f : Filter α
l : Filter ι
inst✝ : l.IsCountablyGenerated
hxy : ¬Tendsto x l f
s : Set α
hs : s ∈ f
hfreq : ∃ᶠ (n : ι) in l, x n ∉ s
⊢ ∃ ns, Tendsto ns atTop l ∧ ∀ (ms : ℕ → ℕ), ¬Tendsto (fun n => x (ns (ms n))) atTop f

Proof state:
case intro.intro.intro.intro
α : Type u_1
ι : Type u_3
x : ι → α
f : Filter α
l : Filter ι
inst✝ : l.IsCountablyGenerated
hxy : ¬Tendsto x l f
s : Set α
hs : s ∈ f
hfreq : ∃ᶠ (n : ι) in l, x n ∉ s
y : ℕ → ι
hy_tendsto : Tendsto y atTop l
hy_freq : ∀ (n : ℕ), x (y n) ∉ s
⊢ ∃ ns, Tendsto ns atTop l ∧ ∀ (ms : ℕ → ℕ), ¬Tendsto (fun n => x (ns (ms n))) atTop f

Tactic:
refine ⟨y, hy_tendsto, fun ms hms_tendsto ↦ ?_⟩

Result:
case intro.intro.intro.intro
α : Type u_1
ι : Type u_3
x : ι → α
f : Filter α
l : Filter ι
inst✝ : l.IsCountablyGenerated
hxy : ¬Tendsto x l f
s : Set α
hs : s ∈ f
hfreq : ∃ᶠ (n : ι) in l, x n ∉ s
y : ℕ → ι
hy_tendsto : Tendsto y atTop l
hy_freq : ∀ (n : ℕ), x (y n) ∉ s
ms : ℕ → ℕ
hms_tendsto : Tendsto (fun n => x (y (ms n))) atTop f
⊢ False

Proof state:
case intro.intro
α : Type u_1
ι : Type u_3
x : ι → α
f : Filter α
l : Filter ι
inst✝ : l.IsCountablyGenerated
hxy : ¬Tendsto x l f
s : Set α
hs : s ∈ f
hfreq : ∃ᶠ (n : ι) in l, x n ∉ s
⊢ ∃ ns, Tendsto ns atTop l ∧ ∀ (ms : ℕ → ℕ), ¬Tendsto (fun n => x (ns (ms n))) atTop f

Tactic:
obtain ⟨y, hy_tendsto, hy_freq⟩ := exists_seq_forall_of_frequently hfreq

Result:
case intro.intro.intro.intro
α : Type u_1
ι : Type u_3
x : ι → α
f : Filter α
l : Filter ι
inst✝ : l.IsCountablyGenerated
hxy : ¬Tendsto x l f
s : Set α
hs : s ∈ f
hfreq : ∃ᶠ (n : ι) in l, x n ∉ s
y : ℕ → ι
hy_tendsto : Tendsto y atTop l
hy_freq : ∀ (n : ℕ), x (y n) ∉ s
⊢ ∃ ns, Tendsto ns atTop l ∧ ∀ (ms : ℕ → ℕ), ¬Tendsto (fun n => x (ns (ms n))) atTop f

Proof state:
case intro.intro.intro.intro.intro
α : Type u_1
ι : Type u_3
x : ι → α
f : Filter α
l : Filter ι
inst✝ : l.IsCountablyGenerated
hxy : ¬Tendsto x l f
s : Set α
hs : s ∈ f
hfreq : ∃ᶠ (n : ι) in l, x n ∉ s
y : ℕ → ι
hy_tendsto : Tendsto y atTop l
hy_freq : ∀ (n : ℕ), x (y n) ∉ s
ms : ℕ → ℕ
hms_tendsto : Tendsto (fun n => x (y (ms n))) atTop f
n : ℕ
hn : x (y (ms n)) ∈ s
⊢ False

Tactic:
exact absurd hn <| hy_freq _

Result:
no goals

Proof state:
α : Type u_1
ι : Type u_3
x : ι → α
f : Filter α
l : Filter ι
inst✝ : l.IsCountablyGenerated
hxy : ¬Tendsto x l f
⊢ ∃ s ∈ f, ∃ᶠ (n : ι) in l, x n ∉ s

Tactic:
rwa [not_tendsto_iff_exists_frequently_nmem] at hxy

Result:
no goals