• 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
              • Explode-implode-equalities
              • Implode-explode-inversion
            • 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

Implode

Convert a character list into a string.

Signature
(implode x) → str
Arguments
x — Guard (character-listp x).
Returns
str — Type (stringp str).

(implode x) is logically nothing more than (coerce x 'string).

Even though coerce is built into ACL2, we prefer to use implode as our normal form. We rewrite all uses of (coerce x 'string) into (str::implode x) with the following rule:

Theorem: coerce-to-string-removal

(defthm coerce-to-string-removal
  (equal (coerce x 'string) (implode x)))

The basic rationale for this is that coerce's extra 'string argument means we can't write, e.g., congruence relations about (coerce x 'string), whereas this is no problem for (implode x).

We do the same thing for (coerce x 'list) — see explode.

Definitions and Theorems

Function: implode$inline

(defun acl2::implode$inline (x)
  (declare (xargs :guard (character-listp x)))
  (let ((acl2::__function__ 'implode))
    (declare (ignorable acl2::__function__))
    (coerce x 'string)))

Theorem: stringp-of-implode

(defthm acl2::stringp-of-implode
  (b* ((str (acl2::implode$inline x)))
    (stringp str))
  :rule-classes :type-prescription)

Theorem: equal-of-implodes

(defthm equal-of-implodes
  (implies (and (character-listp x)
                (character-listp y))
           (equal (equal (implode x) (implode y))
                  (equal x y))))

Theorem: implode-of-make-character-list

(defthm implode-of-make-character-list
  (equal (implode (make-character-list x))
         (implode x)))

Theorem: equal-of-implode-with-empty-string

(defthm equal-of-implode-with-empty-string
  (equal (equal "" (implode x)) (atom x)))

Theorem: coerce-to-string-removal

(defthm coerce-to-string-removal
  (equal (coerce x 'string) (implode x)))

Subtopics

Explode-implode-equalities
Theorems about equalities involving explode and implode.
Implode-explode-inversion
Inversion theorems for implode and explode.