String-based version of b64-encode-last-group.
Function:
(defun b64-encode-last-group-str (x n xl) (declare (xargs :guard (and (stringp x) (natp n) (eql xl (length x))))) (declare (type (integer 0 *) n xl) (type string x)) (declare (xargs :guard (< n xl))) (let ((acl2::__function__ 'b64-encode-last-group-str)) (declare (ignorable acl2::__function__)) (b* (((the (integer 0 *) left) (mbe :logic (nfix (- (nfix xl) (nfix n))) :exec (- xl n))) ((when (int= left 1)) (b* (((mv c1 c2) (b64-enc1 (char x n)))) (mv c1 c2 #\= #\=))) ((when (int= left 2)) (b* (((mv c1 c2 c3) (b64-enc2 (char x n) (char x (+ 1 n))))) (mv c1 c2 c3 #\=)))) (b64-enc3 (char x n) (char x (+ 1 n)) (char x (+ 2 n))))))
Theorem:
(defthm b64-encode-last-group-str-correct (implies (and (force (stringp x)) (force (natp n)) (force (equal xl (length x))) (force (< n xl))) (equal (b64-encode-last-group-str x n xl) (b64-encode-last-group (nthcdr n (explode x))))))