An executable version of 4v-sexpr-purebool-p using SAT.
(4v-sexpr-purebool-check sexpr &key (config 'satlink::*default-config*)) → (mv fail purebool ctrex)
Note: if you want to check whether several sexprs are all purely
Boolean valued, 4v-sexpr-purebool-list-check will typically be far more
efficient than calling
Function:
(defun 4v-sexpr-purebool-check-fn (sexpr config) (declare (xargs :guard (satlink::config-p config))) (let ((__function__ '4v-sexpr-purebool-check)) (declare (ignorable __function__)) (mbe :logic (b* ((faig (sfaig sexpr)) ((mv fail purebool faig-env) (faig-purebool-check faig :config config)) ((when fail) (mv fail nil nil)) ((when purebool) (mv nil t nil)) (4v-env (sfaig-recover-4venv sexpr faig-env))) (mv nil nil 4v-env)) :exec (b* ((vars (4v-sexpr-vars-1pass sexpr)) (onoff (num-varmap vars 0)) (faig (4v-sexpr-to-faig sexpr onoff)) ((mv fail purebool faig-env) (faig-purebool-check faig :config config)) ((when fail) (mv fail nil nil)) ((when purebool) (mv nil t nil)) (4v-env (faig-const-alist->4v-alist (faig-eval-alist onoff faig-env)))) (mv nil nil 4v-env)))))
Theorem:
(defthm booleanp-of-4v-sexpr-purebool-check.fail (b* (((mv ?fail ?purebool ?ctrex) (4v-sexpr-purebool-check-fn sexpr config))) (booleanp fail)) :rule-classes :type-prescription)
Theorem:
(defthm booleanp-of-4v-sexpr-purebool-check.purebool (b* (((mv ?fail ?purebool ?ctrex) (4v-sexpr-purebool-check-fn sexpr config))) (booleanp purebool)) :rule-classes :type-prescription)
Theorem:
(defthm 4v-sexpr-purebool-check-correct (b* (((mv fail purebool ?alist) (4v-sexpr-purebool-check sexpr :config config))) (implies (not fail) (equal purebool (4v-sexpr-purebool-p sexpr)))))
Theorem:
(defthm 4v-sexpr-purebool-check-counterexample-correct (b* (((mv fail ?purebool alist) (4v-sexpr-purebool-check sexpr :config config))) (implies (and (not fail) (not (4v-sexpr-purebool-p sexpr))) (and (not (equal (4v-sexpr-eval sexpr alist) (4vt))) (not (equal (4v-sexpr-eval sexpr alist) (4vf)))))))