Convert a true list of natural numbers below 256 to the corresponding true list of characters.
(nats=>chars nats) → chars
This operation has a natural-recursive definition for logic reasoning and a tail-recursive executional for execution.
Function:
(defun nats=>chars-exec (nats rev-chars) (declare (xargs :guard (and (unsigned-byte-listp 8 nats) (character-listp rev-chars)))) (let ((__function__ 'nats=>chars-exec)) (declare (ignorable __function__)) (cond ((endp nats) (rev rev-chars)) (t (nats=>chars-exec (cdr nats) (cons (code-char (car nats)) rev-chars))))))
Function:
(defun nats=>chars (nats) (declare (xargs :guard (unsigned-byte-listp 8 nats))) (let ((__function__ 'nats=>chars)) (declare (ignorable __function__)) (mbe :logic (cond ((endp nats) nil) (t (cons (code-char (car nats)) (nats=>chars (cdr nats))))) :exec (nats=>chars-exec nats nil))))
Theorem:
(defthm character-listp-of-nats=>chars (b* ((chars (nats=>chars nats))) (character-listp chars)) :rule-classes :rewrite)
Theorem:
(defthm len-of-nats=>chars (equal (len (nats=>chars nats)) (len nats)))
Theorem:
(defthm nats=>chars-of-cons (equal (nats=>chars (cons nat nats)) (cons (code-char nat) (nats=>chars nats))))
Theorem:
(defthm nats=>chars-of-append (equal (nats=>chars (append nats1 nats2)) (append (nats=>chars nats1) (nats=>chars nats2))))
Theorem:
(defthm nats=>chars-of-repeat (equal (nats=>chars (repeat n char)) (repeat n (code-char char))))
Theorem:
(defthm nth-of-nats=>chars (equal (nth i (nats=>chars nats)) (if (< (nfix i) (len nats)) (code-char (nth i nats)) nil)))
Theorem:
(defthm nats=>chars-of-revappend (equal (nats=>chars (revappend x y)) (revappend (nats=>chars x) (nats=>chars y))))
Theorem:
(defthm nats=>chars-of-nthcdr (equal (nats=>chars (nthcdr n nats)) (nthcdr n (nats=>chars nats))))
Theorem:
(defthm nats=>chars-of-take (implies (<= (nfix n) (len nats)) (equal (nats=>chars (take n nats)) (take n (nats=>chars nats)))))