Documentation

Init.Data.List.Nat.Modify

modifyHead #

@[simp]
theorem List.length_modifyHead {α : Type u_1} {f : αα} {l : List α} :
(List.modifyHead f l).length = l.length
theorem List.modifyHead_eq_set {α : Type u_1} [Inhabited α] (f : αα) (l : List α) :
List.modifyHead f l = l.set 0 (f (l[0]?.getD default))
@[simp]
theorem List.modifyHead_eq_nil_iff {α : Type u_1} {f : αα} {l : List α} :
List.modifyHead f l = [] l = []
@[simp]
theorem List.modifyHead_modifyHead {α : Type u_1} {l : List α} {f g : αα} :
theorem List.getElem_modifyHead {α : Type u_1} {l : List α} {f : αα} {n : Nat} (h : n < (List.modifyHead f l).length) :
(List.modifyHead f l)[n] = if h' : n = 0 then f l[0] else l[n]
@[simp]
theorem List.getElem_modifyHead_zero {α : Type u_1} {l : List α} {f : αα} {h : 0 < (List.modifyHead f l).length} :
(List.modifyHead f l)[0] = f l[0]
@[simp]
theorem List.getElem_modifyHead_succ {α : Type u_1} {l : List α} {f : αα} {n : Nat} (h : n + 1 < (List.modifyHead f l).length) :
(List.modifyHead f l)[n + 1] = l[n + 1]
theorem List.getElem?_modifyHead {α : Type u_1} {l : List α} {f : αα} {n : Nat} :
(List.modifyHead f l)[n]? = if n = 0 then Option.map f l[n]? else l[n]?
@[simp]
theorem List.getElem?_modifyHead_zero {α : Type u_1} {l : List α} {f : αα} :
(List.modifyHead f l)[0]? = Option.map f l[0]?
@[simp]
theorem List.getElem?_modifyHead_succ {α : Type u_1} {l : List α} {f : αα} {n : Nat} :
(List.modifyHead f l)[n + 1]? = l[n + 1]?
@[simp]
theorem List.head_modifyHead {α : Type u_1} (f : αα) (l : List α) (h : List.modifyHead f l []) :
(List.modifyHead f l).head h = f (l.head )
@[simp]
theorem List.head?_modifyHead {α : Type u_1} {l : List α} {f : αα} :
(List.modifyHead f l).head? = Option.map f l.head?
@[simp]
theorem List.tail_modifyHead {α : Type u_1} {f : αα} {l : List α} :
(List.modifyHead f l).tail = l.tail
@[simp]
theorem List.take_modifyHead {α : Type u_1} {f : αα} {l : List α} {n : Nat} :
@[simp]
theorem List.drop_modifyHead_of_pos {α : Type u_1} {f : αα} {l : List α} {n : Nat} (h : 0 < n) :
@[simp]
theorem List.eraseIdx_modifyHead_zero {α : Type u_1} {f : αα} {l : List α} :
(List.modifyHead f l).eraseIdx 0 = l.eraseIdx 0
@[simp]
theorem List.eraseIdx_modifyHead_of_pos {α : Type u_1} {f : αα} {l : List α} {n : Nat} (h : 0 < n) :
(List.modifyHead f l).eraseIdx n = List.modifyHead f (l.eraseIdx n)
@[simp]
theorem List.modifyHead_id {α : Type u_1} :

modifyTailIdx #

@[simp]
theorem List.modifyTailIdx_id {α : Type u_1} (n : Nat) (l : List α) :
theorem List.eraseIdx_eq_modifyTailIdx {α : Type u_1} (n : Nat) (l : List α) :
l.eraseIdx n = List.modifyTailIdx List.tail n l
@[simp]
theorem List.length_modifyTailIdx {α : Type u_1} (f : List αList α) (H : ∀ (l : List α), (f l).length = l.length) (n : Nat) (l : List α) :
(List.modifyTailIdx f n l).length = l.length
theorem List.modifyTailIdx_add {α : Type u_1} (f : List αList α) (n : Nat) (l₁ l₂ : List α) :
List.modifyTailIdx f (l₁.length + n) (l₁ ++ l₂) = l₁ ++ List.modifyTailIdx f n l₂
theorem List.modifyTailIdx_eq_take_drop {α : Type u_1} (f : List αList α) (H : f [] = []) (n : Nat) (l : List α) :
theorem List.exists_of_modifyTailIdx {α : Type u_1} (f : List αList α) {n : Nat} {l : List α} (h : n l.length) :
∃ (l₁ : List α), ∃ (l₂ : List α), l = l₁ ++ l₂ l₁.length = n List.modifyTailIdx f n l = l₁ ++ f l₂

modify #

@[simp]
theorem List.modify_nil {α : Type u_1} (f : αα) (n : Nat) :
List.modify f n [] = []
@[simp]
theorem List.modify_zero_cons {α : Type u_1} (f : αα) (a : α) (l : List α) :
List.modify f 0 (a :: l) = f a :: l
@[simp]
theorem List.modify_succ_cons {α : Type u_1} (f : αα) (a : α) (l : List α) (n : Nat) :
List.modify f (n + 1) (a :: l) = a :: List.modify f n l
theorem List.modifyHead_eq_modify_zero {α : Type u_1} (f : αα) (l : List α) :
@[simp]
theorem List.modify_eq_nil_iff {α : Type u_1} (f : αα) (n : Nat) (l : List α) :
List.modify f n l = [] l = []
theorem List.getElem?_modify {α : Type u_1} (f : αα) (n : Nat) (l : List α) (m : Nat) :
(List.modify f n l)[m]? = (fun (a : α) => if n = m then f a else a) <$> l[m]?
@[simp]
theorem List.length_modify {α : Type u_1} (f : αα) (n : Nat) (l : List α) :
(List.modify f n l).length = l.length
@[simp]
theorem List.getElem?_modify_eq {α : Type u_1} (f : αα) (n : Nat) (l : List α) :
(List.modify f n l)[n]? = f <$> l[n]?
@[simp]
theorem List.getElem?_modify_ne {α : Type u_1} (f : αα) {m n : Nat} (l : List α) (h : m n) :
(List.modify f m l)[n]? = l[n]?
theorem List.getElem_modify {α : Type u_1} (f : αα) (n : Nat) (l : List α) (m : Nat) (h : m < (List.modify f n l).length) :
(List.modify f n l)[m] = if n = m then f l[m] else l[m]
@[simp]
theorem List.getElem_modify_eq {α : Type u_1} (f : αα) (n : Nat) (l : List α) (h : n < (List.modify f n l).length) :
(List.modify f n l)[n] = f l[n]
@[simp]
theorem List.getElem_modify_ne {α : Type u_1} (f : αα) {m n : Nat} (l : List α) (h : m n) (h' : n < (List.modify f m l).length) :
(List.modify f m l)[n] = l[n]
theorem List.modify_eq_self {α : Type u_1} {f : αα} {n : Nat} {l : List α} (h : l.length n) :
List.modify f n l = l
theorem List.modify_modify_eq {α : Type u_1} (f g : αα) (n : Nat) (l : List α) :
List.modify g n (List.modify f n l) = List.modify (g f) n l
theorem List.modify_modify_ne {α : Type u_1} (f g : αα) {m n : Nat} (l : List α) (h : m n) :
theorem List.modify_eq_set {α : Type u_1} [Inhabited α] (f : αα) (n : Nat) (l : List α) :
List.modify f n l = l.set n (f (l[n]?.getD default))
theorem List.modify_eq_take_drop {α : Type u_1} (f : αα) (n : Nat) (l : List α) :
theorem List.modify_eq_take_cons_drop {α : Type u_1} {f : αα} {n : Nat} {l : List α} (h : n < l.length) :
List.modify f n l = List.take n l ++ f l[n] :: List.drop (n + 1) l
theorem List.exists_of_modify {α : Type u_1} (f : αα) {n : Nat} {l : List α} (h : n < l.length) :
∃ (l₁ : List α), ∃ (a : α), ∃ (l₂ : List α), l = l₁ ++ a :: l₂ l₁.length = n List.modify f n l = l₁ ++ f a :: l₂
@[simp]
theorem List.modify_id {α : Type u_1} (n : Nat) (l : List α) :
List.modify id n l = l
theorem List.take_modify {α : Type u_1} (f : αα) (n m : Nat) (l : List α) :
theorem List.drop_modify_of_lt {α : Type u_1} (f : αα) (n m : Nat) (l : List α) (h : n < m) :
theorem List.drop_modify_of_ge {α : Type u_1} (f : αα) (n m : Nat) (l : List α) (h : n m) :
List.drop m (List.modify f n l) = List.modify f (n - m) (List.drop m l)
theorem List.eraseIdx_modify_of_eq {α : Type u_1} (f : αα) (n : Nat) (l : List α) :
(List.modify f n l).eraseIdx n = l.eraseIdx n
theorem List.eraseIdx_modify_of_lt {α : Type u_1} (f : αα) (i j : Nat) (l : List α) (h : j < i) :
(List.modify f i l).eraseIdx j = List.modify f (i - 1) (l.eraseIdx j)
theorem List.eraseIdx_modify_of_gt {α : Type u_1} (f : αα) (i j : Nat) (l : List α) (h : j > i) :
(List.modify f i l).eraseIdx j = List.modify f i (l.eraseIdx j)
theorem List.modify_eraseIdx_of_lt {α : Type u_1} (f : αα) (i j : Nat) (l : List α) (h : j < i) :
List.modify f j (l.eraseIdx i) = (List.modify f j l).eraseIdx i
theorem List.modify_eraseIdx_of_ge {α : Type u_1} (f : αα) (i j : Nat) (l : List α) (h : j i) :
List.modify f j (l.eraseIdx i) = (List.modify f (j + 1) l).eraseIdx i