Lemmas about List.eraseP
and List.erase
. #
eraseP #
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.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.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.le_length_eraseP
{α : Type u_1}
{p : α → Bool}
(l : List α)
:
l.length - 1 ≤ (List.eraseP p l).length
theorem
List.mem_of_mem_eraseP
{α : Type u_1}
{p : α → Bool}
{a : α}
{l : List α}
:
a ∈ List.eraseP p l → a ∈ l
theorem
List.eraseP_map
{β : Type u_1}
{α : Type u_2}
{p : α → Bool}
(f : β → α)
(l : List β)
:
List.eraseP p (List.map f l) = List.map f (List.eraseP (p ∘ f) l)
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₁ 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_replicate
{α : Type u_1}
(n : Nat)
(a : α)
(p : α → Bool)
:
List.eraseP p (List.replicate n a) = if p a = true then List.replicate (n - 1) a else List.replicate n a
theorem
List.IsPrefix.eraseP
{α✝ : Type u_1}
{l₁ l₂ : List α✝}
{p : α✝ → Bool}
(h : l₁ <+: l₂)
:
List.eraseP p l₁ <+: List.eraseP p l₂
@[simp]
theorem
List.eraseP_replicate_of_pos
{α : Type u_1}
{p : α → Bool}
{n : Nat}
{a : α}
(h : p a = true)
:
List.eraseP p (List.replicate n a) = List.replicate (n - 1) a
@[simp]
theorem
List.eraseP_replicate_of_neg
{α : Type u_1}
{p : α → Bool}
{n : Nat}
{a : α}
(h : ¬p a = true)
:
List.eraseP p (List.replicate n a) = List.replicate n a
theorem
List.Pairwise.eraseP
{α✝ : Type u_1}
{p : α✝ → α✝ → Prop}
{l : List α✝}
(q : α✝ → Bool)
:
List.Pairwise p l → List.Pairwise p (List.eraseP q l)
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 q : α → Bool}
{l : List α}
(h : ∀ (a : α), a ∈ l → ¬p a = true ∨ ¬q a = true)
:
List.eraseP q (List.eraseP p l) = List.eraseP p (List.eraseP q l)
theorem
List.head_eraseP_mem
{α : Type u_1}
(xs : List α)
(p : α → Bool)
(h : List.eraseP p xs ≠ [])
:
(List.eraseP p xs).head h ∈ xs
theorem
List.getLast_eraseP_mem
{α : Type u_1}
(xs : List α)
(p : α → Bool)
(h : List.eraseP p xs ≠ [])
:
(List.eraseP p xs).getLast h ∈ xs
erase #
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.Sublist.erase
{α : Type u_1}
[BEq α]
(a : α)
{l₁ l₂ : List α}
(h : l₁.Sublist l₂)
:
(l₁.erase a).Sublist (l₂.erase a)
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_replicate
{α : Type u_1}
[BEq α]
[LawfulBEq α]
(n : Nat)
(a b : α)
:
(List.replicate n a).erase b = if (b == a) = true then List.replicate (n - 1) a else List.replicate n a
@[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.Pairwise.erase
{α : Type u_1}
[BEq α]
{p : α → α → Prop}
[LawfulBEq α]
{l : List α}
(a : α)
:
List.Pairwise p l → List.Pairwise p (l.erase 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
eraseIdx #
theorem
List.eraseIdx_replicate
{α : Type u_1}
{n : Nat}
{a : α}
{k : Nat}
:
(List.replicate n a).eraseIdx k = if k < n then List.replicate (n - 1) a else List.replicate n a
theorem
List.Pairwise.eraseIdx
{α : Type u_1}
{p : α → α → Prop}
{l : List α}
(k : Nat)
:
List.Pairwise p l → List.Pairwise p (l.eraseIdx k)