• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • ACL2
    • Macro-libraries
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
      • Sv
      • Fgl
      • Vwsim
      • Vl
      • X86isa
      • Svl
      • 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
      • Software-verification
      • Math
      • 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)))))