Bit-for-bit list equivalence:
This is a universal equivalence, introduced using def-universal-equiv.
Function:
(defun bits-equiv (x y) (declare (xargs :non-executable t)) (declare (xargs :guard t)) (prog2$ (throw-nonexec-error 'bits-equiv (list x y)) (let ((i (bits-equiv-witness x y))) (and (bit-equiv (nth i x) (nth i y))))))
Theorem:
(defthm bits-equiv-necc (implies (not (and (bit-equiv (nth i x) (nth i y)))) (not (bits-equiv x y))))
Theorem:
(defthm bits-equiv-is-an-equivalence (and (booleanp (bits-equiv x y)) (bits-equiv x x) (implies (bits-equiv x y) (bits-equiv y x)) (implies (and (bits-equiv x y) (bits-equiv y z)) (bits-equiv x z))) :rule-classes (:equivalence))
Theorem:
(defthm bits-equiv-implies-bit-equiv-nth-2 (implies (bits-equiv x x-equiv) (bit-equiv (nth i x) (nth i x-equiv))) :rule-classes (:congruence))
Theorem:
(defthm bits-equiv-implies-bits-equiv-update-nth-3 (implies (bits-equiv x x-equiv) (bits-equiv (update-nth i v x) (update-nth i v x-equiv))) :rule-classes (:congruence))
Theorem:
(defthm bit-equiv-implies-bits-equiv-update-nth-2 (implies (bit-equiv v v-equiv) (bits-equiv (update-nth i v x) (update-nth i v-equiv x))) :rule-classes (:congruence))
Theorem:
(defthm bits-equiv-implies-bits-equiv-cdr-1 (implies (bits-equiv a a-equiv) (bits-equiv (cdr a) (cdr a-equiv))) :rule-classes (:congruence))
Theorem:
(defthm bits-equiv-implies-bit-equiv-car-1 (implies (bits-equiv x x-equiv) (bit-equiv (car x) (car x-equiv))) :rule-classes (:congruence))
Theorem:
(defthm bit-equiv-implies-bits-equiv-cons-1 (implies (bit-equiv a a-equiv) (bits-equiv (cons a b) (cons a-equiv b))) :rule-classes (:congruence))
Theorem:
(defthm bits-equiv-implies-bits-equiv-cons-2 (implies (bits-equiv b b-equiv) (bits-equiv (cons a b) (cons a b-equiv))) :rule-classes (:congruence))