Function:
(defun byte-listp (x) (declare (xargs :guard t)) (let ((__function__ 'byte-listp)) (declare (ignorable __function__)) (if (equal x nil) t (and (consp x) (n08p (car x)) (byte-listp (cdr x))))))
Theorem:
(defthm byte-listp-implies-true-listp (implies (byte-listp x) (true-listp x)) :rule-classes :forward-chaining)
Theorem:
(defthm n08p-element-of-byte-listp (implies (and (byte-listp acc) (natp m) (< m (len acc))) (unsigned-byte-p 8 (nth m acc))) :rule-classes (:rewrite (:type-prescription :corollary (implies (and (byte-listp acc) (natp m) (< m (len acc))) (natp (nth m acc))) :hints (("Goal" :in-theory '(unsigned-byte-p integer-range-p natp)))) (:linear :corollary (implies (and (byte-listp acc) (natp m) (< m (len acc))) (and (<= 0 (nth m acc)) (< (nth m acc) 256))) :hints (("Goal" :in-theory '(unsigned-byte-p integer-range-p (:e expt)))))))
Theorem:
(defthm repeat-byte-listp (implies (unsigned-byte-p 8 m) (byte-listp (acl2::repeat n m))) :rule-classes (:type-prescription :rewrite))
Theorem:
(defthm len-of-nthcdr-byte-listp (implies (and (< m (len acc)) (natp m)) (equal (len (nthcdr m acc)) (- (len acc) m))))
Theorem:
(defthm byte-listp-revappend (implies (forced-and (byte-listp lst1) (byte-listp lst2)) (byte-listp (revappend lst1 lst2))) :rule-classes :type-prescription)
Theorem:
(defthm true-listp-make-list-ac (implies (true-listp ac) (true-listp (make-list-ac n val ac))) :rule-classes :type-prescription)
Theorem:
(defthm reverse-byte-listp (implies (byte-listp x) (byte-listp (reverse x))) :rule-classes (:type-prescription :rewrite))
Theorem:
(defthm byte-listp-append (implies (forced-and (byte-listp lst1) (byte-listp lst2)) (byte-listp (append lst1 lst2))) :rule-classes (:rewrite :type-prescription))
Theorem:
(defthm make-list-ac-byte-listp (implies (and (byte-listp x) (n08p m)) (byte-listp (make-list-ac n m x))) :rule-classes (:type-prescription :rewrite))
Function:
(defun combine-bytes (bytes) (declare (xargs :guard (byte-listp bytes))) (let ((__function__ 'combine-bytes)) (declare (ignorable __function__)) (if (endp bytes) 0 (logapp 8 (if (mbt (unsigned-byte-p 8 (car bytes))) (car bytes) 0) (combine-bytes (cdr bytes))))))
Theorem:
(defthm natp-combine-bytes (implies (force (byte-listp bytes)) (natp (combine-bytes bytes))) :rule-classes :type-prescription)
Theorem:
(defthm unsigned-byte-p-of-combine-bytes (implies (and (equal n (ash (len bytes) 3)) (byte-listp bytes)) (unsigned-byte-p n (combine-bytes bytes))) :rule-classes ((:rewrite) (:linear :corollary (implies (and (equal n (ash (len bytes) 3)) (byte-listp bytes)) (<= 0 (combine-bytes bytes))))))
Theorem:
(defthm size-of-combine-bytes (implies (and (equal l (len bytes)) (byte-listp bytes)) (< (combine-bytes bytes) (expt 2 (ash l 3)))) :rule-classes :linear)
Theorem:
(defthm byte-listp-of-nthcdr (implies (byte-listp xs) (byte-listp (nthcdr n xs))))
Theorem:
(defthm byte-listp-of-take (implies (and (byte-listp xs) (<= n (len xs))) (byte-listp (take n xs))))
Function:
(defun combine-n-bytes (low num bytes) (declare (xargs :guard (and (natp low) (natp num) (byte-listp bytes)))) (declare (xargs :guard (<= (+ low num) (len bytes)))) (let ((__function__ 'combine-n-bytes)) (declare (ignorable __function__)) (if (mbt (and (<= (+ low num) (len bytes)) (byte-listp bytes) (natp low) (natp num))) (combine-bytes (take num (nthcdr low bytes))) 0)))
Theorem:
(defthm combine-bytes-and-take-degenerate-case-1 (implies (zp n) (equal (combine-bytes (take n bytes)) 0)))
Theorem:
(defthm combine-bytes-and-take-degenerate-case-2 (equal (combine-bytes (take n nil)) 0))
Theorem:
(defthm natp-of-combine-bytes-of-take (implies (byte-listp bytes) (<= 0 (combine-bytes (take num bytes)))))
Theorem:
(defthm natp-combine-n-bytes (implies (force (byte-listp bytes)) (natp (combine-n-bytes low num bytes))) :rule-classes ((:type-prescription) (:linear :corollary (implies (byte-listp bytes) (<= 0 (combine-n-bytes low num bytes))))))
Theorem:
(defthm unsigned-byte-p-of-combine-n-bytes (implies (and (equal n (ash num 3)) (natp num)) (unsigned-byte-p n (combine-n-bytes low num bytes))))
Theorem:
(defthm size-of-combine-n-bytes (< (combine-n-bytes low num bytes) (expt 2 (ash num 3))) :rule-classes :linear)
Function:
(defun program-at (prog-addr bytes x86) (declare (xargs :stobjs (x86))) (declare (xargs :guard (and (canonical-address-p prog-addr) (canonical-address-p (+ -1 (len bytes) prog-addr)) (byte-listp bytes)) :non-executable t)) (prog2$ (acl2::throw-nonexec-error 'program-at (list prog-addr bytes x86)) (let ((__function__ 'program-at)) (declare (ignorable __function__)) (b* (((mv flg bytes-read ?x86) (rb (len bytes) prog-addr :x x86))) (and (equal flg nil) (equal bytes-read (combine-n-bytes 0 (len bytes) bytes)))))))
Theorem:
(defthm program-at-xw-in-app-view (implies (and (app-view x86) (not (equal fld :mem)) (not (equal fld :app-view))) (equal (program-at addr bytes (xw fld index value x86)) (program-at addr bytes x86))))