• 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
        • 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
          • Std/strings
          • String-listp
          • Stringp
          • Length
          • Search
          • Remove-duplicates
          • Position
          • Coerce
          • Concatenate
          • Reverse
          • String
          • Subseq
          • Substitute
            • Strsubst
              • Strsubst-aux
            • String-upcase
            • String-downcase
            • Count
            • Char
            • String<
            • String-equal
            • String-utilities
            • String-append
            • String>=
            • String<=
            • String>
            • Hex-digit-char-theorems
            • String-downcase-gen
            • String-upcase-gen
          • 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
    • 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))))