Function:
(defun match-string-at (target x index) (declare (xargs :guard (and (stringp target) (stringp x) (natp index)))) (declare (xargs :guard (<= index (strlen x)))) (let ((__function__ 'match-string-at)) (declare (ignorable __function__)) (b* ((match (str::strprefixp-impl (lstrfix target) (lstrfix x) 0 (lnfix index) (strlen target) (strlen x)))) (if match (mv t (+ (strlen target) (lnfix index))) (mv nil (lnfix index))))))
Theorem:
(defthm booleanp-of-match-string-at.matchedp (b* (((mv ?matchedp ?new-index) (match-string-at target x index))) (booleanp matchedp)) :rule-classes :type-prescription)
Theorem:
(defthm natp-of-match-string-at.new-index (b* (((mv ?matchedp ?new-index) (match-string-at target x index))) (natp new-index)) :rule-classes :type-prescription)
Theorem:
(defthm new-index-less-than-length-of-match-string-at (b* (((mv ?matchedp ?new-index) (match-string-at target x index))) (implies (<= (nfix index) (len (acl2::explode x))) (<= new-index (len (acl2::explode x))))) :rule-classes :linear)
Theorem:
(defthm new-index-increasing-of-match-string-at (b* (((mv ?matchedp ?new-index) (match-string-at target x index))) (<= (nfix index) new-index)) :rule-classes :linear)
Theorem:
(defthm new-index-increasing-strong-of-match-string-at (b* (((mv ?matchedp ?new-index) (match-string-at target x index))) (implies (and matchedp (not (equal 0 (strlen target)))) (< (nfix index) new-index))) :rule-classes :linear)
Theorem:
(defthm no-change-of-match-string-at (b* (((mv ?matchedp ?new-index) (match-string-at target x index))) (implies (not matchedp) (equal new-index (lnfix index)))))
Theorem:
(defthm measure-decr-of-match-string-at (b* (((mv ?matchedp ?new-index) (match-string-at target x index))) (<= (nfix (+ (len (acl2::explode x)) (- new-index))) (nfix (+ (- (nfix index)) (len (acl2::explode x)))))) :rule-classes :linear)
Theorem:
(defthm index-lte-len-when-match-string-at-nonempty (b* (((mv ?matchedp ?new-index) (match-string-at target x index))) (implies (and matchedp (not (equal 0 (strlen target)))) (<= (nfix index) (len (acl2::explode x))))) :rule-classes :forward-chaining)
Theorem:
(defthm new-index-less-than-length-of-match-string-at-when-matched-nonempty (b* (((mv ?matchedp ?new-index) (match-string-at target x index))) (implies (and matchedp (not (equal 0 (strlen target)))) (<= new-index (len (acl2::explode x))))) :rule-classes :linear)
Theorem:
(defthm measure-decr-of-match-string-at-strong (b* (((mv ?matchedp ?new-index) (match-string-at target x index))) (implies (and matchedp (not (equal 0 (strlen target)))) (< (nfix (+ (len (acl2::explode x)) (- new-index))) (nfix (+ (- (nfix index)) (len (acl2::explode x))))))) :rule-classes :linear)
Theorem:
(defthm match-string-at-of-str-fix-target (equal (match-string-at (acl2::str-fix target) x index) (match-string-at target x index)))
Theorem:
(defthm match-string-at-streqv-congruence-on-target (implies (acl2::streqv target target-equiv) (equal (match-string-at target x index) (match-string-at target-equiv x index))) :rule-classes :congruence)
Theorem:
(defthm match-string-at-of-str-fix-x (equal (match-string-at target (acl2::str-fix x) index) (match-string-at target x index)))
Theorem:
(defthm match-string-at-streqv-congruence-on-x (implies (acl2::streqv x x-equiv) (equal (match-string-at target x index) (match-string-at target x-equiv index))) :rule-classes :congruence)
Theorem:
(defthm match-string-at-of-nfix-index (equal (match-string-at target x (nfix index)) (match-string-at target x index)))
Theorem:
(defthm match-string-at-nat-equiv-congruence-on-index (implies (acl2::nat-equiv index index-equiv) (equal (match-string-at target x index) (match-string-at target x index-equiv))) :rule-classes :congruence)