-- Mathlib/Topology/Instances/ENNReal/Lemmas.lean
theorem exists_upcrossings_of_not_bounded_under {ι : Type*} {l : Filter ι} {x : ι → ℝ}
    (hf : liminf (fun i => (Real.nnabs (x i) : ℝ≥0∞)) l ≠ ∞)
    (hbdd : ¬IsBoundedUnder (· ≤ ·) l fun i => |x i|) :
    ∃ a b : ℚ, a < b ∧ (∃ᶠ i in l, x i < a) ∧ ∃ᶠ i in l, ↑b < x i

Proof state:
case inr.intro
ι : Type u_4
l : Filter ι
x : ι → ℝ
hf : liminf (fun i => ↑(Real.nnabs (x i))) l ≠ ⊤
hbdd : ¬IsBoundedUnder (fun x1 x2 => x1 ≥ x2) l x
R : ℝ
hR : ∃ᶠ (n : ι) in l, R < x n
⊢ ∃ a b, a < b ∧ (∃ᶠ (i : ι) in l, x i < ↑a) ∧ ∃ᶠ (i : ι) in l, ↑b < x i

Tactic:
obtain ⟨q, hq⟩ := exists_rat_lt R

Result:
case inr.intro.intro
ι : Type u_4
l : Filter ι
x : ι → ℝ
hf : liminf (fun i => ↑(Real.nnabs (x i))) l ≠ ⊤
hbdd : ¬IsBoundedUnder (fun x1 x2 => x1 ≥ x2) l x
R : ℝ
hR : ∃ᶠ (n : ι) in l, R < x n
q : ℚ
hq : ↑q < R
⊢ ∃ a b, a < b ∧ (∃ᶠ (i : ι) in l, x i < ↑a) ∧ ∃ᶠ (i : ι) in l, ↑b < x i

Proof state:
case inl.intro.intro.refine_2
ι : Type u_4
l : Filter ι
x : ι → ℝ
hf : liminf (fun i => ↑(Real.nnabs (x i))) l ≠ ⊤
hbdd : ¬IsBoundedUnder (fun x1 x2 => x1 ≤ x2) l x
R : ℝ
hR : ∃ᶠ (n : ι) in l, x n < R
q : ℚ
hq : R < ↑q
⊢ ∃ᶠ (i : ι) in l, ↑(q + 1) < x i

Tactic:
simp only [IsBoundedUnder, IsBounded, eventually_map, eventually_atTop, not_exists,
  not_forall, not_le, exists_prop] at hbdd

Result:
case inl.intro.intro.refine_2
ι : Type u_4
l : Filter ι
x : ι → ℝ
hf : liminf (fun i => ↑(Real.nnabs (x i))) l ≠ ⊤
R : ℝ
hR : ∃ᶠ (n : ι) in l, x n < R
q : ℚ
hq : R < ↑q
hbdd : ∀ (x_1 : ℝ), ¬∀ᶠ (a : ι) in l, x a ≤ x_1
⊢ ∃ᶠ (i : ι) in l, ↑(q + 1) < x i

Proof state:
case inr.intro.intro.refine_1
ι : Type u_4
l : Filter ι
x : ι → ℝ
hf : liminf (fun i => ↑(Real.nnabs (x i))) l ≠ ⊤
R : ℝ
hR : ∃ᶠ (n : ι) in l, R < x n
q : ℚ
hq : ↑q < R
hbdd : ∀ (x_1 : ℝ), ¬∀ᶠ (a : ι) in l, x a ≥ x_1
hcon : ∀ᶠ (x_1 : ι) in l, ¬(fun i => x i < ↑(q - 1)) x_1
⊢ ∀ᶠ (a : ι) in l, x a ≥ ↑(q - 1)

Tactic:
filter_upwards [hcon] with x hx using not_lt.1 hx

Result:
no goals

Proof state:
case inl.intro.intro.refine_1
ι : Type u_4
l : Filter ι
x : ι → ℝ
hf : liminf (fun i => ↑(Real.nnabs (x i))) l ≠ ⊤
hbdd : ¬IsBoundedUnder (fun x1 x2 => x1 ≤ x2) l x
R : ℝ
hR : ∃ᶠ (n : ι) in l, x n < R
q : ℚ
hq : R < ↑q
hcon : ∀ᶠ (x_1 : ι) in l, ¬(fun i => x i < ↑q) x_1
⊢ ∀ᶠ (x_1 : ι) in l, ¬(fun n => x n < R) x_1

Tactic:
filter_upwards [hcon] with x hx using not_lt.2 (lt_of_lt_of_le hq (not_lt.1 hx)).le

Result:
no goals

Proof state:
case inr.intro.intro
ι : Type u_4
l : Filter ι
x : ι → ℝ
hf : liminf (fun i => ↑(Real.nnabs (x i))) l ≠ ⊤
hbdd : ¬IsBoundedUnder (fun x1 x2 => x1 ≥ x2) l x
R : ℝ
hR : ∃ᶠ (n : ι) in l, R < x n
q : ℚ
hq : ↑q < R
⊢ ∃ a b, a < b ∧ (∃ᶠ (i : ι) in l, x i < ↑a) ∧ ∃ᶠ (i : ι) in l, ↑b < x i

Tactic:
refine ⟨q - 1, q, (sub_lt_self_iff _).2 zero_lt_one, ?_, ?_⟩

Result:
case inr.intro.intro.refine_1
ι : Type u_4
l : Filter ι
x : ι → ℝ
hf : liminf (fun i => ↑(Real.nnabs (x i))) l ≠ ⊤
hbdd : ¬IsBoundedUnder (fun x1 x2 => x1 ≥ x2) l x
R : ℝ
hR : ∃ᶠ (n : ι) in l, R < x n
q : ℚ
hq : ↑q < R
⊢ ∃ᶠ (i : ι) in l, x i < ↑(q - 1)

case inr.intro.intro.refine_2
ι : Type u_4
l : Filter ι
x : ι → ℝ
hf : liminf (fun i => ↑(Real.nnabs (x i))) l ≠ ⊤
hbdd : ¬IsBoundedUnder (fun x1 x2 => x1 ≥ x2) l x
R : ℝ
hR : ∃ᶠ (n : ι) in l, R < x n
q : ℚ
hq : ↑q < R
⊢ ∃ᶠ (i : ι) in l, ↑q < x i

Proof state:
case inr.intro.intro.refine_1
ι : Type u_4
l : Filter ι
x : ι → ℝ
hf : liminf (fun i => ↑(Real.nnabs (x i))) l ≠ ⊤
hbdd : ¬IsBoundedUnder (fun x1 x2 => x1 ≥ x2) l x
R : ℝ
hR : ∃ᶠ (n : ι) in l, R < x n
q : ℚ
hq : ↑q < R
⊢ ∃ᶠ (i : ι) in l, x i < ↑(q - 1)

Tactic:
simp only [IsBoundedUnder, IsBounded, eventually_map, eventually_atTop, not_exists,
  not_forall, not_le, exists_prop] at hbdd

Result:
case inr.intro.intro.refine_1
ι : Type u_4
l : Filter ι
x : ι → ℝ
hf : liminf (fun i => ↑(Real.nnabs (x i))) l ≠ ⊤
R : ℝ
hR : ∃ᶠ (n : ι) in l, R < x n
q : ℚ
hq : ↑q < R
hbdd : ∀ (x_1 : ℝ), ¬∀ᶠ (a : ι) in l, x a ≥ x_1
⊢ ∃ᶠ (i : ι) in l, x i < ↑(q - 1)

Proof state:
case inr
ι : Type u_4
l : Filter ι
x : ι → ℝ
hf : liminf (fun i => ↑(Real.nnabs (x i))) l ≠ ⊤
hbdd : ¬IsBoundedUnder (fun x1 x2 => x1 ≥ x2) l x
⊢ ∃ a b, a < b ∧ (∃ᶠ (i : ι) in l, x i < ↑a) ∧ ∃ᶠ (i : ι) in l, ↑b < x i

Tactic:
obtain ⟨R, hR⟩ := exists_frequently_lt_of_liminf_ne_top' hf

Result:
case inr.intro
ι : Type u_4
l : Filter ι
x : ι → ℝ
hf : liminf (fun i => ↑(Real.nnabs (x i))) l ≠ ⊤
hbdd : ¬IsBoundedUnder (fun x1 x2 => x1 ≥ x2) l x
R : ℝ
hR : ∃ᶠ (n : ι) in l, R < x n
⊢ ∃ a b, a < b ∧ (∃ᶠ (i : ι) in l, x i < ↑a) ∧ ∃ᶠ (i : ι) in l, ↑b < x i

Proof state:
case inl.intro.intro.refine_2
ι : Type u_4
l : Filter ι
x : ι → ℝ
hf : liminf (fun i => ↑(Real.nnabs (x i))) l ≠ ⊤
R : ℝ
hR : ∃ᶠ (n : ι) in l, x n < R
q : ℚ
hq : R < ↑q
hbdd : ∀ (x_1 : ℝ), ¬∀ᶠ (a : ι) in l, x a ≤ x_1
hcon : ∀ᶠ (x_1 : ι) in l, ¬(fun i => ↑(q + 1) < x i) x_1
⊢ ∀ᶠ (a : ι) in l, x a ≤ ↑(q + 1)

Tactic:
filter_upwards [hcon] with x hx using not_lt.1 hx

Result:
no goals

Proof state:
case inl.intro.intro
ι : Type u_4
l : Filter ι
x : ι → ℝ
hf : liminf (fun i => ↑(Real.nnabs (x i))) l ≠ ⊤
hbdd : ¬IsBoundedUnder (fun x1 x2 => x1 ≤ x2) l x
R : ℝ
hR : ∃ᶠ (n : ι) in l, x n < R
q : ℚ
hq : R < ↑q
⊢ ∃ a b, a < b ∧ (∃ᶠ (i : ι) in l, x i < ↑a) ∧ ∃ᶠ (i : ι) in l, ↑b < x i

Tactic:
refine ⟨q, q + 1, (lt_add_iff_pos_right _).2 zero_lt_one, ?_, ?_⟩

Result:
case inl.intro.intro.refine_1
ι : Type u_4
l : Filter ι
x : ι → ℝ
hf : liminf (fun i => ↑(Real.nnabs (x i))) l ≠ ⊤
hbdd : ¬IsBoundedUnder (fun x1 x2 => x1 ≤ x2) l x
R : ℝ
hR : ∃ᶠ (n : ι) in l, x n < R
q : ℚ
hq : R < ↑q
⊢ ∃ᶠ (i : ι) in l, x i < ↑q

case inl.intro.intro.refine_2
ι : Type u_4
l : Filter ι
x : ι → ℝ
hf : liminf (fun i => ↑(Real.nnabs (x i))) l ≠ ⊤
hbdd : ¬IsBoundedUnder (fun x1 x2 => x1 ≤ x2) l x
R : ℝ
hR : ∃ᶠ (n : ι) in l, x n < R
q : ℚ
hq : R < ↑q
⊢ ∃ᶠ (i : ι) in l, ↑(q + 1) < x i

Proof state:
case inl
ι : Type u_4
l : Filter ι
x : ι → ℝ
hf : liminf (fun i => ↑(Real.nnabs (x i))) l ≠ ⊤
hbdd : ¬IsBoundedUnder (fun x1 x2 => x1 ≤ x2) l x
⊢ ∃ a b, a < b ∧ (∃ᶠ (i : ι) in l, x i < ↑a) ∧ ∃ᶠ (i : ι) in l, ↑b < x i

Tactic:
obtain ⟨R, hR⟩ := exists_frequently_lt_of_liminf_ne_top hf

Result:
case inl.intro
ι : Type u_4
l : Filter ι
x : ι → ℝ
hf : liminf (fun i => ↑(Real.nnabs (x i))) l ≠ ⊤
hbdd : ¬IsBoundedUnder (fun x1 x2 => x1 ≤ x2) l x
R : ℝ
hR : ∃ᶠ (n : ι) in l, x n < R
⊢ ∃ a b, a < b ∧ (∃ᶠ (i : ι) in l, x i < ↑a) ∧ ∃ᶠ (i : ι) in l, ↑b < x i

Proof state:
case inr.intro.intro.refine_2
ι : Type u_4
l : Filter ι
x : ι → ℝ
hf : liminf (fun i => ↑(Real.nnabs (x i))) l ≠ ⊤
hbdd : ¬IsBoundedUnder (fun x1 x2 => x1 ≥ x2) l x
R : ℝ
hR : ∃ᶠ (n : ι) in l, R < x n
q : ℚ
hq : ↑q < R
⊢ ∃ᶠ (i : ι) in l, ↑q < x i

Tactic:
refine fun hcon => hR ?_

Result:
case inr.intro.intro.refine_2
ι : Type u_4
l : Filter ι
x : ι → ℝ
hf : liminf (fun i => ↑(Real.nnabs (x i))) l ≠ ⊤
hbdd : ¬IsBoundedUnder (fun x1 x2 => x1 ≥ x2) l x
R : ℝ
hR : ∃ᶠ (n : ι) in l, R < x n
q : ℚ
hq : ↑q < R
hcon : ∀ᶠ (x_1 : ι) in l, ¬(fun i => ↑q < x i) x_1
⊢ ∀ᶠ (x_1 : ι) in l, ¬(fun n => R < x n) x_1

Proof state:
ι : Type u_4
l : Filter ι
x : ι → ℝ
hf : liminf (fun i => ↑(Real.nnabs (x i))) l ≠ ⊤
hbdd : ¬IsBoundedUnder (fun x1 x2 => x1 ≤ x2) l x ∨ ¬IsBoundedUnder (fun x1 x2 => x1 ≥ x2) l x
⊢ ∃ a b, a < b ∧ (∃ᶠ (i : ι) in l, x i < ↑a) ∧ ∃ᶠ (i : ι) in l, ↑b < x i

Tactic:
obtain hbdd | hbdd := hbdd

Result:
case inl
ι : Type u_4
l : Filter ι
x : ι → ℝ
hf : liminf (fun i => ↑(Real.nnabs (x i))) l ≠ ⊤
hbdd : ¬IsBoundedUnder (fun x1 x2 => x1 ≤ x2) l x
⊢ ∃ a b, a < b ∧ (∃ᶠ (i : ι) in l, x i < ↑a) ∧ ∃ᶠ (i : ι) in l, ↑b < x i

case inr
ι : Type u_4
l : Filter ι
x : ι → ℝ
hf : liminf (fun i => ↑(Real.nnabs (x i))) l ≠ ⊤
hbdd : ¬IsBoundedUnder (fun x1 x2 => x1 ≥ x2) l x
⊢ ∃ a b, a < b ∧ (∃ᶠ (i : ι) in l, x i < ↑a) ∧ ∃ᶠ (i : ι) in l, ↑b < x i