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