Lists with no duplicates #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
list.nodup
is defined in data/list/defs
. In this file we prove various properties of this
predicate.
@[protected]
theorem
list.pairwise.nodup
{α : Type u}
{l : list α}
{r : α → α → Prop}
[is_irrefl α r]
(h : list.pairwise r l) :
l.nodup
@[simp]
theorem
list.nth_le_index_of
{α : Type u}
[decidable_eq α]
{l : list α}
(H : l.nodup)
(n : ℕ)
(h : n < l.length) :
list.index_of (l.nth_le n h) l = n
theorem
list.nodup_iff_count_le_one
{α : Type u}
[decidable_eq α]
{l : list α} :
l.nodup ↔ ∀ (a : α), list.count a l ≤ 1
@[simp]
theorem
list.count_eq_one_of_mem
{α : Type u}
[decidable_eq α]
{a : α}
{l : list α}
(d : l.nodup)
(h : a ∈ l) :
list.count a l = 1
theorem
list.count_eq_of_nodup
{α : Type u}
[decidable_eq α]
{a : α}
{l : list α}
(d : l.nodup) :
list.count a l = ite (a ∈ l) 1 0
Alias of the forward direction of list.nodup_attach
.
@[protected]
Alias of the reverse direction of list.nodup_attach
.
theorem
list.nodup.filter
{α : Type u}
(p : α → Prop)
[decidable_pred p]
{l : list α} :
l.nodup → (list.filter p l).nodup
theorem
list.nodup.erase_eq_filter
{α : Type u}
[decidable_eq α]
{l : list α}
(d : l.nodup)
(a : α) :
l.erase a = list.filter (λ (_x : α), _x ≠ a) l
theorem
list.nodup.insert
{α : Type u}
{l : list α}
{a : α}
[decidable_eq α]
(h : l.nodup) :
(has_insert.insert a l).nodup
theorem
list.nodup.diff_eq_filter
{α : Type u}
[decidable_eq α]
{l₁ l₂ : list α}
(hl₁ : l₁.nodup) :
l₁.diff l₂ = list.filter (λ (_x : α), _x ∉ l₂) l₁
@[protected]
theorem
list.nodup.update_nth
{α : Type u}
{l : list α}
{n : ℕ}
{a : α}
(hl : l.nodup)
(ha : a ∉ l) :
(l.update_nth n a).nodup
theorem
list.nodup.map_update
{α : Type u}
{β : Type v}
[decidable_eq α]
{l : list α}
(hl : l.nodup)
(f : α → β)
(x : α)
(y : β) :
list.map (function.update f x y) l = ite (x ∈ l) ((list.map f l).update_nth (list.index_of x l) y) (list.map f l)
theorem
list.nodup.pairwise_of_set_pairwise
{α : Type u}
{l : list α}
{r : α → α → Prop}
(hl : l.nodup)
(h : {x : α | x ∈ l}.pairwise r) :
list.pairwise r l