Theorem: exists_increasing_or_nonincreasing_subseq
File: Mathlib/Order/OrderIsoNat.lean

tactic: obtain ⟨g, hr | hnr⟩ := exists_increasing_or_nonincreasing_subseq' r f
state_before: α : Type u_1
r : α → α → Prop
inst✝ : IsTrans α r
f : ℕ → α
⊢ ∃ g, (∀ (m n : ℕ), m < n → r (f (g m)) (f (g n))) ∨ ∀ (m n : ℕ), m < n → ¬r (f (g m)) (f (g n))
state_after: case intro.inl
α : Type u_1
r : α → α → Prop
inst✝ : IsTrans α r
f : ℕ → α
g : ℕ ↪o ℕ
hr : ∀ (n : ℕ), r (f (g n)) (f (g (n + 1)))
⊢ ∃ g, (∀ (m n : ℕ), m < n → r (f (g m)) (f (g n))) ∨ ∀ (m n : ℕ), m < n → ¬r (f (g m)) (f (g n))

case intro.inr
α : Type u_1
r : α → α → Prop
inst✝ : IsTrans α r
f : ℕ → α
g : ℕ ↪o ℕ
hnr : ∀ (m n : ℕ), m < n → ¬r (f (g m)) (f (g n))
⊢ ∃ g, (∀ (m n : ℕ), m < n → r (f (g m)) (f (g n))) ∨ ∀ (m n : ℕ), m < n → ¬r (f (g m)) (f (g n))

tactic: refine ⟨g, Or.intro_left _ fun m n mn => ?_⟩
state_before: case intro.inl
α : Type u_1
r : α → α → Prop
inst✝ : IsTrans α r
f : ℕ → α
g : ℕ ↪o ℕ
hr : ∀ (n : ℕ), r (f (g n)) (f (g (n + 1)))
⊢ ∃ g, (∀ (m n : ℕ), m < n → r (f (g m)) (f (g n))) ∨ ∀ (m n : ℕ), m < n → ¬r (f (g m)) (f (g n))
state_after: case intro.inl
α : Type u_1
r : α → α → Prop
inst✝ : IsTrans α r
f : ℕ → α
g : ℕ ↪o ℕ
hr : ∀ (n : ℕ), r (f (g n)) (f (g (n + 1)))
m n : ℕ
mn : m < n
⊢ r (f (g m)) (f (g n))

tactic: obtain ⟨x, rfl⟩ := Nat.exists_eq_add_of_le (Nat.succ_le_iff.2 mn)
state_before: case intro.inl
α : Type u_1
r : α → α → Prop
inst✝ : IsTrans α r
f : ℕ → α
g : ℕ ↪o ℕ
hr : ∀ (n : ℕ), r (f (g n)) (f (g (n + 1)))
m n : ℕ
mn : m < n
⊢ r (f (g m)) (f (g n))
state_after: case intro.inl.intro
α : Type u_1
r : α → α → Prop
inst✝ : IsTrans α r
f : ℕ → α
g : ℕ ↪o ℕ
hr : ∀ (n : ℕ), r (f (g n)) (f (g (n + 1)))
m x : ℕ
mn : m < m.succ + x
⊢ r (f (g m)) (f (g (m.succ + x)))

tactic: induction' x with x ih
state_before: case intro.inl.intro
α : Type u_1
r : α → α → Prop
inst✝ : IsTrans α r
f : ℕ → α
g : ℕ ↪o ℕ
hr : ∀ (n : ℕ), r (f (g n)) (f (g (n + 1)))
m x : ℕ
mn : m < m.succ + x
⊢ r (f (g m)) (f (g (m.succ + x)))
state_after: case intro.inl.intro.zero
α : Type u_1
r : α → α → Prop
inst✝ : IsTrans α r
f : ℕ → α
g : ℕ ↪o ℕ
hr : ∀ (n : ℕ), r (f (g n)) (f (g (n + 1)))
m : ℕ
mn : m < m.succ + 0
⊢ r (f (g m)) (f (g (m.succ + 0)))

case intro.inl.intro.succ
α : Type u_1
r : α → α → Prop
inst✝ : IsTrans α r
f : ℕ → α
g : ℕ ↪o ℕ
hr : ∀ (n : ℕ), r (f (g n)) (f (g (n + 1)))
m x : ℕ
ih : m < m.succ + x → r (f (g m)) (f (g (m.succ + x)))
mn : m < m.succ + (x + 1)
⊢ r (f (g m)) (f (g (m.succ + (x + 1))))

tactic: apply hr
state_before: case intro.inl.intro.zero
α : Type u_1
r : α → α → Prop
inst✝ : IsTrans α r
f : ℕ → α
g : ℕ ↪o ℕ
hr : ∀ (n : ℕ), r (f (g n)) (f (g (n + 1)))
m : ℕ
mn : m < m.succ + 0
⊢ r (f (g m)) (f (g (m.succ + 0)))
state_after: no goals

tactic: apply IsTrans.trans _ _ _ _ (hr _)
state_before: case intro.inl.intro.succ
α : Type u_1
r : α → α → Prop
inst✝ : IsTrans α r
f : ℕ → α
g : ℕ ↪o ℕ
hr : ∀ (n : ℕ), r (f (g n)) (f (g (n + 1)))
m x : ℕ
ih : m < m.succ + x → r (f (g m)) (f (g (m.succ + x)))
mn : m < m.succ + (x + 1)
⊢ r (f (g m)) (f (g (m.succ + (x + 1))))
state_after: α : Type u_1
r : α → α → Prop
inst✝ : IsTrans α r
f : ℕ → α
g : ℕ ↪o ℕ
hr : ∀ (n : ℕ), r (f (g n)) (f (g (n + 1)))
m x : ℕ
ih : m < m.succ + x → r (f (g m)) (f (g (m.succ + x)))
mn : m < m.succ + (x + 1)
⊢ r (f (g m)) (f (g (m.succ.add x)))

tactic: exact ih (lt_of_lt_of_le m.lt_succ_self (Nat.le_add_right _ _))
state_before: α : Type u_1
r : α → α → Prop
inst✝ : IsTrans α r
f : ℕ → α
g : ℕ ↪o ℕ
hr : ∀ (n : ℕ), r (f (g n)) (f (g (n + 1)))
m x : ℕ
ih : m < m.succ + x → r (f (g m)) (f (g (m.succ + x)))
mn : m < m.succ + (x + 1)
⊢ r (f (g m)) (f (g (m.succ.add x)))
state_after: no goals

tactic: exact ⟨g, Or.intro_right _ hnr⟩
state_before: case intro.inr
α : Type u_1
r : α → α → Prop
inst✝ : IsTrans α r
f : ℕ → α
g : ℕ ↪o ℕ
hnr : ∀ (m n : ℕ), m < n → ¬r (f (g m)) (f (g n))
⊢ ∃ g, (∀ (m n : ℕ), m < n → r (f (g m)) (f (g n))) ∨ ∀ (m n : ℕ), m < n → ¬r (f (g m)) (f (g n))
state_after: no goals