Theorem: Nat.findGreatest_eq_iff
File: Mathlib/Data/Nat/Defs.lean

tactic: induction' k with k ihk generalizing m
state_before: a b c d m n✝ k : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n : ℕ
⊢ findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
state_after: case zero
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n m : ℕ
⊢ findGreatest P 0 = m ↔ m ≤ 0 ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ 0 → ¬P n

case succ
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
⊢ findGreatest P (k + 1) = m ↔ m ≤ k + 1 ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n

tactic: rw [eq_comm, Iff.comm]
state_before: case zero
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n m : ℕ
⊢ findGreatest P 0 = m ↔ m ≤ 0 ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ 0 → ¬P n
state_after: case zero
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n m : ℕ
⊢ (m ≤ 0 ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ 0 → ¬P n) ↔ m = findGreatest P 0

tactic: simp only [zero_eq, Nat.le_zero, ne_eq, findGreatest_zero, and_iff_left_iff_imp]
state_before: case zero
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n m : ℕ
⊢ (m ≤ 0 ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ 0 → ¬P n) ↔ m = findGreatest P 0
state_after: case zero
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n m : ℕ
⊢ m = 0 → (¬m = 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n = 0 → ¬P n

tactic: rintro rfl
state_before: case zero
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n m : ℕ
⊢ m = 0 → (¬m = 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n = 0 → ¬P n
state_after: case zero
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n : ℕ
⊢ (¬0 = 0 → P 0) ∧ ∀ ⦃n : ℕ⦄, 0 < n → n = 0 → ¬P n

tactic: exact ⟨fun h ↦ (h rfl).elim, fun n hlt heq ↦ by omega⟩
state_before: case zero
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n : ℕ
⊢ (¬0 = 0 → P 0) ∧ ∀ ⦃n : ℕ⦄, 0 < n → n = 0 → ¬P n
state_after: no goals

tactic: omega
state_before: a b c d n✝¹ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n✝ n : ℕ
hlt : 0 < n
heq : n = 0
⊢ ¬P n
state_after: no goals

tactic: by_cases hk : P (k + 1)
state_before: case succ
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
⊢ findGreatest P (k + 1) = m ↔ m ≤ k + 1 ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n
state_after: case pos
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : P (k + 1)
⊢ findGreatest P (k + 1) = m ↔ m ≤ k + 1 ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n

case neg
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
⊢ findGreatest P (k + 1) = m ↔ m ≤ k + 1 ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n

tactic: rw [findGreatest_eq hk]
state_before: case pos
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : P (k + 1)
⊢ findGreatest P (k + 1) = m ↔ m ≤ k + 1 ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n
state_after: case pos
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : P (k + 1)
⊢ k + 1 = m ↔ m ≤ k + 1 ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n

tactic: constructor
state_before: case pos
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : P (k + 1)
⊢ k + 1 = m ↔ m ≤ k + 1 ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n
state_after: case pos.mp
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : P (k + 1)
⊢ k + 1 = m → m ≤ k + 1 ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n

case pos.mpr
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : P (k + 1)
⊢ (m ≤ k + 1 ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n) → k + 1 = m

tactic: rintro rfl
state_before: case pos.mp
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : P (k + 1)
⊢ k + 1 = m → m ≤ k + 1 ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n
state_after: case pos.mp
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
hk : P (k + 1)
⊢ k + 1 ≤ k + 1 ∧ (k + 1 ≠ 0 → P (k + 1)) ∧ ∀ ⦃n : ℕ⦄, k + 1 < n → n ≤ k + 1 → ¬P n

tactic: exact ⟨le_refl _, fun _ ↦ hk, fun n hlt hle ↦ by omega⟩
state_before: case pos.mp
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
hk : P (k + 1)
⊢ k + 1 ≤ k + 1 ∧ (k + 1 ≠ 0 → P (k + 1)) ∧ ∀ ⦃n : ℕ⦄, k + 1 < n → n ≤ k + 1 → ¬P n
state_after: no goals

tactic: omega
state_before: a b c d n✝¹ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n✝ k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
hk : P (k + 1)
n : ℕ
hlt : k + 1 < n
hle : n ≤ k + 1
⊢ ¬P n
state_after: no goals

tactic: rintro ⟨hle, h0, hm⟩
state_before: case pos.mpr
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : P (k + 1)
⊢ (m ≤ k + 1 ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n) → k + 1 = m
state_after: case pos.mpr.intro.intro
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : P (k + 1)
hle : m ≤ k + 1
h0 : m ≠ 0 → P m
hm : ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n
⊢ k + 1 = m

tactic: rcases Decidable.eq_or_lt_of_le hle with (rfl | hlt)
state_before: case pos.mpr.intro.intro
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : P (k + 1)
hle : m ≤ k + 1
h0 : m ≠ 0 → P m
hm : ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n
⊢ k + 1 = m
state_after: case pos.mpr.intro.intro.inl
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
hk : P (k + 1)
hle : k + 1 ≤ k + 1
h0 : k + 1 ≠ 0 → P (k + 1)
hm : ∀ ⦃n : ℕ⦄, k + 1 < n → n ≤ k + 1 → ¬P n
⊢ k + 1 = k + 1

case pos.mpr.intro.intro.inr
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : P (k + 1)
hle : m ≤ k + 1
h0 : m ≠ 0 → P m
hm : ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n
hlt : m < k + 1
⊢ k + 1 = m

tactic: exacts [rfl, (hm hlt (le_refl _) hk).elim]
state_before: case pos.mpr.intro.intro.inl
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
hk : P (k + 1)
hle : k + 1 ≤ k + 1
h0 : k + 1 ≠ 0 → P (k + 1)
hm : ∀ ⦃n : ℕ⦄, k + 1 < n → n ≤ k + 1 → ¬P n
⊢ k + 1 = k + 1

case pos.mpr.intro.intro.inr
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : P (k + 1)
hle : m ≤ k + 1
h0 : m ≠ 0 → P m
hm : ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n
hlt : m < k + 1
⊢ k + 1 = m
state_after: no goals

tactic: rw [findGreatest_of_not hk, ihk]
state_before: case neg
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
⊢ findGreatest P (k + 1) = m ↔ m ≤ k + 1 ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n
state_after: case neg
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
⊢ (m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n) ↔
    m ≤ k + 1 ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n

tactic: constructor
state_before: case neg
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
⊢ (m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n) ↔
    m ≤ k + 1 ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n
state_after: case neg.mp
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
⊢ (m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n) →
    m ≤ k + 1 ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n

case neg.mpr
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
⊢ (m ≤ k + 1 ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n) →
    m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n

tactic: rintro ⟨hle, hP, hm⟩
state_before: case neg.mp
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
⊢ (m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n) →
    m ≤ k + 1 ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n
state_after: case neg.mp.intro.intro
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
hle : m ≤ k
hP : m ≠ 0 → P m
hm : ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
⊢ m ≤ k + 1 ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n

tactic: refine ⟨le_trans hle k.le_succ, hP, fun n hlt hle ↦ ?_⟩
state_before: case neg.mp.intro.intro
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
hle : m ≤ k
hP : m ≠ 0 → P m
hm : ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
⊢ m ≤ k + 1 ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n
state_after: case neg.mp.intro.intro
a b c d n✝¹ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n✝ k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
hle✝ : m ≤ k
hP : m ≠ 0 → P m
hm : ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
n : ℕ
hlt : m < n
hle : n ≤ k + 1
⊢ ¬P n

tactic: rcases Decidable.eq_or_lt_of_le hle with (rfl | hlt')
state_before: case neg.mp.intro.intro
a b c d n✝¹ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n✝ k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
hle✝ : m ≤ k
hP : m ≠ 0 → P m
hm : ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
n : ℕ
hlt : m < n
hle : n ≤ k + 1
⊢ ¬P n
state_after: case neg.mp.intro.intro.inl
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
hle✝ : m ≤ k
hP : m ≠ 0 → P m
hm : ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
hlt : m < k + 1
hle : k + 1 ≤ k + 1
⊢ ¬P (k + 1)

case neg.mp.intro.intro.inr
a b c d n✝¹ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n✝ k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
hle✝ : m ≤ k
hP : m ≠ 0 → P m
hm : ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
n : ℕ
hlt : m < n
hle : n ≤ k + 1
hlt' : n < k + 1
⊢ ¬P n

tactic: exacts [hk, hm hlt <| Nat.lt_succ_iff.1 hlt']
state_before: case neg.mp.intro.intro.inl
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
hle✝ : m ≤ k
hP : m ≠ 0 → P m
hm : ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
hlt : m < k + 1
hle : k + 1 ≤ k + 1
⊢ ¬P (k + 1)

case neg.mp.intro.intro.inr
a b c d n✝¹ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n✝ k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
hle✝ : m ≤ k
hP : m ≠ 0 → P m
hm : ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
n : ℕ
hlt : m < n
hle : n ≤ k + 1
hlt' : n < k + 1
⊢ ¬P n
state_after: no goals

tactic: rintro ⟨hle, hP, hm⟩
state_before: case neg.mpr
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
⊢ (m ≤ k + 1 ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n) →
    m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
state_after: case neg.mpr.intro.intro
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
hle : m ≤ k + 1
hP : m ≠ 0 → P m
hm : ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n
⊢ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n

tactic: refine ⟨Nat.lt_succ_iff.1 (lt_of_le_of_ne hle ?_), hP,
  fun n hlt hle ↦ hm hlt (le_trans hle k.le_succ)⟩
state_before: case neg.mpr.intro.intro
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
hle : m ≤ k + 1
hP : m ≠ 0 → P m
hm : ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n
⊢ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
state_after: case neg.mpr.intro.intro
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
hle : m ≤ k + 1
hP : m ≠ 0 → P m
hm : ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n
⊢ m ≠ k.succ

tactic: rintro rfl
state_before: case neg.mpr.intro.intro
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
m : ℕ
hk : ¬P (k + 1)
hle : m ≤ k + 1
hP : m ≠ 0 → P m
hm : ∀ ⦃n : ℕ⦄, m < n → n ≤ k + 1 → ¬P n
⊢ m ≠ k.succ
state_after: case neg.mpr.intro.intro
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
hk : ¬P (k + 1)
hle : k.succ ≤ k + 1
hP : k.succ ≠ 0 → P k.succ
hm : ∀ ⦃n : ℕ⦄, k.succ < n → n ≤ k + 1 → ¬P n
⊢ False

tactic: exact hk (hP k.succ_ne_zero)
state_before: case neg.mpr.intro.intro
a b c d n✝ : ℕ
p q P Q : ℕ → Prop
inst✝ : DecidablePred P
n k : ℕ
ihk : ∀ {m : ℕ}, findGreatest P k = m ↔ m ≤ k ∧ (m ≠ 0 → P m) ∧ ∀ ⦃n : ℕ⦄, m < n → n ≤ k → ¬P n
hk : ¬P (k + 1)
hle : k.succ ≤ k + 1
hP : k.succ ≠ 0 → P k.succ
hm : ∀ ⦃n : ℕ⦄, k.succ < n → n ≤ k + 1 → ¬P n
⊢ False
state_after: no goals