File: Mathlib/Data/List/InsertNth.lean

full_name: List.insertNth_zero
code: @[simp]
theorem insertNth_zero (s : List α) (x : α) : insertNth 0 x s = x :: s 
goal: List.insertNth 0 x s = x :: s

full_name: List.insertNth_succ_nil
code: @[simp]
theorem insertNth_succ_nil (n : ℕ) (a : α) : insertNth (n + 1) a [] = [] 
goal: List.insertNth (n + 1) a [] = []

full_name: List.insertNth_succ_cons
code: @[simp]
theorem insertNth_succ_cons (s : List α) (hd x : α) (n : ℕ) :
    insertNth (n + 1) x (hd :: s) = hd :: insertNth n x s 
goal: List.insertNth (n + 1) x (hd :: s) = hd :: List.insertNth n x s

full_name: List.length_insertNth
code: theorem length_insertNth : ∀ n as, n ≤ length as → length (insertNth n a as) = length as + 1
  
goal: n ≤ as.length → (List.insertNth n a as).length = as.length + 1

full_name: List.eraseIdx_insertNth
code: theorem eraseIdx_insertNth (n : ℕ) (l : List α) : (l.insertNth n a).eraseIdx n = l 
goal: (List.insertNth n a l).eraseIdx n = l

full_name: List.insertNth_eraseIdx_of_ge
code: theorem insertNth_eraseIdx_of_ge :
    ∀ n m as,
      n < length as → n ≤ m → insertNth m a (as.eraseIdx n) = (as.insertNth (m + 1) a).eraseIdx n
  
goal: n < as.length → n ≤ m → List.insertNth m a (as.eraseIdx n) = (List.insertNth (m + 1) a as).eraseIdx n

full_name: List.insertNth_eraseIdx_of_le
code: theorem insertNth_eraseIdx_of_le :
    ∀ n m as,
      n < length as → m ≤ n → insertNth m a (as.eraseIdx n) = (as.insertNth m a).eraseIdx (n + 1)
  
goal: n < as.length → m ≤ n → List.insertNth m a (as.eraseIdx n) = (List.insertNth m a as).eraseIdx (n + 1)

full_name: List.insertNth_comm
code: theorem insertNth_comm (a b : α) :
    ∀ (i j : ℕ) (l : List α) (_ : i ≤ j) (_ : j ≤ length l),
      (l.insertNth i a).insertNth (j + 1) b = (l.insertNth j b).insertNth i a
  
goal: i ≤ j → j ≤ l.length → List.insertNth (j + 1) b (List.insertNth i a l) = List.insertNth i a (List.insertNth j b l)

full_name: List.mem_insertNth
code: theorem mem_insertNth {a b : α} :
    ∀ {n : ℕ} {l : List α} (_ : n ≤ l.length), a ∈ l.insertNth n b ↔ a = b ∨ a ∈ l
  
goal: n ≤ l.length → (a ∈ List.insertNth n b l ↔ a = b ∨ a ∈ l)

full_name: List.insertNth_of_length_lt
code: theorem insertNth_of_length_lt (l : List α) (x : α) (n : ℕ) (h : l.length < n) :
    insertNth n x l = l 
goal: List.insertNth n x l = l

full_name: List.insertNth_length_self
code: @[simp]
theorem insertNth_length_self (l : List α) (x : α) : insertNth l.length x l = l ++ [x] 
goal: List.insertNth l.length x l = l ++ [x]

full_name: List.length_le_length_insertNth
code: theorem length_le_length_insertNth (l : List α) (x : α) (n : ℕ) :
    l.length ≤ (insertNth n x l).length 
goal: l.length ≤ (List.insertNth n x l).length

full_name: List.length_insertNth_le_succ
code: theorem length_insertNth_le_succ (l : List α) (x : α) (n : ℕ) :
    (insertNth n x l).length ≤ l.length + 1 
goal: (List.insertNth n x l).length ≤ l.length + 1

full_name: List.getElem_insertNth_of_lt
code: theorem getElem_insertNth_of_lt (l : List α) (x : α) (n k : ℕ) (hn : k < n) (hk : k < l.length)
    (hk' : k < (insertNth n x l).length := hk.trans_le (length_le_length_insertNth _ _ _)) :
    (insertNth n x l)[k] = l[k] 
goal: (List.insertNth n x l)[k] = l[k]

full_name: List.get_insertNth_of_lt
code: theorem get_insertNth_of_lt (l : List α) (x : α) (n k : ℕ) (hn : k < n) (hk : k < l.length)
    (hk' : k < (insertNth n x l).length := hk.trans_le (length_le_length_insertNth _ _ _)) :
    (insertNth n x l).get ⟨k, hk'⟩ = l.get ⟨k, hk⟩ 
goal: (List.insertNth n x l).get ⟨k, hk'⟩ = l.get ⟨k, hk⟩

full_name: List.nthLe_insertNth_of_lt
code: @[deprecated get_insertNth_of_lt (since := "2023-01-05")]
theorem nthLe_insertNth_of_lt : ∀ (l : List α) (x : α) (n k : ℕ), k < n → ∀ (hk : k < l.length)
    (hk' : k < (insertNth n x l).length := hk.trans_le (length_le_length_insertNth _ _ _)),
    (insertNth n x l).nthLe k hk' = l.nthLe k hk 
goal: k < n →
  ∀ (hk : k < l.length) (hk' : optParam (k < (List.insertNth n x l).length) ⋯),
    (List.insertNth n x l).nthLe k hk' = l.nthLe k hk

full_name: List.getElem_insertNth_self
code: @[simp]
theorem getElem_insertNth_self (l : List α) (x : α) (n : ℕ) (hn : n ≤ l.length)
    (hn' : n < (insertNth n x l).length := (by rwa [length_insertNth _ _ hn, Nat.lt_succ_iff])) :
    (insertNth n x l)[n] = x 
goal: (List.insertNth n x l)[n] = x

full_name: List.get_insertNth_self
code: theorem get_insertNth_self (l : List α) (x : α) (n : ℕ) (hn : n ≤ l.length)
    (hn' : n < (insertNth n x l).length := (by rwa [length_insertNth _ _ hn, Nat.lt_succ_iff])) :
    (insertNth n x l).get ⟨n, hn'⟩ = x 
goal: (List.insertNth n x l).get ⟨n, hn'⟩ = x

full_name: List.nthLe_insertNth_self
code: @[simp, deprecated get_insertNth_self (since := "2023-01-05")]
theorem nthLe_insertNth_self (l : List α) (x : α) (n : ℕ) (hn : n ≤ l.length)
    (hn' : n < (insertNth n x l).length := (by rwa [length_insertNth _ _ hn, Nat.lt_succ_iff])) :
    (insertNth n x l).nthLe n hn' = x 
goal: (List.insertNth n x l).nthLe n hn' = x

full_name: List.getElem_insertNth_add_succ
code: theorem getElem_insertNth_add_succ (l : List α) (x : α) (n k : ℕ) (hk' : n + k < l.length)
    (hk : n + k + 1 < (insertNth n x l).length := (by
      rwa [length_insertNth _ _ (by omega), Nat.succ_lt_succ_iff])) :
    (insertNth n x l)[n + k + 1] = l[n + k] 
goal: (List.insertNth n x l)[n + k + 1] = l[n + k]

full_name: List.get_insertNth_add_succ
code: theorem get_insertNth_add_succ (l : List α) (x : α) (n k : ℕ) (hk' : n + k < l.length)
    (hk : n + k + 1 < (insertNth n x l).length := (by
      rwa [length_insertNth _ _ (by omega), Nat.succ_lt_succ_iff])) :
    (insertNth n x l).get ⟨n + k + 1, hk⟩ = get l ⟨n + k, hk'⟩ 
goal: (List.insertNth n x l).get ⟨n + k + 1, hk⟩ = l.get ⟨n + k, hk'⟩

full_name: List.nthLe_insertNth_add_succ
code: @[deprecated get_insertNth_add_succ (since := "2023-01-05")]
theorem nthLe_insertNth_add_succ : ∀ (l : List α) (x : α) (n k : ℕ) (hk' : n + k < l.length)
    (hk : n + k + 1 < (insertNth n x l).length := (by
      rwa [length_insertNth _ _ (by omega), Nat.succ_lt_succ_iff])),
    (insertNth n x l).nthLe (n + k + 1) hk = nthLe l (n + k) hk' 
goal: (List.insertNth n x l).nthLe (n + k + 1) hk = l.nthLe (n + k) hk'

full_name: List.insertNth_injective
code: theorem insertNth_injective (n : ℕ) (x : α) : Function.Injective (insertNth n x) 
goal: Function.Injective (List.insertNth n x)