• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • 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
        • Soft
        • C
        • Bv
        • Imp-language
        • Event-macros
        • Java
          • Atj
          • Aij
          • Language
            • Syntax
              • Grammar
              • Unicode-escapes
                • Uniescape-parse-constraints-p
                • Even-backslashes-tree-constraints-p
                • Len-of-string-of-prefix-of-unicode-input-character-trees
                • Uniescape-parse
                • Nonzero-uletters-after-p
                • Abs-unicode-escape
                • Even-backslashes-before-p
                • Uniescape-tree-constraints-p
                • Uniescape-process
                • Uniescape-candidate-valid-p
                • Uniescape-candidate-p
                • Abs-raw-input-character
                • Abs-hex-digit
                  • Abs-unicode-input-character
                  • Some-uniescape-candidate-invalid-p
                  • Uniescapep
                  • Abs-unicode-input-character-list
                  • Uniescape-parse-p
                  • Eligible-backslash-p
                  • Unicode-input-character-tree-is-escape-p
                • Unicode-input-char
                • Escape-sequence
                • Identifiers
                • Primitive-types
                • Reference-types
                • Keywords
                • Unicode-characters
                • Integer-literals
                • String-literals
                • Octal-digits
                • Hexadecimal-digits
                • Decimal-digits
                • Binary-digits
                • Character-literals
                • Null-literal
                • Floating-point-literals
                • Boolean-literals
                • Package-names
                • Literals
              • Semantics
          • Bitcoin
          • Ethereum
          • Yul
          • Zcash
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Lists-light
          • Axe
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Unicode-escapes

    Abs-hex-digit

    Abstract a hex-digit tree to a natural number below 16.

    Signature
    (abs-hex-digit tree) → val
    Arguments
    tree — Guard (abnf-tree-with-root-p tree "hex-digit").
    Returns
    val — Type (natp val).

    A hex-digit tree is essentially a single hexadecimal digit Unicode character, which denotes a natural number below 16. We abstract this kind of tree to the denoted value.

    A hex-digit tree has a single subtree, accessible via caar. That subtree is a terminal leaf tree with a single terminal (natural number) that is the ASCII/Unicode code of a hexadecimal digit, which we map to the value it denotes via hex-digit-value.

    Definitions and Theorems

    Function: abs-hex-digit

    (defun abs-hex-digit (tree)
      (declare (xargs :guard (abnf-tree-with-root-p tree "hex-digit")))
      (let ((__function__ 'abs-hex-digit))
        (declare (ignorable __function__))
        (b* ((subtree (caar (abnf::tree-nonleaf->branches tree)))
             (string (abnf::tree->string subtree))
             (hexdig (car string)))
          (hex-digit-value hexdig))))

    Theorem: natp-of-abs-hex-digit

    (defthm natp-of-abs-hex-digit
      (b* ((val (abs-hex-digit tree)))
        (natp val))
      :rule-classes :rewrite)

    Theorem: abs-hex-digit-upper-bound

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