• 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-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-dec3

    Decode 3 arbitrary characters from 4 base-64 characters.

    Signature
    (b64-dec3 c1 c2 c3 c4) → (mv okp d1 d2 d3)
    Returns
    okp — Decoding can fail if we encounter non Base-64 alphabetic characters in the input.
        Type (booleanp okp).
    d1 — Type (characterp d1).
    d2 — Type (characterp d2).
    d3 — Type (characterp d3).

    This is the main function for decoding, which is used for all but perhaps the last one or two characters.

    Definitions and Theorems

    Function: b64-dec3

    (defun b64-dec3 (c1 c2 c3 c4)
      (declare (type character c1 c2 c3 c4))
      (declare (xargs :guard t))
      (let ((acl2::__function__ 'b64-dec3))
        (declare (ignorable acl2::__function__))
        (b* ((code1 (char-code c1))
             (code2 (char-code c2))
             (code3 (char-code c3))
             (code4 (char-code c4))
             (val1 (b64-value-from-code code1))
             (val2 (b64-value-from-code code2))
             (val3 (b64-value-from-code code3))
             (val4 (b64-value-from-code code4))
             ((unless (and val1 val2 val3 val4))
              (mv nil #\0 #\0 #\0))
             ((mv (the (unsigned-byte 8) b1)
                  (the (unsigned-byte 8) b2)
                  (the (unsigned-byte 8) b3))
              (b64-bytes-from-vals val1 val2 val3 val4))
             (char1 (code-char b1))
             (char2 (code-char b2))
             (char3 (code-char b3)))
          (mv t char1 char2 char3))))

    Theorem: booleanp-of-b64-dec3.okp

    (defthm booleanp-of-b64-dec3.okp
      (b* (((mv ?okp ?d1 ?d2 ?d3)
            (b64-dec3 c1 c2 c3 c4)))
        (booleanp okp))
      :rule-classes :type-prescription)

    Theorem: characterp-of-b64-dec3.d1

    (defthm characterp-of-b64-dec3.d1
      (b* (((mv ?okp ?d1 ?d2 ?d3)
            (b64-dec3 c1 c2 c3 c4)))
        (characterp d1))
      :rule-classes :type-prescription)

    Theorem: characterp-of-b64-dec3.d2

    (defthm characterp-of-b64-dec3.d2
      (b* (((mv ?okp ?d1 ?d2 ?d3)
            (b64-dec3 c1 c2 c3 c4)))
        (characterp d2))
      :rule-classes :type-prescription)

    Theorem: characterp-of-b64-dec3.d3

    (defthm characterp-of-b64-dec3.d3
      (b* (((mv ?okp ?d1 ?d2 ?d3)
            (b64-dec3 c1 c2 c3 c4)))
        (characterp d3))
      :rule-classes :type-prescription)

    Theorem: b64-dec3-of-b64-enc3

    (defthm b64-dec3-of-b64-enc3
      (implies (and (characterp c1)
                    (characterp c2)
                    (characterp c3))
               (b* (((mv e1 e2 e3 e4) (b64-enc3 c1 c2 c3))
                    ((mv okp x1 x2 x3)
                     (b64-dec3 e1 e2 e3 e4)))
                 (and okp (equal x1 c1)
                      (equal x2 c2)
                      (equal x3 c3)))))