(alist-equiv a b) determines whether the alists
This is a fundamental equivalence relation for alists. It allows you to consider the equivalence of alists regardless of the order of their elements, the presence of shadowed elements, etc.
Note that list-equiv is a refinement of alist-equiv.
Function:
(defun alist-equiv (a b) "Do A and B agree on the values of every key?" (declare (xargs :guard t)) (mbe :logic (and (sub-alistp a b) (sub-alistp b a)) :exec (with-fast-alist a (with-fast-alist b (and (sub-alistp a b) (sub-alistp b a))))))
Theorem:
(defthm alist-equiv-is-an-equivalence (and (booleanp (alist-equiv x y)) (alist-equiv x x) (implies (alist-equiv x y) (alist-equiv y x)) (implies (and (alist-equiv x y) (alist-equiv y z)) (alist-equiv x z))) :rule-classes (:equivalence))
Theorem:
(defthm alist-equiv-means-all-keys-agree (implies (alist-equiv x y) (alists-agree keys x y)))
Theorem:
(defthm list-equiv-refines-alist-equiv (implies (list-equiv x y) (alist-equiv x y)) :rule-classes (:refinement))