Safely create a well-typed constant integer atom whose value is n.
Function:
(defun vl-make-integer-fn (n bits) (declare (xargs :guard (and (integerp n) (posp bits)))) (declare (xargs :guard (unsigned-byte-p bits n))) (let ((__function__ 'vl-make-integer)) (declare (ignorable __function__)) (let* ((value (lnfix n)) (bits (lposfix bits))) (hons-copy (make-vl-literal :val (make-vl-constint :origwidth bits :origsign :vl-signed :wasunsized t :value (acl2::loghead bits value)))))))
Theorem:
(defthm vl-expr-p-of-vl-make-integer (b* ((index (vl-make-integer-fn n bits))) (vl-expr-p index)) :rule-classes :rewrite)
Theorem:
(defthm vl-expr-kind-of-vl-make-integer (eq (vl-expr-kind (vl-make-integer n :bits bits)) :vl-literal))
Theorem:
(defthm vl-expr-resolved-p-of-vl-make-integer (vl-expr-resolved-p (vl-make-integer n :bits bits)))
Theorem:
(defthm vl-resolved->val-of-vl-make-integer (equal (vl-resolved->val (vl-make-integer n :bits bits)) (acl2::logext (pos-fix bits) (nfix n))))
Theorem:
(defthm vl-make-integer-fn-of-ifix-n (equal (vl-make-integer-fn (ifix n) bits) (vl-make-integer-fn n bits)))
Theorem:
(defthm vl-make-integer-fn-int-equiv-congruence-on-n (implies (acl2::int-equiv n n-equiv) (equal (vl-make-integer-fn n bits) (vl-make-integer-fn n-equiv bits))) :rule-classes :congruence)
Theorem:
(defthm vl-make-integer-fn-of-pos-fix-bits (equal (vl-make-integer-fn n (pos-fix bits)) (vl-make-integer-fn n bits)))
Theorem:
(defthm vl-make-integer-fn-pos-equiv-congruence-on-bits (implies (acl2::pos-equiv bits bits-equiv) (equal (vl-make-integer-fn n bits) (vl-make-integer-fn n bits-equiv))) :rule-classes :congruence)