Lemmas about last available in the std/lists library.
Theorem:
(defthm last-when-atom (implies (atom x) (equal (last x) x)))
Theorem:
(defthm last-when-atom-of-cdr (implies (atom (cdr x)) (equal (last x) x)))
Theorem:
(defthm last-of-cons (equal (last (cons a x)) (if (consp x) (last x) (cons a x))))
Theorem:
(defthm consp-of-last (equal (consp (last l)) (consp l)))
Theorem:
(defthm true-listp-of-last (equal (true-listp (last l)) (true-listp l)))
Theorem:
(defthm len-of-last (equal (len (last l)) (if (consp l) 1 0)))
Theorem:
(defthm upper-bound-of-len-of-last (< (len (last x)) 2) :rule-classes :linear)
Theorem:
(defthm member-of-car-of-last (iff (member (car (last x)) x) (if (consp x) t nil)))
Theorem:
(defthm subsetp-of-last (subsetp (last x) x))
Theorem:
(defthm last-of-append (equal (last (append x y)) (if (consp y) (last y) (append (last x) y))))
Theorem:
(defthm last-of-rev (equal (last (rev x)) (if (consp x) (list (car x)) nil)))
Theorem:
(defthm last-of-revappend (equal (last (revappend x y)) (cond ((consp y) (last y)) ((consp x) (cons (car x) y)) (t y))))
Theorem:
(defthm element-list-p-of-last (implies (element-list-p (double-rewrite x)) (element-list-p (last x))) :rule-classes :rewrite)