Theorem: List.get?_rotate
File: Mathlib/Data/List/Rotate.lean

tactic: rw [rotate_eq_drop_append_take_mod]
state_before: α : Type u
l : List α
n m : ℕ
hml : m < length l
⊢ get? (rotate l n) m = get? l ((m + n) % length l)

tactic: rcases lt_or_le m (l.drop (n % l.length)).length with hm | hm
state_before: α : Type u
l : List α
n m : ℕ
hml : m < length l
⊢ get? (drop (n % length l) l ++ take (n % length l) l) m = get? l ((m + n) % length l)

tactic: rw [get?_append hm, get?_drop, add_comm m, ← mod_add_mod]
state_before: case inl
α : Type u
l : List α
n m : ℕ
hml : m < length l
hm : m < length (drop (n % length l) l)
⊢ get? (drop (n % length l) l ++ take (n % length l) l) m = get? l ((m + n) % length l)

tactic: rw [length_drop, lt_tsub_iff_left] at hm
state_before: case inl
α : Type u
l : List α
n m : ℕ
hml : m < length l
hm : m < length (drop (n % length l) l)
⊢ get? l (n % length l + m) = get? l ((n % length l + m) % length l)

tactic: rw [mod_eq_of_lt hm]
state_before: case inl
α : Type u
l : List α
n m : ℕ
hml : m < length l
hm✝ : m < length l - n % length l
hm : n % length l + m < length l
⊢ get? l (n % length l + m) = get? l ((n % length l + m) % length l)

tactic: have hlt : n % length l < length l := mod_lt _ (m.zero_le.trans_lt hml)
state_before: case inr
α : Type u
l : List α
n m : ℕ
hml : m < length l
hm : length (drop (n % length l) l) ≤ m
⊢ get? (drop (n % length l) l ++ take (n % length l) l) m = get? l ((m + n) % length l)

tactic: rw [get?_append_right hm, get?_take, length_drop]
state_before: case inr
α : Type u
l : List α
n m : ℕ
hml : m < length l
hm : length (drop (n % length l) l) ≤ m
hlt : n % length l < length l
⊢ get? (drop (n % length l) l ++ take (n % length l) l) m = get? l ((m + n) % length l)

tactic: congr 1
state_before: case inr
α : Type u
l : List α
n m : ℕ
hml : m < length l
hm : length (drop (n % length l) l) ≤ m
hlt : n % length l < length l
⊢ get? l (m - (length l - n % length l)) = get? l ((m + n) % length l)

tactic: rw [length_drop] at hm
state_before: case inr.e_a
α : Type u
l : List α
n m : ℕ
hml : m < length l
hm : length (drop (n % length l) l) ≤ m
hlt : n % length l < length l
⊢ m - (length l - n % length l) = (m + n) % length l

tactic: have hm' := tsub_le_iff_left.1 hm
state_before: case inr.e_a
α : Type u
l : List α
n m : ℕ
hml : m < length l
hm : length l - n % length l ≤ m
hlt : n % length l < length l
⊢ m - (length l - n % length l) = (m + n) % length l

tactic: have : n % length l + m - length l < length l
state_before: case inr.e_a
α : Type u
l : List α
n m : ℕ
hml : m < length l
hm : length l - n % length l ≤ m
hlt : n % length l < length l
hm' : length l ≤ n % length l + m
⊢ m - (length l - n % length l) = (m + n) % length l

tactic: conv_rhs => rw [add_comm m, ← mod_add_mod, mod_eq_sub_mod hm', mod_eq_of_lt this]
state_before: case inr.e_a
α : Type u
l : List α
n m : ℕ
hml : m < length l
hm : length l - n % length l ≤ m
hlt : n % length l < length l
hm' : length l ≤ n % length l + m
this : n % length l + m - length l < length l
⊢ m - (length l - n % length l) = (m + n) % length l

tactic: rw [← add_right_inj l.length, ← add_tsub_assoc_of_le, add_tsub_tsub_cancel,
  add_tsub_cancel_of_le, add_comm]
state_before: case inr.e_a
α : Type u
l : List α
n m : ℕ
hml : m < length l
hm : length l - n % length l ≤ m
hlt : n % length l < length l
hm' : length l ≤ n % length l + m
this : n % length l + m - length l < length l
⊢ m - (length l - n % length l) = n % length l + m - length l

tactic: exacts [hm', hlt.le, hm]
state_before: case inr.e_a
α : Type u
l : List α
n m : ℕ
hml : m < length l
hm : length l - n % length l ≤ m
hlt : n % length l < length l
hm' : length l ≤ n % length l + m
this : n % length l + m - length l < length l
⊢ length l ≤ n % length l + m

case inr.e_a
α : Type u
l : List α
n m : ℕ
hml : m < length l
hm : length l - n % length l ≤ m
hlt : n % length l < length l
hm' : length l ≤ n % length l + m
this : n % length l + m - length l < length l
⊢ n % length l ≤ length l

case inr.e_a.h
α : Type u
l : List α
n m : ℕ
hml : m < length l
hm : length l - n % length l ≤ m
hlt : n % length l < length l
hm' : length l ≤ n % length l + m
this : n % length l + m - length l < length l
⊢ length l - n % length l ≤ m

tactic: rw [tsub_lt_iff_left hm']
state_before: case this
α : Type u
l : List α
n m : ℕ
hml : m < length l
hm : length l - n % length l ≤ m
hlt : n % length l < length l
hm' : length l ≤ n % length l + m
⊢ n % length l + m - length l < length l

tactic: exact Nat.add_lt_add hlt hml
state_before: case this
α : Type u
l : List α
n m : ℕ
hml : m < length l
hm : length l - n % length l ≤ m
hlt : n % length l < length l
hm' : length l ≤ n % length l + m
⊢ n % length l + m < length l + length l

tactic: rwa [tsub_lt_iff_left hm, length_drop, tsub_add_cancel_of_le hlt.le]
state_before: case inr
α : Type u
l : List α
n m : ℕ
hml : m < length l
hm : length (drop (n % length l) l) ≤ m
hlt : n % length l < length l
⊢ m - length (drop (n % length l) l) < n % length l