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

    Base64-decode-list

    Base64 decode a character list.

    Signature
    (base64-decode-list x) → (mv okp ans)
    Arguments
    x — Character list to decode.
        Guard (character-listp x).
    Returns
    okp — Was decoding successful? It can fail if we encounter non Base-64 alphabetic characters in the input, or if the input is not of the proper length (a multiple of 4), or if there is incorrect padding.
        Type (booleanp okp).
    ans — On success, the decoded version of x. On failure, it is some nonsensical character list that should not be relied on.
        Type (character-listp ans).

    Definitions and Theorems

    Function: base64-decode-list

    (defun base64-decode-list (x)
      (declare (xargs :guard (character-listp x)))
      (let ((acl2::__function__ 'base64-decode-list))
        (declare (ignorable acl2::__function__))
        (mbe :logic
             (b* (((when (atom x)) (mv t nil))
                  ((when (atom (cdddr x))) (mv nil nil))
                  (c1 (first x))
                  (c2 (second x))
                  (c3 (third x))
                  (c4 (fourth x))
                  (rest (cddddr x))
                  ((when (atom rest))
                   (b64-decode-last-group c1 c2 c3 c4))
                  ((mv okp x1 x2 x3)
                   (b64-dec3 c1 c2 c3 c4))
                  ((unless okp) (mv nil nil))
                  ((mv rest-ok rest-ans)
                   (base64-decode-list (cddddr x))))
               (mv (and okp rest-ok)
                   (list* x1 x2 x3 rest-ans)))
             :exec
             (b* (((mv okp acc)
                   (b64-decode-list-impl x nil)))
               (mv okp (reverse acc))))))

    Theorem: booleanp-of-base64-decode-list.okp

    (defthm booleanp-of-base64-decode-list.okp
      (b* (((mv ?okp ?ans) (base64-decode-list x)))
        (booleanp okp))
      :rule-classes :type-prescription)

    Theorem: character-listp-of-base64-decode-list.ans

    (defthm character-listp-of-base64-decode-list.ans
      (b* (((mv ?okp ?ans) (base64-decode-list x)))
        (character-listp ans))
      :rule-classes :rewrite)

    Theorem: b64-decode-list-impl-removal

    (defthm b64-decode-list-impl-removal
      (equal (b64-decode-list-impl x acc)
             (mv (mv-nth 0 (base64-decode-list x))
                 (revappend (mv-nth 1 (base64-decode-list x))
                            acc))))

    Theorem: base64-decode-list-of-base64-encode-list

    (defthm base64-decode-list-of-base64-encode-list
      (implies (character-listp x)
               (b* ((encoded (base64-encode-list x))
                    ((mv okp decoded)
                     (base64-decode-list encoded)))
                 (and okp (equal decoded x)))))