Function:
(defun parse-k-backref (x index) (declare (xargs :guard (and (stringp x) (natp index)))) (declare (xargs :guard (<= index (strlen x)))) (let ((__function__ 'parse-k-backref)) (declare (ignorable __function__)) (b* ((index (lnfix index)) ((when (<= (strlen x) (lnfix index))) (mv "EOS parsing \\k backref" nil index)) (char (char x index)) (end-delim (case char (#\{ "}") (#\< ">") (#\' "'") (t nil))) ((unless end-delim) (mv "Bad delimiter in \\k backref" nil index)) (idx (find-substr end-delim x index)) ((unless idx) (mv "Unclosed name in \\k capture form" nil index)) (name (subseq x index idx)) (index (+ 1 idx))) (mv nil (regex-backref name) index))))
Theorem:
(defthm maybe-stringp-of-parse-k-backref.err (b* (((mv ?err ?pat ?new-index) (parse-k-backref x index))) (acl2::maybe-stringp err)) :rule-classes :type-prescription)
Theorem:
(defthm return-type-of-parse-k-backref.pat (b* (((mv ?err ?pat ?new-index) (parse-k-backref x index))) (implies (not err) (regex-p pat))) :rule-classes :rewrite)
Theorem:
(defthm natp-of-parse-k-backref.new-index (b* (((mv ?err ?pat ?new-index) (parse-k-backref x index))) (natp new-index)) :rule-classes :type-prescription)
Theorem:
(defthm new-index-of-parse-k-backref (b* (((mv ?err ?pat ?new-index) (parse-k-backref x index))) (<= (nfix index) new-index)) :rule-classes :linear)
Theorem:
(defthm new-index-of-parse-k-backref-strong (b* (((mv ?err ?pat ?new-index) (parse-k-backref x index))) (implies (not err) (< (nfix index) new-index))) :rule-classes :linear)
Theorem:
(defthm new-index-of-parse-k-backref-less-than-length (b* (((mv ?err ?pat ?new-index) (parse-k-backref x index))) (implies (<= (nfix index) (len (acl2::explode x))) (<= new-index (len (acl2::explode x))))) :rule-classes :linear)
Theorem:
(defthm no-change-of-parse-k-backref (b* (((mv ?err ?pat ?new-index) (parse-k-backref x index))) (implies err (equal new-index (nfix index)))))
Theorem:
(defthm parse-k-backref-of-str-fix-x (equal (parse-k-backref (acl2::str-fix x) index) (parse-k-backref x index)))
Theorem:
(defthm parse-k-backref-streqv-congruence-on-x (implies (acl2::streqv x x-equiv) (equal (parse-k-backref x index) (parse-k-backref x-equiv index))) :rule-classes :congruence)
Theorem:
(defthm parse-k-backref-of-nfix-index (equal (parse-k-backref x (nfix index)) (parse-k-backref x index)))
Theorem:
(defthm parse-k-backref-nat-equiv-congruence-on-index (implies (acl2::nat-equiv index index-equiv) (equal (parse-k-backref x index) (parse-k-backref x index-equiv))) :rule-classes :congruence)