Theorem: List.getElem_insertNth_add_succ
File: Mathlib/Data/List/InsertNth.lean

tactic: rwa [length_insertNth _ _ (by omega), Nat.succ_lt_succ_iff]
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
a : α
l : List α
x : α
n k : ℕ
hk' : n + k < l.length
⊢ n + k + 1 < (insertNth n x l).length
state_after: no goals

tactic: omega
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
a : α
l : List α
x : α
n k : ℕ
hk' : n + k < l.length
⊢ n ≤ l.length
state_after: no goals

tactic: induction' l with hd tl IH generalizing n k
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
a : α
l : List α
x : α
n k : ℕ
hk' : n + k < l.length
hk : optParam (n + k + 1 < (insertNth n x l).length) ⋯
⊢ (insertNth n x l)[n + k + 1] = l[n + k]
state_after: case nil
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
a x : α
n k : ℕ
hk' : n + k < [].length
hk : optParam (n + k + 1 < (insertNth n x []).length) ⋯
⊢ (insertNth n x [])[n + k + 1] = [][n + k]

case cons
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
a x hd : α
tl : List α
IH :
  ∀ (n k : ℕ) (hk' : n + k < tl.length) (hk : optParam (n + k + 1 < (insertNth n x tl).length) ⋯),
    (insertNth n x tl)[n + k + 1] = tl[n + k]
n k : ℕ
hk' : n + k < (hd :: tl).length
hk : optParam (n + k + 1 < (insertNth n x (hd :: tl)).length) ⋯
⊢ (insertNth n x (hd :: tl))[n + k + 1] = (hd :: tl)[n + k]

tactic: simp at hk'
state_before: case nil
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
a x : α
n k : ℕ
hk' : n + k < [].length
hk : optParam (n + k + 1 < (insertNth n x []).length) ⋯
⊢ (insertNth n x [])[n + k + 1] = [][n + k]
state_after: no goals

tactic: cases n
state_before: case cons
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
a x hd : α
tl : List α
IH :
  ∀ (n k : ℕ) (hk' : n + k < tl.length) (hk : optParam (n + k + 1 < (insertNth n x tl).length) ⋯),
    (insertNth n x tl)[n + k + 1] = tl[n + k]
n k : ℕ
hk' : n + k < (hd :: tl).length
hk : optParam (n + k + 1 < (insertNth n x (hd :: tl)).length) ⋯
⊢ (insertNth n x (hd :: tl))[n + k + 1] = (hd :: tl)[n + k]
state_after: case cons.zero
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
a x hd : α
tl : List α
IH :
  ∀ (n k : ℕ) (hk' : n + k < tl.length) (hk : optParam (n + k + 1 < (insertNth n x tl).length) ⋯),
    (insertNth n x tl)[n + k + 1] = tl[n + k]
k : ℕ
hk' : 0 + k < (hd :: tl).length
hk : optParam (0 + k + 1 < (insertNth 0 x (hd :: tl)).length) ⋯
⊢ (insertNth 0 x (hd :: tl))[0 + k + 1] = (hd :: tl)[0 + k]

case cons.succ
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
a x hd : α
tl : List α
IH :
  ∀ (n k : ℕ) (hk' : n + k < tl.length) (hk : optParam (n + k + 1 < (insertNth n x tl).length) ⋯),
    (insertNth n x tl)[n + k + 1] = tl[n + k]
k n✝ : ℕ
hk' : n✝ + 1 + k < (hd :: tl).length
hk : optParam (n✝ + 1 + k + 1 < (insertNth (n✝ + 1) x (hd :: tl)).length) ⋯
⊢ (insertNth (n✝ + 1) x (hd :: tl))[n✝ + 1 + k + 1] = (hd :: tl)[n✝ + 1 + k]

tactic: simp
state_before: case cons.zero
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
a x hd : α
tl : List α
IH :
  ∀ (n k : ℕ) (hk' : n + k < tl.length) (hk : optParam (n + k + 1 < (insertNth n x tl).length) ⋯),
    (insertNth n x tl)[n + k + 1] = tl[n + k]
k : ℕ
hk' : 0 + k < (hd :: tl).length
hk : optParam (0 + k + 1 < (insertNth 0 x (hd :: tl)).length) ⋯
⊢ (insertNth 0 x (hd :: tl))[0 + k + 1] = (hd :: tl)[0 + k]
state_after: no goals

tactic: simpa [Nat.add_right_comm] using IH _ _ _
state_before: case cons.succ
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
a x hd : α
tl : List α
IH :
  ∀ (n k : ℕ) (hk' : n + k < tl.length) (hk : optParam (n + k + 1 < (insertNth n x tl).length) ⋯),
    (insertNth n x tl)[n + k + 1] = tl[n + k]
k n✝ : ℕ
hk' : n✝ + 1 + k < (hd :: tl).length
hk : optParam (n✝ + 1 + k + 1 < (insertNth (n✝ + 1) x (hd :: tl)).length) ⋯
⊢ (insertNth (n✝ + 1) x (hd :: tl))[n✝ + 1 + k + 1] = (hd :: tl)[n✝ + 1 + k]
state_after: no goals