(list-equiv x y) is an equivalence relation that determines
whether
This is a very common equivalence relation for functions that process lists. See also list-fix for more discussion.
Function:
(defun fast-list-equiv (x y) (declare (xargs :guard t)) (if (consp x) (and (consp y) (equal (car x) (car y)) (fast-list-equiv (cdr x) (cdr y))) (atom y)))
Function:
(defun list-equiv (x y) (mbe :logic (equal (list-fix x) (list-fix y)) :exec (fast-list-equiv x y)))
Theorem:
(defthm list-equiv-is-an-equivalence (and (booleanp (list-equiv x y)) (list-equiv x x) (implies (list-equiv x y) (list-equiv y x)) (implies (and (list-equiv x y) (list-equiv y z)) (list-equiv x z))) :rule-classes (:equivalence))
Theorem:
(defthm list-equiv-when-atom-left (implies (atom x) (equal (list-equiv x y) (atom y))))
Theorem:
(defthm list-equiv-when-atom-right (implies (atom y) (equal (list-equiv x y) (atom x))))
Theorem:
(defthm list-equiv-of-nil-left (equal (list-equiv nil y) (not (consp y))))
Theorem:
(defthm list-equiv-of-nil-right (equal (list-equiv x nil) (not (consp x))))
Theorem:
(defthm list-fix-under-list-equiv (list-equiv (list-fix x) x))
Theorem:
(defthm list-fix-equal-forward-to-list-equiv (implies (equal (list-fix x) (list-fix y)) (list-equiv x y)) :rule-classes :forward-chaining)
Theorem:
(defthm append-atom-under-list-equiv (implies (atom y) (list-equiv (append x y) x)))