Basic fixing function for "modern" alists that respects the behavior of hons-assoc-equal.
Function:
(defun alist-fix (x) (declare (xargs :guard t)) (if (atom x) nil (if (consp (car x)) (cons (car x) (alist-fix (cdr x))) (alist-fix (cdr x)))))
Theorem:
(defthm alistp-of-alist-fix (alistp (alist-fix x)))
Theorem:
(defthm alist-fix-when-alistp (implies (alistp x) (equal (alist-fix x) x)))
Theorem:
(defthm hons-assoc-equal-of-alist-fix (equal (hons-assoc-equal k (alist-fix x)) (hons-assoc-equal k x)))
Theorem:
(defthm alist-fix-of-cons (equal (alist-fix (cons a b)) (if (consp a) (cons a (alist-fix b)) (alist-fix b))))
Theorem:
(defthm alist-fix-of-atom (implies (not (consp x)) (equal (alist-fix x) nil)) :rule-classes ((:rewrite :backchain-limit-lst 0)))