Specification for the
(idiv-spec size dst src) → (mv * * *)
Function:
(defun idiv-spec$inline (size dst src) (declare (type (member 1 2 4 8) size)) (declare (xargs :guard (and (not (equal src 0)) (case size (1 (and (n08p src) (n16p dst))) (2 (and (n16p src) (n32p dst))) (4 (and (n32p src) (n64p dst))) (8 (and (n64p src) (n128p dst))) (otherwise nil))))) (case size (1 (idiv-spec-8 dst src)) (2 (idiv-spec-16 dst src)) (4 (idiv-spec-32 dst src)) (8 (idiv-spec-64 dst src)) (otherwise (mv nil 0 0))))
Theorem:
(defthm mv-nth-1-idiv-spec (implies (and (member size '(1 2 4 8)) (not (mv-nth 0 (idiv-spec size dst src)))) (unsigned-byte-p (ash size 3) (mv-nth 1 (idiv-spec size dst src)))) :rule-classes (:rewrite (:type-prescription :corollary (implies (and (syntaxp (quotep size)) (force (member size '(1 2 4 8))) (not (mv-nth 0 (idiv-spec size dst src)))) (natp (mv-nth 1 (idiv-spec size dst src)))) :hints (("Goal" :in-theory '(unsigned-byte-p integer-range-p natp)))) (:linear :corollary (implies (and (member size '(1 2 4 8)) (not (mv-nth 0 (idiv-spec size dst src)))) (and (<= 0 (mv-nth 1 (idiv-spec size dst src))) (< (mv-nth 1 (idiv-spec size dst src)) (expt 2 (ash size 3))))) :hints (("Goal" :in-theory '(unsigned-byte-p integer-range-p (:e expt)))))))
Theorem:
(defthm mv-nth-2-idiv-spec (implies (and (member size '(1 2 4 8)) (not (equal src 0)) (unsigned-byte-p (ash size 3) src)) (unsigned-byte-p (ash size 3) (mv-nth 2 (idiv-spec size dst src)))) :rule-classes (:rewrite (:type-prescription :corollary (implies (and (syntaxp (quotep size)) (force (member size '(1 2 4 8))) (force (not (equal src 0))) (force (unsigned-byte-p (ash size 3) src))) (natp (mv-nth 2 (idiv-spec size dst src)))) :hints (("Goal" :in-theory '(unsigned-byte-p integer-range-p natp)))) (:linear :corollary (implies (and (member size '(1 2 4 8)) (not (equal src 0)) (unsigned-byte-p (ash size 3) src)) (and (<= 0 (mv-nth 2 (idiv-spec size dst src))) (< (mv-nth 2 (idiv-spec size dst src)) (expt 2 (ash size 3))))) :hints (("Goal" :in-theory '(unsigned-byte-p integer-range-p (:e expt)))))))