• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • C
          • Syntax-for-tools
          • Atc
          • Transformation-tools
          • Language
            • Abstract-syntax
            • Integer-ranges
              • Def-integer-range
              • Integer-type-rangep
                • Ushort-integer
                • Ullong-integer
                • Sshort-integer
                • Sllong-integer
                • Ulong-integer
                • Uint-integer
                • Uchar-integer
                • Slong-integer
                • Sint-integer
                • Schar-integer
                • Ushort-max
                • Slong-max
                • Sllong-max
                • Integer-type-min
                • Integer-type-max
                • Uint-max
                • Sint-max
                • Ulong-max
                • Uchar-max
                • Def-integer-range-loop
                • Sshort-min
                • Sshort-max
                • Slong-min
                • Sint-min
                • Ullong-max
                • Sllong-min
                • Schar-min
                • Schar-max
                • Ushort-integer-list
                • Ulong-integer-list
                • Ullong-integer-list
                • Uint-integer-list
                • Uchar-integer-list
                • Sshort-integer-list
                • Slong-integer-list
                • Sllong-integer-list
                • Sint-integer-list
                • Schar-integer-list
                • Uchar-integerp-alt-def
                • Ushort-integerp-alt-def
                • Ulong-integerp-alt-def
                • Ullong-integerp-alt-def
                • Uint-integerp-alt-def
                • Sshort-integerp-alt-def
                • Slong-integerp-alt-def
                • Sllong-integerp-alt-def
                • Sint-integerp-alt-def
                • Schar-integerp-alt-def
              • Implementation-environments
              • Dynamic-semantics
              • Static-semantics
              • Grammar
              • Types
              • Integer-formats-definitions
              • Computation-states
              • Portable-ascii-identifiers
              • Values
              • Integer-operations
              • Object-designators
              • Operations
              • Errors
              • Tag-environments
              • Function-environments
              • Character-sets
              • Flexible-array-member-removal
              • Arithmetic-operations
              • Pointer-operations
              • Real-operations
              • Array-operations
              • Scalar-operations
              • Structure-operations
            • Representation
            • Insertion-sort
            • Pack
          • Soft
          • Bv
          • Imp-language
          • Ethereum
          • Event-macros
          • Java
          • Riscv
          • Bitcoin
          • Zcash
          • Yul
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Axe
          • Lists-light
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Integer-ranges

    Integer-type-rangep

    Check if a mathematical integer is in the range of an integer type.

    Signature
    (integer-type-rangep mathint type) → yes/no
    Arguments
    mathint — Guard (integerp mathint).
    type — Guard (typep type).
    Returns
    yes/no — Type (booleanp yes/no).

    Fot now we exclude the plain char type, via the guard. However, we prefer to keep the name of this function more general, in anticipation for extending it to those two types.

    Definitions and Theorems

    Function: integer-type-rangep

    (defun integer-type-rangep (mathint type)
      (declare (xargs :guard (and (integerp mathint) (typep type))))
      (declare (xargs :guard (type-nonchar-integerp type)))
      (and (<= (integer-type-min type)
               (ifix mathint))
           (<= (ifix mathint)
               (integer-type-max type))))

    Theorem: booleanp-of-integer-type-rangep

    (defthm booleanp-of-integer-type-rangep
      (b* ((yes/no (integer-type-rangep mathint type)))
        (booleanp yes/no))
      :rule-classes :rewrite)

    Theorem: integer-type-rangep-to-signed-byte-p

    (defthm integer-type-rangep-to-signed-byte-p
      (implies (and (type-signed-integerp type)
                    (integerp int))
               (equal (integer-type-rangep int type)
                      (signed-byte-p (integer-type-bits type)
                                     int))))

    Theorem: integer-type-rangep-to-unsigned-byte-p

    (defthm integer-type-rangep-to-unsigned-byte-p
      (implies (and (type-unsigned-integerp type)
                    (integerp int))
               (equal (integer-type-rangep int type)
                      (unsigned-byte-p (integer-type-bits type)
                                       int))))

    Theorem: integer-type-rangep-of-ifix-mathint

    (defthm integer-type-rangep-of-ifix-mathint
      (equal (integer-type-rangep (ifix mathint)
                                  type)
             (integer-type-rangep mathint type)))

    Theorem: integer-type-rangep-int-equiv-congruence-on-mathint

    (defthm integer-type-rangep-int-equiv-congruence-on-mathint
      (implies (acl2::int-equiv mathint mathint-equiv)
               (equal (integer-type-rangep mathint type)
                      (integer-type-rangep mathint-equiv type)))
      :rule-classes :congruence)

    Theorem: integer-type-rangep-of-type-fix-type

    (defthm integer-type-rangep-of-type-fix-type
      (equal (integer-type-rangep mathint (type-fix type))
             (integer-type-rangep mathint type)))

    Theorem: integer-type-rangep-type-equiv-congruence-on-type

    (defthm integer-type-rangep-type-equiv-congruence-on-type
      (implies (type-equiv type type-equiv)
               (equal (integer-type-rangep mathint type)
                      (integer-type-rangep mathint type-equiv)))
      :rule-classes :congruence)