Interpret a string as a decimal number.
For example,
Function:
(defun strval (x) (declare (xargs :guard (stringp x))) (declare (type string x)) (declare (xargs :split-types t)) (let ((acl2::__function__ 'strval)) (declare (ignorable acl2::__function__)) (mbe :logic (let ((chars (explode x))) (and (consp chars) (dec-digit-char-list*p chars) (dec-digit-chars-value chars))) :exec (b* (((the unsigned-byte xl) (length x)) ((mv (the unsigned-byte val) (the unsigned-byte len)) (parse-nat-from-string x 0 0 0 xl))) (and (not (eql 0 len)) (eql len xl) val)))))
Theorem:
(defthm return-type-of-strval (b* ((value? (strval x))) (or (natp value?) (not value?))) :rule-classes :type-prescription)
Theorem:
(defthm istreqv-implies-equal-strval-1 (implies (istreqv x x-equiv) (equal (strval x) (strval x-equiv))) :rule-classes (:congruence))