This file contains utilities for working with lists that are canonical or equivalent modulo ordering and duplicates. A canonical list is sorted and duplicate-free according to a strict total order <.
def
List.insertCanonical
{β : Type u_1}
{α : Type u_2}
[LT β]
[DecidableLT β]
(f : α → β)
(x : α)
(xs : List α)
:
List α
Equations
Instances For
If the ordering relation < on β is strict, then canonicalize returns a
canonical representation of the input list, which is sorted and free of
duplicates.
Equations
- List.canonicalize f [] = []
- List.canonicalize f (hd :: tl) = List.insertCanonical f hd (List.canonicalize f tl)
Instances For
def
List.mapUnion
{α : Type u_1}
{β : Type u_2}
[Union α]
[EmptyCollection α]
(f : β → α)
(bs : List β)
:
α
Generalization of List.flatMap from the standard library:
works for f returning various collection types, not just List.
That said, if your f does return List, you may want to use flatMap
instead, as there is a large library of lemmas about it in the standard library.
Equations
- List.mapUnion f bs = List.foldl (fun (a : α) (b : β) => a ∪ f b) ∅ bs