Parse an optional repetition range.
Function:
(defun parse-?repeat (input) (declare (xargs :guard (nat-listp input))) (seq-backtrack input ((tree := (parse-repeat input)) (return (make-tree-nonleaf :rulename? nil :branches (list (list tree))))) ((return-raw (mv nil (make-tree-nonleaf :rulename? nil :branches nil) (nat-list-fix input))))))
Theorem:
(defthm not-of-parse-?repeat.error? (b* (((mv ?error? ?tree ?rest-input) (parse-?repeat input))) (not error?)) :rule-classes :rewrite)
Theorem:
(defthm treep-of-parse-?repeat.tree (b* (((mv ?error? ?tree ?rest-input) (parse-?repeat input))) (treep tree)) :rule-classes :rewrite)
Theorem:
(defthm nat-listp-of-parse-?repeat.rest-input (b* (((mv ?error? ?tree ?rest-input) (parse-?repeat input))) (nat-listp rest-input)) :rule-classes :rewrite)
Theorem:
(defthm len-of-parse-?repeat-linear (b* (((mv ?error? ?tree ?rest-input) (parse-?repeat input))) (<= (len rest-input) (len input))) :rule-classes :linear)
Theorem:
(defthm parse-?repeat-of-nat-list-fix-input (equal (parse-?repeat (nat-list-fix input)) (parse-?repeat input)))
Theorem:
(defthm parse-?repeat-nat-list-equiv-congruence-on-input (implies (acl2::nat-list-equiv input input-equiv) (equal (parse-?repeat input) (parse-?repeat input-equiv))) :rule-classes :congruence)