Determine if a character is an upper-case letter (A-Z).
(up-alpha-p x) → bool
ACL2 has a built-in alternative to this function, common-lisp::upper-case-p, which however can also recognize characters that are not standard characters. (Historical note: Before May 2024, the guard for acl2::upper-case-p required standard-char-p yet also converted only standard characters; this provided motivation for the development of up-alpha-p.)
Function:
(defun up-alpha-p$inline (x) (declare (type character x)) (let ((acl2::__function__ 'up-alpha-p)) (declare (ignorable acl2::__function__)) (b* (((the (unsigned-byte 8) code) (char-code x))) (and (<= (big-a) code) (<= code (big-z))))))
Theorem:
(defthm chareqv-implies-equal-up-alpha-p-1 (implies (chareqv x x-equiv) (equal (up-alpha-p x) (up-alpha-p x-equiv))) :rule-classes (:congruence))
Theorem:
(defthm upper-case-p-is-up-alpha-p (implies (standard-char-p x) (equal (common-lisp::upper-case-p x) (up-alpha-p (double-rewrite x)))))