Add (an occurrence of) a value to an obag.
This is similar to set::insert on osets.
Function:
(defun insert (x bag) (declare (xargs :guard (bagp bag))) (let ((__function__ 'insert)) (declare (ignorable __function__)) (cond ((emptyp bag) (list x)) ((equal x (head bag)) (cons x bag)) ((<< x (head bag)) (cons x bag)) (t (cons (head bag) (insert x (tail bag)))))))
Theorem:
(defthm bagp-of-insert (b* ((bag1 (insert x bag))) (bagp bag1)) :rule-classes :rewrite)