Parse a case-sensitive character value consisting of a given string of characters.
(parse-schars chars input) → (mv tree rest-input)
Function:
(defun parse-schars-aux (chars input) (declare (xargs :guard (and (character-listp chars) (nat-listp input)))) (let ((__function__ 'parse-schars-aux)) (declare (ignorable __function__)) (b* (((when (endp chars)) (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 (nat-match-sensitive-char-p nat (car chars))) (mv (reserrf (list :found nat :required (char-fix (car chars)))) (nat-list-fix input))) ((mv nats? input2) (parse-schars-aux (cdr chars) input1)) ((when (reserrp nats?)) (mv (reserrf-push nats?) input1)) (nats nats?)) (mv (cons nat nats) input2))))
Theorem:
(defthm nat-list-resultp-of-parse-schars-aux.nats (b* (((mv ?nats ?rest-input) (parse-schars-aux chars input))) (nat-list-resultp nats)) :rule-classes :rewrite)
Theorem:
(defthm nat-listp-of-parse-schars-aux.rest-input (b* (((mv ?nats ?rest-input) (parse-schars-aux chars input))) (nat-listp rest-input)) :rule-classes :rewrite)
Theorem:
(defthm len-of-parse-schars-aux-<= (b* (((mv ?nats ?rest-input) (parse-schars-aux chars input))) (<= (len rest-input) (len input))) :rule-classes :linear)
Theorem:
(defthm len-of-parse-schars-aux-< (b* (((mv ?nats ?rest-input) (parse-schars-aux chars input))) (implies (and (not (reserrp nats)) (consp chars)) (< (len rest-input) (len input)))) :rule-classes :linear)
Theorem:
(defthm parse-schars-aux-of-make-character-list-chars (equal (parse-schars-aux (make-character-list chars) input) (parse-schars-aux chars input)))
Theorem:
(defthm parse-schars-aux-charlisteqv-congruence-on-chars (implies (str::charlisteqv chars chars-equiv) (equal (parse-schars-aux chars input) (parse-schars-aux chars-equiv input))) :rule-classes :congruence)
Theorem:
(defthm parse-schars-aux-of-nat-list-fix-input (equal (parse-schars-aux chars (nat-list-fix input)) (parse-schars-aux chars input)))
Theorem:
(defthm parse-schars-aux-nat-list-equiv-congruence-on-input (implies (acl2::nat-list-equiv input input-equiv) (equal (parse-schars-aux chars input) (parse-schars-aux chars input-equiv))) :rule-classes :congruence)
Function:
(defun parse-schars (chars input) (declare (xargs :guard (and (common-lisp::stringp chars) (nat-listp input)))) (let ((__function__ 'parse-schars)) (declare (ignorable __function__)) (b* (((mv nats input) (parse-schars-aux (explode chars) input)) ((when (reserrp nats)) (mv (reserrf-push nats) input))) (mv (tree-leafterm nats) input))))
Theorem:
(defthm tree-resultp-of-parse-schars.tree (b* (((mv ?tree ?rest-input) (parse-schars chars input))) (tree-resultp tree)) :rule-classes :rewrite)
Theorem:
(defthm nat-listp-of-parse-schars.rest-input (b* (((mv ?tree ?rest-input) (parse-schars chars input))) (nat-listp rest-input)) :rule-classes :rewrite)
Theorem:
(defthm len-of-parse-schars-<= (b* (((mv ?tree ?rest-input) (parse-schars chars input))) (<= (len rest-input) (len input))) :rule-classes :linear)
Theorem:
(defthm len-of-parse-schars-< (b* (((mv ?tree ?rest-input) (parse-schars chars input))) (implies (and (not (reserrp tree)) (consp (explode chars))) (< (len rest-input) (len input)))) :rule-classes :linear)
Theorem:
(defthm parse-schars-of-str-fix-chars (equal (parse-schars (acl2::str-fix chars) input) (parse-schars chars input)))
Theorem:
(defthm parse-schars-streqv-congruence-on-chars (implies (acl2::streqv chars chars-equiv) (equal (parse-schars chars input) (parse-schars chars-equiv input))) :rule-classes :congruence)
Theorem:
(defthm parse-schars-of-nat-list-fix-input (equal (parse-schars chars (nat-list-fix input)) (parse-schars chars input)))
Theorem:
(defthm parse-schars-nat-list-equiv-congruence-on-input (implies (acl2::nat-list-equiv input input-equiv) (equal (parse-schars chars input) (parse-schars chars input-equiv))) :rule-classes :congruence)