-- Mathlib/Order/Filter/AtTopBot/Basic.lean
theorem extraction_forall_of_frequently {P : ℕ → ℕ → Prop} (h : ∀ n, ∃ᶠ k in atTop, P n k) :
    ∃ φ : ℕ → ℕ, StrictMono φ ∧ ∀ n, P n (φ n)

Proof state:
case h.left.hf
P : ℕ → ℕ → Prop
u : ℕ → ℕ → ℕ
hu : ∀ (n a : ℕ), u n a > a
hu' : ∀ (n a : ℕ), P n (u n a)
n : ℕ
⊢ (Nat.recOn n (u 0 0) fun n v => u (n + 1) v) < Nat.recOn (n + 1) (u 0 0) fun n v => u (n + 1) v

Tactic:
apply hu

Result:
no goals

Proof state:
P : ℕ → ℕ → Prop
u : ℕ → ℕ → ℕ
hu : ∀ (n a : ℕ), u n a > a
hu' : ∀ (n a : ℕ), P n (u n a)
⊢ ∃ φ, StrictMono φ ∧ ∀ (n : ℕ), P n (φ n)

Tactic:
use (fun n => Nat.recOn n (u 0 0) fun n v => u (n + 1) v : ℕ → ℕ)

Result:
case h
P : ℕ → ℕ → Prop
u : ℕ → ℕ → ℕ
hu : ∀ (n a : ℕ), u n a > a
hu' : ∀ (n a : ℕ), P n (u n a)
⊢ (StrictMono fun n => Nat.recOn n (u 0 0) fun n v => u (n + 1) v) ∧
    ∀ (n : ℕ), P n ((fun n => Nat.recOn n (u 0 0) fun n v => u (n + 1) v) n)

Proof state:
case h.left
P : ℕ → ℕ → Prop
u : ℕ → ℕ → ℕ
hu : ∀ (n a : ℕ), u n a > a
hu' : ∀ (n a : ℕ), P n (u n a)
⊢ StrictMono fun n => Nat.recOn n (u 0 0) fun n v => u (n + 1) v

Tactic:
apply strictMono_nat_of_lt_succ

Result:
case h.left.hf
P : ℕ → ℕ → Prop
u : ℕ → ℕ → ℕ
hu : ∀ (n a : ℕ), u n a > a
hu' : ∀ (n a : ℕ), P n (u n a)
⊢ ∀ (n : ℕ), (Nat.recOn n (u 0 0) fun n v => u (n + 1) v) < Nat.recOn (n + 1) (u 0 0) fun n v => u (n + 1) v

Proof state:
case h.left.hf
P : ℕ → ℕ → Prop
u : ℕ → ℕ → ℕ
hu : ∀ (n a : ℕ), u n a > a
hu' : ∀ (n a : ℕ), P n (u n a)
⊢ ∀ (n : ℕ), (Nat.recOn n (u 0 0) fun n v => u (n + 1) v) < Nat.recOn (n + 1) (u 0 0) fun n v => u (n + 1) v

Tactic:
intro n

Result:
case h.left.hf
P : ℕ → ℕ → Prop
u : ℕ → ℕ → ℕ
hu : ∀ (n a : ℕ), u n a > a
hu' : ∀ (n a : ℕ), P n (u n a)
n : ℕ
⊢ (Nat.recOn n (u 0 0) fun n v => u (n + 1) v) < Nat.recOn (n + 1) (u 0 0) fun n v => u (n + 1) v

Proof state:
case h.right
P : ℕ → ℕ → Prop
u : ℕ → ℕ → ℕ
hu : ∀ (n a : ℕ), u n a > a
hu' : ∀ (n a : ℕ), P n (u n a)
⊢ ∀ (n : ℕ), P n (Nat.recOn n (u 0 0) fun n v => u (n + 1) v)

Tactic:
intro n

Result:
case h.right
P : ℕ → ℕ → Prop
u : ℕ → ℕ → ℕ
hu : ∀ (n a : ℕ), u n a > a
hu' : ∀ (n a : ℕ), P n (u n a)
n : ℕ
⊢ P n (Nat.recOn n (u 0 0) fun n v => u (n + 1) v)

Proof state:
case h
P : ℕ → ℕ → Prop
u : ℕ → ℕ → ℕ
hu : ∀ (n a : ℕ), u n a > a
hu' : ∀ (n a : ℕ), P n (u n a)
⊢ (StrictMono fun n => Nat.recOn n (u 0 0) fun n v => u (n + 1) v) ∧
    ∀ (n : ℕ), P n ((fun n => Nat.recOn n (u 0 0) fun n v => u (n + 1) v) n)

Tactic:
constructor

Result:
case h.left
P : ℕ → ℕ → Prop
u : ℕ → ℕ → ℕ
hu : ∀ (n a : ℕ), u n a > a
hu' : ∀ (n a : ℕ), P n (u n a)
⊢ StrictMono fun n => Nat.recOn n (u 0 0) fun n v => u (n + 1) v

case h.right
P : ℕ → ℕ → Prop
u : ℕ → ℕ → ℕ
hu : ∀ (n a : ℕ), u n a > a
hu' : ∀ (n a : ℕ), P n (u n a)
⊢ ∀ (n : ℕ), P n (Nat.recOn n (u 0 0) fun n v => u (n + 1) v)

Proof state:
case h.right
P : ℕ → ℕ → Prop
u : ℕ → ℕ → ℕ
hu : ∀ (n a : ℕ), u n a > a
hu' : ∀ (n a : ℕ), P n (u n a)
n : ℕ
⊢ P n (Nat.recOn n (u 0 0) fun n v => u (n + 1) v)

Tactic:
cases n <;> simp [hu']

Result:
no goals

Proof state:
P : ℕ → ℕ → Prop
h : ∀ (n a : ℕ), ∃ b > a, P n b
⊢ ∃ φ, StrictMono φ ∧ ∀ (n : ℕ), P n (φ n)

Tactic:
choose u hu hu' using h

Result:
P : ℕ → ℕ → Prop
u : ℕ → ℕ → ℕ
hu : ∀ (n a : ℕ), u n a > a
hu' : ∀ (n a : ℕ), P n (u n a)
⊢ ∃ φ, StrictMono φ ∧ ∀ (n : ℕ), P n (φ n)

Proof state:
P : ℕ → ℕ → Prop
h : ∀ (n : ℕ), ∃ᶠ (k : ℕ) in atTop, P n k
⊢ ∃ φ, StrictMono φ ∧ ∀ (n : ℕ), P n (φ n)

Tactic:
simp only [frequently_atTop'] at h

Result:
P : ℕ → ℕ → Prop
h : ∀ (n a : ℕ), ∃ b > a, P n b
⊢ ∃ φ, StrictMono φ ∧ ∀ (n : ℕ), P n (φ n)