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

Explode

Convert a string to a character list.

Signature
(explode x) → chars
Returns
chars — Type (character-listp chars).

(explode x) is logically nothing more than (coerce x 'list).

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

Theorem: coerce-to-list-removal

(defthm coerce-to-list-removal
  (equal (coerce x 'list) (explode x)))

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

We do the same thing for (coerce x 'string) — see implode.

BOZO consider using misc/fast-coerce here.

Definitions and Theorems

Function: explode$inline

(defun acl2::explode$inline (x)
  (declare (type string x))
  (let ((acl2::__function__ 'explode))
    (declare (ignorable acl2::__function__))
    (coerce x 'list)))

Theorem: character-listp-of-explode

(defthm acl2::character-listp-of-explode
  (b* ((chars (acl2::explode$inline x)))
    (character-listp chars))
  :rule-classes :rewrite)

Theorem: true-listp-of-explode

(defthm true-listp-of-explode
  (true-listp (explode x))
  :rule-classes :type-prescription)

Theorem: explode-when-not-stringp

(defthm explode-when-not-stringp
  (implies (not (stringp x))
           (equal (explode x) nil)))

Theorem: equal-of-explodes

(defthm equal-of-explodes
  (implies (and (stringp x) (stringp y))
           (equal (equal (explode x) (explode y))
                  (equal x y))))

Theorem: explode-under-iff

(defthm explode-under-iff
  (iff (explode string)
       (and (stringp string)
            (not (equal "" string)))))

Theorem: consp-of-explode

(defthm consp-of-explode
  (equal (consp (explode string))
         (and (stringp string)
              (not (equal "" string)))))

Theorem: coerce-to-list-removal

(defthm coerce-to-list-removal
  (equal (coerce x 'list) (explode x)))

Subtopics

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