Documentation

CslibFrontier.Foundations.Data.List.EraseDups

Erasing duplicates, keeping first occurrences #

Core List.eraseDups keeps the first occurrence of each entry, in order, and core proves that it keeps every entry (List.mem_eraseDups). This file adds that the result is a duplicate-free sublist, that it fixes exactly the duplicate-free lists, and that its length is the number of distinct entries.

Main results #

theorem List.eraseDups_sublist {α : Type u_1} [BEq α] (l : List α) :

eraseDups keeps a sublist.

theorem List.nodup_eraseDups {α : Type u_1} [BEq α] [LawfulBEq α] (l : List α) :

eraseDups leaves no duplicates.

theorem List.eraseDups_eq_self {α : Type u_1} [BEq α] [LawfulBEq α] {l : List α} :

eraseDups fixes exactly the duplicate-free lists.

@[simp]
theorem List.length_eraseDups {α : Type u_1} [DecidableEq α] (l : List α) :

The length of eraseDups is the number of distinct entries.