• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
    • Math
      • 100-theorems
      • Arithmetic
      • Bit-vectors
        • Sparseint
          • Sparseint-impl
            • Sparseint$-binary-bitop-width
            • Sparseint$-plus-width
            • Sparseint$-binary-bitop-offset
            • Sparseint$-binary-bitop-int-width
            • Sparseint$-plus-int-width
            • Sum-with-cin
            • Sparseint$-plus-offset
            • Sparseint$-binary-bitop-int
            • Sparseint$-finalize-concat
            • Sparseint$-plus-int
            • Sparseint$-binary-bittest-width
            • Sparseint$-binary-bittest-int-width
            • Sparseint$-trailing-0-count-width
            • Sparseint$-height
            • Int-to-sparseint$-rec
            • Carry-out
            • Sparseint$-compare-width
            • Sparseint$-binary-bittest-offset
            • Sparseint$-equal-width
            • Sparseint$-binary-bittest-int
            • Sparseint$-compare-int-width
            • Sparseint$-bitcount-width
            • Sparseint$-unary-bittest-width
            • Sparseint$-rightshift-rec
            • Sparseint$-equal-int-width
            • Sparseint$-trailing-0-count-rec
            • Sparseint$-unary-bitop
            • Sparseint$-concatenate
            • Sparseint$-length-width-rec
            • Sparseint$-sign-ext
            • Sparseint$-binary-bitop
            • Binary-bitop
              • Sparseint$-compare-offset
              • Sparseint$-unary-bittest-offset
              • Sparseint$-equal-offset
              • Sparseint$-truncate
              • Sparseint$-mergeable-leaves-p
              • Carry-out-bit
              • Sparseint$-truncate-height
              • Sparseint$-compare-int
              • Sparseint$-binary-bittest
              • Sparseint$-equal-int
              • Sparseint$-rightshift
              • Sparseint$-leaves-mergeable-p
              • Sparseint$-plus
              • Unary-bitop
              • Sparseint$-bitcount-rec
              • Within-1
              • Sparseint$
              • Binary-bitop-cofactor2
              • Binary-bitop-cofactor1
              • Sparseint$-compare
              • Sparseint$-unary-bittest
              • Sparseint$-height-correct-exec
              • Sparseint$-equal
              • Sparseint$-bitnot
              • Sparseint$-unary-minus
              • Sparseint$-bit
              • Int-to-sparseint$
              • Binary-bittest
              • Sparseint$-length-rec
              • Sparseint$-val
              • Binary-bitop-swap
              • Compare
              • Sparseint$-real-height
              • Sparseint$-height-correctp
              • Sparseint$-length
            • Sparseint-p
            • Sparseint-binary-bittest
            • Sparseint-concatenate
            • Sparseint-binary-bitop
            • Sparseint-bitite
            • Sparseint-fix
            • Sparseint$-binary-minus
            • Sparseint-trailing-1-count-from
            • Sparseint-trailing-0-count-from
            • Sparseint-equal
            • Sparseint-test-bitorc2
            • Sparseint-test-bitorc1
            • Sparseint-test-bitnand
            • Sparseint-test-bitandc2
            • Sparseint-test-bitandc1
            • Sparseint-test-bitand
            • Sparseint-rightshift
            • Sparseint-bitcount-from
            • Sparseint-test-bitxor
            • Sparseint-test-bitor
            • Sparseint-test-bitnor
            • Sparseint-test-biteqv
            • Sparseint-compare
            • Sparseint-binary-minus
            • Sparseint-sign-ext
            • Sparseint-plus
            • Sparseint-bitandc2
            • Sparseint-bitandc1
            • Sparseint-bitand
            • Sparseint$-leaf-bitlimit
            • Sparseint-bitxor
            • Sparseint-bitorc2
            • Sparseint-bitorc1
            • Sparseint-bitor
            • Sparseint-bitnor
            • Sparseint-bitnand
            • Sparseint-biteqv
            • Sparseint-ash
            • Sparseint-<
            • Sparseint-bit
            • Sparseint-trailing-1-count
            • Sparseint-trailing-0-count
            • Sparseint-unary-minus
            • Sparseint-length
            • Sparseint-bitnot
            • Sparseint-bitcount
            • Int-to-sparseint
            • Sparseint-val
          • Bitops
          • Bv
          • Ihs
          • Rtl
        • Algebra
      • Testing-utilities
    • Sparseint-impl

    Binary-bitop

    Signature
    (binary-bitop op x y) → binary
    Arguments
    op — Guard (integerp op).
    x — Guard (integerp x).
    y — Guard (integerp y).
    Returns
    binary — Type (integerp binary).

    Definitions and Theorems

    Function: binary-bitop

    (defun binary-bitop (op x y)
      (declare (type (unsigned-byte 4) op))
      (declare (xargs :guard (and (integerp op)
                                  (integerp x)
                                  (integerp y))))
      (let ((__function__ 'binary-bitop))
        (declare (ignorable __function__))
        (b* ((op (mbe :logic (loghead 4 op) :exec op)))
          (case op
            (0 0)
            (1 (lognor x y))
            (2 (logandc2 x y))
            (3 (lognot y))
            (4 (logandc1 x y))
            (5 (lognot x))
            (6 (logxor x y))
            (7 (lognand x y))
            (8 (logand x y))
            (9 (logeqv x y))
            (10 (lifix x))
            (11 (logorc2 x y))
            (12 (lifix y))
            (13 (logorc1 x y))
            (14 (logior x y))
            (t -1)))))

    Theorem: integerp-of-binary-bitop

    (defthm integerp-of-binary-bitop
      (b* ((binary (binary-bitop op x y)))
        (integerp binary))
      :rule-classes :type-prescription)

    Theorem: binary-bitop-correct

    (defthm binary-bitop-correct
      (b* ((?binary (binary-bitop op x y)))
        (equal (logbitp n binary)
               (logbitp (+ (logbit n x) (* 2 (logbit n y)))
                        op))))

    Theorem: logext-of-binary-bitop

    (defthm logext-of-binary-bitop
      (b* ((?binary (binary-bitop op x y)))
        (equal (logext n binary)
               (binary-bitop op (logext n x)
                             (logext n y)))))

    Theorem: logtail-of-binary-bitop

    (defthm logtail-of-binary-bitop
      (b* ((?binary (binary-bitop op x y)))
        (equal (logtail n binary)
               (binary-bitop op (logtail n x)
                             (logtail n y)))))

    Theorem: open-binary-bitop

    (defthm open-binary-bitop
      (b* ((?binary (binary-bitop op x y)))
        (implies (syntaxp (quotep op))
                 (equal binary
                        (b* ((op (mbe :logic (loghead 4 op) :exec op)))
                          (case op
                            (0 0)
                            (1 (lognor x y))
                            (2 (logandc2 x y))
                            (3 (lognot y))
                            (4 (logandc1 x y))
                            (5 (lognot x))
                            (6 (logxor x y))
                            (7 (lognand x y))
                            (8 (logand x y))
                            (9 (logeqv x y))
                            (10 (lifix x))
                            (11 (logorc2 x y))
                            (12 (lifix y))
                            (13 (logorc1 x y))
                            (14 (logior x y))
                            (t -1)))))))

    Theorem: binary-bitop-of-ifix-op

    (defthm binary-bitop-of-ifix-op
      (equal (binary-bitop (ifix op) x y)
             (binary-bitop op x y)))

    Theorem: binary-bitop-int-equiv-congruence-on-op

    (defthm binary-bitop-int-equiv-congruence-on-op
      (implies (int-equiv op op-equiv)
               (equal (binary-bitop op x y)
                      (binary-bitop op-equiv x y)))
      :rule-classes :congruence)

    Theorem: binary-bitop-of-ifix-x

    (defthm binary-bitop-of-ifix-x
      (equal (binary-bitop op (ifix x) y)
             (binary-bitop op x y)))

    Theorem: binary-bitop-int-equiv-congruence-on-x

    (defthm binary-bitop-int-equiv-congruence-on-x
      (implies (int-equiv x x-equiv)
               (equal (binary-bitop op x y)
                      (binary-bitop op x-equiv y)))
      :rule-classes :congruence)

    Theorem: binary-bitop-of-ifix-y

    (defthm binary-bitop-of-ifix-y
      (equal (binary-bitop op x (ifix y))
             (binary-bitop op x y)))

    Theorem: binary-bitop-int-equiv-congruence-on-y

    (defthm binary-bitop-int-equiv-congruence-on-y
      (implies (int-equiv y y-equiv)
               (equal (binary-bitop op x y)
                      (binary-bitop op x y-equiv)))
      :rule-classes :congruence)