Match exactly some particular string literal.
(sin-match-lit lit sin) → (mv match sin)
Examples:
(sin-match-lit "apple" [applesauce]) --> ("apple" [sauce]) (sin-match-lit "apple" [candyapple]) --> (nil [candyapple])
Corner case: when
Function:
(defun sin-match-lit (lit sin) (declare (xargs :stobjs (sin))) (declare (xargs :guard (stringp lit))) (let ((__function__ 'sin-match-lit)) (declare (ignorable __function__)) (b* (((when (or (mbe :logic (not (stringp lit)) :exec nil) (equal lit ""))) (mv nil sin)) ((unless (sin-matches-p lit sin)) (mv nil sin)) (sin (sin-nthcdr (length lit) sin))) (mv lit sin))))
Theorem:
(defthm return-type-of-sin-match-lit.match (b* (((mv ?match ?sin) (sin-match-lit lit sin))) (or (stringp match) (not match))) :rule-classes :type-prescription)
Theorem:
(defthm stringp-of-sin-match-lit.match (b* (((mv ?match ?new-sin) (sin-match-lit lit sin))) (equal (stringp match) (if match t nil))))
Theorem:
(defthm non-empty-of-sin-match-lit.match (b* (((mv ?match ?new-sin) (sin-match-lit lit sin))) (equal (equal match "") nil)))
Theorem:
(defthm sin-match-lit-progress-weak (b* (((mv ?match ?new-sin) (sin-match-lit lit sin))) (<= (len (strin-left new-sin)) (len (strin-left sin)))) :rule-classes ((:rewrite) (:linear)))
Theorem:
(defthm sin-match-lit-progress-strong (b* (((mv ?match ?new-sin) (sin-match-lit lit sin))) (implies match (< (len (strin-left new-sin)) (len (strin-left sin))))) :rule-classes ((:rewrite) (:linear)))
Theorem:
(defthm sin-match-lit-reconstruction (b* (((mv ?match ?new-sin) (sin-match-lit lit sin))) (equal (append (explode match) (strin-left new-sin)) (strin-left sin))))
Theorem:
(defthm sin-match-lit-graceful-failure (b* (((mv ?match ?new-sin) (sin-match-lit lit sin))) (implies (not match) (equal new-sin sin))))
Theorem:
(defthm sin-match-lit.match-when-ok (b* (((mv ?match ?new-sin) (sin-match-lit lit sin))) (implies match (equal match lit))))
Theorem:
(defthm equal-of-sin-match-lit-and-lit (b* (((mv ?match ?new-sin) (sin-match-lit lit sin))) (equal (equal match lit) (if match (and (stringp lit) (consp (explode lit))) (not lit)))))