Function:
(defun parse-charset (x index) (declare (xargs :guard (and (stringp x) (natp index)))) (let ((__function__ 'parse-charset)) (declare (ignorable __function__)) (b* ((x (lstrfix x)) (index (lnfix index)) ((when (<= (strlen x) index)) (mv "String ended inside charset" nil index)) ((mv negp index) (if (eql (char x index) #\^) (mv t (+ 1 index)) (mv nil index))) ((when (<= (strlen x) index)) (mv "String ended inside charset" nil index)) ((mv err chars last-index) (parse-charset-aux x index)) ((when err) (mv err nil last-index))) (mv nil (regex-charset (coerce chars 'string) negp) last-index))))
Theorem:
(defthm maybe-stringp-of-parse-charset.err (b* (((mv ?err ?pat ?new-index) (parse-charset x index))) (acl2::maybe-stringp err)) :rule-classes :type-prescription)
Theorem:
(defthm return-type-of-parse-charset.pat (b* (((mv ?err ?pat ?new-index) (parse-charset x index))) (implies (not err) (regex-p pat))) :rule-classes :rewrite)
Theorem:
(defthm natp-of-parse-charset.new-index (b* (((mv ?err ?pat ?new-index) (parse-charset x index))) (natp new-index)) :rule-classes :type-prescription)
Theorem:
(defthm new-index-of-parse-charset (b* (((mv ?err ?pat ?new-index) (parse-charset x index))) (<= (nfix index) new-index)) :rule-classes :linear)
Theorem:
(defthm new-index-of-parse-charset-strong (b* (((mv ?err ?pat ?new-index) (parse-charset x index))) (implies (not err) (< (nfix index) new-index))) :rule-classes :linear)
Theorem:
(defthm new-index-of-parse-charset-less-than-length (b* (((mv ?err ?pat ?new-index) (parse-charset x index))) (implies (<= (nfix index) (len (acl2::explode x))) (<= new-index (len (acl2::explode x))))) :rule-classes :linear)
Theorem:
(defthm parse-charset-of-str-fix-x (equal (parse-charset (acl2::str-fix x) index) (parse-charset x index)))
Theorem:
(defthm parse-charset-streqv-congruence-on-x (implies (acl2::streqv x x-equiv) (equal (parse-charset x index) (parse-charset x-equiv index))) :rule-classes :congruence)
Theorem:
(defthm parse-charset-of-nfix-index (equal (parse-charset x (nfix index)) (parse-charset x index)))
Theorem:
(defthm parse-charset-nat-equiv-congruence-on-index (implies (acl2::nat-equiv index index-equiv) (equal (parse-charset x index) (parse-charset x index-equiv))) :rule-classes :congruence)