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