• 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
        • Bitops
        • Bv
        • Ihs
          • Logops-definitions
            • Logops-byte-functions
            • Defword
            • Defbytetype
            • Logext
            • Logrev
            • Loghead
            • Logops-bit-functions
            • Logtail
            • Logapp
            • Logsat
            • Binary--
            • Logcdr
            • Logcar
            • Logbit
            • Logextu
            • Logcons
            • Lshu
            • Logrpl
            • Ashu
            • Logmaskp
              • Ihs/logmaskp-lemmas
              • Logmaskp*
            • Lognotu
            • Logmask
            • Imod
            • Ifloor
            • Bfix
            • Bitmaskp
            • Logite
            • Expt2
            • Zbp
            • *logops-functions*
            • Word/bit-macros
            • Logops-definitions-theory
            • Logops-functions
            • Lbfix
            • Logextu-guard
            • Lshu-guard
            • Logtail-guard
            • Logrpl-guard
            • Logrev-guard
            • Lognotu-guard
            • Logmask-guard
            • Loghead-guard
            • Logext-guard
            • Logbit-guard
            • Logapp-guard
            • Ashu-guard
          • Math-lemmas
          • Ihs-theories
          • Ihs-init
          • Logops
        • Rtl
      • Algebra
    • Testing-utilities
  • Logops-definitions

Logmaskp

(logmaskp i) recognizes positive bit-masks, i.e., numbers of the form 2^n - 1.

Signature
(logmaskp i) → bool

Note that this function explicitly checks (integerp i), which means it doesn't satisfy an int-equiv congruence. See also bitmaskp, which fixes its argument and may execute slightly faster.

Definitions and Theorems

Function: logmaskp

(defun logmaskp (i)
  (declare (xargs :guard t))
  (let ((__function__ 'logmaskp))
    (declare (ignorable __function__))
    (mbe :logic (and (integerp i)
                     (>= i 0)
                     (equal i (- (expt2 (integer-length i)) 1)))
         :exec (and (integerp i)
                    (eql i
                         (the unsigned-byte
                              (- (the unsigned-byte
                                      (ash 1 (integer-length i)))
                                 1)))))))

Subtopics

Ihs/logmaskp-lemmas
Lemmas about logmaskp from the logops-lemmas book.
Logmaskp*
Recursive definition of logmaskp.