Convert a character to upper-case.
(upcase-char x) → char
(upcase-char x) converts lower-case standard characters into their upper-case equivalents, and returns other characters unchanged.
ACL2 has a built-in alternative to this function, common-lisp::char-upcase, which however can also convert characters that are not standard characters. (Historical note: Before May 2024, the guard for acl2::char-upcase required standard-char-p yet also converted only standard characters; this provided motivation for the development of upcase-char.)
Function:
(defun upcase-char$inline (x) (declare (type character x)) (let ((acl2::__function__ 'upcase-char)) (declare (ignorable acl2::__function__)) (b* (((the (unsigned-byte 8) code) (char-code x))) (if (and (<= (little-a) code) (<= code (little-z))) (code-char (the (unsigned-byte 8) (- code (case-delta)))) (mbe :logic (char-fix x) :exec x)))))
Theorem:
(defthm characterp-of-upcase-char (b* ((char (upcase-char$inline x))) (characterp char)) :rule-classes :type-prescription)
Theorem:
(defthm chareqv-implies-equal-upcase-char-1 (implies (chareqv x x-equiv) (equal (upcase-char x) (upcase-char x-equiv))) :rule-classes (:congruence))
Theorem:
(defthm upcase-char-does-nothing-unless-down-alpha-p (implies (not (down-alpha-p x)) (equal (upcase-char x) (char-fix x))))
Theorem:
(defthm upcase-char-of-upcase-char (equal (upcase-char (upcase-char x)) (upcase-char x)))
Theorem:
(defthm char-upcase-is-upcase-char (implies (standard-char-p x) (equal (common-lisp::char-upcase x) (upcase-char (double-rewrite x)))))
Theorem:
(defthm not-down-alpha-p-of-upcase-char (not (down-alpha-p (upcase-char x))))