Number of occurrences of a value in an obag.
Function:
(defun occs (x bag) (declare (xargs :guard (bagp bag))) (let ((__function__ 'occs)) (declare (ignorable __function__)) (cond ((emptyp bag) 0) ((equal x (head bag)) (1+ (occs x (tail bag)))) (t (occs x (tail bag))))))
Theorem:
(defthm natp-of-occs (b* ((occs (occs x bag))) (natp occs)) :rule-classes :rewrite)