• 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
            • Logcollapse
            • Limshift-loghead-of-logapp
            • Limshift-logext-of-logapp
            • Limshift-loghead-of-ash
            • 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
    • Limited-shifts

    Limshift-loghead-of-ash

    Computes (loghead width (ash x shift-amt)).

    Signature
    (limshift-loghead-of-ash width x shift-amt) → shifted
    Arguments
    width — Guard (natp width).
    x — Guard (integerp x).
    shift-amt — Guard (integerp shift-amt).
    Returns
    shifted — Type (integerp shifted).

    Definitions and Theorems

    Function: limshift-loghead-of-ash

    (defun
        limshift-loghead-of-ash
        (width x shift-amt)
        (declare (xargs :guard (and (natp width)
                                    (integerp x)
                                    (integerp shift-amt))))
        (let ((__function__ 'limshift-loghead-of-ash))
             (declare (ignorable __function__))
             (b* ((shift-amt (lifix shift-amt))
                  (x (lifix x))
                  (width (lnfix width))
                  ((when (< shift-amt 0))
                   (loghead width (logtail (- shift-amt) x)))
                  (shift-amt-limited (logcollapse (integer-length width)
                                                  shift-amt)))
                 (loghead width (ash x shift-amt-limited)))))

    Theorem: integerp-of-limshift-loghead-of-ash

    (defthm integerp-of-limshift-loghead-of-ash
            (b* ((shifted (limshift-loghead-of-ash width x shift-amt)))
                (integerp shifted))
            :rule-classes :type-prescription)

    Theorem: limshift-loghead-of-ash-correct

    (defthm limshift-loghead-of-ash-correct
            (equal (limshift-loghead-of-ash width x shift-amt)
                   (loghead width (ash x shift-amt))))