(idiv-spec-8 dst src) → (mv * * *)
Function:
(defun idiv-spec-8 (dst src) (declare (type (unsigned-byte 16) dst) (type (unsigned-byte 8) src)) (declare (xargs :guard (not (equal src 0)))) (let ((__function__ 'idiv-spec-8)) (declare (ignorable __function__)) (b* ((dst-int (the (signed-byte 16) (ntoi 16 dst))) (src-int (the (signed-byte 8) (ntoi 8 src))) (quotient-int (the (signed-byte 17) (truncate dst-int src-int))) (remainder-int (the (signed-byte 8) (rem dst-int src-int))) (overflow? (or (< (the (signed-byte 17) quotient-int) -128) (< 127 (the (signed-byte 17) quotient-int)))) ((when overflow?) (mv (list (cons 'quotient-int quotient-int) (cons 'remainder-int remainder-int)) 0 0)) (quotient (the (unsigned-byte 8) (n-size 8 quotient-int))) (remainder (the (unsigned-byte 8) (n-size 8 remainder-int)))) (mv overflow? quotient remainder))))
Theorem:
(defthm n08-mv-nth-1-idiv-spec-8 (implies (not (mv-nth 0 (idiv-spec-8 dst src))) (unsigned-byte-p 8 (mv-nth 1 (idiv-spec-8 dst src)))) :rule-classes (:rewrite (:type-prescription :corollary (implies (not (mv-nth 0 (idiv-spec-8 dst src))) (natp (mv-nth 1 (idiv-spec-8 dst src)))) :hints (("Goal" :in-theory '(unsigned-byte-p integer-range-p natp)))) (:linear :corollary (implies (not (mv-nth 0 (idiv-spec-8 dst src))) (and (<= 0 (mv-nth 1 (idiv-spec-8 dst src))) (< (mv-nth 1 (idiv-spec-8 dst src)) 256))) :hints (("Goal" :in-theory '(unsigned-byte-p integer-range-p (:e expt)))))))
Theorem:
(defthm mv-nth-2-idiv-spec-8 (implies (and (unsigned-byte-p 8 src) (< 0 src)) (unsigned-byte-p 8 (mv-nth 2 (idiv-spec-8 dst src)))) :rule-classes (:rewrite (:type-prescription :corollary (implies (and (unsigned-byte-p 8 src) (< 0 src)) (natp (mv-nth 2 (idiv-spec-8 dst src)))) :hints (("Goal" :in-theory '(unsigned-byte-p integer-range-p natp)))) (:linear :corollary (implies (and (unsigned-byte-p 8 src) (< 0 src)) (and (<= 0 (mv-nth 2 (idiv-spec-8 dst src))) (< (mv-nth 2 (idiv-spec-8 dst src)) 256))) :hints (("Goal" :in-theory '(unsigned-byte-p integer-range-p (:e expt)))))))