• 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

    Bagp

    Recognize obags.

    Signature
    (bagp x) → yes/no
    Returns
    yes/no — Type (booleanp yes/no).

    This is similar to the definition of setp, but each element of the list is checked to be either equal or smaller than the next.

    Since a strictly ordered list is also non-strictly ordered, an oset is an obag.

    Definitions and Theorems

    Function: bagp

    (defun bagp (x)
           (declare (xargs :guard t))
           (let ((__function__ 'bagp))
                (declare (ignorable __function__))
                (if (atom x)
                    (null x)
                    (or (null (cdr x))
                        (and (consp (cdr x))
                             (or (equal (car x) (cadr x))
                                 (fast-<< (car x) (cadr x)))
                             (bagp (cdr x)))))))

    Theorem: booleanp-of-bagp

    (defthm booleanp-of-bagp
            (b* ((yes/no (bagp x)))
                (booleanp yes/no))
            :rule-classes :rewrite)

    Theorem: bagp-when-setp

    (defthm bagp-when-setp
            (implies (setp x) (bagp x))
            :rule-classes (:rewrite :forward-chaining))