• 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
              • Basic-nat-to-hex-chars
                • Nat-to-hex-chars-aux
              • Parse-hex-from-charlist
              • Hex-digit-chars-value
              • 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
      • ACL2
      • Macro-libraries
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Nat-to-hex-chars

    Basic-nat-to-hex-chars

    Logically simple definition that is similar to nat-to-hex-chars.

    Signature
    (basic-nat-to-hex-chars n) → chars
    Arguments
    n — Guard (natp n).
    Returns
    chars — Type (hex-digit-char-list*p chars).

    This almost computes (nat-to-hex-chars n), but when n is zero it returns nil instead of (#\0). You would normally never call this function directly, but it is convenient for reasoning about nat-to-hex-chars.

    Definitions and Theorems

    Function: basic-nat-to-hex-chars

    (defun basic-nat-to-hex-chars (n)
      (declare (xargs :guard (natp n)))
      (let ((acl2::__function__ 'basic-nat-to-hex-chars))
        (declare (ignorable acl2::__function__))
        (if (zp n)
            nil
          (cons (hex-digit-to-char (logand n 15))
                (basic-nat-to-hex-chars (ash n -4))))))

    Theorem: hex-digit-char-list*p-of-basic-nat-to-hex-chars

    (defthm hex-digit-char-list*p-of-basic-nat-to-hex-chars
      (b* ((chars (basic-nat-to-hex-chars n)))
        (hex-digit-char-list*p chars))
      :rule-classes :rewrite)

    Theorem: basic-nat-to-hex-chars-when-zp

    (defthm basic-nat-to-hex-chars-when-zp
      (implies (zp n)
               (equal (basic-nat-to-hex-chars n) nil)))

    Theorem: true-listp-of-basic-nat-to-hex-chars

    (defthm true-listp-of-basic-nat-to-hex-chars
      (true-listp (basic-nat-to-hex-chars n))
      :rule-classes :type-prescription)

    Theorem: character-listp-of-basic-nat-to-hex-chars

    (defthm character-listp-of-basic-nat-to-hex-chars
      (character-listp (basic-nat-to-hex-chars n)))

    Theorem: basic-nat-to-hex-chars-under-iff

    (defthm basic-nat-to-hex-chars-under-iff
      (iff (basic-nat-to-hex-chars n)
           (not (zp n))))

    Theorem: consp-of-basic-nat-to-hex-chars

    (defthm consp-of-basic-nat-to-hex-chars
      (equal (consp (basic-nat-to-hex-chars n))
             (if (basic-nat-to-hex-chars n) t nil)))

    Theorem: basic-nat-to-hex-chars-one-to-one

    (defthm basic-nat-to-hex-chars-one-to-one
      (equal (equal (basic-nat-to-hex-chars n)
                    (basic-nat-to-hex-chars m))
             (equal (nfix n) (nfix m))))