A printable element: a string, a character, or NIL, which we take as equivalent to the empty string.
The main operation on a printable element is
Function:
(defun printable-p (x) (declare (xargs :guard t)) (or (stringp x) (characterp x) (eq x nil)))
Theorem:
(defthm printable-p-compound-recognizer (iff (printable-p x) (or (stringp x) (characterp x) (eq x nil))) :rule-classes :compound-recognizer)
Theorem:
(defthm printable-p-when-stringp (implies (stringp x) (printable-p x)))
Theorem:
(defthm printable-p-when-characterp (implies (characterp x) (printable-p x)))
Function:
(defun printable-fix$ (x) (declare (xargs :guard t)) (and (printable-p x) x))
Function:
(defun printable-fix (x) (declare (xargs :guard (printable-p x))) (mbe :logic (and (printable-p x) x) :exec x))
Theorem:
(defthm printable-p-of-printable-fix (printable-p (printable-fix x)))
Theorem:
(defthm printable-fix-when-printable-p (implies (printable-p x) (equal (printable-fix x) x)))
Theorem:
(defthm printable-fix$-is-printable-fix (equal (printable-fix$ x) (printable-fix x)))
Function:
(defun printable->str (x) (declare (xargs :guard (printable-p x))) (cond ((stringp x) x) ((characterp x) (coerce (list x) 'string)) (t "")))
Function:
(defun revappend-printable (x acc) (declare (xargs :guard (printable-p x))) (mbe :logic (revappend-chars (printable->str x) acc) :exec (cond ((stringp x) (revappend-chars x acc)) ((characterp x) (cons x acc)) (t acc))))