(vl-echarlist-unsigned-value x radix) interprets the extended character
list
(vl-echarlist-unsigned-value x radix) → *
We see if X is made up entirely of base RADIX digits. If so, we return the number represented by X, treating the digits as if they are written with the most significant digit first. For instance, an echarlist whose string is "987" has, in base 10, an unsigned-value of 987. Otherwise, if there are any invalid digits, we return NIL.
Function:
(defun vl-echarlist-unsigned-value (x radix) (declare (xargs :guard (and (vl-echarlist-p x) (natp radix)))) (declare (xargs :guard (and (<= 2 radix) (<= radix 36)))) (let ((__function__ 'vl-echarlist-unsigned-value)) (declare (ignorable __function__)) (if (not (consp x)) nil (vl-echarlist-unsigned-value-aux x (lnfix radix) (len x)))))
Theorem:
(defthm natp-of-vl-echarlist-unsigned-value-aux (implies (vl-echarlist-unsigned-value x radix) (and (natp (vl-echarlist-unsigned-value x radix)) (integerp (vl-echarlist-unsigned-value x radix)) (<= 0 (vl-echarlist-unsigned-value x radix)))) :rule-classes ((:rewrite) (:type-prescription :corollary (or (not (vl-echarlist-unsigned-value x radix)) (and (integerp (vl-echarlist-unsigned-value x radix)) (<= 0 (vl-echarlist-unsigned-value x radix)))))))
Theorem:
(defthm vl-echarlist-unsigned-value-when-not-consp (implies (not (consp x)) (equal (vl-echarlist-unsigned-value x radix) nil)))
Theorem:
(defthm type-of-vl-echarlist-unsigned-value (or (not (vl-echarlist-unsigned-value x radix)) (natp (vl-echarlist-unsigned-value x radix))) :rule-classes :type-prescription)
Theorem:
(defthm vl-echarlist-unsigned-value-of-vl-echarlist-fix-x (equal (vl-echarlist-unsigned-value (vl-echarlist-fix x) radix) (vl-echarlist-unsigned-value x radix)))
Theorem:
(defthm vl-echarlist-unsigned-value-vl-echarlist-equiv-congruence-on-x (implies (vl-echarlist-equiv x x-equiv) (equal (vl-echarlist-unsigned-value x radix) (vl-echarlist-unsigned-value x-equiv radix))) :rule-classes :congruence)
Theorem:
(defthm vl-echarlist-unsigned-value-of-nfix-radix (equal (vl-echarlist-unsigned-value x (nfix radix)) (vl-echarlist-unsigned-value x radix)))
Theorem:
(defthm vl-echarlist-unsigned-value-nat-equiv-congruence-on-radix (implies (acl2::nat-equiv radix radix-equiv) (equal (vl-echarlist-unsigned-value x radix) (vl-echarlist-unsigned-value x radix-equiv))) :rule-classes :congruence)