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

tactic: rwa [length_insertNth _ _ hn, Nat.lt_succ_iff]
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
a : α
l : List α
x : α
n : ℕ
hn : n ≤ l.length
⊢ n < (insertNth n x l).length
state_after: no goals

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

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

tactic: simp only [length] at hn
state_before: case nil
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
a x : α
n : ℕ
hn : n ≤ [].length
hn' : optParam (n < (insertNth n x []).length) ⋯
⊢ (insertNth n x [])[n] = x
state_after: case nil
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
a x : α
n : ℕ
hn : n ≤ 0
hn' : optParam (n < (insertNth n x []).length) ⋯
⊢ (insertNth n x [])[n] = x

tactic: cases hn
state_before: case nil
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
a x : α
n : ℕ
hn : n ≤ 0
hn' : optParam (n < (insertNth n x []).length) ⋯
⊢ (insertNth n x [])[n] = x
state_after: case nil.refl
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
a x : α
hn' : optParam (0 < (insertNth 0 x []).length) ⋯
⊢ (insertNth 0 x [])[0] = x

tactic: simp only [insertNth_zero, getElem_singleton]
state_before: case nil.refl
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
a x : α
hn' : optParam (0 < (insertNth 0 x []).length) ⋯
⊢ (insertNth 0 x [])[0] = x
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 : ℕ) (hn : n ≤ tl.length) (hn' : optParam (n < (insertNth n x tl).length) ⋯), (insertNth n x tl)[n] = x
n : ℕ
hn : n ≤ (hd :: tl).length
hn' : optParam (n < (insertNth n x (hd :: tl)).length) ⋯
⊢ (insertNth n x (hd :: tl))[n] = x
state_after: case cons.zero
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
a x hd : α
tl : List α
IH : ∀ (n : ℕ) (hn : n ≤ tl.length) (hn' : optParam (n < (insertNth n x tl).length) ⋯), (insertNth n x tl)[n] = x
hn : 0 ≤ (hd :: tl).length
hn' : optParam (0 < (insertNth 0 x (hd :: tl)).length) ⋯
⊢ (insertNth 0 x (hd :: tl))[0] = x

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

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 : ℕ) (hn : n ≤ tl.length) (hn' : optParam (n < (insertNth n x tl).length) ⋯), (insertNth n x tl)[n] = x
hn : 0 ≤ (hd :: tl).length
hn' : optParam (0 < (insertNth 0 x (hd :: tl)).length) ⋯
⊢ (insertNth 0 x (hd :: tl))[0] = x
state_after: no goals

tactic: simp only [Nat.succ_le_succ_iff, length] at hn
state_before: case cons.succ
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
a x hd : α
tl : List α
IH : ∀ (n : ℕ) (hn : n ≤ tl.length) (hn' : optParam (n < (insertNth n x tl).length) ⋯), (insertNth n x tl)[n] = x
n✝ : ℕ
hn : n✝ + 1 ≤ (hd :: tl).length
hn' : optParam (n✝ + 1 < (insertNth (n✝ + 1) x (hd :: tl)).length) ⋯
⊢ (insertNth (n✝ + 1) x (hd :: tl))[n✝ + 1] = x
state_after: case cons.succ
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
a x hd : α
tl : List α
IH : ∀ (n : ℕ) (hn : n ≤ tl.length) (hn' : optParam (n < (insertNth n x tl).length) ⋯), (insertNth n x tl)[n] = x
n✝ : ℕ
hn✝ : n✝ + 1 ≤ (hd :: tl).length
hn' : optParam (n✝ + 1 < (insertNth (n✝ + 1) x (hd :: tl)).length) ⋯
hn : n✝ ≤ tl.length
⊢ (insertNth (n✝ + 1) x (hd :: tl))[n✝ + 1] = x

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