• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Projects
    • Debugging
    • 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

    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 ((empty 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)