Extract a portion of a
(4v-sexpr-alist-extract keys al) is given:
It produces a new alist that binds all of the names in
More precisely, the new alist binds each
This is just slightly different than fal-extract: whereas fal-extract omits missing keys, this binds them to nil.
This function can be a useful for removing any "extraneous" bindings from
an the sexpr-alist
Theorem:
(defthm 4v-sexpr-alist-equiv-implies-4v-sexpr-alist-equiv-append-1 (implies (4v-sexpr-alist-equiv a a-equiv) (4v-sexpr-alist-equiv (append a b) (append a-equiv b))) :rule-classes (:congruence))
Function:
(defun 4v-sexpr-alist-extract1 (keys al) "Assumes AL is fast" (declare (xargs :guard t)) (if (atom keys) nil (cons (cons (car keys) (cdr (hons-get (car keys) al))) (4v-sexpr-alist-extract1 (cdr keys) al))))
Function:
(defun 4v-sexpr-alist-extract (keys al) "Makes AL fast if necessary" (declare (xargs :guard t)) (mbe :logic (if (atom keys) nil (cons (cons (car keys) (cdr (hons-get (car keys) al))) (4v-sexpr-alist-extract (cdr keys) al))) :exec (with-fast-alist al (4v-sexpr-alist-extract1 keys al))))
Theorem:
(defthm 4v-sexpr-alist-extract1-removal (equal (4v-sexpr-alist-extract1 keys al) (4v-sexpr-alist-extract keys al)))
Theorem:
(defthm alist-equiv-implies-equal-4v-sexpr-alist-extract-2 (implies (alist-equiv al al-equiv) (equal (4v-sexpr-alist-extract keys al) (4v-sexpr-alist-extract keys al-equiv))) :rule-classes (:congruence))