Parse a given natural number into a tree that matches a direct numeric value notation that consists of that number.
(parse-exact nat input) → (mv error? tree? rest-input)
Function:
(defun parse-exact (nat input) (declare (xargs :guard (and (natp nat) (nat-listp input)))) (b* ((nat (lnfix nat)) ((mv error? input-nat input) (parse-any input)) ((when error?) (mv error? nil input)) ((unless (= input-nat nat)) (mv (msg "Failed to parse ~x0; found ~x1 instead." nat input-nat) nil (cons input-nat input)))) (mv nil (tree-leafterm (list nat)) input)))
Theorem:
(defthm maybe-msgp-of-parse-exact.error? (b* (((mv ?error? ?tree? ?rest-input) (parse-exact nat input))) (maybe-msgp error?)) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-parse-exact.tree? (b* (((mv ?error? ?tree? ?rest-input) (parse-exact nat input))) (and (tree-optionp tree?) (implies (not error?) (treep tree?)) (implies error? (not tree?)))) :rule-classes :rewrite)
Theorem:
(defthm nat-listp-of-parse-exact.rest-input (b* (((mv ?error? ?tree? ?rest-input) (parse-exact nat input))) (nat-listp rest-input)) :rule-classes :rewrite)
Theorem:
(defthm len-of-parse-exact-linear-<= (b* (((mv ?error? ?tree? ?rest-input) (parse-exact nat input))) (<= (len rest-input) (len input))) :rule-classes :linear)
Theorem:
(defthm len-of-parse-exact-linear-< (b* (((mv ?error? ?tree? ?rest-input) (parse-exact nat input))) (implies (not error?) (< (len rest-input) (len input)))) :rule-classes :linear)
Theorem:
(defthm parse-exact-of-nfix-nat (equal (parse-exact (nfix nat) input) (parse-exact nat input)))
Theorem:
(defthm parse-exact-nat-equiv-congruence-on-nat (implies (acl2::nat-equiv nat nat-equiv) (equal (parse-exact nat input) (parse-exact nat-equiv input))) :rule-classes :congruence)
Theorem:
(defthm parse-exact-of-nat-list-fix-input (equal (parse-exact nat (nat-list-fix input)) (parse-exact nat input)))
Theorem:
(defthm parse-exact-nat-list-equiv-congruence-on-input (implies (acl2::nat-list-equiv input input-equiv) (equal (parse-exact nat input) (parse-exact nat input-equiv))) :rule-classes :congruence)