• 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
          • Istrpos
          • Strrpos
          • Strpos
          • Collect-syms-with-isubstr
          • Istrprefixp
          • Collect-strs-with-isubstr
          • Iprefixp
          • Strsuffixp
          • Firstn-chars
          • Strprefixp
            • Strprefixp-impl
          • Isubstrp
          • Substrp
        • Strtok
        • Equivalences
        • Url-encoding
        • Lines
        • Explode-implode-equalities
        • Ordering
        • Numbers
        • Pad-trim
        • Coercion
        • 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
  • Substrings

Strprefixp

Case-sensitive string prefix test.

(strprefixp x y) determines if the string x is a prefix of the string y, in a case-sensitive manner.

Logically, this is identical to

(prefixp (explode x) (explode y))

But we use a more efficient implementation which avoids coercing the strings into character lists.

Definitions and Theorems

Function: strprefixp$inline

(defun strprefixp$inline (x y)
 (declare (type string x)
          (type string y))
 (mbe
     :logic (prefixp (explode x) (explode y))
     :exec (strprefixp-impl (the string x)
                            (the string y)
                            (the integer 0)
                            (the integer 0)
                            (the integer (length (the string x)))
                            (the integer (length (the string y))))))

Theorem: streqv-implies-equal-strprefixp-1

(defthm streqv-implies-equal-strprefixp-1
  (implies (streqv x x-equiv)
           (equal (strprefixp x y)
                  (strprefixp x-equiv y)))
  :rule-classes (:congruence))

Theorem: streqv-implies-equal-strprefixp-2

(defthm streqv-implies-equal-strprefixp-2
  (implies (streqv y y-equiv)
           (equal (strprefixp x y)
                  (strprefixp x y-equiv)))
  :rule-classes (:congruence))

Subtopics

Strprefixp-impl
Fast implementation of strprefixp.