• 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-max

    Maximum mathematical integer value of an integer type.

    Signature
    (integer-type-max type) → min
    Arguments
    type — Guard (typep type).
    Returns
    min — Type (integerp min).

    For 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-max

    (defun integer-type-max (type)
      (declare (xargs :guard (typep type)))
      (declare (xargs :guard (type-nonchar-integerp type)))
      (cond ((type-case type :schar) (schar-max))
            ((type-case type :uchar) (uchar-max))
            ((type-case type :sshort) (sshort-max))
            ((type-case type :ushort) (ushort-max))
            ((type-case type :sint) (sint-max))
            ((type-case type :uint) (uint-max))
            ((type-case type :slong) (slong-max))
            ((type-case type :ulong) (ulong-max))
            ((type-case type :sllong) (sllong-max))
            ((type-case type :ullong) (ullong-max))
            (t (prog2$ (impossible) 0))))

    Theorem: integerp-of-integer-type-max

    (defthm integerp-of-integer-type-max
      (b* ((min (integer-type-max type)))
        (integerp min))
      :rule-classes :rewrite)

    Theorem: integer-type-max-of-type-fix-type

    (defthm integer-type-max-of-type-fix-type
      (equal (integer-type-max (type-fix type))
             (integer-type-max type)))

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

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