Documentation

Init.Data.List.Erase

Lemmas about List.eraseP and List.erase. #

eraseP #

@[simp]
theorem List.eraseP_nil :
∀ {α : Type u_1} {p : αBool}, List.eraseP p [] = []
theorem List.eraseP_cons {α : Type u_1} {p : αBool} (a : α) (l : List α) :
List.eraseP p (a :: l) = bif p a then l else a :: List.eraseP p l
@[simp]
theorem List.eraseP_cons_of_pos {α : Type u_1} {a : α} {l : List α} {p : αBool} (h : p a = true) :
List.eraseP p (a :: l) = l
@[simp]
theorem List.eraseP_cons_of_neg {α : Type u_1} {a : α} {l : List α} {p : αBool} (h : ¬p a = true) :
List.eraseP p (a :: l) = a :: List.eraseP p l
theorem List.eraseP_of_forall_not {α : Type u_1} {p : αBool} {l : List α} (h : ∀ (a : α), a l¬p a = true) :
theorem List.exists_of_eraseP {α : Type u_1} {p : αBool} {l : List α} {a : α} (al : a l) (pa : p a = true) :
∃ (a : α), ∃ (l₁ : List α), ∃ (l₂ : List α), (∀ (b : α), b l₁¬p b = true) p a = true l = l₁ ++ a :: l₂ List.eraseP p l = l₁ ++ l₂
theorem List.exists_or_eq_self_of_eraseP {α : Type u_1} (p : αBool) (l : List α) :
List.eraseP p l = l ∃ (a : α), ∃ (l₁ : List α), ∃ (l₂ : List α), (∀ (b : α), b l₁¬p b = true) p a = true l = l₁ ++ a :: l₂ List.eraseP p l = l₁ ++ l₂
@[simp]
theorem List.length_eraseP_of_mem :
∀ {α : Type u_1} {a : α} {l : List α} {p : αBool}, a lp a = true(List.eraseP p l).length = l.length - 1
theorem List.length_eraseP {α : Type u_1} {p : αBool} {l : List α} :
(List.eraseP p l).length = if l.any p = true then l.length - 1 else l.length
theorem List.eraseP_sublist {α : Type u_1} {p : αBool} (l : List α) :
(List.eraseP p l).Sublist l
theorem List.eraseP_subset {α : Type u_1} {p : αBool} (l : List α) :
theorem List.Sublist.eraseP :
∀ {α : Type u_1} {l₁ l₂ : List α} {p : αBool}, l₁.Sublist l₂(List.eraseP p l₁).Sublist (List.eraseP p l₂)
theorem List.length_eraseP_le {α : Type u_1} {p : αBool} (l : List α) :
(List.eraseP p l).length l.length
theorem List.mem_of_mem_eraseP {α : Type u_1} {a : α} {p : αBool} {l : List α} :
a List.eraseP p la l
@[simp]
theorem List.mem_eraseP_of_neg {α : Type u_1} {p : αBool} {a : α} {l : List α} (pa : ¬p a = true) :
@[simp]
theorem List.eraseP_eq_self_iff {α : Type u_1} {p : αBool} {l : List α} :
List.eraseP p l = l ∀ (a : α), a l¬p a = true
theorem List.eraseP_map {β : Type u_1} {α : Type u_2} {p : αBool} (f : βα) (l : List β) :
theorem List.eraseP_filterMap {α : Type u_1} {β : Type u_2} {p : βBool} (f : αOption β) (l : List α) :
List.eraseP p (List.filterMap f l) = List.filterMap f (List.eraseP (fun (x : α) => match f x with | some y => p y | none => false) l)
theorem List.eraseP_filter {α : Type u_1} {p : αBool} (f : αBool) (l : List α) :
List.eraseP p (List.filter f l) = List.filter f (List.eraseP (fun (x : α) => p x && f x) l)
theorem List.eraseP_append_left {α : Type u_1} {p : αBool} {a : α} (pa : p a = true) {l₁ : List α} (l₂ : List α) :
a l₁List.eraseP p (l₁ ++ l₂) = List.eraseP p l₁ ++ l₂
theorem List.eraseP_append_right {α : Type u_1} {p : αBool} {l₁ : List α} (l₂ : List α) :
(∀ (b : α), b l₁¬p b = true)List.eraseP p (l₁ ++ l₂) = l₁ ++ List.eraseP p l₂
theorem List.eraseP_append {α : Type u_1} {p : αBool} (l₁ : List α) (l₂ : List α) :
List.eraseP p (l₁ ++ l₂) = if l₁.any p = true then List.eraseP p l₁ ++ l₂ else l₁ ++ List.eraseP p l₂
theorem List.eraseP_eq_iff {α : Type u_1} {l' : List α} {p : αBool} {l : List α} :
List.eraseP p l = l' (∀ (a : α), a l¬p a = true) l = l' ∃ (a : α), ∃ (l₁ : List α), ∃ (l₂ : List α), (∀ (b : α), b l₁¬p b = true) p a = true l = l₁ ++ a :: l₂ l' = l₁ ++ l₂
@[simp]
theorem List.eraseP_replicate_of_pos {α : Type u_1} {p : αBool} {n : Nat} {a : α} (h : p a = true) :
@[simp]
theorem List.eraseP_replicate_of_neg {α : Type u_1} {p : αBool} {n : Nat} {a : α} (h : ¬p a = true) :
theorem List.Nodup.eraseP :
∀ {α : Type u_1} {l : List α} (p : αBool), l.Nodup(List.eraseP p l).Nodup
theorem List.eraseP_comm {α : Type u_1} {p : αBool} {q : αBool} {l : List α} (h : ∀ (a : α), a l¬p a = true ¬q a = true) :

erase #

@[simp]
theorem List.erase_cons_head {α : Type u_1} [BEq α] [LawfulBEq α] (a : α) (l : List α) :
(a :: l).erase a = l
@[simp]
theorem List.erase_cons_tail {α : Type u_1} [BEq α] {a : α} {b : α} {l : List α} (h : ¬(b == a) = true) :
(b :: l).erase a = b :: l.erase a
theorem List.erase_of_not_mem {α : Type u_1} [BEq α] [LawfulBEq α] {a : α} {l : List α} :
¬a ll.erase a = l
theorem List.erase_eq_eraseP' {α : Type u_1} [BEq α] (a : α) (l : List α) :
l.erase a = List.eraseP (fun (x : α) => x == a) l
theorem List.erase_eq_eraseP {α : Type u_1} [BEq α] [LawfulBEq α] (a : α) (l : List α) :
l.erase a = List.eraseP (fun (x : α) => a == x) l
theorem List.exists_erase_eq {α : Type u_1} [BEq α] [LawfulBEq α] {a : α} {l : List α} (h : a l) :
∃ (l₁ : List α), ∃ (l₂ : List α), ¬a l₁ l = l₁ ++ a :: l₂ l.erase a = l₁ ++ l₂
@[simp]
theorem List.length_erase_of_mem {α : Type u_1} [BEq α] [LawfulBEq α] {a : α} {l : List α} (h : a l) :
(l.erase a).length = l.length - 1
theorem List.length_erase {α : Type u_1} [BEq α] [LawfulBEq α] (a : α) (l : List α) :
(l.erase a).length = if a l then l.length - 1 else l.length
theorem List.erase_sublist {α : Type u_1} [BEq α] (a : α) (l : List α) :
(l.erase a).Sublist l
theorem List.erase_subset {α : Type u_1} [BEq α] (a : α) (l : List α) :
l.erase a l
theorem List.Sublist.erase {α : Type u_1} [BEq α] (a : α) {l₁ : List α} {l₂ : List α} (h : l₁.Sublist l₂) :
(l₁.erase a).Sublist (l₂.erase a)
theorem List.length_erase_le {α : Type u_1} [BEq α] (a : α) (l : List α) :
(l.erase a).length l.length
theorem List.mem_of_mem_erase {α : Type u_1} [BEq α] {a : α} {b : α} {l : List α} (h : a l.erase b) :
a l
@[simp]
theorem List.mem_erase_of_ne {α : Type u_1} [BEq α] [LawfulBEq α] {a : α} {b : α} {l : List α} (ab : a b) :
a l.erase b a l
@[simp]
theorem List.erase_eq_self_iff {α : Type u_1} [BEq α] {a : α} [LawfulBEq α] {l : List α} :
l.erase a = l ¬a l
theorem List.erase_filter {α : Type u_1} [BEq α] {a : α} [LawfulBEq α] (f : αBool) (l : List α) :
(List.filter f l).erase a = List.filter f (l.erase a)
theorem List.erase_append_left {α : Type u_1} [BEq α] {a : α} [LawfulBEq α] {l₁ : List α} (l₂ : List α) (h : a l₁) :
(l₁ ++ l₂).erase a = l₁.erase a ++ l₂
theorem List.erase_append_right {α : Type u_1} [BEq α] [LawfulBEq α] {a : α} {l₁ : List α} (l₂ : List α) (h : ¬a l₁) :
(l₁ ++ l₂).erase a = l₁ ++ l₂.erase a
theorem List.erase_append {α : Type u_1} [BEq α] [LawfulBEq α] {a : α} {l₁ : List α} {l₂ : List α} :
(l₁ ++ l₂).erase a = if a l₁ then l₁.erase a ++ l₂ else l₁ ++ l₂.erase a
theorem List.erase_comm {α : Type u_1} [BEq α] [LawfulBEq α] (a : α) (b : α) (l : List α) :
(l.erase a).erase b = (l.erase b).erase a
theorem List.erase_eq_iff {α : Type u_1} [BEq α] {l' : List α} [LawfulBEq α] {a : α} {l : List α} :
l.erase a = l' ¬a l l = l' ∃ (l₁ : List α), ∃ (l₂ : List α), ¬a l₁ l = l₁ ++ a :: l₂ l' = l₁ ++ l₂
@[simp]
theorem List.erase_replicate_self {α : Type u_1} [BEq α] {n : Nat} [LawfulBEq α] {a : α} :
(List.replicate n a).erase a = List.replicate (n - 1) a
@[simp]
theorem List.erase_replicate_ne {α : Type u_1} [BEq α] {n : Nat} [LawfulBEq α] {a : α} {b : α} (h : (!b == a) = true) :
(List.replicate n a).erase b = List.replicate n a
theorem List.Nodup.erase_eq_filter {α : Type u_1} [BEq α] [LawfulBEq α] {l : List α} (d : l.Nodup) (a : α) :
l.erase a = List.filter (fun (x : α) => x != a) l
theorem List.Nodup.mem_erase_iff {α : Type u_1} [BEq α] {l : List α} {b : α} [LawfulBEq α] {a : α} (d : l.Nodup) :
a l.erase b a b a l
theorem List.Nodup.not_mem_erase {α : Type u_1} [BEq α] {l : List α} [LawfulBEq α] {a : α} (h : l.Nodup) :
¬a l.erase a
theorem List.Nodup.erase {α : Type u_1} [BEq α] {l : List α} [LawfulBEq α] (a : α) :
l.Nodup(l.erase a).Nodup

eraseIdx #

theorem List.length_eraseIdx {α : Type u_1} {l : List α} {i : Nat} :
i < l.length(l.eraseIdx i).length = l.length - 1
@[simp]
theorem List.eraseIdx_zero {α : Type u_1} (l : List α) :
l.eraseIdx 0 = l.tail
theorem List.eraseIdx_eq_take_drop_succ {α : Type u_1} (l : List α) (i : Nat) :
l.eraseIdx i = List.take i l ++ List.drop (i + 1) l
theorem List.eraseIdx_sublist {α : Type u_1} (l : List α) (k : Nat) :
(l.eraseIdx k).Sublist l
theorem List.eraseIdx_subset {α : Type u_1} (l : List α) (k : Nat) :
l.eraseIdx k l
@[simp]
theorem List.eraseIdx_eq_self {α : Type u_1} {l : List α} {k : Nat} :
l.eraseIdx k = l l.length k
theorem List.eraseIdx_of_length_le {α : Type u_1} {l : List α} {k : Nat} (h : l.length k) :
l.eraseIdx k = l
theorem List.eraseIdx_append_of_lt_length {α : Type u_1} {l : List α} {k : Nat} (hk : k < l.length) (l' : List α) :
(l ++ l').eraseIdx k = l.eraseIdx k ++ l'
theorem List.eraseIdx_append_of_length_le {α : Type u_1} {l : List α} {k : Nat} (hk : l.length k) (l' : List α) :
(l ++ l').eraseIdx k = l ++ l'.eraseIdx (k - l.length)
theorem List.IsPrefix.eraseIdx {α : Type u_1} {l : List α} {l' : List α} (h : l <+: l') (k : Nat) :
l.eraseIdx k <+: l'.eraseIdx k