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

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.