• 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
        • Set-register-invariant-risk
        • Strings
          • Std/strings
            • Pretty-printing
            • Printtree
              • Printable
              • Base64
              • Charset-p
              • Strtok!
              • Cases
              • Concatenation
              • Html-encoding
              • Character-kinds
              • 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
        • Debugging
        • Miscellaneous
        • Output-controls
        • Macros
        • Interfacing-tools
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Printtree

    Printable

    A printable element: a string, a character, or NIL, which we take as equivalent to the empty string.

    The main operation on a printable element is printable->str, which turns it into a string. Printable objects are the leaves of printtree objects.

    Definitions and Theorems

    Function: printable-p

    (defun printable-p (x)
      (declare (xargs :guard t))
      (or (stringp x)
          (characterp x)
          (eq x nil)))

    Theorem: printable-p-compound-recognizer

    (defthm printable-p-compound-recognizer
      (iff (printable-p x)
           (or (stringp x)
               (characterp x)
               (eq x nil)))
      :rule-classes :compound-recognizer)

    Theorem: printable-p-when-stringp

    (defthm printable-p-when-stringp
      (implies (stringp x) (printable-p x)))

    Theorem: printable-p-when-characterp

    (defthm printable-p-when-characterp
      (implies (characterp x)
               (printable-p x)))

    Function: printable-fix$

    (defun printable-fix$ (x)
      (declare (xargs :guard t))
      (and (printable-p x) x))

    Function: printable-fix

    (defun printable-fix (x)
      (declare (xargs :guard (printable-p x)))
      (mbe :logic (and (printable-p x) x)
           :exec x))

    Theorem: printable-p-of-printable-fix

    (defthm printable-p-of-printable-fix
      (printable-p (printable-fix x)))

    Theorem: printable-fix-when-printable-p

    (defthm printable-fix-when-printable-p
      (implies (printable-p x)
               (equal (printable-fix x) x)))

    Theorem: printable-fix$-is-printable-fix

    (defthm printable-fix$-is-printable-fix
      (equal (printable-fix$ x)
             (printable-fix x)))

    Function: printable->str

    (defun printable->str (x)
      (declare (xargs :guard (printable-p x)))
      (cond ((stringp x) x)
            ((characterp x)
             (coerce (list x) 'string))
            (t "")))

    Function: revappend-printable

    (defun revappend-printable (x acc)
      (declare (xargs :guard (printable-p x)))
      (mbe :logic (revappend-chars (printable->str x) acc)
           :exec (cond ((stringp x) (revappend-chars x acc))
                       ((characterp x) (cons x acc))
                       (t acc))))