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