• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
      • Std/lists
      • Omaps
      • Std/alists
      • Obags
      • Std/util
      • 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
        • Std/osets
        • Std/io
        • Std/basic
        • Std/system
        • Std/typed-lists
        • Std/bitsets
        • Std/testing
        • Std/typed-alists
        • Std/stobjs
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Base64-impl

    B64-decode-last-group

    Decode the final group of base-64 encoded characters into 1-3 characters.

    Signature
    (b64-decode-last-group c1 c2 c3 c4) → (mv okp ans)
    Returns
    okp — Type (booleanp okp).
    ans — Type (character-listp ans).

    Definitions and Theorems

    Function: b64-decode-last-group

    (defun b64-decode-last-group (c1 c2 c3 c4)
      (declare (type character c1 c2 c3 c4))
      (declare (xargs :guard t))
      (let ((acl2::__function__ 'b64-decode-last-group))
        (declare (ignorable acl2::__function__))
        (cond ((not (eql c4 #\=))
               (b* (((mv okp char1 char2 char3)
                     (b64-dec3 c1 c2 c3 c4)))
                 (mv okp (list char1 char2 char3))))
              ((not (eql c3 #\=))
               (b* (((mv okp char1 char2)
                     (b64-dec2 c1 c2 c3)))
                 (mv okp (list char1 char2))))
              (t (b* (((mv okp char1) (b64-dec1 c1 c2)))
                   (mv okp (list char1)))))))

    Theorem: booleanp-of-b64-decode-last-group.okp

    (defthm booleanp-of-b64-decode-last-group.okp
      (b* (((mv ?okp ?ans)
            (b64-decode-last-group c1 c2 c3 c4)))
        (booleanp okp))
      :rule-classes :rewrite)

    Theorem: character-listp-of-b64-decode-last-group.ans

    (defthm character-listp-of-b64-decode-last-group.ans
      (b* (((mv ?okp ?ans)
            (b64-decode-last-group c1 c2 c3 c4)))
        (character-listp ans))
      :rule-classes :rewrite)

    Theorem: b64-decode-last-group-of-b64-encode-last-group

    (defthm b64-decode-last-group-of-b64-encode-last-group
      (implies (and (character-listp x)
                    (consp x)
                    (atom (cdddr x)))
               (b* (((mv c1 c2 c3 c4)
                     (b64-encode-last-group x))
                    ((mv okp result)
                     (b64-decode-last-group c1 c2 c3 c4)))
                 (and okp (equal result x)))))