Union of all (the occurrences of) all the elements of two obags.
This is similar to set::union for osets.
Function:
(defun union (bag1 bag2) (declare (xargs :guard (and (bagp bag1) (bagp bag2)))) (let ((__function__ 'union)) (declare (ignorable __function__)) (if (emptyp bag1) (bfix bag2) (insert (head bag1) (union (tail bag1) bag2)))))
Theorem:
(defthm bagp-of-union (b* ((bag (union bag1 bag2))) (bagp bag)) :rule-classes :rewrite)