• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • 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
        • Ordering
        • Numbers
        • Pad-trim
        • Coercion
        • Std/strings-extensions
        • Std/strings/digit-to-char
        • Substitution
          • Strsubst-list
            • Strsubst
          • Symbols
        • Std/io
        • Std/osets
        • Std/system
        • Std/basic
        • Std/typed-lists
        • Std/bitsets
        • Std/testing
        • Std/typed-alists
        • Std/stobjs
        • Std-extensions
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Testing-utilities
      • Math
    • Substitution

    Strsubst-list

    Carry out a strsubst replacement throughout a list of strings.

    (strsubst-list old new x) replaces every occurrence of old with new throughout x. Here, old and new are strings, but x is a list of strings. A new list of strings is returned.

    Example:

    (strsubst-list "Sun"
                   "Moon"
                   '("Sun Roof" "Hello Sun" "Sunny Sunshades"))
      -->
    ("Moon Roof" "Hello Moon" "Moonny Moonshades")

    Definitions and Theorems

    Function: strsubst-list

    (defun strsubst-list (old new x)
           (declare (xargs :guard (and (stringp old)
                                       (stringp new)
                                       (string-listp x))))
           (if (atom x)
               nil
               (cons (strsubst old new (car x))
                     (strsubst-list old new (cdr x)))))

    Theorem: strsubst-list-when-atom

    (defthm strsubst-list-when-atom
            (implies (atom x)
                     (equal (strsubst-list old new x) nil)))

    Theorem: strsubst-list-of-cons

    (defthm strsubst-list-of-cons
            (equal (strsubst-list old new (cons a x))
                   (cons (strsubst old new a)
                         (strsubst-list old new x))))

    Theorem: string-listp-of-strsubst-list

    (defthm string-listp-of-strsubst-list
            (string-listp (strsubst-list old new x)))

    Theorem: list-equiv-implies-equal-strsubst-list-3

    (defthm list-equiv-implies-equal-strsubst-list-3
            (implies (list-equiv x x-equiv)
                     (equal (strsubst-list old new x)
                            (strsubst-list old new x-equiv)))
            :rule-classes (:congruence))

    Theorem: strsubst-list-of-append

    (defthm strsubst-list-of-append
            (equal (strsubst-list old new (append x y))
                   (append (strsubst-list old new x)
                           (strsubst-list old new y))))

    Theorem: strsubst-list-of-revappend

    (defthm strsubst-list-of-revappend
            (equal (strsubst-list old new (revappend x y))
                   (revappend (strsubst-list old new x)
                              (strsubst-list old new y))))

    Theorem: strsubst-list-of-rev

    (defthm strsubst-list-of-rev
            (equal (strsubst-list old new (rev x))
                   (rev (strsubst-list old new x))))