Print a character list, escaping backslashes and some other character.
(print-escaped-charlist x slash-char acc) → new-acc
This is a logically nice definition for print-escaped-str.
Function:
(defun print-escaped-charlist (x slash-char acc) (declare (xargs :guard (and (character-listp x) (characterp slash-char)))) (let ((acl2::__function__ 'print-escaped-charlist)) (declare (ignorable acl2::__function__)) (if (atom x) acc (print-escaped-charlist (cdr x) slash-char (if (or (eql (car x) #\\) (eql (car x) slash-char)) (list* (car x) #\\ acc) (cons (car x) acc))))))
Theorem:
(defthm character-listp-of-print-escaped-charlist (implies (and (character-listp acc) (character-listp x)) (b* ((new-acc (print-escaped-charlist x slash-char acc))) (character-listp new-acc))) :rule-classes :rewrite)
Theorem:
(defthm print-escaped-charlist-when-atom (implies (atom x) (equal (print-escaped-charlist x slash-char acc) acc)))
Theorem:
(defthm len-of-print-escaped-charlist-weak (<= (len acc) (len (print-escaped-charlist x slash-char acc))) :rule-classes ((:rewrite) (:linear)))
Theorem:
(defthm len-of-print-escaped-charlist-strong (implies (consp x) (< (len acc) (len (print-escaped-charlist x slash-char acc)))) :rule-classes ((:rewrite) (:linear)))
Theorem:
(defthm equal-with-print-escaped-charlist (equal (equal (print-escaped-charlist x slash-char acc) acc) (atom x)))