• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • 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$
        • Defconst
        • Fast-alists
        • Defmacro
        • Loop$-primer
        • 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
            • Pretty-printing
            • Printtree
            • Base64
              • Base64-impl
                • B64-bytes-from-vals
                • B64-vals-from-bytes
                • B64-dec3
                • B64-decode-str-impl
                • B64-dec2
                • B64-encode-last-group
                • B64-value-from-code
                  • *b64-vals-from-codes-array*
                • B64-enc3
                • B64-enc2
                • B64-decode-last-group
                • B64-dec1
                • B64-decode-list-impl
                • B64-encode-str-impl
                • B64-encode-last-group-str
                • B64-enc1
                • B64-char-from-value
                • B64-encode-list-impl
              • Base64-decode-list
              • Base64-decode
              • Base64-encode-list
              • Base64-revappend-decode
              • Base64-revappend-encode
              • Base64-encode
            • Charset-p
            • Strtok!
            • Cases
            • Concatenation
            • Character-kinds
            • Html-encoding
            • Substrings
            • Strtok
            • Equivalences
            • Url-encoding
            • Lines
            • Explode-implode-equalities
            • Ordering
            • Numbers
            • Pad-trim
            • Coercion
            • Std/strings/digit-to-char
            • Substitution
            • Symbols
          • 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
          • 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
      • Miscellaneous
      • Output-controls
      • Bdd
      • Macros
      • Installation
      • Mailing-lists
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
    • Math
    • Testing-utilities
  • Base64-impl

B64-value-from-code

Look up the value of a Base64 character code, e.g., (char-code #\A) → 0.

Signature
(b64-value-from-code code) → value
Returns
value — Type (or (not value) (natp value)).

This is our lowest level decoding function. It's just an array lookup. Codes for characters that aren't part of the Base64 alphabet are mapped to NIL.

Definitions and Theorems

Function: b64-value-from-code$inline

(defun b64-value-from-code$inline (code)
  (declare (type (unsigned-byte 8) code))
  (let ((acl2::__function__ 'b64-value-from-code))
    (declare (ignorable acl2::__function__))
    (aref1 '*b64-vals-from-codes-array*
           *b64-vals-from-codes-array*
           (lnfix code))))

Theorem: return-type-of-b64-value-from-code

(defthm return-type-of-b64-value-from-code
  (b* ((value (b64-value-from-code$inline code)))
    (or (not value) (natp value)))
  :rule-classes :type-prescription)

Theorem: unsigned-byte-p-6-of-b64-value-from-code

(defthm unsigned-byte-p-6-of-b64-value-from-code
  (iff (unsigned-byte-p 6 (b64-value-from-code code))
       (b64-value-from-code code)))

Theorem: b64-value-from-code-of-b64-char-from-value

(defthm b64-value-from-code-of-b64-char-from-value
 (implies
  (unsigned-byte-p 6 value)
  (equal
       (b64-value-from-code (char-code (b64-char-from-value value)))
       value)))

Subtopics

*b64-vals-from-codes-array*
Array mapping each character code back to its associated value.