(vl-consteval-binop op aval bval) → ans
Function:
(defun vl-consteval-binop (op aval bval) (declare (xargs :guard (and (member op '(:vl-binary-plus :vl-binary-minus :vl-binary-times :vl-binary-div :vl-binary-rem :vl-binary-bitand :vl-binary-bitor :vl-binary-xor :vl-binary-xnor)) (natp aval) (natp bval)))) (declare (xargs :guard (implies (member op '(:vl-binary-div :vl-binary-rem)) (posp bval)))) (let ((__function__ 'vl-consteval-binop)) (declare (ignorable __function__)) (b* ((aval (lnfix aval)) (bval (lnfix bval))) (case op (:vl-binary-plus (+ aval bval)) (:vl-binary-minus (- aval bval)) (:vl-binary-times (* aval bval)) (:vl-binary-div (truncate aval bval)) (:vl-binary-rem (rem aval bval)) (:vl-binary-bitand (logand aval bval)) (:vl-binary-bitor (logior aval bval)) (:vl-binary-xor (logxor aval bval)) (:vl-binary-xnor (lognot (logxor aval bval))) (otherwise (progn$ (impossible) 0))))))
Theorem:
(defthm integerp-of-vl-consteval-binop (b* ((ans (vl-consteval-binop op aval bval))) (integerp ans)) :rule-classes :type-prescription)
Theorem:
(defthm vl-consteval-binop-of-nfix-aval (equal (vl-consteval-binop op (nfix aval) bval) (vl-consteval-binop op aval bval)))
Theorem:
(defthm vl-consteval-binop-nat-equiv-congruence-on-aval (implies (acl2::nat-equiv aval aval-equiv) (equal (vl-consteval-binop op aval bval) (vl-consteval-binop op aval-equiv bval))) :rule-classes :congruence)
Theorem:
(defthm vl-consteval-binop-of-nfix-bval (equal (vl-consteval-binop op aval (nfix bval)) (vl-consteval-binop op aval bval)))
Theorem:
(defthm vl-consteval-binop-nat-equiv-congruence-on-bval (implies (acl2::nat-equiv bval bval-equiv) (equal (vl-consteval-binop op aval bval) (vl-consteval-binop op aval bval-equiv))) :rule-classes :congruence)