(parse-hex-charcode x index) → (mv err char new-index)
Function:
(defun parse-hex-charcode (x index) (declare (xargs :guard (and (stringp x) (natp index)))) (let ((__function__ 'parse-hex-charcode)) (declare (ignorable __function__)) (b* ((index (lnfix index)) ((unless (< (+ 1 index) (strlen x))) (mv "String ended within hex charcode" (code-char 0) index)) (hex0 (char x index)) (hex1 (char x (+ 1 index))) ((unless (and (str::hex-digit-char-p hex0) (str::hex-digit-char-p hex1))) (mv "Malformed hex charcode" (code-char 0) index)) (val (str::hex-digit-chars-value (list hex0 hex1)))) (mv nil (code-char val) (+ 2 index)))))
Theorem:
(defthm maybe-stringp-of-parse-hex-charcode.err (b* (((mv ?err common-lisp::?char ?new-index) (parse-hex-charcode x index))) (acl2::maybe-stringp err)) :rule-classes :type-prescription)
Theorem:
(defthm characterp-of-parse-hex-charcode.char (b* (((mv ?err common-lisp::?char ?new-index) (parse-hex-charcode x index))) (characterp char)) :rule-classes :rewrite)
Theorem:
(defthm natp-of-parse-hex-charcode.new-index (b* (((mv ?err common-lisp::?char ?new-index) (parse-hex-charcode x index))) (natp new-index)) :rule-classes :type-prescription)
Theorem:
(defthm new-index-of-parse-hex-charcode (b* (((mv ?err common-lisp::?char ?new-index) (parse-hex-charcode x index))) (<= (nfix index) new-index)) :rule-classes :linear)
Theorem:
(defthm new-index-of-parse-hex-charcode-strong (b* (((mv ?err common-lisp::?char ?new-index) (parse-hex-charcode x index))) (implies (not err) (< (nfix index) new-index))) :rule-classes :linear)
Theorem:
(defthm new-index-of-parse-hex-charcode-less-than-length (b* (((mv ?err common-lisp::?char ?new-index) (parse-hex-charcode x index))) (implies (<= (nfix index) (len (acl2::explode x))) (<= new-index (len (acl2::explode x))))) :rule-classes :linear)
Theorem:
(defthm parse-hex-charcode-of-str-fix-x (equal (parse-hex-charcode (acl2::str-fix x) index) (parse-hex-charcode x index)))
Theorem:
(defthm parse-hex-charcode-streqv-congruence-on-x (implies (acl2::streqv x x-equiv) (equal (parse-hex-charcode x index) (parse-hex-charcode x-equiv index))) :rule-classes :congruence)
Theorem:
(defthm parse-hex-charcode-of-nfix-index (equal (parse-hex-charcode x (nfix index)) (parse-hex-charcode x index)))
Theorem:
(defthm parse-hex-charcode-nat-equiv-congruence-on-index (implies (acl2::nat-equiv index index-equiv) (equal (parse-hex-charcode x index) (parse-hex-charcode x index-equiv))) :rule-classes :congruence)