Cheaply detect always-constant bits in an svex by approximately evaluating it under the empty (i.e., all X) environment.
This is a lightweight way to tell that certain bits of an svex expression are actually particular constants, no matter how you bind its
variables. It returns an 4vec which tells us that certain bits of
Consider the following expression:
(bitand (bitor a b) (bitand c #b1000))
What values can this expression return? You can see that, regardless of the
values of
When we use
(svex-xeval '(bitand (bitor a b) (bitand c #b1000))) == (8 . 0)
Here is the interpretation of the resulting 4vec,
bits of upper (8) are: 0...01000 bits of lower (0) are: 0...00000 --------------------------------- 01ZX interpretation: 0...0X000
So
If all of our expressions were ``properly monotonic'' and truly
treated
This almost works. However, the case-equality operator
(svex-eval '(=== a b) nil) --> -1 (all bits true)
But obviously this expression isn't always true, for instance:
(let ((env '((a . 1) (b . 0)))) (svex-eval '(=== a b) env)) --> 0 (all bits false)
To correct for this,
(svex-xeval '(=== a b)) --> all Xes (svex-xeval '(=== a a)) --> all Xes (svex-xeval '(=== 0 0)) --> all true
Theorem:
(defthm return-type-of-svex-xeval.val (b* ((?val (svex-xeval x))) (4vec-p val)) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-svex-call-xeval.val (b* ((?val (svex-call-xeval x))) (4vec-p val)) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-svex-fn/args-xeval.val (b* ((?val (svex-fn/args-xeval fn args))) (4vec-p val)) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-svexlist-xeval.val (b* ((?val (svexlist-xeval x))) (4veclist-p val)) :rule-classes :rewrite)
Theorem:
(defthm svex-xeval-of-quote (implies (svex-case x :quote) (equal (svex-xeval x) (svex-quote->val x))))
Theorem:
(defthm svex-xeval-of-svex-fix-x (equal (svex-xeval (svex-fix x)) (svex-xeval x)))
Theorem:
(defthm svex-call-xeval-of-svex-fix-x (equal (svex-call-xeval (svex-fix x)) (svex-call-xeval x)))
Theorem:
(defthm svex-fn/args-xeval-of-fnsym-fix-fn (equal (svex-fn/args-xeval (fnsym-fix fn) args) (svex-fn/args-xeval fn args)))
Theorem:
(defthm svex-fn/args-xeval-of-svexlist-fix-args (equal (svex-fn/args-xeval fn (svexlist-fix args)) (svex-fn/args-xeval fn args)))
Theorem:
(defthm svexlist-xeval-of-svexlist-fix-x (equal (svexlist-xeval (svexlist-fix x)) (svexlist-xeval x)))
Theorem:
(defthm svex-xeval-svex-equiv-congruence-on-x (implies (svex-equiv x x-equiv) (equal (svex-xeval x) (svex-xeval x-equiv))) :rule-classes :congruence)
Theorem:
(defthm svex-call-xeval-svex-equiv-congruence-on-x (implies (svex-equiv x x-equiv) (equal (svex-call-xeval x) (svex-call-xeval x-equiv))) :rule-classes :congruence)
Theorem:
(defthm svex-fn/args-xeval-fnsym-equiv-congruence-on-fn (implies (fnsym-equiv fn fn-equiv) (equal (svex-fn/args-xeval fn args) (svex-fn/args-xeval fn-equiv args))) :rule-classes :congruence)
Theorem:
(defthm svex-fn/args-xeval-svexlist-equiv-congruence-on-args (implies (svexlist-equiv args args-equiv) (equal (svex-fn/args-xeval fn args) (svex-fn/args-xeval fn args-equiv))) :rule-classes :congruence)
Theorem:
(defthm svexlist-xeval-svexlist-equiv-congruence-on-x (implies (svexlist-equiv x x-equiv) (equal (svexlist-xeval x) (svexlist-xeval x-equiv))) :rule-classes :congruence)
Theorem:
(defthm svexlist-xeval-nil (equal (svexlist-xeval nil) nil))
Theorem:
(defthm car-of-svexlist-xeval (4vec-equiv (car (svexlist-xeval x)) (svex-xeval (car x))))
Theorem:
(defthm cdr-of-svexlist-xeval (4veclist-equiv (cdr (svexlist-xeval x)) (svexlist-xeval (cdr x))))
Theorem:
(defthm len-of-svexlist-xeval (equal (len (svexlist-xeval x)) (len x)))
Theorem:
(defthm svexlist-xeval-of-append (equal (svexlist-xeval (append a b)) (append (svexlist-xeval a) (svexlist-xeval b))))