• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Recursion-and-induction
      • Hons-and-memoization
      • Events
      • Parallelism
      • History
      • Programming
        • Defun
        • Declare
        • System-utilities
        • Stobj
        • State
        • Mutual-recursion
        • Memoize
        • Mbe
        • Io
        • Defpkg
        • Apply$
        • Loop$
        • Programming-with-state
        • Arrays
        • Characters
        • Time$
        • Defmacro
        • Loop$-primer
        • Fast-alists
        • Defconst
        • Evaluation
        • Guard
        • Equality-variants
        • Compilation
        • Hons
        • ACL2-built-ins
        • Developers-guide
        • System-attachments
        • Advanced-features
        • Set-check-invariant-risk
        • Numbers
        • Efficiency
        • Irrelevant-formals
        • Introduction-to-programming-in-ACL2-for-those-who-know-lisp
        • Redefining-programs
        • Lists
        • Invariant-risk
        • Errors
        • Defabbrev
        • Conses
        • Alists
        • Set-register-invariant-risk
        • Strings
          • Std/strings
          • String-listp
          • Stringp
          • Length
          • Search
          • Remove-duplicates
          • Position
          • Coerce
          • Concatenate
          • Reverse
          • String
          • Subseq
          • Substitute
          • String-upcase
          • String-downcase
          • Count
          • Char
          • String<
          • String-equal
          • String-utilities
            • Code-char-injectivity-theorem
            • 8bitbytes-hexchars-conversions
            • Code-char-inverses-theorems
            • String-kinds
            • String-codelist-conversions
            • Charlist-codelist-conversions
            • 8bitbytes-hexstrings-conversions
              • Ubyte8s=>hexstring
              • Hexstring=>ubyte8s
                • Ubyte8s<=>hexstring-inverses-theorems
          • String-append
          • String>=
          • String<=
          • String>
          • Hex-digit-char-theorems
          • String-downcase-gen
          • String-upcase-gen
        • Program-wrapper
        • Get-internal-time
        • Basics
        • Packages
        • Oracle-eval
        • Defmacro-untouchable
        • <<
        • Primitive
        • Revert-world
        • Unmemoize
        • Set-duplicate-keys-action
        • Symbols
        • Def-list-constructor
        • Easy-simplify-term
        • Defiteration
        • Fake-oracle-eval
        • Defopen
        • Sleep
      • Operational-semantics
      • Real
      • Start-here
      • Debugging
      • Miscellaneous
      • Output-controls
      • Macros
      • Interfacing-tools
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
    • Math
    • Testing-utilities
  • 8bitbytes-hexstrings-conversions

Hexstring=>ubyte8s

Convert an even-length string of hexadecimal digit characters to a list of natural numbers below 256.

Signature
(hexstring=>ubyte8s string) → bytes
Arguments
string — Guard (and (stringp string) (str::hex-digit-string-p string) (evenp (length string))) .
Returns
bytes — Type (unsigned-byte-listp 8 bytes).

Each pair of hexadecimal digit characters is turned into sa number. Each such two-digit hexadecimal notation is treated as big endian, i.e. the most significant digit appears first.

Definitions and Theorems

Function: hexstring=>ubyte8s

(defun hexstring=>ubyte8s (string)
  (declare (xargs :guard (and (stringp string)
                              (str::hex-digit-string-p string)
                              (evenp (length string)))))
  (let ((__function__ 'hexstring=>ubyte8s))
    (declare (ignorable __function__))
    (hexchars=>ubyte8s (explode string))))

Theorem: return-type-of-hexstring=>ubyte8s

(defthm return-type-of-hexstring=>ubyte8s
  (b* ((bytes (hexstring=>ubyte8s string)))
    (unsigned-byte-listp 8 bytes))
  :rule-classes :rewrite)

Theorem: hexstring=>ubyte8s-of-string-append

(defthm hexstring=>ubyte8s-of-string-append
  (implies
       (evenp (length string1))
       (equal (hexstring=>ubyte8s (string-append string1 string2))
              (append (hexstring=>ubyte8s string1)
                      (hexstring=>ubyte8s string2)))))

Subtopics

Ubyte8s<=>hexstring-inverses-theorems
ubyte8s=>hexstring and hexstring=>ubyte8s are mutual inverses.