Lattice structure of lists #
This files prove basic properties about list.disjoint, list.union, list.inter and
list.bag_inter, which are defined in core Lean and data.list.defs.
l₁ ∪ l₂ is the list where all elements of l₁ have been inserted in l₂ in order. For example,
[0, 0, 1, 2, 2, 3] ∪ [4, 3, 3, 0] = [1, 2, 4, 3, 3, 0]
l₁ ∩ l₂ is the list of elements of l₁ in order which are in l₂. For example,
[0, 0, 1, 2, 2, 3] ∪ [4, 3, 3, 0] = [0, 0, 3]
bag_inter l₁ l₂ is the list of elements that are in both l₁ and l₂, counted with multiplicity
and in the order they appear in l₁. As opposed to list.inter, list.bag_inter copes well with
multiplicity. For example,
bag_inter [0, 1, 2, 3, 2, 1, 0] [1, 0, 1, 4, 3] = [0, 1, 3, 1]
union #
@[simp]
@[simp]
@[simp]
theorem
list.mem_union_left
{α : Type u_1}
{l₁ : list α}
{a : α}
[decidable_eq α]
(h : a ∈ l₁)
(l₂ : list α) :
theorem
list.mem_union_right
{α : Type u_1}
{l₂ : list α}
{a : α}
[decidable_eq α]
(l₁ : list α)
(h : a ∈ l₂) :
theorem
list.forall_mem_of_forall_mem_union_left
{α : Type u_1}
{l₁ l₂ : list α}
{p : α → Prop}
[decidable_eq α]
(h : ∀ (x : α), x ∈ l₁ ∪ l₂ → p x)
(x : α)
(H : x ∈ l₁) :
p x
theorem
list.forall_mem_of_forall_mem_union_right
{α : Type u_1}
{l₁ l₂ : list α}
{p : α → Prop}
[decidable_eq α]
(h : ∀ (x : α), x ∈ l₁ ∪ l₂ → p x)
(x : α)
(H : x ∈ l₂) :
p x
inter #
@[simp]
@[simp]
theorem
list.inter_cons_of_not_mem
{α : Type u_1}
{l₂ : list α}
{a : α}
[decidable_eq α]
(l₁ : list α)
(h : a ∉ l₂) :
@[simp]
theorem
list.subset_inter
{α : Type u_1}
[decidable_eq α]
{l l₁ l₂ : list α}
(h₁ : l ⊆ l₁)
(h₂ : l ⊆ l₂) :
theorem
list.forall_mem_inter_of_forall_left
{α : Type u_1}
{l₁ : list α}
{p : α → Prop}
[decidable_eq α]
(h : ∀ (x : α), x ∈ l₁ → p x)
(l₂ : list α)
(x : α) :
theorem
list.forall_mem_inter_of_forall_right
{α : Type u_1}
{l₂ : list α}
{p : α → Prop}
[decidable_eq α]
(l₁ : list α)
(h : ∀ (x : α), x ∈ l₂ → p x)
(x : α) :
@[simp]
bag_inter #
@[simp]
@[simp]
@[simp]
theorem
list.cons_bag_inter_of_neg
{α : Type u_1}
{l₂ : list α}
{a : α}
[decidable_eq α]
(l₁ : list α)
(h : a ∉ l₂) :
@[simp]
@[simp]
theorem
list.count_bag_inter
{α : Type u_1}
[decidable_eq α]
{a : α}
{l₁ l₂ : list α} :
list.count a (l₁.bag_inter l₂) = min (list.count a l₁) (list.count a l₂)