Note: if you only want to know whether or not two sets intersect, bitset-intersectp is probably more efficient.
Function:
(defun bitset-binary-intersect$inline (x y) (declare (type unsigned-byte x) (type unsigned-byte y)) (declare (xargs :guard (and (natp x) (natp y)))) (declare (xargs :split-types t)) (let ((__function__ 'bitset-binary-intersect)) (declare (ignorable __function__)) (the unsigned-byte (logand (the unsigned-byte (lnfix x)) (the unsigned-byte (lnfix y))))))
Theorem:
(defthm natp-of-bitset-binary-intersect (b* ((bitset (bitset-binary-intersect$inline x y))) (natp bitset)) :rule-classes :type-prescription)
Theorem:
(defthm bitset-intersect-when-not-natp-left (implies (not (natp x)) (equal (bitset-intersect x y) 0)))
Theorem:
(defthm bitset-intersect-when-not-natp-right (implies (not (natp y)) (equal (bitset-intersect x y) 0)))
Theorem:
(defthm bitset-intersect-of-nfix-left (equal (bitset-intersect (nfix x) y) (bitset-intersect x y)))
Theorem:
(defthm bitset-intersect-of-nfix-right (equal (bitset-intersect x (nfix y)) (bitset-intersect x y)))
Theorem:
(defthm bitset-members-of-bitset-intersect (equal (bitset-members (bitset-intersect x y)) (intersect (bitset-members x) (bitset-members y))))