Theorem: List.injOn_insertNth_index_of_not_mem
File: Mathlib/Data/List/Lemmas.lean

tactic: induction' l with hd tl IH
state_before: α : Type u_1
β : Type ?u.14
γ : Type ?u.17
l : List α
x : α
hx : ¬x ∈ l
⊢ Set.InjOn (fun k => insertNth k x l) {n | n ≤ length l}

tactic: intro n hn m hm _
state_before: case nil
α : Type u_1
β : Type ?u.14
γ : Type ?u.17
l : List α
x : α
hx✝ : ¬x ∈ l
hx : ¬x ∈ []
⊢ Set.InjOn (fun k => insertNth k x []) {n | n ≤ length []}

tactic: simp only [Set.mem_singleton_iff, Set.setOf_eq_eq_singleton,
  length, nonpos_iff_eq_zero] at hn hm
state_before: case nil
α : Type u_1
β : Type ?u.14
γ : Type ?u.17
l : List α
x : α
hx✝ : ¬x ∈ l
hx : ¬x ∈ []
n : ℕ
hn : n ∈ {n | n ≤ length []}
m : ℕ
hm : m ∈ {n | n ≤ length []}
a✝ : (fun k => insertNth k x []) n = (fun k => insertNth k x []) m
⊢ n = m

tactic: simp [hn, hm]
state_before: case nil
α : Type u_1
β : Type ?u.14
γ : Type ?u.17
l : List α
x : α
hx✝ : ¬x ∈ l
hx : ¬x ∈ []
n m : ℕ
a✝ : (fun k => insertNth k x []) n = (fun k => insertNth k x []) m
hn : n = 0
hm : m = 0
⊢ n = m

tactic: intro n hn m hm h
state_before: case cons
α : Type u_1
β : Type ?u.14
γ : Type ?u.17
l : List α
x : α
hx✝ : ¬x ∈ l
hd : α
tl : List α
IH : ¬x ∈ tl → Set.InjOn (fun k => insertNth k x tl) {n | n ≤ length tl}
hx : ¬x ∈ hd :: tl
⊢ Set.InjOn (fun k => insertNth k x (hd :: tl)) {n | n ≤ length (hd :: tl)}

tactic: simp only [length, Set.mem_setOf_eq] at hn hm
state_before: case cons
α : Type u_1
β : Type ?u.14
γ : Type ?u.17
l : List α
x : α
hx✝ : ¬x ∈ l
hd : α
tl : List α
IH : ¬x ∈ tl → Set.InjOn (fun k => insertNth k x tl) {n | n ≤ length tl}
hx : ¬x ∈ hd :: tl
n : ℕ
hn : n ∈ {n | n ≤ length (hd :: tl)}
m : ℕ
hm : m ∈ {n | n ≤ length (hd :: tl)}
h : (fun k => insertNth k x (hd :: tl)) n = (fun k => insertNth k x (hd :: tl)) m
⊢ n = m

tactic: simp only [mem_cons, not_or] at hx
state_before: case cons
α : Type u_1
β : Type ?u.14
γ : Type ?u.17
l : List α
x : α
hx✝ : ¬x ∈ l
hd : α
tl : List α
IH : ¬x ∈ tl → Set.InjOn (fun k => insertNth k x tl) {n | n ≤ length tl}
hx : ¬x ∈ hd :: tl
n : ℕ
hn : n ≤ length tl + 1
m : ℕ
hm : m ≤ length tl + 1
h : (fun k => insertNth k x (hd :: tl)) n = (fun k => insertNth k x (hd :: tl)) m
⊢ n = m

tactic: cases n <;> cases m
state_before: case cons
α : Type u_1
β : Type ?u.14
γ : Type ?u.17
l : List α
x : α
hx✝ : ¬x ∈ l
hd : α
tl : List α
IH : ¬x ∈ tl → Set.InjOn (fun k => insertNth k x tl) {n | n ≤ length tl}
n : ℕ
hn : n ≤ length tl + 1
m : ℕ
hm : m ≤ length tl + 1
h : (fun k => insertNth k x (hd :: tl)) n = (fun k => insertNth k x (hd :: tl)) m
hx : ¬x = hd ∧ ¬x ∈ tl
⊢ n = m

tactic: rfl
state_before: case cons.zero.zero
α : Type u_1
β : Type ?u.14
γ : Type ?u.17
l : List α
x : α
hx✝ : ¬x ∈ l
hd : α
tl : List α
IH : ¬x ∈ tl → Set.InjOn (fun k => insertNth k x tl) {n | n ≤ length tl}
hx : ¬x = hd ∧ ¬x ∈ tl
hn hm : Nat.zero ≤ length tl + 1
h : (fun k => insertNth k x (hd :: tl)) Nat.zero = (fun k => insertNth k x (hd :: tl)) Nat.zero
⊢ Nat.zero = Nat.zero

tactic: simp [hx.left] at h
state_before: case cons.zero.succ
α : Type u_1
β : Type ?u.14
γ : Type ?u.17
l : List α
x : α
hx✝ : ¬x ∈ l
hd : α
tl : List α
IH : ¬x ∈ tl → Set.InjOn (fun k => insertNth k x tl) {n | n ≤ length tl}
hx : ¬x = hd ∧ ¬x ∈ tl
hn : Nat.zero ≤ length tl + 1
n✝ : ℕ
hm : Nat.succ n✝ ≤ length tl + 1
h : (fun k => insertNth k x (hd :: tl)) Nat.zero = (fun k => insertNth k x (hd :: tl)) (Nat.succ n✝)
⊢ Nat.zero = Nat.succ n✝

tactic: simp [Ne.symm hx.left] at h
state_before: case cons.succ.zero
α : Type u_1
β : Type ?u.14
γ : Type ?u.17
l : List α
x : α
hx✝ : ¬x ∈ l
hd : α
tl : List α
IH : ¬x ∈ tl → Set.InjOn (fun k => insertNth k x tl) {n | n ≤ length tl}
hx : ¬x = hd ∧ ¬x ∈ tl
n✝ : ℕ
hn : Nat.succ n✝ ≤ length tl + 1
hm : Nat.zero ≤ length tl + 1
h : (fun k => insertNth k x (hd :: tl)) (Nat.succ n✝) = (fun k => insertNth k x (hd :: tl)) Nat.zero
⊢ Nat.succ n✝ = Nat.zero

tactic: simp only [true_and_iff, eq_self_iff_true, insertNth_succ_cons] at h
state_before: case cons.succ.succ
α : Type u_1
β : Type ?u.14
γ : Type ?u.17
l : List α
x : α
hx✝ : ¬x ∈ l
hd : α
tl : List α
IH : ¬x ∈ tl → Set.InjOn (fun k => insertNth k x tl) {n | n ≤ length tl}
hx : ¬x = hd ∧ ¬x ∈ tl
n✝¹ : ℕ
hn : Nat.succ n✝¹ ≤ length tl + 1
n✝ : ℕ
hm : Nat.succ n✝ ≤ length tl + 1
h : (fun k => insertNth k x (hd :: tl)) (Nat.succ n✝¹) = (fun k => insertNth k x (hd :: tl)) (Nat.succ n✝)
⊢ Nat.succ n✝¹ = Nat.succ n✝

tactic: rw [Nat.succ_inj']
state_before: case cons.succ.succ
α : Type u_1
β : Type ?u.14
γ : Type ?u.17
l : List α
x : α
hx✝ : ¬x ∈ l
hd : α
tl : List α
IH : ¬x ∈ tl → Set.InjOn (fun k => insertNth k x tl) {n | n ≤ length tl}
hx : ¬x = hd ∧ ¬x ∈ tl
n✝¹ : ℕ
hn : Nat.succ n✝¹ ≤ length tl + 1
n✝ : ℕ
hm : Nat.succ n✝ ≤ length tl + 1
h : hd :: insertNth n✝¹ x tl = hd :: insertNth n✝ x tl
⊢ Nat.succ n✝¹ = Nat.succ n✝

tactic: refine' IH hx.right _ _ (by injection h)
state_before: case cons.succ.succ
α : Type u_1
β : Type ?u.14
γ : Type ?u.17
l : List α
x : α
hx✝ : ¬x ∈ l
hd : α
tl : List α
IH : ¬x ∈ tl → Set.InjOn (fun k => insertNth k x tl) {n | n ≤ length tl}
hx : ¬x = hd ∧ ¬x ∈ tl
n✝¹ : ℕ
hn : Nat.succ n✝¹ ≤ length tl + 1
n✝ : ℕ
hm : Nat.succ n✝ ≤ length tl + 1
h : hd :: insertNth n✝¹ x tl = hd :: insertNth n✝ x tl
⊢ n✝¹ = n✝

tactic: injection h
state_before: α : Type u_1
β : Type ?u.14
γ : Type ?u.17
l : List α
x : α
hx✝ : ¬x ∈ l
hd : α
tl : List α
IH : ¬x ∈ tl → Set.InjOn (fun k => insertNth k x tl) {n | n ≤ length tl}
hx : ¬x = hd ∧ ¬x ∈ tl
n✝¹ : ℕ
hn : Nat.succ n✝¹ ≤ length tl + 1
n✝ : ℕ
hm : Nat.succ n✝ ≤ length tl + 1
h : hd :: insertNth n✝¹ x tl = hd :: insertNth n✝ x tl
⊢ (fun k => insertNth k x tl) n✝¹ = (fun k => insertNth k x tl) n✝

tactic: simpa [Nat.succ_le_succ_iff] using hn
state_before: case cons.succ.succ.refine'_1
α : Type u_1
β : Type ?u.14
γ : Type ?u.17
l : List α
x : α
hx✝ : ¬x ∈ l
hd : α
tl : List α
IH : ¬x ∈ tl → Set.InjOn (fun k => insertNth k x tl) {n | n ≤ length tl}
hx : ¬x = hd ∧ ¬x ∈ tl
n✝¹ : ℕ
hn : Nat.succ n✝¹ ≤ length tl + 1
n✝ : ℕ
hm : Nat.succ n✝ ≤ length tl + 1
h : hd :: insertNth n✝¹ x tl = hd :: insertNth n✝ x tl
⊢ n✝¹ ∈ {n | n ≤ length tl}

tactic: simpa [Nat.succ_le_succ_iff] using hm
state_before: case cons.succ.succ.refine'_2
α : Type u_1
β : Type ?u.14
γ : Type ?u.17
l : List α
x : α
hx✝ : ¬x ∈ l
hd : α
tl : List α
IH : ¬x ∈ tl → Set.InjOn (fun k => insertNth k x tl) {n | n ≤ length tl}
hx : ¬x = hd ∧ ¬x ∈ tl
n✝¹ : ℕ
hn : Nat.succ n✝¹ ≤ length tl + 1
n✝ : ℕ
hm : Nat.succ n✝ ≤ length tl + 1
h : hd :: insertNth n✝¹ x tl = hd :: insertNth n✝ x tl
⊢ n✝ ∈ {n | n ≤ length tl}