Translate a BED into an AIG.
(aig-from-bed bed) → aig
This is an especially naive conversion. For efficiency this function is memoized, and you should generally clear its memo table after you use it.
Function:
(defun aig-from-bed (bed) (declare (xargs :guard t)) (let ((__function__ 'aig-from-bed)) (declare (ignorable __function__)) (b* (((when (atom bed)) (if bed t nil)) ((cons a b) bed) ((unless (integerp b)) (if (booleanp a) (if a (aig-from-bed (car$ b)) (aig-from-bed (cdr$ b))) (aig-ite (make-aig-var a) (aig-from-bed (car$ b)) (aig-from-bed (cdr$ b))))) (op (bed-op-fix b)) (left (aig-from-bed (car$ a))) (right (aig-from-bed (cdr$ a))) ((when (eql op (bed-op-true))) t) ((when (eql op (bed-op-false))) nil) ((when (eql op (bed-op-ior))) (aig-or left right)) ((when (eql op (bed-op-orc2))) (aig-or left (aig-not right))) ((when (eql op (bed-op-arg1))) left) ((when (eql op (bed-op-orc1))) (aig-or (aig-not left) right)) ((when (eql op (bed-op-arg2))) right) ((when (eql op (bed-op-eqv))) (aig-iff left right)) ((when (eql op (bed-op-and))) (aig-and left right)) ((when (eql op (bed-op-nand))) (aig-not (aig-and left right))) ((when (eql op (bed-op-xor))) (aig-xor left right)) ((when (eql op (bed-op-not2))) (aig-not right)) ((when (eql op (bed-op-andc2))) (aig-and left (aig-not right))) ((when (eql op (bed-op-not1))) (aig-not left)) ((when (eql op (bed-op-andc1))) (aig-and (aig-not left) right)) ((when (eql op (bed-op-nor))) (aig-not (aig-or left right)))) :impossible)))
Function:
(defun aig-from-bed-memoize-condition (bed) (declare (ignorable bed) (xargs :guard 't)) (consp bed))
Theorem:
(defthm aig-eval-of-aig-from-bed (equal (aig-eval (aig-from-bed bed) env) (eql 1 (bed-eval bed (aig-env-to-bed-env env)))))