Recognize the ACL2 ASCII characters that correspond to the members of the basic source character set in C.
(ascii-basic-source-charp x) → yes/no
These are uppercase and lowercase letters, decimal digits, graphic characters, space, horizontal tab, vertical tab, and form feed [C:5.2.1/3].
Note that the double quote character and the backslash character
must be escaped (i.e. preceded by a backslash) in ACL2 strings.
The ACL2 character
Function:
(defun ascii-basic-source-charp (x) (declare (xargs :guard t)) (or (and (common-lisp::member x (acl2::explode "ABCDEFGHIJKLMNOPQRSTUVWXYZ")) t) (and (common-lisp::member x (acl2::explode "abcdefghijklmnopqrstuvwxyz")) t) (and (common-lisp::member x (acl2::explode "0123456789")) t) (and (common-lisp::member x (acl2::explode "!\"#%&'()*+,-./:;<=>?[\\]^_{|}~")) t) (and (common-lisp::member x (list #\Space #\Tab (code-char 11) #\Page)) t)))
Theorem:
(defthm booleanp-of-ascii-basic-source-charp (b* ((yes/no (ascii-basic-source-charp x))) (booleanp yes/no)) :rule-classes :rewrite)
Theorem:
(defthm characterp-when-ascii-basic-source-charp (implies (ascii-basic-source-charp x) (characterp x)) :rule-classes :compound-recognizer)