Function:
(defun binary-bitop-swap (op) (declare (type (unsigned-byte 4) op)) (declare (xargs :guard (integerp op))) (let ((__function__ 'binary-bitop-swap)) (declare (ignorable __function__)) (b* ((op (mbe :logic (loghead 4 op) :exec op)) (same 9) (x&~y 2) (y&~x 4)) (logior (logand same op) (ash (logand x&~y op) 1) (ash (logand y&~x op) -1)))))
Theorem:
(defthm integerp-of-binary-bitop-swap (b* ((swap (binary-bitop-swap op))) (integerp swap)) :rule-classes :type-prescription)
Theorem:
(defthm unsigned-byte-p-of-binary-bitop-swap (b* ((?swap (binary-bitop-swap op))) (unsigned-byte-p 4 swap)))
Theorem:
(defthm binary-bitop-swap-correct (equal (binary-bitop (binary-bitop-swap op) x y) (binary-bitop op y x)))
Theorem:
(defthm binary-bitop-swap-of-ifix-op (equal (binary-bitop-swap (ifix op)) (binary-bitop-swap op)))
Theorem:
(defthm binary-bitop-swap-int-equiv-congruence-on-op (implies (int-equiv op op-equiv) (equal (binary-bitop-swap op) (binary-bitop-swap op-equiv))) :rule-classes :congruence)