Theorem: List.rotate_reverse
File: Mathlib/Data/List/Rotate.lean

tactic: rw [← reverse_reverse l]
state_before: α : Type u
l : List α
n : ℕ
⊢ rotate (reverse l) n = reverse (rotate l (length l - n % length l))

tactic: simp_rw [reverse_rotate, reverse_reverse, rotate_eq_iff, rotate_rotate, length_rotate,
  length_reverse]
state_before: α : Type u
l : List α
n : ℕ
⊢ rotate (reverse (reverse (reverse l))) n =
    reverse (rotate (reverse (reverse l)) (length (reverse (reverse l)) - n % length (reverse (reverse l))))

tactic: rw [← length_reverse l]
state_before: α : Type u
l : List α
n : ℕ
⊢ reverse l = rotate (reverse l) (length l - (length l - n % length l) % length l + (length l - n % length l))

tactic: let k := n % l.reverse.length
state_before: α : Type u
l : List α
n : ℕ
⊢ reverse l =
    rotate (reverse l)
      (length (reverse l) - (length (reverse l) - n % length (reverse l)) % length (reverse l) +
        (length (reverse l) - n % length (reverse l)))

tactic: cases' hk' : k with k'
state_before: α : Type u
l : List α
n : ℕ
k : ℕ := n % length (reverse l)
⊢ reverse l =
    rotate (reverse l)
      (length (reverse l) - (length (reverse l) - n % length (reverse l)) % length (reverse l) +
        (length (reverse l) - n % length (reverse l)))

tactic: simp_all! [length_reverse, ← rotate_rotate]
state_before: case zero
α : Type u
l : List α
n : ℕ
k : ℕ := n % length (reverse l)
hk' : k = zero
⊢ reverse l =
    rotate (reverse l)
      (length (reverse l) - (length (reverse l) - n % length (reverse l)) % length (reverse l) +
        (length (reverse l) - n % length (reverse l)))

tactic: cases' l with x l
state_before: case succ
α : Type u
l : List α
n : ℕ
k : ℕ := n % length (reverse l)
k' : ℕ
hk' : k = succ k'
⊢ reverse l =
    rotate (reverse l)
      (length (reverse l) - (length (reverse l) - n % length (reverse l)) % length (reverse l) +
        (length (reverse l) - n % length (reverse l)))

tactic: simp
state_before: case succ.nil
α : Type u
n k' : ℕ
k : ℕ := n % length (reverse [])
hk' : k = succ k'
⊢ reverse [] =
    rotate (reverse [])
      (length (reverse []) - (length (reverse []) - n % length (reverse [])) % length (reverse []) +
        (length (reverse []) - n % length (reverse [])))

tactic: rw [Nat.mod_eq_of_lt, tsub_add_cancel_of_le, rotate_length]
state_before: case succ.cons
α : Type u
n k' : ℕ
x : α
l : List α
k : ℕ := n % length (reverse (x :: l))
hk' : k = succ k'
⊢ reverse (x :: l) =
    rotate (reverse (x :: l))
      (length (reverse (x :: l)) -
          (length (reverse (x :: l)) - n % length (reverse (x :: l))) % length (reverse (x :: l)) +
        (length (reverse (x :: l)) - n % length (reverse (x :: l))))

tactic: exact tsub_le_self
state_before: case succ.cons
α : Type u
n k' : ℕ
x : α
l : List α
k : ℕ := n % length (reverse (x :: l))
hk' : k = succ k'
⊢ length (reverse (x :: l)) - n % length (reverse (x :: l)) ≤ length (reverse (x :: l))

tactic: exact tsub_lt_self (by simp) (by simp_all!)
state_before: case succ.cons
α : Type u
n k' : ℕ
x : α
l : List α
k : ℕ := n % length (reverse (x :: l))
hk' : k = succ k'
⊢ length (reverse (x :: l)) - n % length (reverse (x :: l)) < length (reverse (x :: l))

tactic: simp
state_before: α : Type u
n k' : ℕ
x : α
l : List α
k : ℕ := n % length (reverse (x :: l))
hk' : k = succ k'
⊢ 0 < length (reverse (x :: l))

tactic: simp_all!
state_before: α : Type u
n k' : ℕ
x : α
l : List α
k : ℕ := n % length (reverse (x :: l))
hk' : k = succ k'
⊢ 0 < n % length (reverse (x :: l))