• 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
            • Pretty-printing
            • Printtree
            • Base64
            • Charset-p
            • Strtok!
            • Cases
              • Icharlisteqv
              • Upcase-charlist
              • Downcase-charlist
              • Upcase-string
              • Istreqv
                • Downcase-char
                • Upcase-char
                • Ichareqv
                • Downcase-string
                • Upcase-first-charlist
                • Downcase-first-charlist
                • Downcase-first
                • Upcase-first
                • Down-alpha-p
                • Up-alpha-p
                • Upcase-char-str
                • Downcase-char-str
                • Upcase-string-list
                • Downcase-string-list
              • 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
              • Symbols
            • String-listp
            • Stringp
            • Length
            • Search
            • Remove-duplicates
            • Position
            • Coerce
            • Concatenate
            • Reverse
            • String
            • Subseq
            • Substitute
            • 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
    • Equivalences
    • Cases

    Istreqv

    Case-insensitive string equivalence test.

    Signature
    (istreqv x y) → bool

    (istreqv x y) determines if x and y are case-insensitively equivalent strings. That is, x and y must have the same length and their elements must be ichareqv to one another.

    Logically this is identical to

    (icharlisteqv (explode x) (explode y))

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

    NOTE: for reasoning, we leave this function enabled and prefer to work with icharlisteqv of the coerces as our normal form.

    Definitions and Theorems

    Function: istreqv-aux

    (defun istreqv-aux (x y n l)
      (declare (type string x)
               (type string y)
               (type (integer 0 *) n)
               (type (integer 0 *) l)
               (xargs :guard (and (natp n)
                                  (natp l)
                                  (equal (length x) l)
                                  (equal (length y) l)
                                  (<= n l))))
      (mbe :logic
           (if (zp (- (nfix l) (nfix n)))
               t
             (and (ichareqv (char x n) (char y n))
                  (istreqv-aux x y (+ (nfix n) 1) l)))
           :exec
           (if (eql n l)
               t
             (and (ichareqv (the character (char x n))
                            (the character (char y n)))
                  (istreqv-aux x y (the (integer 0 *) (+ 1 n))
                               l)))))

    Theorem: istreqv-aux-removal

    (defthm istreqv-aux-removal
      (implies (and (stringp x)
                    (stringp y)
                    (natp n)
                    (<= n l)
                    (= l (length x))
                    (= l (length y)))
               (equal (istreqv-aux x y n l)
                      (icharlisteqv (nthcdr n (explode x))
                                    (nthcdr n (explode y))))))

    Function: istreqv$inline

    (defun istreqv$inline (x y)
      (declare (type string x)
               (type string y))
      (let ((acl2::__function__ 'istreqv))
        (declare (ignorable acl2::__function__))
        (mbe :logic
             (icharlisteqv (explode x) (explode y))
             :exec
             (b* (((the (integer 0 *) xl) (length x))
                  ((the (integer 0 *) yl) (length y)))
               (and (eql xl yl)
                    (istreqv-aux x y 0 xl))))))

    Theorem: istreqv-is-an-equivalence

    (defthm istreqv-is-an-equivalence
      (and (booleanp (istreqv x y))
           (istreqv x x)
           (implies (istreqv x y) (istreqv y x))
           (implies (and (istreqv x y) (istreqv y z))
                    (istreqv x z)))
      :rule-classes (:equivalence))

    Theorem: streqv-refines-istreqv

    (defthm streqv-refines-istreqv
      (implies (streqv x y) (istreqv x y))
      :rule-classes (:refinement))

    Theorem: istreqv-implies-ichareqv-char-1

    (defthm istreqv-implies-ichareqv-char-1
      (implies (istreqv x x-equiv)
               (ichareqv (char x n) (char x-equiv n)))
      :rule-classes (:congruence))

    Theorem: istreqv-implies-icharlisteqv-explode-1

    (defthm istreqv-implies-icharlisteqv-explode-1
      (implies (istreqv x x-equiv)
               (icharlisteqv (explode x)
                             (explode x-equiv)))
      :rule-classes (:congruence))

    Theorem: istreqv-implies-istreqv-string-append-1

    (defthm istreqv-implies-istreqv-string-append-1
      (implies (istreqv x x-equiv)
               (istreqv (string-append x y)
                        (string-append x-equiv y)))
      :rule-classes (:congruence))

    Theorem: istreqv-implies-istreqv-string-append-2

    (defthm istreqv-implies-istreqv-string-append-2
      (implies (istreqv y y-equiv)
               (istreqv (string-append x y)
                        (string-append x y-equiv)))
      :rule-classes (:congruence))