An Isomorphism
between a wrapped and unwrapped bag
Remove the BagWrapper
from a bag (the required proof from PosNat
makes
this safe)
Merge two bags
Convert a Sorted Bag to a List, keeping it sorted.
A single item (more efficient than insert x empty
)
Apply an n-ary function over the wrapped SortedMap
.
Special case for n=1 for onMaps
O(1). Are there any items? The proof in PosNat ensures that there are no
zero-counted items.
insert a given number of items
insert a single item.
Convert a list to a Sorted Bag
An empty bag.
delete a given number of items
delete 1 item (equivalent to deleteN 1
)
Delete all ocurances
Perform a count on the underlying SortedMap
Count the number of occurances
Is a count non-zero?
Apply a function (Nat -> Nat)
to a given argument
The type of insert
and the common core of most functions that update
the contests of a Bag.
A type for converting a function from an operation over SortedMaps to an
operation over SortedBags