• 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

    Head

    Smallest element of a non-empty obag.

    Signature
    (head bag) → *
    Arguments
    bag — Guard (bagp bag).

    This is similar to head for osets.

    Definitions and Theorems

    Function: head

    (defun head (bag)
           (declare (xargs :guard (bagp bag)))
           (declare (xargs :guard (not (empty bag))))
           (let ((__function__ 'head))
                (declare (ignorable __function__))
                (mbe :logic (car (bfix bag))
                     :exec (car bag))))

    Theorem: head-when-empty

    (defthm head-when-empty
            (implies (empty bag)
                     (equal (head bag) nil))
            :rule-classes (:rewrite :type-prescription))

    Theorem: head-count

    (defthm head-count
            (implies (not (empty bag))
                     (< (acl2-count (head bag))
                        (acl2-count bag)))
            :rule-classes (:rewrite :linear))

    Theorem: head-count-built-in

    (defthm head-count-built-in
            (implies (not (empty bag))
                     (o< (acl2-count (head bag))
                         (acl2-count bag)))
            :rule-classes :built-in-clause)