Append a string's characters onto a list.
(append-chars x y) → *
(append-chars x y) takes the characters from the string
Its logical definition is nothing more than
In the execution, we traverse the string
Function:
(defun append-chars-aux (x n y) "Appends the characters from x[0:n] onto y" (declare (type string x) (type (integer 0 *) n) (xargs :guard (< n (length x)))) (if (zp n) (cons (char x 0) y) (append-chars-aux x (the (integer 0 *) (- n 1)) (cons (char x n) y))))
Theorem:
(defthm append-chars-aux-correct (implies (and (stringp x) (natp n) (< n (length x))) (equal (append-chars-aux x n y) (append (take (+ 1 n) (explode x)) y))))
Function:
(defun append-chars$inline (x y) (declare (type string x)) (let ((acl2::__function__ 'append-chars)) (declare (ignorable acl2::__function__)) (mbe :logic (append (explode x) y) :exec (b* (((the (integer 0 *) xl) (length x)) ((when (eql xl 0)) y) ((the (integer 0 *) n) (- xl 1))) (append-chars-aux x n y)))))
Theorem:
(defthm character-listp-of-append-chars (equal (character-listp (append-chars x y)) (character-listp y)))
Theorem:
(defthm streqv-implies-equal-append-chars-1 (implies (streqv x x-equiv) (equal (append-chars x y) (append-chars x-equiv y))) :rule-classes (:congruence))
Theorem:
(defthm istreqv-implies-icharlisteqv-append-chars-1 (implies (istreqv x x-equiv) (icharlisteqv (append-chars x y) (append-chars x-equiv y))) :rule-classes (:congruence))
Theorem:
(defthm list-equiv-implies-list-equiv-append-chars-2 (implies (list-equiv y y-equiv) (list-equiv (append-chars x y) (append-chars x y-equiv))) :rule-classes (:congruence))
Theorem:
(defthm charlisteqv-implies-charlisteqv-append-chars-2 (implies (charlisteqv y y-equiv) (charlisteqv (append-chars x y) (append-chars x y-equiv))) :rule-classes (:congruence))
Theorem:
(defthm icharlisteqv-implies-icharlisteqv-append-chars-2 (implies (icharlisteqv y y-equiv) (icharlisteqv (append-chars x y) (append-chars x y-equiv))) :rule-classes (:congruence))