Lemmas about coerce available in the std/strings library.
We typically do not want to ever reason about coerce. Instead, we rewrite it away into explode or implode.
Theorem:
(defthm equal-of-coerce-strings (implies (and (character-listp x) (character-listp y)) (equal (equal (coerce x 'string) (coerce y 'string)) (equal x y))))
Theorem:
(defthm equal-of-coerce-lists (implies (and (stringp x) (stringp y)) (equal (equal (coerce x 'list) (coerce y 'list)) (equal x y))))
Theorem:
(defthm coerce-list-under-iff (iff (coerce string 'list) (and (stringp string) (not (equal "" string)))))
Theorem:
(defthm length-of-coerce (equal (length (coerce x y)) (cond ((equal y 'list) (if (stringp x) (length x) 0)) (t (if (stringp x) 0 (len x))))))
Theorem:
(defthm len-of-coerce-to-string (equal (len (coerce x 'string)) 0))
Theorem:
(defthm coerce-inverse-1-better (equal (coerce (coerce x 'string) 'list) (if (stringp x) nil (make-character-list x))))
Theorem:
(defthm coerce-inverse-2-better (equal (coerce (coerce x 'list) 'string) (if (stringp x) x "")))
Theorem:
(defthm coerce-to-list-of-make-character-list (equal (coerce (make-character-list x) 'string) (coerce x 'string)))