• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
      • Std/lists
      • Std/alists
      • Obags
        • Bagp
        • Bag
        • Tail
        • Head
        • Emptyp
        • Subbag
        • Intersect
        • Union
        • Insert
        • Difference
          • Delete
          • Cardinality
          • Bfix
          • In
          • Occs
        • Std/util
        • Std/strings
        • Std/osets
        • Std/io
        • Std/basic
        • Std/system
        • Std/typed-lists
        • Std/bitsets
        • Std/testing
        • Std/typed-alists
        • Std/stobjs
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Obags

    Difference

    Remove from the first obag all (the occurrences of) the elements of the second obag.

    Signature
    (difference bag1 bag2) → bag
    Arguments
    bag1 — Guard (bagp bag1).
    bag2 — Guard (bagp bag2).
    Returns
    bag — Type (bagp bag).

    Definitions and Theorems

    Function: difference

    (defun difference (bag1 bag2)
      (declare (xargs :guard (and (bagp bag1) (bagp bag2))))
      (let ((__function__ 'difference))
        (declare (ignorable __function__))
        (cond ((emptyp bag1) nil)
              ((in (head bag1) bag2)
               (difference (tail bag1) bag2))
              (t (insert (head bag1)
                         (difference (tail bag1) bag2))))))

    Theorem: bagp-of-difference

    (defthm bagp-of-difference
      (b* ((bag (difference bag1 bag2)))
        (bagp bag))
      :rule-classes :rewrite)