Theorem: Fin.succAbove_predAbove
File: Mathlib/Data/Fin/Basic.lean

tactic: dsimp [predAbove, succAbove]
state_before: n m : ℕ
p : Fin n
i : Fin (n + 1)
h : i ≠ ↑castSucc p
⊢ ↑(succAbove (↑castSucc p)) (predAbove p i) = i

tactic: rcases p with ⟨p, _⟩
state_before: n m : ℕ
p : Fin n
i : Fin (n + 1)
h : i ≠ ↑castSucc p
⊢ (if ↑castSucc (if h : ↑castSucc p < i then pred i (_ : i ≠ 0) else castLT i (_ : ↑i < n)) < ↑castSucc p then
      ↑castSucc (if h : ↑castSucc p < i then pred i (_ : i ≠ 0) else castLT i (_ : ↑i < n))
    else succ (if h : ↑castSucc p < i then pred i (_ : i ≠ 0) else castLT i (_ : ↑i < n))) =
    i

tactic: rcases i with ⟨i, _⟩
state_before: case mk
n m : ℕ
i : Fin (n + 1)
p : ℕ
isLt✝ : p < n
h : i ≠ ↑castSucc { val := p, isLt := isLt✝ }
⊢ (if
        ↑castSucc
            (if h : ↑castSucc { val := p, isLt := isLt✝ } < i then pred i (_ : i ≠ 0) else castLT i (_ : ↑i < n)) <
          ↑castSucc { val := p, isLt := isLt✝ } then
      ↑castSucc (if h : ↑castSucc { val := p, isLt := isLt✝ } < i then pred i (_ : i ≠ 0) else castLT i (_ : ↑i < n))
    else succ (if h : ↑castSucc { val := p, isLt := isLt✝ } < i then pred i (_ : i ≠ 0) else castLT i (_ : ↑i < n))) =
    i

tactic: cases' lt_or_le i p with H H
state_before: case mk.mk
n m p : ℕ
isLt✝¹ : p < n
i : ℕ
isLt✝ : i < n + 1
h : { val := i, isLt := isLt✝ } ≠ ↑castSucc { val := p, isLt := isLt✝¹ }
⊢ (if
        ↑castSucc
            (if h : ↑castSucc { val := p, isLt := isLt✝¹ } < { val := i, isLt := isLt✝ } then
              pred { val := i, isLt := isLt✝ } (_ : { val := i, isLt := isLt✝ } ≠ 0)
            else castLT { val := i, isLt := isLt✝ } (_ : ↑{ val := i, isLt := isLt✝ } < n)) <
          ↑castSucc { val := p, isLt := isLt✝¹ } then
      ↑castSucc
        (if h : ↑castSucc { val := p, isLt := isLt✝¹ } < { val := i, isLt := isLt✝ } then
          pred { val := i, isLt := isLt✝ } (_ : { val := i, isLt := isLt✝ } ≠ 0)
        else castLT { val := i, isLt := isLt✝ } (_ : ↑{ val := i, isLt := isLt✝ } < n))
    else
      succ
        (if h : ↑castSucc { val := p, isLt := isLt✝¹ } < { val := i, isLt := isLt✝ } then
          pred { val := i, isLt := isLt✝ } (_ : { val := i, isLt := isLt✝ } ≠ 0)
        else castLT { val := i, isLt := isLt✝ } (_ : ↑{ val := i, isLt := isLt✝ } < n))) =
    { val := i, isLt := isLt✝ }

tactic: rw [dif_neg]
state_before: case mk.mk.inl
n m p : ℕ
isLt✝¹ : p < n
i : ℕ
isLt✝ : i < n + 1
h : { val := i, isLt := isLt✝ } ≠ ↑castSucc { val := p, isLt := isLt✝¹ }
H : i < p
⊢ (if
        ↑castSucc
            (if h : ↑castSucc { val := p, isLt := isLt✝¹ } < { val := i, isLt := isLt✝ } then
              pred { val := i, isLt := isLt✝ } (_ : { val := i, isLt := isLt✝ } ≠ 0)
            else castLT { val := i, isLt := isLt✝ } (_ : ↑{ val := i, isLt := isLt✝ } < n)) <
          ↑castSucc { val := p, isLt := isLt✝¹ } then
      ↑castSucc
        (if h : ↑castSucc { val := p, isLt := isLt✝¹ } < { val := i, isLt := isLt✝ } then
          pred { val := i, isLt := isLt✝ } (_ : { val := i, isLt := isLt✝ } ≠ 0)
        else castLT { val := i, isLt := isLt✝ } (_ : ↑{ val := i, isLt := isLt✝ } < n))
    else
      succ
        (if h : ↑castSucc { val := p, isLt := isLt✝¹ } < { val := i, isLt := isLt✝ } then
          pred { val := i, isLt := isLt✝ } (_ : { val := i, isLt := isLt✝ } ≠ 0)
        else castLT { val := i, isLt := isLt✝ } (_ : ↑{ val := i, isLt := isLt✝ } < n))) =
    { val := i, isLt := isLt✝ }

tactic: rw [if_pos]
state_before: case mk.mk.inl
n m p : ℕ
isLt✝¹ : p < n
i : ℕ
isLt✝ : i < n + 1
h : { val := i, isLt := isLt✝ } ≠ ↑castSucc { val := p, isLt := isLt✝¹ }
H : i < p
⊢ (if
        ↑castSucc (castLT { val := i, isLt := isLt✝ } (_ : ↑{ val := i, isLt := isLt✝ } < n)) <
          ↑castSucc { val := p, isLt := isLt✝¹ } then
      ↑castSucc (castLT { val := i, isLt := isLt✝ } (_ : ↑{ val := i, isLt := isLt✝ } < n))
    else succ (castLT { val := i, isLt := isLt✝ } (_ : ↑{ val := i, isLt := isLt✝ } < n))) =
    { val := i, isLt := isLt✝ }

case mk.mk.inl.hnc
n m p : ℕ
isLt✝¹ : p < n
i : ℕ
isLt✝ : i < n + 1
h : { val := i, isLt := isLt✝ } ≠ ↑castSucc { val := p, isLt := isLt✝¹ }
H : i < p
⊢ ¬↑castSucc { val := p, isLt := isLt✝¹ } < { val := i, isLt := isLt✝ }

tactic: rfl
state_before: case mk.mk.inl
n m p : ℕ
isLt✝¹ : p < n
i : ℕ
isLt✝ : i < n + 1
h : { val := i, isLt := isLt✝ } ≠ ↑castSucc { val := p, isLt := isLt✝¹ }
H : i < p
⊢ ↑castSucc (castLT { val := i, isLt := isLt✝ } (_ : ↑{ val := i, isLt := isLt✝ } < n)) = { val := i, isLt := isLt✝ }

case mk.mk.inl.hc
n m p : ℕ
isLt✝¹ : p < n
i : ℕ
isLt✝ : i < n + 1
h : { val := i, isLt := isLt✝ } ≠ ↑castSucc { val := p, isLt := isLt✝¹ }
H : i < p
⊢ ↑castSucc (castLT { val := i, isLt := isLt✝ } (_ : ↑{ val := i, isLt := isLt✝ } < n)) <
    ↑castSucc { val := p, isLt := isLt✝¹ }

case mk.mk.inl.hnc
n m p : ℕ
isLt✝¹ : p < n
i : ℕ
isLt✝ : i < n + 1
h : { val := i, isLt := isLt✝ } ≠ ↑castSucc { val := p, isLt := isLt✝¹ }
H : i < p
⊢ ¬↑castSucc { val := p, isLt := isLt✝¹ } < { val := i, isLt := isLt✝ }

case mk.mk.inl.hnc
n m p : ℕ
isLt✝¹ : p < n
i : ℕ
isLt✝ : i < n + 1
h : { val := i, isLt := isLt✝ } ≠ ↑castSucc { val := p, isLt := isLt✝¹ }
H : i < p
⊢ ¬↑castSucc { val := p, isLt := isLt✝¹ } < { val := i, isLt := isLt✝ }

tactic: exact H
state_before: case mk.mk.inl.hc
n m p : ℕ
isLt✝¹ : p < n
i : ℕ
isLt✝ : i < n + 1
h : { val := i, isLt := isLt✝ } ≠ ↑castSucc { val := p, isLt := isLt✝¹ }
H : i < p
⊢ ↑castSucc (castLT { val := i, isLt := isLt✝ } (_ : ↑{ val := i, isLt := isLt✝ } < n)) <
    ↑castSucc { val := p, isLt := isLt✝¹ }

case mk.mk.inl.hnc
n m p : ℕ
isLt✝¹ : p < n
i : ℕ
isLt✝ : i < n + 1
h : { val := i, isLt := isLt✝ } ≠ ↑castSucc { val := p, isLt := isLt✝¹ }
H : i < p
⊢ ¬↑castSucc { val := p, isLt := isLt✝¹ } < { val := i, isLt := isLt✝ }

case mk.mk.inl.hnc
n m p : ℕ
isLt✝¹ : p < n
i : ℕ
isLt✝ : i < n + 1
h : { val := i, isLt := isLt✝ } ≠ ↑castSucc { val := p, isLt := isLt✝¹ }
H : i < p
⊢ ¬↑castSucc { val := p, isLt := isLt✝¹ } < { val := i, isLt := isLt✝ }

tactic: simp
state_before: case mk.mk.inl.hnc
n m p : ℕ
isLt✝¹ : p < n
i : ℕ
isLt✝ : i < n + 1
h : { val := i, isLt := isLt✝ } ≠ ↑castSucc { val := p, isLt := isLt✝¹ }
H : i < p
⊢ ¬↑castSucc { val := p, isLt := isLt✝¹ } < { val := i, isLt := isLt✝ }

case mk.mk.inl.hnc
n m p : ℕ
isLt✝¹ : p < n
i : ℕ
isLt✝ : i < n + 1
h : { val := i, isLt := isLt✝ } ≠ ↑castSucc { val := p, isLt := isLt✝¹ }
H : i < p
⊢ ¬↑castSucc { val := p, isLt := isLt✝¹ } < { val := i, isLt := isLt✝ }

tactic: apply le_of_lt H
state_before: case mk.mk.inl.hnc
n m p : ℕ
isLt✝¹ : p < n
i : ℕ
isLt✝ : i < n + 1
h : { val := i, isLt := isLt✝ } ≠ ↑castSucc { val := p, isLt := isLt✝¹ }
H : i < p
⊢ i ≤ p

tactic: rw [dif_pos]
state_before: case mk.mk.inr
n m p : ℕ
isLt✝¹ : p < n
i : ℕ
isLt✝ : i < n + 1
h : { val := i, isLt := isLt✝ } ≠ ↑castSucc { val := p, isLt := isLt✝¹ }
H : p ≤ i
⊢ (if
        ↑castSucc
            (if h : ↑castSucc { val := p, isLt := isLt✝¹ } < { val := i, isLt := isLt✝ } then
              pred { val := i, isLt := isLt✝ } (_ : { val := i, isLt := isLt✝ } ≠ 0)
            else castLT { val := i, isLt := isLt✝ } (_ : ↑{ val := i, isLt := isLt✝ } < n)) <
          ↑castSucc { val := p, isLt := isLt✝¹ } then
      ↑castSucc
        (if h : ↑castSucc { val := p, isLt := isLt✝¹ } < { val := i, isLt := isLt✝ } then
          pred { val := i, isLt := isLt✝ } (_ : { val := i, isLt := isLt✝ } ≠ 0)
        else castLT { val := i, isLt := isLt✝ } (_ : ↑{ val := i, isLt := isLt✝ } < n))
    else
      succ
        (if h : ↑castSucc { val := p, isLt := isLt✝¹ } < { val := i, isLt := isLt✝ } then
          pred { val := i, isLt := isLt✝ } (_ : { val := i, isLt := isLt✝ } ≠ 0)
        else castLT { val := i, isLt := isLt✝ } (_ : ↑{ val := i, isLt := isLt✝ } < n))) =
    { val := i, isLt := isLt✝ }

tactic: rw [if_neg]
state_before: case mk.mk.inr
n m p : ℕ
isLt✝¹ : p < n
i : ℕ
isLt✝ : i < n + 1
h : { val := i, isLt := isLt✝ } ≠ ↑castSucc { val := p, isLt := isLt✝¹ }
H : p ≤ i
⊢ (if
        ↑castSucc (pred { val := i, isLt := isLt✝ } (_ : { val := i, isLt := isLt✝ } ≠ 0)) <
          ↑castSucc { val := p, isLt := isLt✝¹ } then
      ↑castSucc (pred { val := i, isLt := isLt✝ } (_ : { val := i, isLt := isLt✝ } ≠ 0))
    else succ (pred { val := i, isLt := isLt✝ } (_ : { val := i, isLt := isLt✝ } ≠ 0))) =
    { val := i, isLt := isLt✝ }

case mk.mk.inr.hc
n m p : ℕ
isLt✝¹ : p < n
i : ℕ
isLt✝ : i < n + 1
h : { val := i, isLt := isLt✝ } ≠ ↑castSucc { val := p, isLt := isLt✝¹ }
H : p ≤ i
⊢ ↑castSucc { val := p, isLt := isLt✝¹ } < { val := i, isLt := isLt✝ }

tactic: simp
state_before: case mk.mk.inr
n m p : ℕ
isLt✝¹ : p < n
i : ℕ
isLt✝ : i < n + 1
h : { val := i, isLt := isLt✝ } ≠ ↑castSucc { val := p, isLt := isLt✝¹ }
H : p ≤ i
⊢ succ (pred { val := i, isLt := isLt✝ } (_ : { val := i, isLt := isLt✝ } ≠ 0)) = { val := i, isLt := isLt✝ }

tactic: simp only [pred, Fin.mk_lt_mk, not_lt]
state_before: case mk.mk.inr.hnc
n m p : ℕ
isLt✝¹ : p < n
i : ℕ
isLt✝ : i < n + 1
h : { val := i, isLt := isLt✝ } ≠ ↑castSucc { val := p, isLt := isLt✝¹ }
H : p ≤ i
⊢ ¬↑castSucc (pred { val := i, isLt := isLt✝ } (_ : { val := i, isLt := isLt✝ } ≠ 0)) <
      ↑castSucc { val := p, isLt := isLt✝¹ }

tactic: exact Nat.le_pred_of_lt (h.symm.lt_of_le H)
state_before: case mk.mk.inr.hnc
n m p : ℕ
isLt✝¹ : p < n
i : ℕ
isLt✝ : i < n + 1
h : { val := i, isLt := isLt✝ } ≠ ↑castSucc { val := p, isLt := isLt✝¹ }
H : p ≤ i
⊢ ↑castSucc { val := p, isLt := isLt✝¹ } ≤ ↑castSucc { val := Nat.pred i, isLt := (_ : Nat.pred i < Nat.pred (n + 1)) }

tactic: exact lt_of_le_of_ne H h.symm
state_before: case mk.mk.inr.hc
n m p : ℕ
isLt✝¹ : p < n
i : ℕ
isLt✝ : i < n + 1
h : { val := i, isLt := isLt✝ } ≠ ↑castSucc { val := p, isLt := isLt✝¹ }
H : p ≤ i
⊢ ↑castSucc { val := p, isLt := isLt✝¹ } < { val := i, isLt := isLt✝ }