Safely create a constant integer atom whose value is n.
(vl-make-index n) → index
Function:
(defun vl-make-index (n) (declare (xargs :guard t)) (let ((__function__ 'vl-make-index)) (declare (ignorable __function__)) (let* ((value (if (natp n) n (prog2$ (raise "Proposed index is not a natural: ~x0." n) 0))) (width (+ 1 (integer-length value)))) (if (<= width 31) (hons-copy (make-vl-atom :guts (make-vl-constint :origwidth 32 :origtype :vl-signed :wasunsized t :value value) :finalwidth 32 :finaltype :vl-signed)) (hons-copy (make-vl-atom :guts (make-vl-constint :origwidth width :origtype :vl-signed :value value) :finalwidth width :finaltype :vl-signed))))))
Theorem:
(defthm vl-expr-p-of-vl-make-index (b* ((index (vl-make-index n))) (vl-expr-p index)) :rule-classes :rewrite)
Theorem:
(defthm vl-expr-kind-of-vl-make-index (eq (vl-expr-kind (vl-make-index n)) :atom))
Theorem:
(defthm vl-expr-resolved-p-of-vl-make-index (vl-expr-resolved-p (vl-make-index n)))
Theorem:
(defthm vl-resolved->val-of-vl-make-index (equal (vl-resolved->val (vl-make-index n)) (nfix n)))
Theorem:
(defthm posp-of-vl-expr->finalwidth-of-vl-make-index (posp (vl-expr->finalwidth (vl-make-index n))) :rule-classes :type-prescription)
Theorem:
(defthm vl-make-index-of-nfix-n (equal (vl-make-index (nfix n)) (vl-make-index n)))
Theorem:
(defthm vl-make-index-nat-equiv-congruence-on-n (implies (acl2::nat-equiv n n-equiv) (equal (vl-make-index n) (vl-make-index n-equiv))) :rule-classes :congruence)