• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Debugging
    • Projects
    • Std
      • Std/lists
      • Std/alists
      • Obags
        • Bagp
        • Bag
        • Tail
        • Head
        • Subbag
        • Intersect
        • Empty
        • Difference
          • Union
          • Insert
          • Bfix
          • Delete
          • Cardinality
          • Occs
          • In
        • Std/util
        • Std/strings
        • Std/io
        • Std/osets
        • Std/system
        • Std/basic
        • Std/typed-lists
        • Std/bitsets
        • Std/testing
        • Std/typed-alists
        • Std/stobjs
        • Std-extensions
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Testing-utilities
      • Math
    • 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 ((empty 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)