• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Recursion-and-induction
      • Hons-and-memoization
      • Events
      • Parallelism
      • History
      • Programming
        • Defun
        • Declare
        • System-utilities
        • Stobj
        • State
        • Mutual-recursion
        • Memoize
        • Mbe
        • Io
        • Defpkg
        • Apply$
        • Loop$
        • Programming-with-state
        • Arrays
        • Characters
        • Time$
        • Defmacro
        • Loop$-primer
        • Fast-alists
        • Defconst
        • Evaluation
        • Guard
        • Equality-variants
        • Compilation
        • Hons
        • ACL2-built-ins
        • Developers-guide
        • System-attachments
        • Advanced-features
        • Set-check-invariant-risk
        • Numbers
        • Efficiency
        • Irrelevant-formals
        • Introduction-to-programming-in-ACL2-for-those-who-know-lisp
        • Redefining-programs
        • Lists
        • Invariant-risk
        • Errors
        • Defabbrev
        • Conses
        • Alists
          • Omaps
            • Defomap
            • Update
            • Mapp
            • Assoc
            • Update*
            • Size
              • Keys
              • From-lists
              • Update-induction-on-maps
              • Compatiblep
              • Tail
              • Head
              • Restrict
              • Submap
              • Map
              • Rlookup
              • Emptyp
              • Rlookup*
              • Lookup*
              • Delete*
              • Values
              • In*
              • Lookup
              • Delete
              • Mfix
              • Head-val
              • Head-key
              • Omap-induction2
              • Omap-order-rules
            • Std/alists
            • Fast-alists
            • Alistp
            • Misc/records
            • Remove-assocs
            • Assoc
            • Symbol-alistp
            • Rassoc
            • Remove-assoc
            • Remove1-assoc
            • Alist-map-vals
            • Depgraph
            • Alist-map-keys
            • Put-assoc
            • Strip-cars
            • Pairlis$
            • Strip-cdrs
            • Sublis
            • Acons
            • Eqlable-alistp
            • Assoc-string-equal
            • Alist-to-doublets
            • Character-alistp
            • String-alistp
            • Alist-keys-subsetp
            • R-symbol-alistp
            • R-eqlable-alistp
            • Pairlis
            • Pairlis-x2
            • Pairlis-x1
            • Delete-assoc
          • Set-register-invariant-risk
          • Strings
          • Program-wrapper
          • Get-internal-time
          • Basics
          • Packages
          • Oracle-eval
          • Defmacro-untouchable
          • <<
          • Primitive
          • Revert-world
          • Unmemoize
          • Set-duplicate-keys-action
          • Symbols
          • Def-list-constructor
          • Easy-simplify-term
          • Defiteration
          • Fake-oracle-eval
          • Defopen
          • Sleep
        • Operational-semantics
        • Real
        • Start-here
        • Debugging
        • Miscellaneous
        • Output-controls
        • Macros
        • Interfacing-tools
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Omaps

    Size

    Size of an omap.

    Signature
    (size map) → size
    Arguments
    map — Guard (mapp map).
    Returns
    size — Type (natp size).

    This is the number of keys in the omap.

    The unfold-...-size-const are useful to turn assertions about sizes and constants into assertions about emptyp and tail; the expansion terminates because of the syntaxp restriction. These theorems are disabled by default. These are the omap analogous of these theorems for lists.

    Definitions and Theorems

    Function: size

    (defun size (map)
      (declare (xargs :guard (mapp map)))
      (let ((__function__ 'size))
        (declare (ignorable __function__))
        (cond ((emptyp map) 0)
              (t (1+ (size (tail map)))))))

    Theorem: natp-of-size

    (defthm natp-of-size
      (b* ((size (size map))) (natp size))
      :rule-classes :rewrite)

    Theorem: unfold-equal-size-const

    (defthm unfold-equal-size-const
      (implies (syntaxp (quotep c))
               (equal (equal (size map) c)
                      (if (natp c)
                          (if (equal c 0)
                              (emptyp map)
                            (and (not (emptyp map))
                                 (equal (size (tail map)) (1- c))))
                        nil))))

    Theorem: unfold-gteq-size-const

    (defthm unfold-gteq-size-const
      (implies (syntaxp (quotep c))
               (equal (>= (size map) c)
                      (or (<= (fix c) 0)
                          (and (not (emptyp map))
                               (>= (size (tail map)) (1- c)))))))

    Theorem: unfold-gt-size-const

    (defthm unfold-gt-size-const
      (implies (syntaxp (quotep c))
               (equal (> (size map) c)
                      (or (< (fix c) 0)
                          (and (not (emptyp map))
                               (> (size (tail map)) (1- c)))))))

    Theorem: size-to-cardinality-of-keys

    (defthm size-to-cardinality-of-keys
      (equal (size map)
             (cardinality (keys map))))

    Theorem: cardinality-of-keys-to-size

    (defthm cardinality-of-keys-to-size
      (equal (cardinality (keys map))
             (size map)))