Case-insensitive character-list prefix test.
(iprefixp x y) determines whether one character list is a prefix of another, where each character is tested using ichareqv.
Function:
(defun iprefixp (x y) (declare (xargs :guard (and (character-listp x) (character-listp y)))) (if (consp x) (and (consp y) (ichareqv (car x) (car y)) (iprefixp (cdr x) (cdr y))) t))
Theorem:
(defthm iprefixp-when-not-consp-left (implies (not (consp x)) (iprefixp x y)))
Theorem:
(defthm iprefixp-of-cons-left (equal (iprefixp (cons a x) y) (and (consp y) (ichareqv a (car y)) (iprefixp x (cdr y)))))
Theorem:
(defthm iprefixp-when-not-consp-right (implies (not (consp y)) (equal (iprefixp x y) (not (consp x)))))
Theorem:
(defthm iprefixp-of-cons-right (equal (iprefixp x (cons a y)) (if (consp x) (and (ichareqv (car x) a) (iprefixp (cdr x) y)) t)))
Theorem:
(defthm iprefixp-of-list-fix-left (equal (iprefixp (list-fix x) y) (iprefixp x y)))
Theorem:
(defthm iprefixp-of-list-fix-right (equal (iprefixp x (list-fix y)) (iprefixp x y)))
Theorem:
(defthm icharlisteqv-implies-equal-iprefixp-1 (implies (icharlisteqv x x-equiv) (equal (iprefixp x y) (iprefixp x-equiv y))) :rule-classes (:congruence))
Theorem:
(defthm icharlisteqv-implies-equal-iprefixp-2 (implies (icharlisteqv y y-equiv) (equal (iprefixp x y) (iprefixp x y-equiv))) :rule-classes (:congruence))
Theorem:
(defthm iprefixp-when-prefixp (implies (prefixp x y) (iprefixp x y)))