• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
    • Testing-utilities
    • Math
      • Arithmetic
      • Bit-vectors
        • Sparseint
        • Bitops
          • Bitops/merge
          • Bitops-compatibility
          • Bitops-books
            • Logbitp-reasoning
            • Bitops/signed-byte-p
            • Fast-part-select
            • Bitops/integer-length
            • Bitops/extra-defs
            • Install-bit
            • Trailing-0-count
            • Bitops/defaults
            • Logbitp-mismatch
            • Trailing-1-count
            • Bitops/rotate
            • Bitops/equal-by-logbitp
            • Bitops/ash-bounds
            • Bitops/fast-logrev
            • Limited-shifts
            • Bitops/part-select
            • Bitops/parity
            • Bitops/saturate
            • Bitops/part-install
            • Bitops/logbitp-bounds
            • Bitops/ihsext-basics
            • Bitops/fast-rotate
            • Bitops/fast-logext
            • Bitops/ihs-extensions
          • Bv
          • Ihs
          • Rtl
        • Algebra
    • Bitops

    Bitops-books

    Guide to the books in the Bitops library.

    Here is a summary of some of the books in the library.

    Major Lemma Books

    bitops/ihsext-basics

    This is a key book in the library and is generally a good starting point. It is intended to be a (still lightweight) replacement for books such as ihs/logops-lemmas.lisp.

    For instance, it has rules such as logand**, which is a recursive definition of logand that is well-suited for doing inductive proofs, etc. This rule is much like IHS's logand* but is improved since there are no hypotheses.

    A lot of the rules in ihsext-basics are improved versions of ihs rules, but some others are not included at all in ihs.

    bitops/ihs-extensions

    This book is sort of a continuation of ihsext-basics. Oftentimes you will not need it. It adds some bounding theorems that relate various bit-vector operations to (expt 2 n) and may be useful when combining the Bitops library with books like arithmetic-3 and arithmetic-5. The rules here tend to be more expensive than those in ihsext-basics, so this may not be well-suited for machine-code models.

    bitops/integer-length

    This is included in ihs-extensions.lisp. It has some basic lemmas about integer-length and its relationship to (expt 2 n). It may be useful when combining Bitops with libraries such as arithmetic-3 and arithmetic-5.

    bitops/signed-byte-p

    This is a nice, light-weight book that adds a number of "obvious" lemmas about signed-byte-p and unsigned-byte-p, e.g., that when you add two n-bit signed numbers, you get an n+1-bit signed number.

    These rules can be very helpful when you are trying to write optimized functions using Common Lisp ACL2::type-specs and need to satisfy the guard obligations that come from terms such as (the (unsigned-byte 16) x).

    You can use this book independently of the rest of the library. It currently has some support for reasoning about +, -, *, lognot, ash, logcdr, loghead, and logtail, and will likely be extended as we find it lacking. You may often wish to at least also load ihsext-basics, since that has bounds for many bit-vector operations.

    bitops/equal-by-logbitp

    This is a very cool book that allows you to carry out pick-a-point proofs: to show that integers x and y are the same, you can show that their nth bit is always the same. This can be a very effective strategy for working with sequences of bit-manipulation operations, e.g., updates to a flags register on a processor model. Some computed hints like equal-by-logbitp-hammer are also provided, which can automate this strategy.

    Other Lemma Books

    congruences.lisp

    This is an advanced book that implements an n-ary like mechanism for rewriting terms in an n-bit context.

    bitops/ash-bounds

    This book adds some basic bounding and monotonicity lemmas for ash and logtail.

    bitops/logbitp-bounds

    This book adds some basic lemmas about logbitp and expt.

    bitops/defaults

    This book just has basic theorems about the "default" behavior of bit-vector operations when their inputs are ill-formed (e.g., not integers, not naturals). You probably shouldn't load it; most of this should be subsumed by more recent congruence reasoning for nat-equiv and int-equiv.

    Books with Extra Definitions

    bitops/extra-defs

    This book is a random assortment of functions for slicing integers, manipulating individual bits, and bit scanning. It will likely be split up and organized into separate books in the future.

    bitops/merge

    This book provides several optimized functions for merging together, e.g., four bytes into a 32-bit value, or four 16-bit unsigned values into a 64-bit result, etc.

    bitops/fast-logrev

    This book provides optimized implementations of logrev at various widths; these definitions are logically just the ordinary, nice, logical definition of logrev, thanks to mbe.

    bitops/parity

    This book provides a simple recursive definition of a parity (i.e., reduction xor) function, and also a faster version for execution.

    bitops/part-select

    This book provides a readable nice macro for extracting a portion of an integer, e.g., bits 15-8.

    bitops/part-install

    This book provides a function and a macro to set a portion of an integer to some value. It also includes some theorems about the interaction of part-install with bitops/part-select.

    bitops/rotate

    This book defines rotate-left and rotate-right operations. It provides lemmas explaining how logbitp interacts with these operations, and it makes use of the equal-by-logbitp strategy to provide equivalent, recursive definitions.

    bitops/fast-rotate

    This book defines fast-rotate operations that are proved equivalent to rotate-left and rotate-right.

    bitops/saturate

    This book defines some optimized signed and unsigned saturation functions.

    bitops/fast-logext

    This book provides an optimized sign-extension functions, and proves them equivalent to logext. These optimizations don't impact reasoning because we carry them out with mbe.