• 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
          • Character-listp
          • Characterp
          • Coerce
            • Explode
            • Implode
            • Std/strings/coerce
            • Digit-char-p
            • Code-char
            • Char-code
            • Char-upcase
            • Char-downcase
            • Standard-char-p
            • Char
            • Alpha-char-p
            • Upper-case-p
            • Lower-case-p
            • Explode-nonnegative-integer
            • Explode-atom
            • Char-equal
            • Digit-to-char
            • Char<
            • Char>=
            • Make-character-list
            • Char>
            • Char<=
            • Standard-char-listp
            • Character-alistp
            • Standard-char-p+
            • Chars-upcase-gen
            • Chars-downcase-gen
            • Char-upcase-gen
            • Char-downcase-gen
          • 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
          • 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
    • Coercion
    • Coerce

    Std/strings/coerce

    Lemmas about coerce available in the std/strings library.

    We typically do not want to ever reason about coerce. Instead, we rewrite it away into explode or implode.

    Definitions and Theorems

    Theorem: equal-of-coerce-strings

    (defthm equal-of-coerce-strings
      (implies (and (character-listp x)
                    (character-listp y))
               (equal (equal (coerce x 'string)
                             (coerce y 'string))
                      (equal x y))))

    Theorem: equal-of-coerce-lists

    (defthm equal-of-coerce-lists
      (implies (and (stringp x) (stringp y))
               (equal (equal (coerce x 'list)
                             (coerce y 'list))
                      (equal x y))))

    Theorem: coerce-list-under-iff

    (defthm coerce-list-under-iff
      (iff (coerce string 'list)
           (and (stringp string)
                (not (equal "" string)))))

    Theorem: length-of-coerce

    (defthm length-of-coerce
      (equal (length (coerce x y))
             (cond ((equal y 'list)
                    (if (stringp x) (length x) 0))
                   (t (if (stringp x) 0 (len x))))))

    Theorem: len-of-coerce-to-string

    (defthm len-of-coerce-to-string
      (equal (len (coerce x 'string)) 0))

    Theorem: coerce-inverse-1-better

    (defthm coerce-inverse-1-better
      (equal (coerce (coerce x 'string) 'list)
             (if (stringp x)
                 nil
               (make-character-list x))))

    Theorem: coerce-inverse-2-better

    (defthm coerce-inverse-2-better
      (equal (coerce (coerce x 'list) 'string)
             (if (stringp x) x "")))

    Theorem: coerce-to-list-of-make-character-list

    (defthm coerce-to-list-of-make-character-list
      (equal (coerce (make-character-list x) 'string)
             (coerce x 'string)))