Finite maps over multiset
multisets of sigma types
Multiset of keys of an association multiset.
Equations
- s.keys = multiset.map sigma.fst s
nodupkeys s
means that s
has no duplicate keys.
Equations
- s.nodupkeys = quot.lift_on s list.nodupkeys multiset.nodupkeys._proof_1
finmap
lifting from alist
induction
extensionality
mem
keys
empty
The empty map.
Equations
- finmap.inhabited = {default := ∅}
singleton
The singleton map.
Equations
- finmap.singleton a b = (alist.singleton a b).to_finmap
Equations
- finmap.has_decidable_eq s₁ s₂ = decidable_of_iff (s₁.entries = s₂.entries) finmap.ext_iff
lookup
Look up the value associated to a key in a map.
Equations
- finmap.lookup a s = s.lift_on (alist.lookup a) _
Equations
- finmap.decidable a s = decidable_of_iff ↥((finmap.lookup a s).is_some) _
replace
Replace a key with a given value in a finite map. If the key is not present it does nothing.
Equations
- finmap.replace a b s = s.lift_on (λ (t : alist β), (alist.replace a b t).to_finmap) _
foldl
Fold a commutative function over the key-value pairs in the map
Equations
- finmap.foldl f H d m = multiset.foldl (λ (d : δ) (s : sigma β), f d s.fst s.snd) _ d m.entries
any f s
returns tt
iff there exists a value v
in s
such that f v = tt
.
Equations
- finmap.any f s = finmap.foldl (λ (x : bool) (y : α) (z : β y), decidable.to_bool (↥x ∨ ↥(f y z))) _ bool.ff s
all f s
returns tt
iff f v = tt
for all values v
in s
.
Equations
- finmap.all f s = finmap.foldl (λ (x : bool) (y : α) (z : β y), decidable.to_bool (↥x ∧ ↥(f y z))) _ bool.ff s
erase
Erase a key from the map. If the key is not present it does nothing.
Equations
- finmap.erase a s = s.lift_on (λ (t : alist β), (alist.erase a t).to_finmap) _
sdiff
sdiff s s'
consists of all key-value pairs from s
and s'
where the keys are in s
or
s'
but not both.
Equations
- s.sdiff s' = finmap.foldl (λ (s : finmap β) (x : α) (_x : β x), finmap.erase x s) finmap.sdiff._proof_1 s s'
Equations
- finmap.has_sdiff = {sdiff := finmap.sdiff (λ (a b : α), _inst_1 a b)}
insert
Insert a key-value pair into a finite map, replacing any existing pair with the same key.
Equations
- finmap.insert a b s = s.lift_on (λ (t : alist β), (alist.insert a b t).to_finmap) _
extract
Erase a key from the map, and return the corresponding value, if found.
Equations
- finmap.extract a s = s.lift_on (λ (t : alist β), prod.map id alist.to_finmap (alist.extract a t)) _
union
s₁ ∪ s₂
is the key-based union of two finite maps. It is left-biased: if
there exists an a ∈ s₁
, lookup a (s₁ ∪ s₂) = lookup a s₁
.
Equations
- finmap.has_union = {union := finmap.union (λ (a b : α), _inst_1 a b)}
disjoint
Equations
- finmap.decidable_rel = λ (x y : finmap β), id multiset.decidable_dforall_multiset