Decode 4 base-64 values into 3 bytes.
This is just doing the inverse of b64-vals-from-bytes.
Function:
(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:
(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:
(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:
(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:
(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:
(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:
(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:
(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))))