• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
      • Std/lists
      • Std/alists
      • Obags
      • Std/util
      • Std/strings
        • Pretty-printing
        • Printtree
        • Base64
        • Charset-p
        • Strtok!
        • Cases
        • Concatenation
        • Html-encoding
        • Character-kinds
        • Substrings
        • Strtok
        • Equivalences
        • Url-encoding
        • Lines
        • Explode-implode-equalities
        • Ordering
        • Numbers
          • Decimal
          • Hex
            • Parse-hex-from-string
            • Hex-digit-char-p
            • Nat-to-hex-chars
            • Parse-hex-from-charlist
            • Hex-digit-chars-value
              • Hex-digit-chars-value1
            • Hex-digit-char-value
            • Take-leading-hex-digit-chars
            • Hexify
            • Hex-digit-char-listp
            • Hex-digit-char-list*p
            • Hex-digit-string-p
            • Strval16
            • Skip-leading-hex-digits
            • Nat-to-hex-string
            • Hexify-width
            • Nonzero-hex-digit-char-p
            • Nat-to-hex-string-list
            • Revappend-nat-to-hex-chars
            • Hex-digit-to-char
            • Nat-to-hex-string-size
          • Octal
          • Binary
        • Pad-trim
        • Coercion
        • Std/strings/digit-to-char
        • Substitution
        • Symbols
      • Std/osets
      • Std/io
      • Std/basic
      • Std/system
      • Std/typed-lists
      • Std/bitsets
      • Std/testing
      • Std/typed-alists
      • Std/stobjs
    • Community
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
    • Math
    • Testing-utilities
  • Hex

Hex-digit-chars-value

Coerces a hex-digit-char-list*p into a natural number.

Signature
(hex-digit-chars-value x) → value
Arguments
x — Guard (hex-digit-char-list*p x).
Returns
value — Type (natp value).

For instance, (hex-digit-chars-value '(#1 #F)) is 31. See also parse-hex-from-charlist for a more flexible function that can tolerate non-hexadecimal characters after the number.

Definitions and Theorems

Function: hex-digit-chars-value$inline

(defun hex-digit-chars-value$inline (x)
  (declare (xargs :guard (hex-digit-char-list*p x)))
  (let ((acl2::__function__ 'hex-digit-chars-value))
    (declare (ignorable acl2::__function__))
    (mbe :logic
         (if (consp x)
             (+ (ash (hex-digit-char-value (car x))
                     (* 4 (1- (len x))))
                (hex-digit-chars-value (cdr x)))
           0)
         :exec (hex-digit-chars-value1 x 0))))

Theorem: natp-of-hex-digit-chars-value

(defthm natp-of-hex-digit-chars-value
  (b* ((value (hex-digit-chars-value$inline x)))
    (natp value))
  :rule-classes :type-prescription)

Theorem: icharlisteqv-implies-equal-hex-digit-chars-value-1

(defthm icharlisteqv-implies-equal-hex-digit-chars-value-1
  (implies (icharlisteqv x x-equiv)
           (equal (hex-digit-chars-value x)
                  (hex-digit-chars-value x-equiv)))
  :rule-classes (:congruence))

Theorem: unsigned-byte-p-of-hex-digit-chars-value

(defthm unsigned-byte-p-of-hex-digit-chars-value
  (unsigned-byte-p (* 4 (len x))
                   (hex-digit-chars-value x)))

Theorem: hex-digit-chars-value-upper-bound

(defthm hex-digit-chars-value-upper-bound
  (< (hex-digit-chars-value x)
     (expt 2 (* 4 (len x))))
  :rule-classes ((:rewrite) (:linear)))

Theorem: hex-digit-chars-value-upper-bound-free

(defthm hex-digit-chars-value-upper-bound-free
  (implies (equal n (len x))
           (< (hex-digit-chars-value x)
              (expt 2 (* 4 n)))))

Theorem: hex-digit-chars-value1-removal

(defthm hex-digit-chars-value1-removal
  (implies (natp val)
           (equal (hex-digit-chars-value1 x val)
                  (+ (hex-digit-chars-value x)
                     (ash (nfix val) (* 4 (len x)))))))

Theorem: hex-digit-chars-value-of-append

(defthm hex-digit-chars-value-of-append
  (equal (hex-digit-chars-value (append x (list a)))
         (+ (ash (hex-digit-chars-value x) 4)
            (hex-digit-char-value a))))

Subtopics

Hex-digit-chars-value1