(final-cdr x) returns the atom in the "cdr-most branch" of
For example,
This function is related to list-fix. It is occasionally useful for strengthening rewrite rules by removing hypotheses.
Function:
(defun final-cdr (x) (declare (xargs :guard t)) (if (atom x) x (final-cdr (cdr x))))
Theorem:
(defthm final-cdr-when-atom (implies (atom x) (equal (final-cdr x) x)))
Theorem:
(defthm final-cdr-of-cons (equal (final-cdr (cons a x)) (final-cdr x)))
Theorem:
(defthm final-cdr-when-true-listp (implies (true-listp x) (equal (final-cdr x) nil)))
Theorem:
(defthm equal-final-cdr-nil (equal (equal (final-cdr x) nil) (true-listp x)))
Theorem:
(defthm equal-of-final-cdr-and-self (equal (equal x (final-cdr x)) (atom x)))
Theorem:
(defthm final-cdr-of-append (equal (final-cdr (append x y)) (final-cdr y)))
Theorem:
(defthm final-cdr-of-revappend (equal (final-cdr (revappend x y)) (final-cdr y)))
Theorem:
(defthm final-cdr-of-union-equal (equal (final-cdr (union-equal x y)) (final-cdr y)))
Theorem:
(defthm final-cdr-of-acons (equal (final-cdr (acons key val alist)) (final-cdr alist)))
Theorem:
(defthm final-cdr-of-hons-acons (equal (final-cdr (hons-acons key val alist)) (final-cdr alist)))
Theorem:
(defthm final-cdr-of-hons-shrink-alist (equal (final-cdr (hons-shrink-alist alist ans)) (final-cdr ans)))
Theorem:
(defthm final-cdr-of-add-to-set-equal (equal (final-cdr (add-to-set-equal a x)) (final-cdr x)))
Theorem:
(defthm final-cdr-of-last (equal (final-cdr (last x)) (final-cdr x)))
Theorem:
(defthm final-cdr-of-nthcdr (equal (final-cdr (nthcdr n x)) (if (<= (nfix n) (len x)) (final-cdr x) nil)))
Theorem:
(defthm append-self-onto-final-cdr (equal (append x (final-cdr x)) x))