Canonical list-based sets #
This file defines a simple set data type, backed by a sorted duplicate-free list. Functions on sets assume but don't require their inputs to be well-formed (sorted and duplicate-free). Separate theorems show that these functions produce well-formed outputs when given well-formed inputs.
Use Set.make to construct well-formed sets from lists.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Cedar.Data.instReprSet = { reprPrec := Cedar.Data.instReprSet.repr }
Equations
- Cedar.Data.instDecidableEqSet.decEq (Cedar.Data.Set.mk a) (Cedar.Data.Set.mk b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
Instances For
Instances For
Equations
Equations
Equations
Instances For
Creates a well-formed set from the given list.
Equations
- Cedar.Data.Set.make elts = Cedar.Data.Set.mk (List.canonicalize (fun (x : α) => x) elts)
Instances For
Empty set ∅
Equations
Instances For
elt ∈ s
Instances For
s₁ ∩ s₂
Instances For
s₁ ∪ s₂
Instances For
Equations
Filters s using f.
Equations
- Cedar.Data.Set.filter f s = Cedar.Data.Set.mk (List.filter f s.elts)
Instances For
def
Cedar.Data.Set.difference
{α : Type u_1}
[LT α]
[DecidableLT α]
[DecidableEq α]
(s₁ s₂ : Set α)
:
Set α
s₁ \ s₂.
Equations
- s₁.difference s₂ = Cedar.Data.Set.filter (fun (x : α) => !s₂.contains x) s₁
Instances For
def
Cedar.Data.Set.map
{α : Type u_1}
{β : Type u_2}
[LT β]
[DecidableLT β]
(f : α → β)
(s : Set α)
:
Set β
Maps f to s.
Equations
- Cedar.Data.Set.map f s = Cedar.Data.Set.make (List.map f s.elts)
Instances For
def
Cedar.Data.Set.mapOrErr
{α : Type u_1}
{β : Type u_2}
{ε : Type u_3}
[DecidableEq β]
[LT β]
[DecidableRel fun (x1 x2 : β) => x1 < x2]
(f : α → Except ε β)
(s : Set α)
(err : ε)
:
Maps f to s and returns the result of err if any error is encountered.
Equations
- Cedar.Data.Set.mapOrErr f s err = match List.mapM f s.elts with | Except.ok elts => Except.ok (Cedar.Data.Set.make elts) | Except.error a => Except.error err
Instances For
Returns true if all elements of s satisfy f.
Equations
- Cedar.Data.Set.all f s = s.elts.all f
Instances For
Returns true if some element of s satisfies f.
Equations
- Cedar.Data.Set.any f s = s.elts.any f
Instances For
Equations
Instances For
Equations
- Cedar.Data.Set.foldl f init s = List.foldl f init s.elts
Instances For
Equations
- Cedar.Data.Set.instLT = { lt := fun (a b : Cedar.Data.Set α) => a.elts < b.elts }
Equations
- (Cedar.Data.Set.mk nelts).decLt (Cedar.Data.Set.mk melts) = nelts.decidableLT melts
Equations
- Cedar.Data.Set.instEmptyCollection = { emptyCollection := Cedar.Data.Set.empty }
Equations
- Cedar.Data.Set.instMembership = { mem := fun (s : Cedar.Data.Set α) (v : α) => v ∈ s.elts }
Equations
- Cedar.Data.Set.instHasSubsetOfDecidableEq = { Subset := fun (s₁ s₂ : Cedar.Data.Set α) => s₁.subset s₂ = true }