• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
      • Std/lists
      • Std/alists
      • Obags
      • Std/util
      • Std/strings
        • Pretty-printing
        • Printtree
        • Base64
        • Charset-p
        • Strtok!
        • Cases
        • Concatenation
        • Html-encoding
        • Character-kinds
        • Substrings
        • Strtok
        • Equivalences
        • Url-encoding
        • Lines
        • Explode-implode-equalities
        • Ordering
        • Numbers
        • Pad-trim
        • Coercion
          • Explode
          • Implode
            • Explode-implode-equalities
            • Implode-explode-inversion
          • Std/strings/make-character-list
          • Std/strings/coerce
        • Std/strings/digit-to-char
        • Substitution
        • Symbols
      • Std/osets
      • Std/io
      • Std/basic
      • Std/system
      • Std/typed-lists
      • Std/bitsets
      • Std/testing
      • Std/typed-alists
      • Std/stobjs
    • Proof-automation
    • Macro-libraries
    • ACL2
    • 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.