• 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

    Intersect

    Intersection of all (the occurrences of) all the elements of two obags.

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

    This is similar to set::intersect for osets.

    Definitions and Theorems

    Function: intersect

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

    Theorem: bagp-of-intersect

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