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