Theorem: toZ_iterate_succ_of_not_isMax
File: Mathlib/Order/SuccPred/LinearLocallyFinite.lean

tactic: let m := (toZ i0 ((succ^[n]) i0)).toNat
state_before: ι : Type u_1
inst✝³ : LinearOrder ι
inst✝² : SuccOrder ι
inst✝¹ : IsSuccArchimedean ι
inst✝ : PredOrder ι
i0 i : ι
n : ℕ
hn : ¬IsMax ((succ^[n]) i0)
⊢ toZ i0 ((succ^[n]) i0) = ↑n

tactic: have h_eq : (succ^[m]) i0 = (succ^[n]) i0 := iterate_succ_toZ _ (le_succ_iterate _ _)
state_before: ι : Type u_1
inst✝³ : LinearOrder ι
inst✝² : SuccOrder ι
inst✝¹ : IsSuccArchimedean ι
inst✝ : PredOrder ι
i0 i : ι
n : ℕ
hn : ¬IsMax ((succ^[n]) i0)
m : ℕ := Int.toNat (toZ i0 ((succ^[n]) i0))
⊢ toZ i0 ((succ^[n]) i0) = ↑n

tactic: by_cases hmn : m = n
state_before: ι : Type u_1
inst✝³ : LinearOrder ι
inst✝² : SuccOrder ι
inst✝¹ : IsSuccArchimedean ι
inst✝ : PredOrder ι
i0 i : ι
n : ℕ
hn : ¬IsMax ((succ^[n]) i0)
m : ℕ := Int.toNat (toZ i0 ((succ^[n]) i0))
h_eq : (succ^[m]) i0 = (succ^[n]) i0
⊢ toZ i0 ((succ^[n]) i0) = ↑n

tactic: suffices : IsMax ((succ^[n]) i0)
state_before: case neg
ι : Type u_1
inst✝³ : LinearOrder ι
inst✝² : SuccOrder ι
inst✝¹ : IsSuccArchimedean ι
inst✝ : PredOrder ι
i0 i : ι
n : ℕ
hn : ¬IsMax ((succ^[n]) i0)
m : ℕ := Int.toNat (toZ i0 ((succ^[n]) i0))
h_eq : (succ^[m]) i0 = (succ^[n]) i0
hmn : ¬m = n
⊢ toZ i0 ((succ^[n]) i0) = ↑n

tactic: exact absurd this hn
state_before: case neg
ι : Type u_1
inst✝³ : LinearOrder ι
inst✝² : SuccOrder ι
inst✝¹ : IsSuccArchimedean ι
inst✝ : PredOrder ι
i0 i : ι
n : ℕ
hn : ¬IsMax ((succ^[n]) i0)
m : ℕ := Int.toNat (toZ i0 ((succ^[n]) i0))
h_eq : (succ^[m]) i0 = (succ^[n]) i0
hmn : ¬m = n
this : IsMax ((succ^[n]) i0)
⊢ toZ i0 ((succ^[n]) i0) = ↑n

case this
ι : Type u_1
inst✝³ : LinearOrder ι
inst✝² : SuccOrder ι
inst✝¹ : IsSuccArchimedean ι
inst✝ : PredOrder ι
i0 i : ι
n : ℕ
hn : ¬IsMax ((succ^[n]) i0)
m : ℕ := Int.toNat (toZ i0 ((succ^[n]) i0))
h_eq : (succ^[m]) i0 = (succ^[n]) i0
hmn : ¬m = n
⊢ IsMax ((succ^[n]) i0)

tactic: exact isMax_iterate_succ_of_eq_of_ne h_eq.symm (Ne.symm hmn)
state_before: case this
ι : Type u_1
inst✝³ : LinearOrder ι
inst✝² : SuccOrder ι
inst✝¹ : IsSuccArchimedean ι
inst✝ : PredOrder ι
i0 i : ι
n : ℕ
hn : ¬IsMax ((succ^[n]) i0)
m : ℕ := Int.toNat (toZ i0 ((succ^[n]) i0))
h_eq : (succ^[m]) i0 = (succ^[n]) i0
hmn : ¬m = n
⊢ IsMax ((succ^[n]) i0)

tactic: nth_rw 2 [← hmn]
state_before: case pos
ι : Type u_1
inst✝³ : LinearOrder ι
inst✝² : SuccOrder ι
inst✝¹ : IsSuccArchimedean ι
inst✝ : PredOrder ι
i0 i : ι
n : ℕ
hn : ¬IsMax ((succ^[n]) i0)
m : ℕ := Int.toNat (toZ i0 ((succ^[n]) i0))
h_eq : (succ^[m]) i0 = (succ^[n]) i0
hmn : m = n
⊢ toZ i0 ((succ^[n]) i0) = ↑n

tactic: rw [Int.toNat_eq_max, toZ_of_ge (le_succ_iterate _ _), max_eq_left]
state_before: case pos
ι : Type u_1
inst✝³ : LinearOrder ι
inst✝² : SuccOrder ι
inst✝¹ : IsSuccArchimedean ι
inst✝ : PredOrder ι
i0 i : ι
n : ℕ
hn : ¬IsMax ((succ^[n]) i0)
m : ℕ := Int.toNat (toZ i0 ((succ^[n]) i0))
h_eq : (succ^[m]) i0 = (succ^[n]) i0
hmn : m = n
⊢ toZ i0 ((succ^[n]) i0) = ↑m

tactic: exact Nat.cast_nonneg _
state_before: case pos
ι : Type u_1
inst✝³ : LinearOrder ι
inst✝² : SuccOrder ι
inst✝¹ : IsSuccArchimedean ι
inst✝ : PredOrder ι
i0 i : ι
n : ℕ
hn : ¬IsMax ((succ^[n]) i0)
m : ℕ := Int.toNat (toZ i0 ((succ^[n]) i0))
h_eq : (succ^[m]) i0 = (succ^[n]) i0
hmn : m = n
⊢ 0 ≤ ↑(Nat.find (_ : ∃ n_1, (succ^[n_1]) i0 = (succ^[n]) i0))