Remove all pairs with given keys from an alist.
General Forms: (remove-assocs keys alist) (remove-assocs keys alist :test 'eql) ; same as above (eql as equality test) (remove-assocs keys alist :test 'eq) ; same, but eq is equality test (remove-assocs keys alist :test 'equal) ; same, but equal is equality test
This generalizes remove-assoc to multiple keys.
The optional keyword,
The guard for a call of
See equality-variants for a discussion of
the relation between
(remove-assocs-eq keys alist) is equivalent to(remove-assocs keys alist :test 'eq) ;
(remove-assocs-equal keys alist) is equivalent to(remove-assocs keys alist :test 'equal) .
In particular, reasoning about any of these primitives
reduces to reasoning about the function
Function:
(defun remove-assocs-equal (keys alist) (declare (xargs :guard (and (true-listp keys) (alistp alist)))) (cond ((endp alist) nil) ((member-equal (car (car alist)) keys) (remove-assocs-equal keys (cdr alist))) (t (cons (car alist) (remove-assocs-equal keys (cdr alist))))))
Function:
(defun remove-assocs-eq-exec$guard-check (keys alist) (declare (xargs :guard (if (symbol-listp keys) (alistp alist) (and (true-listp keys) (symbol-alistp alist))))) (declare (ignore keys alist)) t)
Function:
(defun remove-assocs-eq-exec (keys alist) (declare (xargs :guard (if (symbol-listp keys) (alistp alist) (and (true-listp keys) (symbol-alistp alist))))) (cond ((endp alist) nil) ((member-eq (car (car alist)) keys) (remove-assocs-eq-exec keys (cdr alist))) (t (cons (car alist) (remove-assocs-eq-exec keys (cdr alist))))))
Function:
(defun remove-assocs-eql-exec$guard-check (keys alist) (declare (xargs :guard (if (eqlable-listp keys) (alistp alist) (and (true-listp keys) (eqlable-alistp alist))))) (declare (ignore keys alist)) t)
Function:
(defun remove-assocs-eql-exec (keys alist) (declare (xargs :guard (if (eqlable-listp keys) (alistp alist) (and (true-listp keys) (eqlable-alistp alist))))) (cond ((endp alist) nil) ((member (car (car alist)) keys) (remove-assocs-eql-exec keys (cdr alist))) (t (cons (car alist) (remove-assocs-eql-exec keys (cdr alist))))))
Theorem:
(defthm remove-assocs-eq-exec-is-remove-assocs-equal (equal (remove-assocs-eq-exec keys alist) (remove-assocs-equal keys alist)))
Theorem:
(defthm remove-assocs-eql-exec-is-remove-assocs-equal (equal (remove-assocs-eql-exec keys alist) (remove-assocs-equal keys alist)))
Theorem:
(defthm alistp-of-remove-assocs-equal (implies (alistp alist) (alistp (remove-assocs-equal keys alist))))
Theorem:
(defthm symbol-alistp-of-remove-assocs-equal (implies (symbol-alistp alist) (symbol-alistp (remove-assocs-equal keys alist))))