• 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

    Union

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

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

    This is similar to set::union for osets.

    Definitions and Theorems

    Function: union

    (defun union (bag1 bag2)
      (declare (xargs :guard (and (bagp bag1) (bagp bag2))))
      (let ((__function__ 'union))
        (declare (ignorable __function__))
        (if (emptyp bag1)
            (bfix bag2)
          (insert (head bag1)
                  (union (tail bag1) bag2)))))

    Theorem: bagp-of-union

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