• 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-unicode-escape

    Abstract a unicode-escape tree to a Unicode character.

    Signature
    (abs-unicode-escape tree) → unicode
    Arguments
    tree — Guard (abnf-tree-with-root-p tree "unicode-escape").
    Returns
    unicode — Type (unicodep unicode), given the guard.

    A unicode-escape tree consists of a Unicode escape, which is essentially a number represented via four hexadecimal digit characters. We abstract this kind of tree to the Unicode character whose code is the number represented by the four hexadecimal digits, in big-endian order.

    A unicode-escape tree has six subtrees, for the backslash, the `u' letter, and the four hexadecimal digits. We obtain the hex-digit subtrees (ignoring the other two subtrees), abstract them to four natural numbers below 16, and combine them in big-endian order.

    Definitions and Theorems

    Function: abs-unicode-escape

    (defun abs-unicode-escape (tree)
      (declare
           (xargs :guard (abnf-tree-with-root-p tree "unicode-escape")))
      (let ((__function__ 'abs-unicode-escape))
        (declare (ignorable __function__))
        (b* ((subtrees (abnf::tree-nonleaf->branches tree))
             (subtree1 (car (third subtrees)))
             (subtree2 (car (fourth subtrees)))
             (subtree3 (car (fifth subtrees)))
             (subtree4 (car (sixth subtrees)))
             (val1 (abs-hex-digit subtree1))
             (val2 (abs-hex-digit subtree2))
             (val3 (abs-hex-digit subtree3))
             (val4 (abs-hex-digit subtree4)))
          (+ (ash val1 12)
             (ash val2 8)
             (ash val3 4)
             val4))))

    Theorem: unicodep-of-abs-unicode-escape

    (defthm unicodep-of-abs-unicode-escape
      (implies (and (abnf-tree-with-root-p tree '"unicode-escape"))
               (b* ((unicode (abs-unicode-escape tree)))
                 (unicodep unicode)))
      :rule-classes :rewrite)