Parse a range numeric value consisting of given minimum and maximum.
(parse-range min max input) → (mv tree rest-input)
Function:
(defun parse-range (min max input) (declare (xargs :guard (and (natp min) (natp max) (nat-listp input)))) (declare (xargs :guard (<= min max))) (let ((__function__ 'parse-range)) (declare (ignorable __function__)) (b* (((mv nat? input1) (parse-next input)) ((when (reserrp nat?)) (mv (reserrf-push nat?) (nat-list-fix input))) (nat nat?) ((unless (and (<= (lnfix min) nat) (<= nat (lnfix max)))) (mv (reserrf (list :found nat :required (lnfix min) (lnfix max))) (nat-list-fix input)))) (mv (tree-leafterm (list nat)) input1))))
Theorem:
(defthm tree-resultp-of-parse-range.tree (b* (((mv ?tree ?rest-input) (parse-range min max input))) (tree-resultp tree)) :rule-classes :rewrite)
Theorem:
(defthm nat-listp-of-parse-range.rest-input (b* (((mv ?tree ?rest-input) (parse-range min max input))) (nat-listp rest-input)) :rule-classes :rewrite)
Theorem:
(defthm len-of-parse-range-<= (b* (((mv ?tree ?rest-input) (parse-range min max input))) (<= (len rest-input) (len input))) :rule-classes :linear)
Theorem:
(defthm len-of-parse-range-< (b* (((mv ?tree ?rest-input) (parse-range min max input))) (implies (not (reserrp tree)) (< (len rest-input) (len input)))) :rule-classes :linear)
Theorem:
(defthm parse-range-of-nfix-min (equal (parse-range (nfix min) max input) (parse-range min max input)))
Theorem:
(defthm parse-range-nat-equiv-congruence-on-min (implies (acl2::nat-equiv min min-equiv) (equal (parse-range min max input) (parse-range min-equiv max input))) :rule-classes :congruence)
Theorem:
(defthm parse-range-of-nfix-max (equal (parse-range min (nfix max) input) (parse-range min max input)))
Theorem:
(defthm parse-range-nat-equiv-congruence-on-max (implies (acl2::nat-equiv max max-equiv) (equal (parse-range min max input) (parse-range min max-equiv input))) :rule-classes :congruence)
Theorem:
(defthm parse-range-of-nat-list-fix-input (equal (parse-range min max (nat-list-fix input)) (parse-range min max input)))
Theorem:
(defthm parse-range-nat-list-equiv-congruence-on-input (implies (acl2::nat-list-equiv input input-equiv) (equal (parse-range min max input) (parse-range min max input-equiv))) :rule-classes :congruence)