Parse a natural number that encodes, case-insensitively, a given character, into a tree that matches a case-insensitive character value notation that consists of that character.
(parse-ichar char input) → (mv error? tree? rest-input)
Function:
(defun parse-ichar (char input) (declare (xargs :guard (and (characterp char) (nat-listp input)))) (b* (((mv error? nat input) (parse-any input)) ((when error?) (mv error? nil input)) ((unless (nat-match-insensitive-char-p nat char)) (mv *grammar-parser-error-msg* nil (cons nat input)))) (mv nil (tree-leafterm (list nat)) input)))
Theorem:
(defthm maybe-msgp-of-parse-ichar.error? (b* (((mv ?error? ?tree? ?rest-input) (parse-ichar char input))) (maybe-msgp error?)) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-parse-ichar.tree? (b* (((mv ?error? ?tree? ?rest-input) (parse-ichar char input))) (and (tree-optionp tree?) (implies (not error?) (treep tree?)) (implies error? (not tree?)))) :rule-classes :rewrite)
Theorem:
(defthm nat-listp-of-parse-ichar.rest-input (b* (((mv ?error? ?tree? ?rest-input) (parse-ichar char input))) (nat-listp rest-input)) :rule-classes :rewrite)
Theorem:
(defthm len-of-parse-ichar-linear (b* (((mv ?error? ?tree? ?rest-input) (parse-ichar char input))) (and (<= (len rest-input) (len input)) (implies (not error?) (< (len rest-input) (len input))))) :rule-classes :linear)
Theorem:
(defthm parse-ichar-of-char-fix-char (equal (parse-ichar (char-fix char) input) (parse-ichar char input)))
Theorem:
(defthm parse-ichar-chareqv-congruence-on-char (implies (acl2::chareqv char char-equiv) (equal (parse-ichar char input) (parse-ichar char-equiv input))) :rule-classes :congruence)
Theorem:
(defthm parse-ichar-of-nat-list-fix-input (equal (parse-ichar char (nat-list-fix input)) (parse-ichar char input)))
Theorem:
(defthm parse-ichar-nat-list-equiv-congruence-on-input (implies (acl2::nat-list-equiv input input-equiv) (equal (parse-ichar char input) (parse-ichar char input-equiv))) :rule-classes :congruence)