Theorem: Fin.cycleRange_of_le
File: Mathlib/GroupTheory/Perm/Fin.lean

tactic: cases n
state_before: n : ℕ
i j : Fin n.succ
h : j ≤ i
⊢ i.cycleRange j = if j = i then 0 else j + 1
state_after: case zero
i j : Fin (Nat.succ 0)
h : j ≤ i
⊢ i.cycleRange j = if j = i then 0 else j + 1

case succ
n✝ : ℕ
i j : Fin (n✝ + 1).succ
h : j ≤ i
⊢ i.cycleRange j = if j = i then 0 else j + 1

tactic: have : j = (Fin.castLE (Nat.succ_le_of_lt i.is_lt))
  ⟨j, lt_of_le_of_lt h (Nat.lt_succ_self i)⟩ := by simp
state_before: case succ
n✝ : ℕ
i j : Fin (n✝ + 1).succ
h : j ≤ i
⊢ i.cycleRange j = if j = i then 0 else j + 1
state_after: case succ
n✝ : ℕ
i j : Fin (n✝ + 1).succ
h : j ≤ i
this : j = castLE ⋯ ⟨↑j, ⋯⟩
⊢ i.cycleRange j = if j = i then 0 else j + 1

tactic: ext
state_before: case succ
n✝ : ℕ
i j : Fin (n✝ + 1).succ
h : j ≤ i
this : j = castLE ⋯ ⟨↑j, ⋯⟩
⊢ i.cycleRange j = if j = i then 0 else j + 1
state_after: case succ.h
n✝ : ℕ
i j : Fin (n✝ + 1).succ
h : j ≤ i
this : j = castLE ⋯ ⟨↑j, ⋯⟩
⊢ ↑(i.cycleRange j) = ↑(if j = i then 0 else j + 1)

tactic: erw [this, cycleRange, ofLeftInverse'_eq_ofInjective, ←
  Function.Embedding.toEquivRange_eq_ofInjective, ← viaFintypeEmbedding,
  viaFintypeEmbedding_apply_image, Function.Embedding.coeFn_mk,
  coe_castLE, coe_finRotate]
state_before: case succ.h
n✝ : ℕ
i j : Fin (n✝ + 1).succ
h : j ≤ i
this : j = castLE ⋯ ⟨↑j, ⋯⟩
⊢ ↑(i.cycleRange j) = ↑(if j = i then 0 else j + 1)
state_after: case succ.h
n✝ : ℕ
i j : Fin (n✝ + 1).succ
h : j ≤ i
this : j = castLE ⋯ ⟨↑j, ⋯⟩
⊢ (if ⟨↑j, ⋯⟩ = last ↑i then 0 else ↑⟨↑j, ⋯⟩ + 1) = ↑(if castLE ⋯ ⟨↑j, ⋯⟩ = i then 0 else castLE ⋯ ⟨↑j, ⋯⟩ + 1)

tactic: simp only [Fin.ext_iff, val_last, val_mk, val_zero, Fin.eta, castLE_mk]
state_before: case succ.h
n✝ : ℕ
i j : Fin (n✝ + 1).succ
h : j ≤ i
this : j = castLE ⋯ ⟨↑j, ⋯⟩
⊢ (if ⟨↑j, ⋯⟩ = last ↑i then 0 else ↑⟨↑j, ⋯⟩ + 1) = ↑(if castLE ⋯ ⟨↑j, ⋯⟩ = i then 0 else castLE ⋯ ⟨↑j, ⋯⟩ + 1)
state_after: case succ.h
n✝ : ℕ
i j : Fin (n✝ + 1).succ
h : j ≤ i
this : j = castLE ⋯ ⟨↑j, ⋯⟩
⊢ (if ↑j = ↑i then 0 else ↑j + 1) = ↑(if ↑j = ↑i then 0 else j + 1)

tactic: split_ifs with heq
state_before: case succ.h
n✝ : ℕ
i j : Fin (n✝ + 1).succ
h : j ≤ i
this : j = castLE ⋯ ⟨↑j, ⋯⟩
⊢ (if ↑j = ↑i then 0 else ↑j + 1) = ↑(if ↑j = ↑i then 0 else j + 1)
state_after: case pos
n✝ : ℕ
i j : Fin (n✝ + 1).succ
h : j ≤ i
this : j = castLE ⋯ ⟨↑j, ⋯⟩
heq : ↑j = ↑i
⊢ 0 = ↑0

case neg
n✝ : ℕ
i j : Fin (n✝ + 1).succ
h : j ≤ i
this : j = castLE ⋯ ⟨↑j, ⋯⟩
heq : ¬↑j = ↑i
⊢ ↑j + 1 = ↑(j + 1)

tactic: exact Subsingleton.elim (α := Fin 1) _ _
state_before: case zero
i j : Fin (Nat.succ 0)
h : j ≤ i
⊢ i.cycleRange j = if j = i then 0 else j + 1
state_after: no goals

tactic: simp
state_before: n✝ : ℕ
i j : Fin (n✝ + 1).succ
h : j ≤ i
⊢ j = castLE ⋯ ⟨↑j, ⋯⟩
state_after: no goals

tactic: rfl
state_before: case pos
n✝ : ℕ
i j : Fin (n✝ + 1).succ
h : j ≤ i
this : j = castLE ⋯ ⟨↑j, ⋯⟩
heq : ↑j = ↑i
⊢ 0 = ↑0
state_after: no goals

tactic: rw [Fin.val_add_one_of_lt]
state_before: case neg
n✝ : ℕ
i j : Fin (n✝ + 1).succ
h : j ≤ i
this : j = castLE ⋯ ⟨↑j, ⋯⟩
heq : ¬↑j = ↑i
⊢ ↑j + 1 = ↑(j + 1)
state_after: case neg
n✝ : ℕ
i j : Fin (n✝ + 1).succ
h : j ≤ i
this : j = castLE ⋯ ⟨↑j, ⋯⟩
heq : ¬↑j = ↑i
⊢ j < last (n✝ + 1)

tactic: exact lt_of_lt_of_le (lt_of_le_of_ne h (mt (congr_arg _) heq)) (le_last i)
state_before: case neg
n✝ : ℕ
i j : Fin (n✝ + 1).succ
h : j ≤ i
this : j = castLE ⋯ ⟨↑j, ⋯⟩
heq : ¬↑j = ↑i
⊢ j < last (n✝ + 1)
state_after: no goals