Construct a reduced BED using bed-order.
(mk-op-reorder op left right order) → (mv bed order)
We expect that by now, we've already dealt with:
And we've decided that we're really going to construct op(left, right). We
now want to take symmetry into account. That is, we can merge
Something subtle is, what do we want to do with symmetry w.r.t. the negation
operators like
I think that to start, I want to try out the latter option. It seems like it might have some slight advantages w.r.t. structure sharing, and I guess the whole point of BEDs is to embrace having a lot of operators.
Function:
(defun mk-op-reorder (op left right order) (declare (xargs :guard (bed-op-p op))) (let ((__function__ 'mk-op-reorder)) (declare (ignorable __function__)) (b* ((op (bed-op-fix$ op)) ((when (eql op (bed-op-true))) (mv t order)) ((when (eql op (bed-op-false))) (mv nil order)) ((when (eql op (bed-op-arg1))) (mv left order)) ((when (eql op (bed-op-arg2))) (mv right order)) ((when (eql op (bed-op-not2))) (mv (mk-not right) order)) ((when (eql op (bed-op-not1))) (mv (mk-not left) order)) ((mv okp order) (bed-order left right order)) ((when (or (eql op (bed-op-and)) (eql op (bed-op-ior)) (eql op (bed-op-eqv)) (eql op (bed-op-nand)) (eql op (bed-op-nor)) (eql op (bed-op-xor)))) (mv (if okp (mk-op-raw op left right) (mk-op-raw op right left)) order)) ((when (eql op (bed-op-orc1))) (mv (if okp (mk-op-raw op left right) (mk-op-raw (bed-op-orc2) right left)) order)) ((when (eql op (bed-op-andc1))) (mv (if okp (mk-op-raw op left right) (mk-op-raw (bed-op-andc2) right left)) order)) ((when (eql op (bed-op-orc2))) (mv (if okp (mk-op-raw op left right) (mk-op-raw (bed-op-orc1) right left)) order)) ((when (eql op (bed-op-andc2))) (mv (if okp (mk-op-raw op left right) (mk-op-raw (bed-op-andc1) right left)) order))) (mv (mk-op-raw op left right) order))))
Theorem:
(defthm bed-eval-of-mk-op-reorder (b* (((mv bed &) (mk-op-reorder op left right order))) (equal (bed-eval bed env) (bed-eval (mk-op-raw op left right) env))))