Finite maps over multiset
#
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
multisets of sigma types #
nodupkeys s
means that s
has no duplicate keys.
Equations
- s.nodupkeys = quot.lift_on s list.nodupkeys multiset.nodupkeys._proof_1
finmap #
finmap β
is the type of finite maps over a multiset. It is effectively
a quotient of alist β
by permutation of the underlying list.
Instances for finmap
- finmap.has_sizeof_inst
- finmap.has_mem
- finmap.has_emptyc
- finmap.inhabited
- finmap.has_sdiff
- finmap.has_union
lifting from alist #
induction #
extensionality #
mem #
keys #
empty #
The empty map.
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) _
A version of finmap.mem_lookup_iff
with LHS in the simp-normal form.
Equations
- finmap.has_mem.mem.decidable a s = decidable_of_iff ↥((finmap.lookup a s).is_some) _
An equivalence between finmap β
and pairs (keys : finset α, lookup : Π a, option (β a))
such
that (lookup a).is_some ↔ a ∈ keys
.
Equations
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
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)}