• 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
            • Implementation-environments
              • Integer-format-templates
              • Ienv
              • Integer-formats
              • Ienv-ushort-rangep
              • Ienv-ulong-rangep
              • Ienv-ullong-rangep
              • Ienv-uint-rangep
              • Ienv-uchar-rangep
              • Ienv-sshort-rangep
              • Ienv-slong-rangep
              • Ienv-sllong-rangep
              • Ienv-sint-rangep
              • Ienv-schar-rangep
              • Ienv-char-rangep
              • Ienv->schar-min
              • Ienv->schar-max
              • Ienv->char-size
              • Ienv->char-min
              • Ienv->char-max
              • Ienv->uchar-max
              • Ienv->short-bit-size
              • Ienv->long-bit-size
              • Ienv->llong-bit-size
              • Ienv->int-bit-size
              • Ienv->short-byte-size
              • Ienv->long-byte-size
              • Ienv->llong-byte-size
              • Ienv->int-byte-size
              • Versions
              • Ienv->ushort-max
              • Ienv->ullong-max
              • Ienv->sshort-min
              • Ienv->sllong-min
              • Ienv->sllong-max
              • Ienv->bool-byte-size
              • Ienv->bool-bit-size
              • Ienv->ulong-max
              • Ienv->uint-max
              • Ienv->sshort-max
              • Ienv->slong-min
              • Ienv->slong-max
              • Ienv->sint-min
              • Ienv->sint-max
              • Schar-formats
                • Schar-format
                • Schar-format->min
                • Schar-format->max
                  • Schar-format-8tcnt
                • Char-formats
                • Uchar-formats
                • Signed-formats
                • Bool-formats
              • 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
    • Schar-formats

    Schar-format->max

    The ACL2 integer value of SCHAR_MAX [C17:5.2.4.2.1/1].

    Signature
    (schar-format->max schar-format uchar-format) → max
    Arguments
    schar-format — Guard (schar-formatp schar-format).
    uchar-format — Guard (uchar-formatp uchar-format).
    Returns
    max — Type (posp max).

    Based on the discussion in schar-format, this is always 2^{\mathtt{CHAR\_BIT}-1} - 1.

    This depends on CHAR_BIT, so this function also takes the unsigned char format as input. In fact, this function only depends on CHAR_BIT, but we include the signed char format as input for uniformity.

    Definitions and Theorems

    Function: schar-format->max

    (defun schar-format->max (schar-format uchar-format)
      (declare (xargs :guard (and (schar-formatp schar-format)
                                  (uchar-formatp uchar-format))))
      (declare (ignore schar-format))
      (1- (expt 2
                (1- (uchar-format->size uchar-format)))))

    Theorem: posp-of-schar-format->max

    (defthm posp-of-schar-format->max
      (b* ((max (schar-format->max schar-format uchar-format)))
        (posp max))
      :rule-classes :rewrite)

    Theorem: schar-format->max-type-prescription

    (defthm schar-format->max-type-prescription
      (b* ((common-lisp::?max
                (schar-format->max schar-format uchar-format)))
        (and (posp max) (> max 1)))
      :rule-classes :type-prescription)

    Theorem: schar-format->max-lower-bound

    (defthm schar-format->max-lower-bound
      (b* ((common-lisp::?max
                (schar-format->max schar-format uchar-format)))
        (>= max 127))
      :rule-classes :linear)

    Theorem: schar-format->max-of-schar-format-fix-schar-format

    (defthm schar-format->max-of-schar-format-fix-schar-format
      (equal (schar-format->max (schar-format-fix schar-format)
                                uchar-format)
             (schar-format->max schar-format uchar-format)))

    Theorem: schar-format->max-schar-format-equiv-congruence-on-schar-format

    (defthm
        schar-format->max-schar-format-equiv-congruence-on-schar-format
      (implies
           (schar-format-equiv schar-format schar-format-equiv)
           (equal (schar-format->max schar-format uchar-format)
                  (schar-format->max schar-format-equiv uchar-format)))
      :rule-classes :congruence)

    Theorem: schar-format->max-of-uchar-format-fix-uchar-format

    (defthm schar-format->max-of-uchar-format-fix-uchar-format
      (equal (schar-format->max schar-format
                                (uchar-format-fix uchar-format))
             (schar-format->max schar-format uchar-format)))

    Theorem: schar-format->max-uchar-format-equiv-congruence-on-uchar-format

    (defthm
        schar-format->max-uchar-format-equiv-congruence-on-uchar-format
      (implies
           (uchar-format-equiv uchar-format uchar-format-equiv)
           (equal (schar-format->max schar-format uchar-format)
                  (schar-format->max schar-format uchar-format-equiv)))
      :rule-classes :congruence)