• 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
        • Std/strings/digit-to-char
        • Substitution
          • Strsubst-list
          • Strsubst
            • Strsubst-aux
          • 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
    • Strsubst

    Strsubst-aux

    Fast implementation of strsubst.

    Definitions and Theorems

    Function: strsubst-aux

    (defun strsubst-aux (old new x n xl oldl acc)
     (declare (type string old new x)
              (type (integer 0 *) n xl oldl)
              (xargs :guard (and (stringp old)
                                 (stringp new)
                                 (stringp x)
                                 (natp n)
                                 (natp xl)
                                 (posp oldl)
                                 (= oldl (length old))
                                 (= xl (length x)))))
     (cond ((mbe :logic (zp oldl) :exec nil) acc)
           ((mbe :logic (zp (- (nfix xl) (nfix n)))
                 :exec (>= n xl))
            acc)
           ((strprefixp-impl old x 0 n oldl xl)
            (let ((acc (revappend-chars new acc)))
              (strsubst-aux old new x
                            (the (integer 0 *)
                                 (+ oldl (the (integer 0 *) (lnfix n))))
                            xl oldl acc)))
           (t (let ((acc (cons (char x n) acc)))
                (strsubst-aux old new x
                              (the (integer 0 *)
                                   (+ 1 (the (integer 0 *) (lnfix n))))
                              xl oldl acc)))))

    Theorem: character-listp-of-strsubst-aux

    (defthm character-listp-of-strsubst-aux
     (implies (and (stringp old)
                   (stringp new)
                   (stringp x)
                   (natp n)
                   (posp oldl)
                   (= oldl (length old))
                   (= xl (length x))
                   (character-listp acc))
              (character-listp (strsubst-aux old new x n xl oldl acc))))