(sublistp x y) checks whether the list
ACL2 has a built-in search function, but it's very complicated; it can operate on either lists or strings, using either equality or case-insensitive character comparison, and can stop early, and can search from the front or end, and so on.
In comparison,
Function:
(defun sublistp (x y) (declare (xargs :guard t)) (cond ((prefixp x y) t) ((atom y) nil) (t (sublistp x (cdr y)))))
Theorem:
(defthm sublistp-when-atom-left (implies (atom x) (equal (sublistp x y) t)))
Theorem:
(defthm sublistp-when-atom-right (implies (atom y) (equal (sublistp x y) (atom x))))
Theorem:
(defthm sublistp-of-cons-right (equal (sublistp x (cons a y)) (or (prefixp x (cons a y)) (sublistp x y))))
Theorem:
(defthm sublistp-when-prefixp (implies (prefixp x y) (sublistp x y)))
Theorem:
(defthm sublistp-of-list-fix-left (equal (sublistp (list-fix x) y) (sublistp x y)))
Theorem:
(defthm sublistp-of-list-fix-right (equal (sublistp x (list-fix y)) (sublistp x y)))
Theorem:
(defthm list-equiv-implies-equal-sublistp-1 (implies (list-equiv x x-equiv) (equal (sublistp x y) (sublistp x-equiv y))) :rule-classes (:congruence))
Theorem:
(defthm list-equiv-implies-equal-sublistp-2 (implies (list-equiv y y-equiv) (equal (sublistp x y) (sublistp x y-equiv))) :rule-classes (:congruence))
Theorem:
(defthm lower-bound-of-len-when-sublistp (implies (sublistp x y) (<= (len x) (len y))) :rule-classes ((:rewrite) (:linear)))
Theorem:
(defthm sublistp-sound (implies (sublistp x y) (let ((n (listpos x y))) (prefixp x (nthcdr n y)))))
Theorem:
(defthm sublistp-complete (implies (prefixp x (nthcdr n y)) (sublistp x y)))