Split
(split-bytes n bytes) → (mv one two)
Function:
(defun split-bytes (n bytes) (declare (xargs :guard (and (natp n) (byte-listp bytes)))) (let ((__function__ 'split-bytes)) (declare (ignorable __function__)) (b* ((rest (nthcdr n bytes)) ((unless (<= n (len bytes))) (prog2$ (raise "Not enough bytes to split into two by ~x0! (len bytes): ~x1" n (len bytes)) (mv (make-list n :initial-element 0) rest))) (first (take n bytes))) (mv first rest))))
Theorem:
(defthm byte-listp-of-split-bytes.one (implies (byte-listp bytes) (b* (((mv ?one ?two) (split-bytes n bytes))) (byte-listp one))) :rule-classes :rewrite)
Theorem:
(defthm byte-listp-of-split-bytes.two (implies (byte-listp bytes) (b* (((mv ?one ?two) (split-bytes n bytes))) (byte-listp two))) :rule-classes :rewrite)
Theorem:
(defthm len-of-mv-nth-0-split-bytes (b* (((mv ?one ?two) (split-bytes n bytes))) (equal (len one) (nfix n))))
Theorem:
(defthm len-of-mv-nth-1-split-bytes (b* (((mv ?one ?two) (split-bytes n bytes))) (equal (len two) (nfix (- (len bytes) (nfix n))))))