Function:
(defun unary-bitop (op x) (declare (type (unsigned-byte 2) op)) (declare (xargs :guard (and (integerp op) (integerp x)))) (let ((__function__ 'unary-bitop)) (declare (ignorable __function__)) (b* ((op (mbe :logic (loghead 2 op) :exec op))) (case op (0 0) (1 (lognot x)) (2 (lifix x)) (t -1)))))
Theorem:
(defthm integerp-of-unary-bitop (b* ((unary (unary-bitop op x))) (integerp unary)) :rule-classes :type-prescription)
Theorem:
(defthm unary-bitop-correct (b* ((?unary (unary-bitop op x))) (equal (logbitp n unary) (logbitp (logbit n x) op))))
Theorem:
(defthm logext-of-unary-bitop (b* ((?unary (unary-bitop op x))) (equal (logext n unary) (unary-bitop op (logext n x)))))
Theorem:
(defthm logtail-of-unary-bitop (b* ((?unary (unary-bitop op x))) (equal (logtail n unary) (unary-bitop op (logtail n x)))))
Theorem:
(defthm open-unary-bitop (b* ((?unary (unary-bitop op x))) (implies (syntaxp (quotep op)) (equal unary (b* ((op (mbe :logic (loghead 2 op) :exec op))) (case op (0 0) (1 (lognot x)) (2 (lifix x)) (t -1)))))))
Theorem:
(defthm unary-bitop-of-ifix-op (equal (unary-bitop (ifix op) x) (unary-bitop op x)))
Theorem:
(defthm unary-bitop-int-equiv-congruence-on-op (implies (int-equiv op op-equiv) (equal (unary-bitop op x) (unary-bitop op-equiv x))) :rule-classes :congruence)
Theorem:
(defthm unary-bitop-of-ifix-x (equal (unary-bitop op (ifix x)) (unary-bitop op x)))
Theorem:
(defthm unary-bitop-int-equiv-congruence-on-x (implies (int-equiv x x-equiv) (equal (unary-bitop op x) (unary-bitop op x-equiv))) :rule-classes :congruence)