Optimized base-10 natural number printing into ps.
Function:
(defun vl-print-natchars-aux (n acc col) (declare (xargs :guard (and (natp n) (natp col)))) (declare (type unsigned-byte n col)) (declare (xargs :split-types t)) (let ((__function__ 'vl-print-natchars-aux)) (declare (ignorable __function__)) (if (mbe :logic (zp n) :exec (eql (the integer n) 0)) (mv acc (lnfix col)) (mv-let (acc col) (vl-print-natchars-aux (the integer (truncate (the integer n) 10)) acc col) (mv (cons (the character (code-char (the (unsigned-byte 8) (+ (the (unsigned-byte 8) 48) (the (unsigned-byte 8) (rem (the integer n) 10)))))) acc) (the (integer 0 *) (+ 1 col)))))))
Theorem:
(defthm natp-of-vl-print-natchars-aux.new-col (b* (((mv ?acc ?new-col) (vl-print-natchars-aux n acc col))) (natp new-col)) :rule-classes :type-prescription)
Theorem:
(defthm acc-of-vl-print-natchars-aux (equal (mv-nth 0 (vl-print-natchars-aux n acc col)) (str::revappend-nat-to-dec-chars-aux n acc)))
Theorem:
(defthm vl-print-natchars-aux-of-nfix-n (equal (vl-print-natchars-aux (nfix n) acc col) (vl-print-natchars-aux n acc col)))
Theorem:
(defthm vl-print-natchars-aux-nat-equiv-congruence-on-n (implies (acl2::nat-equiv n n-equiv) (equal (vl-print-natchars-aux n acc col) (vl-print-natchars-aux n-equiv acc col))) :rule-classes :congruence)
Theorem:
(defthm vl-print-natchars-aux-of-nfix-col (equal (vl-print-natchars-aux n acc (nfix col)) (vl-print-natchars-aux n acc col)))
Theorem:
(defthm vl-print-natchars-aux-nat-equiv-congruence-on-col (implies (acl2::nat-equiv col col-equiv) (equal (vl-print-natchars-aux n acc col) (vl-print-natchars-aux n acc col-equiv))) :rule-classes :congruence)