• 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-bytes-from-vals

    Decode 4 base-64 values into 3 bytes.

    Signature
    (b64-bytes-from-vals v1 v2 v3 v4) → (mv b1 b2 b3)
    Returns
    b1 — Type (natp b1).
    b2 — Type (natp b2).
    b3 — Type (natp b3).

    This is just doing the inverse of b64-vals-from-bytes.

    Definitions and Theorems

    Function: b64-bytes-from-vals$inline

    (defun b64-bytes-from-vals$inline (v1 v2 v3 v4)
      (declare (type (unsigned-byte 6) v1 v2 v3 v4))
      (declare (xargs :guard t))
      (let ((acl2::__function__ 'b64-bytes-from-vals))
        (declare (ignorable acl2::__function__))
        (b* ((b1 (the (unsigned-byte 8)
                      (logior (the (unsigned-byte 8)
                                   (ash (lnfix v1) 2))
                              (the (unsigned-byte 8)
                                   (ash (lnfix v2) -4)))))
             (b2 (the (unsigned-byte 8)
                      (logior (the (unsigned-byte 8)
                                   (ash (the (unsigned-byte 8)
                                             (logand (lnfix v2) 15))
                                        4))
                              (the (unsigned-byte 8)
                                   (ash (lnfix v3) -2)))))
             (b3 (the (unsigned-byte 8)
                      (logior (the (unsigned-byte 8)
                                   (ash (the (unsigned-byte 8)
                                             (logand (lnfix v3) 3))
                                        6))
                              (lnfix v4)))))
          (mv b1 b2 b3))))

    Theorem: natp-of-b64-bytes-from-vals.b1

    (defthm natp-of-b64-bytes-from-vals.b1
      (b* (((mv ?b1 ?b2 ?b3)
            (b64-bytes-from-vals$inline v1 v2 v3 v4)))
        (natp b1))
      :rule-classes :type-prescription)

    Theorem: natp-of-b64-bytes-from-vals.b2

    (defthm natp-of-b64-bytes-from-vals.b2
      (b* (((mv ?b1 ?b2 ?b3)
            (b64-bytes-from-vals$inline v1 v2 v3 v4)))
        (natp b2))
      :rule-classes :type-prescription)

    Theorem: natp-of-b64-bytes-from-vals.b3

    (defthm natp-of-b64-bytes-from-vals.b3
      (b* (((mv ?b1 ?b2 ?b3)
            (b64-bytes-from-vals$inline v1 v2 v3 v4)))
        (natp b3))
      :rule-classes :type-prescription)

    Theorem: unsigned-byte-p-8-of-b64-decode-4-chars

    (defthm unsigned-byte-p-8-of-b64-decode-4-chars
      (implies (and (force (unsigned-byte-p 6 v1))
                    (force (unsigned-byte-p 6 v2))
                    (force (unsigned-byte-p 6 v3))
                    (force (unsigned-byte-p 6 v4)))
               (b* (((mv b1 b2 b3)
                     (b64-bytes-from-vals v1 v2 v3 v4)))
                 (and (unsigned-byte-p 8 b1)
                      (unsigned-byte-p 8 b2)
                      (unsigned-byte-p 8 b3)))))

    Theorem: b64-bytes-from-vals-of-b64-vals-from-bytes

    (defthm b64-bytes-from-vals-of-b64-vals-from-bytes
      (b* (((mv v1 v2 v3 v4)
            (b64-vals-from-bytes b1 b2 b3))
           ((mv x1 x2 x3)
            (b64-bytes-from-vals v1 v2 v3 v4)))
        (implies (and (force (unsigned-byte-p 8 b1))
                      (force (unsigned-byte-p 8 b2))
                      (force (unsigned-byte-p 8 b3)))
                 (and (equal x1 b1)
                      (equal x2 b2)
                      (equal x3 b3)))))

    Theorem: b64-bytes-from-vals-padding-1

    (defthm b64-bytes-from-vals-padding-1
      (b* (((mv v1 v2 v3 ?v4)
            (b64-vals-from-bytes b1 b2 0))
           ((mv x1 x2 ?x3)
            (b64-bytes-from-vals v1 v2 v3 0)))
        (implies (and (force (unsigned-byte-p 8 b1))
                      (force (unsigned-byte-p 8 b2)))
                 (and (equal x1 b1) (equal x2 b2)))))

    Theorem: b64-bytes-from-vals-padding-2

    (defthm b64-bytes-from-vals-padding-2
      (b* (((mv v1 v2 ?v3 ?v4)
            (b64-vals-from-bytes b1 0 0))
           ((mv x1 ?x2 ?x3)
            (b64-bytes-from-vals v1 v2 0 0)))
        (implies (force (unsigned-byte-p 8 b1))
                 (equal x1 b1))))