• 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

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