• 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

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