• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • Proof-checker-array
      • Soft
      • C
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Leftist-trees
      • Java
        • Atj
        • Aij
        • Language
          • Syntax
            • Grammar
            • Unicode-escapes
            • Unicode-input-char
            • Escape-sequence
            • Identifiers
            • Primitive-types
            • Reference-types
            • Keywords
            • Unicode-characters
            • Integer-literals
            • String-literals
            • Octal-digits
            • Hexadecimal-digits
              • Hex-digit
              • Hex-digit-value
                • Hexadecimal-digits-grammar-validation
                • Hex-digit-list
                • Hexadecimal-digits-std/strings-theorems
              • Decimal-digits
              • Binary-digits
              • Character-literals
              • Null-literal
              • Floating-point-literals
              • Boolean-literals
              • Package-names
              • Literals
            • Semantics
        • Taspi
        • Riscv
        • Bitcoin
        • Des
        • Ethereum
        • X86isa
        • Sha-2
        • Yul
        • Zcash
        • Proof-checker-itp13
        • Regex
        • ACL2-programming-language
        • Json
        • Jfkr
        • Equational
        • Cryptography
        • Poseidon
        • Where-do-i-place-my-book
        • Axe
        • Aleo
        • Bigmems
        • Builtins
        • Execloader
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Community
      • Proof-automation
      • ACL2
      • Macro-libraries
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Hexadecimal-digits

    Hex-digit-value

    Numeric value of a Java hexadecimal digit.

    Signature
    (hex-digit-value x) → val
    Arguments
    x — Guard (hex-digitp x).
    Returns
    val — Type (natp val).

    Definitions and Theorems

    Function: hex-digit-value

    (defun hex-digit-value (x)
      (declare (xargs :guard (hex-digitp x)))
      (let ((__function__ 'hex-digit-value))
        (declare (ignorable __function__))
        (b* ((x (mbe :logic (hex-digit-fix x) :exec x)))
          (cond ((and (<= (char-code #\0) x)
                      (<= x (char-code #\9)))
                 (- x (char-code #\0)))
                ((and (<= (char-code #\A) x)
                      (<= x (char-code #\F)))
                 (+ 10 (- x (char-code #\A))))
                ((and (<= (char-code #\a) x)
                      (<= x (char-code #\f)))
                 (+ 10 (- x (char-code #\a))))
                (t (impossible))))))

    Theorem: natp-of-hex-digit-value

    (defthm natp-of-hex-digit-value
      (b* ((val (hex-digit-value x)))
        (natp val))
      :rule-classes (:rewrite :type-prescription))

    Theorem: hex-digit-value-upper-bound

    (defthm hex-digit-value-upper-bound
      (b* ((?val (hex-digit-value x)))
        (<= val 15))
      :rule-classes :linear)

    Theorem: hex-digit-value-of-hex-digit-fix-x

    (defthm hex-digit-value-of-hex-digit-fix-x
      (equal (hex-digit-value (hex-digit-fix x))
             (hex-digit-value x)))

    Theorem: hex-digit-value-hex-digit-equiv-congruence-on-x

    (defthm hex-digit-value-hex-digit-equiv-congruence-on-x
      (implies (hex-digit-equiv x x-equiv)
               (equal (hex-digit-value x)
                      (hex-digit-value x-equiv)))
      :rule-classes :congruence)