• 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
        • Rtl
          • Floating-Point Exceptions and Specification of Elementary Arithmetic Instructions
          • Implementation of Elementary Operations
          • Register-Transfer Logic
          • Floating-Point Arithmetic
            • Rounding
            • Floating-Point Formats
              • Normal Encodings
              • Denormals and Zeroes
              • Classification of Formats
              • Rebiasing Exponents
                • Infinities and NaNs
              • Floating-Point Numbers
            • Modeling Algorithms in C++ and ACL2
            • Bibliography
        • Algebra
      • Testing-utilities
    • Floating-Point Formats

    Rebiasing Exponents

    Rebiasing Exponents

    Definitions and Theorems

    Function: rebias

    (defun rebias (expo old new)
      (declare (xargs :guard (and (integerp expo)
                                  (posp old)
                                  (posp new))))
      (+ expo
         (- (expt 2 (1- new))
            (expt 2 (1- old)))))

    Theorem: natp-rebias-up

    (defthm natp-rebias-up
      (implies (and (natp n)
                    (natp m)
                    (< 0 m)
                    (<= m n)
                    (bvecp x m))
               (natp (rebias x m n))))

    Theorem: natp-rebias-down

    (defthm natp-rebias-down
      (implies (and (natp n)
                    (natp m)
                    (< 0 m)
                    (<= m n)
                    (bvecp x n)
                    (< x (+ (expt 2 (1- n)) (expt 2 (1- m))))
                    (>= x (- (expt 2 (1- n)) (expt 2 (1- m)))))
               (natp (rebias x n m))))

    Theorem: bvecp-rebias-up

    (defthm bvecp-rebias-up
      (implies (and (natp n)
                    (natp m)
                    (< 0 m)
                    (<= m n)
                    (bvecp x m))
               (bvecp (rebias x m n) n)))

    Theorem: bvecp-rebias-down

    (defthm bvecp-rebias-down
      (implies (and (natp n)
                    (natp m)
                    (< 0 m)
                    (<= m n)
                    (bvecp x n)
                    (< x (+ (expt 2 (1- n)) (expt 2 (1- m))))
                    (>= x (- (expt 2 (1- n)) (expt 2 (1- m)))))
               (bvecp (rebias x n m) m)))

    Theorem: rebias-lower

    (defthm rebias-lower
      (implies (and (natp n)
                    (natp m)
                    (> n m)
                    (> m 1)
                    (bvecp x n)
                    (< x (+ (expt 2 (1- n)) (expt 2 (1- m))))
                    (>= x (- (expt 2 (1- n)) (expt 2 (1- m)))))
               (equal (rebias x n m)
                      (cat (bitn x (1- n))
                           1 (bits x (- m 2) 0)
                           (1- m)))))

    Theorem: rebias-higher

    (defthm rebias-higher
      (implies (and (natp n)
                    (natp m)
                    (> n m)
                    (> m 1)
                    (bvecp x m))
               (equal (rebias x m n)
                      (cat (cat (bitn x (1- m))
                                1
                                (mulcat 1 (- n m)
                                        (bitn (lognot x) (1- m)))
                                (- n m))
                           (1+ (- n m))
                           (bits x (- m 2) 0)
                           (1- m)))))