• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Recursion-and-induction
      • Hons-and-memoization
      • Events
      • Parallelism
      • History
      • Programming
        • Defun
        • Declare
        • System-utilities
        • Stobj
        • State
        • Mutual-recursion
        • Memoize
        • Mbe
        • Io
        • Defpkg
        • Apply$
        • Loop$
        • Programming-with-state
        • Arrays
        • Characters
        • Time$
        • Defmacro
        • Loop$-primer
        • Fast-alists
        • Defconst
        • Evaluation
        • Guard
        • Equality-variants
        • Compilation
        • Hons
        • ACL2-built-ins
        • Developers-guide
        • System-attachments
        • Advanced-features
        • Set-check-invariant-risk
        • Numbers
          • Df
          • Unsigned-byte-p
          • Posp
          • Natp
          • <
          • +
          • Bitp
          • Zero-test-idioms
          • Nat-listp
          • Integerp
          • *
          • -
          • Zp
          • Signed-byte-p
            • Defbyte
            • Defbytelist
            • Bitops/signed-byte-p
            • Signed-byte-fix
              • Signed-byte-list-fix
            • Bytep
            • Nibblep
            • Signed-byte-listp
            • Signed-byte-p-logops
            • Ihs/signed-byte-p-lemmas
            • Signed-byte-p*
            • Signed-byte-p-basics
          • Logbitp
          • Sharp-f-reader
          • Expt
          • <=
          • Ash
          • Rationalp
          • =
          • Nfix
          • Logand
          • Floor
          • Random$
          • Integer-listp
          • Complex
          • Numbers-introduction
          • Truncate
          • Code-char
          • Char-code
          • Integer-length
          • Zip
          • Logior
          • Sharp-u-reader
          • Mod
          • Unary--
          • Boole$
          • /
          • Logxor
          • Ifix
          • Lognot
          • Integer-range-p
          • Allocate-fixnum-range
          • ACL2-numberp
          • Sharp-d-reader
          • Mod-expt
          • Ceiling
          • Round
          • Logeqv
          • Fix
          • Explode-nonnegative-integer
          • Max
          • Evenp
          • Zerop
          • Abs
          • Nonnegative-integer-quotient
          • Rfix
          • 1+
          • Pos-listp
          • Signum
          • Rem
          • Real/rationalp
          • Rational-listp
          • >=
          • >
          • Logcount
          • ACL2-number-listp
          • /=
          • Unary-/
          • Realfix
          • Complex/complex-rationalp
          • Logtest
          • Logandc1
          • Logorc1
          • Logandc2
          • Denominator
          • 1-
          • Numerator
          • Logorc2
          • The-number
          • Int=
          • Complex-rationalp
          • Min
          • Lognor
          • Zpf
          • Oddp
          • Minusp
          • Lognand
          • Imagpart
          • Conjugate
          • Realpart
          • Plusp
        • Efficiency
        • Irrelevant-formals
        • Introduction-to-programming-in-ACL2-for-those-who-know-lisp
        • Redefining-programs
        • Lists
        • Invariant-risk
        • Errors
        • Defabbrev
        • Conses
        • Alists
        • Set-register-invariant-risk
        • Strings
        • Program-wrapper
        • Get-internal-time
        • Basics
        • Packages
        • Oracle-eval
        • Defmacro-untouchable
        • <<
        • Primitive
        • Revert-world
        • Unmemoize
        • Set-duplicate-keys-action
        • Symbols
        • Def-list-constructor
        • Easy-simplify-term
        • Defiteration
        • Fake-oracle-eval
        • Defopen
        • Sleep
      • Operational-semantics
      • Real
      • Start-here
      • Debugging
      • Miscellaneous
      • Output-controls
      • Macros
      • Interfacing-tools
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
    • Math
    • Testing-utilities
  • Kestrel-utilities
  • Signed-byte-p

Signed-byte-fix

Fixing function for signed-byte-p.

Signature
(signed-byte-fix bits x) → fixed-x
Arguments
bits — Guard (posp bits).
x — Guard (signed-byte-p bits x).
Returns
fixed-x — Type (signed-byte-p bits fixed-x), given (posp bits).

Since the set denoted by signed-byte-p is empty for some values of bits (namely, when bits is not a positive integer), this fixing function cannot always return a value satisfying the predicate. Even though signed-byte-p does not fix its bits to posp, this fixing function does, i.e. it treats bits as a positive integer. Thus, the set denoted by signed-byte-p is never empty. If x is not in the range of signed-byte-p, we return 0; another option is to return loghead (or its equivalent with built-in functions, to avoid a dependency on the IHS library).

Since signed-byte-p is enabled by default, this fixing function is also enabled by default. When these functions are enabled, they are meant as abbreviations, and theorems triggered by them may not fire during proofs.

Definitions and Theorems

Function: signed-byte-fix

(defun signed-byte-fix (bits x)
  (declare (xargs :guard (and (posp bits)
                              (signed-byte-p bits x))))
  (let ((__function__ 'signed-byte-fix))
    (declare (ignorable __function__))
    (mbe :logic
         (b* ((bits (pos-fix bits)))
           (if (signed-byte-p bits x) x 0))
         :exec x)))

Theorem: return-type-of-signed-byte-fix

(defthm return-type-of-signed-byte-fix
  (implies (posp bits)
           (b* ((fixed-x (signed-byte-fix bits x)))
             (signed-byte-p bits fixed-x)))
  :rule-classes :rewrite)

Theorem: signed-byte-fix-when-signed-byte-p

(defthm signed-byte-fix-when-signed-byte-p
  (implies (signed-byte-p (pos-fix bits) x)
           (equal (signed-byte-fix bits x) x)))

Theorem: signed-byte-fix-of-pos-fix-bits

(defthm signed-byte-fix-of-pos-fix-bits
  (equal (signed-byte-fix (pos-fix bits) x)
         (signed-byte-fix bits x)))

Theorem: signed-byte-fix-of-pos-fix-bits-normalize-const

(defthm signed-byte-fix-of-pos-fix-bits-normalize-const
  (implies (syntaxp (and (quotep bits)
                         (not (natp (cadr bits)))))
           (equal (signed-byte-fix bits x)
                  (signed-byte-fix (pos-fix bits) x))))

Subtopics

Signed-byte-list-fix
Fixing function for signed-byte-listp.