• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • 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$
        • Defconst
        • Fast-alists
        • Defmacro
        • Loop$-primer
        • 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
        • Set-register-invariant-risk
        • Strings
          • Std/strings
            • Pretty-printing
              • Pretty-printing-implementation
                • Missing-functionality
                • Printconfig
                • Cons-ppr1
                • Print-escaped-charlist
                • Atom-size
                • Print-escaped-str
                • Obj-size
                  • Maybe-merge-flat
                  • Ppr
                  • Printer-instructions
                  • Keyword-param-valuep
                  • Print-flat-objs
                  • Radix-print-int
                  • Print-escaped-atom
                  • Print-atom
                  • Print-escaped-symbol
                  • Radix-print-complex
                  • Basic-print-complex
                  • Radix-print-rat
                  • Spaces1
                  • Basic-print-rat
                  • Basic-print-nat
                  • Basic-print-int
                  • Spaces
                  • My-needs-slashes
                  • Pinstlist->max-width
                  • Nat-size
                  • Special-term-num
                  • Print-column
                  • Print-base-fix
                  • Int-size
                  • Keyword-fix
                  • Print-instruction
                  • Pinst->width
                  • In-home-package-p
                  • Eviscerated->guts
                  • Evisceratedp
                  • Pprdot
                • Eviscerate
                • Pretty
                • Revappend-pretty
                • Pretty-list
              • Printtree
              • Base64
              • Charset-p
              • Strtok!
              • Cases
              • Concatenation
              • Character-kinds
              • Html-encoding
              • Substrings
              • Strtok
              • Equivalences
              • Url-encoding
              • Lines
              • Explode-implode-equalities
              • Ordering
              • Numbers
              • Pad-trim
              • Coercion
              • Std/strings/digit-to-char
              • Substitution
              • Symbols
            • String-listp
            • Stringp
            • Length
            • Search
            • Remove-duplicates
            • Position
            • Coerce
            • Concatenate
            • Reverse
            • String
            • Subseq
            • Substitute
            • String-upcase
            • String-downcase
            • Count
            • Char
            • String<
            • String-equal
            • String-utilities
            • String-append
            • String>=
            • String<=
            • String>
            • Hex-digit-char-theorems
            • String-downcase-gen
            • String-upcase-gen
          • 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
        • Miscellaneous
        • Output-controls
        • Bdd
        • Macros
        • Installation
        • Mailing-lists
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Pretty-printing-implementation

    Obj-size

    How many characters are required to print an object. (bounded)

    Signature
    (obj-size x size max eviscp config) → size
    Arguments
    x — Object whose size we are counting.
    size — Size we've counted up so far.
        Guard (natp size).
    max — Limit on how large of a size to compute.
        Guard (natp max).
    eviscp — Is evisceration enabled?.
        Guard (booleanp eviscp).
    config — For settings like print-base, etc.
        Guard (printconfig-p config).
    Returns
    size — Type (posp size).

    Definitions and Theorems

    Function: obj-size

    (defun obj-size (x size max eviscp config)
      (declare (xargs :guard (and (natp size)
                                  (natp max)
                                  (booleanp eviscp)
                                  (printconfig-p config))))
      (let ((acl2::__function__ 'obj-size))
        (declare (ignorable acl2::__function__))
        (b* ((size (lnfix size))
             (max (lnfix max))
             ((when (> size max)) size)
             ((when (atom x))
              (+ size (atom-size x config)))
             ((when (and eviscp (evisceratedp x)))
              (+ size
                 (max 1 (length (eviscerated->guts x)))))
             ((when (atom (cdr x)))
              (if (not (cdr x))
                  (obj-size (car x)
                            (+ 2 size)
                            max eviscp config)
                (obj-size (cdr x)
                          (obj-size (car x)
                                    (+ 5 size)
                                    max eviscp config)
                          max eviscp config)))
             ((when (and (eq (car x) 'quote)
                         (consp (cdr x))
                         (null (cddr x))))
              (obj-size (cadr x)
                        (+ 1 size)
                        max eviscp config)))
          (obj-size (cdr x)
                    (obj-size (car x)
                              (+ 1 size)
                              max eviscp config)
                    max eviscp config))))

    Theorem: posp-of-obj-size

    (defthm posp-of-obj-size
      (b* ((size (obj-size x size max eviscp config)))
        (posp size))
      :rule-classes :type-prescription)