Restrict an svex-env to only particular variables. Variables that are present in keys but not env will be left unbound.
(svex-env-reduce keys env) → sub-env
Function:
(defun svex-env-reduce (keys env) (declare (xargs :guard (and (svarlist-p keys) (svex-env-p env)))) (let ((__function__ 'svex-env-reduce)) (declare (ignorable __function__)) (mbe :logic (if (atom keys) nil (b* ((key (svar-fix (car keys))) (look (hons-get key (svex-env-fix env)))) (if look (cons (cons key (cdr look)) (svex-env-reduce (cdr keys) env)) (svex-env-reduce (cdr keys) env)))) :exec (with-fast-alist env (svex-env-reduce-aux keys env)))))
Theorem:
(defthm svex-env-p-of-svex-env-reduce (b* ((sub-env (svex-env-reduce keys env))) (svex-env-p sub-env)) :rule-classes :rewrite)
Theorem:
(defthm svex-env-lookup-of-svex-env-reduce (equal (svex-env-lookup v (svex-env-reduce vars env)) (if (member (svar-fix v) (svarlist-fix vars)) (svex-env-lookup v env) (4vec-x))))
Theorem:
(defthm svex-env-boundp-of-svex-env-reduce (iff (svex-env-boundp key (svex-env-reduce vars x)) (and (member-equal (svar-fix key) (svarlist-fix vars)) (svex-env-boundp key x))))
Theorem:
(defthm svex-eval-reduce-var-superset (implies (subsetp (svex-vars x) (svarlist-fix vars)) (equal (svex-eval x (svex-env-reduce vars env)) (svex-eval x env))))
Theorem:
(defthm svexlist-eval-reduce-var-superset (implies (subsetp (svexlist-vars x) (svarlist-fix vars)) (equal (svexlist-eval x (svex-env-reduce vars env)) (svexlist-eval x env))))
Theorem:
(defthm svex-alist-eval-of-reduce-var-supserset (implies (subsetp (svexlist-vars (svex-alist-vals x)) (svarlist-fix vars)) (equal (svex-alist-eval x (svex-env-reduce vars env)) (svex-alist-eval x env))))
Theorem:
(defthm alist-keys-of-svex-env-reduce (equal (alist-keys (svex-env-reduce vars env)) (intersection-equal (svarlist-fix vars) (alist-keys (svex-env-fix env)))))
Theorem:
(defthm svex-env-reduce-when-alist-keys-equal (implies (and (equal (alist-keys (svex-env-fix x)) keys) (no-duplicatesp keys)) (equal (svex-env-reduce keys x) (svex-env-fix x))))
Theorem:
(defthm hons-assoc-equal-of-svex-env-reduce (equal (hons-assoc-equal v (svex-env-reduce keys x)) (and (member v (svarlist-fix keys)) (hons-assoc-equal v (svex-env-fix x)))))
Theorem:
(defthm svex-env-reduce-of-superset (implies (subsetp (svarlist-fix keys) (svarlist-fix keys2)) (equal (svex-env-reduce keys (svex-env-reduce keys2 x)) (svex-env-reduce keys x))))
Theorem:
(defthm svex-env-extract-of-subset-of-env-reduce (implies (subsetp (svarlist-fix keys) (svarlist-fix keys2)) (equal (svex-env-extract keys (svex-env-reduce keys2 x)) (svex-env-extract keys x))))
Theorem:
(defthm svex-env-reduce-redef (equal (svex-env-reduce keys env) (if (atom keys) nil (if (svex-env-boundp (car keys) env) (cons (cons (svar-fix (car keys)) (svex-env-lookup (car keys) env)) (svex-env-reduce (cdr keys) env)) (svex-env-reduce (cdr keys) env)))) :rule-classes :definition)
Theorem:
(defthm svex-env-reduce-of-svarlist-fix-keys (equal (svex-env-reduce (svarlist-fix keys) env) (svex-env-reduce keys env)))
Theorem:
(defthm svex-env-reduce-svarlist-equiv-congruence-on-keys (implies (svarlist-equiv keys keys-equiv) (equal (svex-env-reduce keys env) (svex-env-reduce keys-equiv env))) :rule-classes :congruence)
Theorem:
(defthm svex-env-reduce-of-svex-env-fix-env (equal (svex-env-reduce keys (svex-env-fix env)) (svex-env-reduce keys env)))
Theorem:
(defthm svex-env-reduce-svex-env-equiv-congruence-on-env (implies (svex-env-equiv env env-equiv) (equal (svex-env-reduce keys env) (svex-env-reduce keys env-equiv))) :rule-classes :congruence)