Parse a direct numeric value consisting of given natural numbers.
(parse-direct nats input) → (mv tree rest-input)
Function:
(defun parse-direct-aux (nats input) (declare (xargs :guard (and (nat-listp nats) (nat-listp input)))) (let ((__function__ 'parse-direct-aux)) (declare (ignorable __function__)) (b* (((when (endp nats)) (mv nil (nat-list-fix input))) ((mv nat? input1) (parse-next input)) ((when (reserrp nat?)) (mv (reserrf-push nat?) (nat-list-fix input))) (nat nat?) ((unless (equal nat (lnfix (car nats)))) (mv (reserrf (list :found nat :required (lnfix (car nats)))) (nat-list-fix input))) ((mv nats? input2) (parse-direct-aux (cdr nats) input1)) ((when (reserrp nats?)) (mv (reserrf-push nats?) input1)) (nats nats?)) (mv (cons nat nats) input2))))
Theorem:
(defthm nat-list-resultp-of-parse-direct-aux.nats1 (b* (((mv ?nats1 ?rest-input) (parse-direct-aux nats input))) (nat-list-resultp nats1)) :rule-classes :rewrite)
Theorem:
(defthm nat-listp-of-parse-direct-aux.rest-input (b* (((mv ?nats1 ?rest-input) (parse-direct-aux nats input))) (nat-listp rest-input)) :rule-classes :rewrite)
Theorem:
(defthm len-of-parse-direct-aux-<= (b* (((mv ?nats1 ?rest-input) (parse-direct-aux nats input))) (<= (len rest-input) (len input))) :rule-classes :linear)
Theorem:
(defthm len-of-parse-direct-aux-< (b* (((mv ?nats1 ?rest-input) (parse-direct-aux nats input))) (implies (and (not (reserrp nats1)) (consp nats)) (< (len rest-input) (len input)))) :rule-classes :linear)
Theorem:
(defthm parse-direct-aux-of-nat-list-fix-nats (equal (parse-direct-aux (nat-list-fix nats) input) (parse-direct-aux nats input)))
Theorem:
(defthm parse-direct-aux-nat-list-equiv-congruence-on-nats (implies (acl2::nat-list-equiv nats nats-equiv) (equal (parse-direct-aux nats input) (parse-direct-aux nats-equiv input))) :rule-classes :congruence)
Theorem:
(defthm parse-direct-aux-of-nat-list-fix-input (equal (parse-direct-aux nats (nat-list-fix input)) (parse-direct-aux nats input)))
Theorem:
(defthm parse-direct-aux-nat-list-equiv-congruence-on-input (implies (acl2::nat-list-equiv input input-equiv) (equal (parse-direct-aux nats input) (parse-direct-aux nats input-equiv))) :rule-classes :congruence)
Function:
(defun parse-direct (nats input) (declare (xargs :guard (and (nat-listp nats) (nat-listp input)))) (let ((__function__ 'parse-direct)) (declare (ignorable __function__)) (b* (((mv nats input) (parse-direct-aux nats input)) ((when (reserrp nats)) (mv (reserrf-push nats) input))) (mv (tree-leafterm nats) input))))
Theorem:
(defthm tree-resultp-of-parse-direct.tree (b* (((mv ?tree ?rest-input) (parse-direct nats input))) (tree-resultp tree)) :rule-classes :rewrite)
Theorem:
(defthm nat-listp-of-parse-direct.rest-input (b* (((mv ?tree ?rest-input) (parse-direct nats input))) (nat-listp rest-input)) :rule-classes :rewrite)
Theorem:
(defthm len-of-parse-direct-<= (b* (((mv ?tree ?rest-input) (parse-direct nats input))) (<= (len rest-input) (len input))) :rule-classes :linear)
Theorem:
(defthm len-of-parse-direct-< (b* (((mv ?tree ?rest-input) (parse-direct nats input))) (implies (and (not (reserrp tree)) (consp nats)) (< (len rest-input) (len input)))) :rule-classes :linear)
Theorem:
(defthm parse-direct-of-nat-list-fix-nats (equal (parse-direct (nat-list-fix nats) input) (parse-direct nats input)))
Theorem:
(defthm parse-direct-nat-list-equiv-congruence-on-nats (implies (acl2::nat-list-equiv nats nats-equiv) (equal (parse-direct nats input) (parse-direct nats-equiv input))) :rule-classes :congruence)
Theorem:
(defthm parse-direct-of-nat-list-fix-input (equal (parse-direct nats (nat-list-fix input)) (parse-direct nats input)))
Theorem:
(defthm parse-direct-nat-list-equiv-congruence-on-input (implies (acl2::nat-list-equiv input input-equiv) (equal (parse-direct nats input) (parse-direct nats input-equiv))) :rule-classes :congruence)