• 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
          • Octal
            • Parse-octal-from-string
            • Parse-octal-from-charlist
            • Nat-to-oct-chars
            • Oct-digit-chars-value
            • Oct-digit-char-p
            • Take-leading-oct-digit-chars
            • Oct-digit-char-value
              • Oct-digit-char-list*p
              • Oct-digit-char-listp
              • Skip-leading-octal-digits
              • Oct-digit-string-p
              • Nat-to-oct-string
              • Strval8
              • Nat-to-oct-string-list
              • Revappend-nat-to-oct-chars
              • Nonzero-oct-digit-char-p
              • Nat-to-oct-string-size
              • Octal-digit-to-char
            • 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
    • Octal

    Oct-digit-char-value

    Coerces a oct-digit-char-p character into a number.

    Signature
    (oct-digit-char-value x) → val
    Arguments
    x — Guard (oct-digit-char-p x).
    Returns
    val — Type (natp val).

    For instance, (oct-digit-char-value #\a) is 10. For any non-oct-digit-char-p, 0 is returned.

    Definitions and Theorems

    Function: oct-digit-char-value$inline

    (defun oct-digit-char-value$inline (x)
      (declare (xargs :guard (oct-digit-char-p x)))
      (declare (xargs :split-types t))
      (let ((acl2::__function__ 'oct-digit-char-value))
        (declare (ignorable acl2::__function__))
        (mbe :logic
             (b* (((unless (oct-digit-char-p x)) 0)
                  (code (char-code x)))
               (- code (char-code #\0)))
             :exec (the (unsigned-byte 8)
                        (- (the (unsigned-byte 8)
                                (char-code (the character x)))
                           48)))))

    Theorem: natp-of-oct-digit-char-value

    (defthm natp-of-oct-digit-char-value
      (b* ((val (oct-digit-char-value$inline x)))
        (natp val))
      :rule-classes :type-prescription)

    Theorem: ichareqv-implies-equal-oct-digit-char-value-1

    (defthm ichareqv-implies-equal-oct-digit-char-value-1
      (implies (ichareqv x x-equiv)
               (equal (oct-digit-char-value x)
                      (oct-digit-char-value x-equiv)))
      :rule-classes (:congruence))

    Theorem: oct-digit-char-value-upper-bound

    (defthm oct-digit-char-value-upper-bound
      (< (oct-digit-char-value x) 8)
      :rule-classes ((:rewrite) (:linear)))

    Theorem: unsigned-byte-p-of-oct-digit-char-value

    (defthm unsigned-byte-p-of-oct-digit-char-value
      (unsigned-byte-p 3 (oct-digit-char-value x)))

    Theorem: equal-of-oct-digit-char-value-and-oct-digit-char-value

    (defthm equal-of-oct-digit-char-value-and-oct-digit-char-value
      (implies (and (oct-digit-char-p x)
                    (oct-digit-char-p y))
               (equal (equal (oct-digit-char-value x)
                             (oct-digit-char-value y))
                      (ichareqv x y))))

    Theorem: oct-digit-char-value-of-digit-to-char

    (defthm oct-digit-char-value-of-digit-to-char
      (implies (and (natp n) (< n 8))
               (equal (oct-digit-char-value (digit-to-char n))
                      n)))