• 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-chars-value1
            • 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-chars-value

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

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

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

Definitions and Theorems

Function: oct-digit-chars-value$inline

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

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

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

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

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

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

(defthm unsigned-byte-p-of-oct-digit-chars-value
  (unsigned-byte-p (* 3 (len x))
                   (oct-digit-chars-value x)))

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

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

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

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

Theorem: oct-digit-chars-value1-removal

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

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

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

Subtopics

Oct-digit-chars-value1