Match any one of several string literals.
(sin-match-some-lit lits sin) → (mv match sin)
Since the
Corner case: like sin-match-lit, we will always fail to match the empty string.
Examples:
(sin-match-some-lit '("applesauce" "apple" "snake") [applesnake]) --> ("apple" [snake]) (sin-match-some-lit '("applesauce" "apple" "snake") [applesaucesnake]) --> ("applesauce" [snake]) (sin-match-some-lit '("applesauce" "apple" "snake") [serpent]) --> (nil [serpent])
Function:
(defun sin-match-some-lit (lits sin) (declare (xargs :stobjs (sin))) (declare (xargs :guard (string-listp lits))) (let ((__function__ 'sin-match-some-lit)) (declare (ignorable __function__)) (b* (((when (atom lits)) (mv nil sin)) ((mv match1 sin) (sin-match-lit (car lits) sin)) ((when match1) (mv match1 sin))) (sin-match-some-lit (cdr lits) sin))))
Theorem:
(defthm return-type-of-sin-match-some-lit.match (b* (((mv ?match ?sin) (sin-match-some-lit lits sin))) (or (stringp match) (not match))) :rule-classes :type-prescription)
Theorem:
(defthm stringp-of-sin-match-some-lit.match (b* (((mv ?match ?new-sin) (sin-match-some-lit lits sin))) (equal (stringp match) (if match t nil))))
Theorem:
(defthm non-empty-of-sin-match-some-lit.match (b* (((mv ?match ?new-sin) (sin-match-some-lit lits sin))) (equal (equal match "") nil)))
Theorem:
(defthm sin-match-some-lit-progress-weak (b* (((mv ?match ?new-sin) (sin-match-some-lit lits sin))) (<= (len (strin-left new-sin)) (len (strin-left sin)))) :rule-classes ((:rewrite) (:linear)))
Theorem:
(defthm sin-match-some-lit-progress-strong (b* (((mv ?match ?new-sin) (sin-match-some-lit lits sin))) (implies match (< (len (strin-left new-sin)) (len (strin-left sin))))) :rule-classes ((:rewrite) (:linear)))
Theorem:
(defthm sin-match-some-lit-reconstruction (b* (((mv ?match ?new-sin) (sin-match-some-lit lits sin))) (equal (append (explode match) (strin-left new-sin)) (strin-left sin))))
Theorem:
(defthm sin-match-some-lit-graceful-failure (b* (((mv ?match ?new-sin) (sin-match-some-lit lits sin))) (implies (not match) (equal new-sin sin))))
Theorem:
(defthm member-of-sin-match-some-lit (b* (((mv match ?new-sin) (sin-match-some-lit lits sin))) (implies match (member match lits))))