Number of (occurrences of) elements in an obag.
This is similar to set::cardinality on osets.
Function:
(defun cardinality (bag) (declare (xargs :guard (bagp bag))) (let ((__function__ 'cardinality)) (declare (ignorable __function__)) (if (emptyp bag) 0 (1+ (cardinality (tail bag))))))
Theorem:
(defthm natp-of-cardinality (b* ((card (cardinality bag))) (natp card)) :rule-classes :rewrite)