• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Hons-and-memoization
      • Events
      • History
      • Parallelism
      • Programming
        • Defun
        • Declare
        • System-utilities
        • Stobj
        • State
        • Memoize
        • Mbe
        • Io
        • Apply$
        • Defpkg
        • Mutual-recursion
        • Loop$
        • Programming-with-state
        • Arrays
        • Characters
        • Time$
        • Loop$-primer
        • Fast-alists
        • Defmacro
        • Defconst
        • Evaluation
        • Guard
        • Equality-variants
        • Compilation
        • Hons
        • ACL2-built-ins
        • Developers-guide
        • System-attachments
        • Advanced-features
        • Set-check-invariant-risk
        • Numbers
          • Natp
          • Unsigned-byte-p
          • Posp
          • +
          • Bitp
          • Zero-test-idioms
          • Nat-listp
          • Integerp
          • <
          • *
          • Zp
          • -
          • Signed-byte-p
          • Logbitp
          • Expt
          • Ash
          • Rationalp
          • Sharp-f-reader
          • Logand
            • Ihs/logand-lemmas
            • Logand-defaults
            • Logand*
          • =
          • <=
          • Floor
          • Random$
          • Nfix
          • Truncate
          • Complex
          • Numbers-introduction
          • Code-char
          • Integer-length
          • Zip
          • Logior
          • Sharp-u-reader
          • Char-code
          • Unary--
          • Integer-listp
          • Boole$
          • /
          • Mod
          • Logxor
          • Lognot
          • Integer-range-p
          • Ifix
          • ACL2-numberp
          • Ceiling
          • Mod-expt
          • Round
          • Logeqv
          • Explode-nonnegative-integer
          • Max
          • Evenp
          • Nonnegative-integer-quotient
          • Zerop
          • Abs
          • Fix
          • Allocate-fixnum-range
          • Rem
          • 1+
          • Pos-listp
          • Signum
          • Real/rationalp
          • Rational-listp
          • Rfix
          • >=
          • >
          • Logcount
          • ACL2-number-listp
          • /=
          • Unary-/
          • Complex/complex-rationalp
          • Logtest
          • Logandc1
          • Logorc1
          • Logandc2
          • 1-
          • Numerator
          • Logorc2
          • Denominator
          • The-number
          • Realfix
          • Complex-rationalp
          • Min
          • Lognor
          • Zpf
          • Oddp
          • Minusp
          • Lognand
          • Imagpart
          • Conjugate
          • Int=
          • Realpart
          • Plusp
        • Irrelevant-formals
        • Efficiency
        • Introduction-to-programming-in-ACL2-for-those-who-know-lisp
        • Redefining-programs
        • Lists
        • Invariant-risk
        • Errors
        • Defabbrev
        • Conses
        • Alists
        • Set-register-invariant-risk
        • Strings
        • Program-wrapper
        • Get-internal-time
        • Basics
        • Packages
        • Defmacro-untouchable
        • Primitive
        • <<
        • Revert-world
        • Set-duplicate-keys-action
        • Unmemoize
        • Symbols
        • Def-list-constructor
        • Easy-simplify-term
        • Defiteration
        • Defopen
        • Sleep
      • Start-here
      • Real
      • Debugging
      • Miscellaneous
      • Output-controls
      • Macros
      • Interfacing-tools
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
    • Testing-utilities
    • Math
  • Numbers
  • ACL2-built-ins

Logand

Bitwise logical `and' of zero or more integers

When integers are viewed in their two's complement representation, logand returns their bitwise logical `and'. In ACL2 logand is a macro that expands into calls of the binary function binary-logand, except that (logand) expands to -1 and (logand x) expands to (the integer x).

The guard for binary-logand requires its arguments to be integers. Logand is defined in Common Lisp. See any Common Lisp documentation for more information.

Macro: logand

(defmacro logand (&rest args)
          (cond ((null args) -1)
                ((null (cdr args))
                 (cons 'the
                       (cons 'integer (cons (car args) 'nil))))
                (t (xxxjoin 'binary-logand args))))

Function: binary-logand

(defun binary-logand (i j)
       (declare (xargs :guard (and (integerp i) (integerp j))))
       (cond ((zip i) 0)
             ((zip j) 0)
             ((eql i -1) j)
             ((eql j -1) i)
             (t (let ((x (* 2 (logand (floor i 2) (floor j 2)))))
                     (+ x
                        (cond ((evenp i) 0)
                              ((evenp j) 0)
                              (t 1)))))))

Subtopics

Ihs/logand-lemmas
Lemmas about logand from the logops-lemmas book.
Logand-defaults
Behavior of logand on bad inputs.
Logand*
Recursive definition of logand.