• 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

    Occs

    Number of occurrences of a value in an obag.

    Signature
    (occs x bag) → occs
    Arguments
    bag — Guard (bagp bag).
    Returns
    occs — Type (natp occs).

    Definitions and Theorems

    Function: occs

    (defun occs (x bag)
           (declare (xargs :guard (bagp bag)))
           (let ((__function__ 'occs))
                (declare (ignorable __function__))
                (cond ((empty bag) 0)
                      ((equal x (head bag))
                       (1+ (occs x (tail bag))))
                      (t (occs x (tail bag))))))

    Theorem: natp-of-occs

    (defthm natp-of-occs
            (b* ((occs (occs x bag))) (natp occs))
            :rule-classes :rewrite)