• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Recursion-and-induction
      • Hons-and-memoization
      • Events
      • Parallelism
      • History
      • Programming
        • Defun
        • Declare
        • System-utilities
        • Stobj
        • State
        • Mutual-recursion
        • Memoize
        • Mbe
        • Io
        • Defpkg
        • Apply$
        • Loop$
        • Programming-with-state
        • Arrays
        • Characters
          • Character-listp
          • Characterp
          • Coerce
          • Digit-char-p
          • Code-char
          • Char-code
          • Char-upcase
            • Upcase-char
            • Char-downcase
            • Standard-char-p
            • Char
            • Alpha-char-p
            • Upper-case-p
            • Lower-case-p
            • Explode-nonnegative-integer
            • Explode-atom
            • Char-equal
            • Digit-to-char
            • Char<
            • Char>=
            • Make-character-list
            • Char>
            • Char<=
            • Standard-char-listp
            • Character-alistp
            • Standard-char-p+
            • Chars-upcase-gen
            • Chars-downcase-gen
            • Char-upcase-gen
            • Char-downcase-gen
          • Time$
          • Defmacro
          • Loop$-primer
          • Fast-alists
          • Defconst
          • Evaluation
          • Guard
          • Equality-variants
          • Compilation
          • Hons
          • ACL2-built-ins
          • Developers-guide
          • System-attachments
          • Advanced-features
          • Set-check-invariant-risk
          • Numbers
          • Efficiency
          • Irrelevant-formals
          • Introduction-to-programming-in-ACL2-for-those-who-know-lisp
          • Redefining-programs
          • Lists
          • Invariant-risk
          • Errors
          • Defabbrev
          • Conses
          • Alists
          • Set-register-invariant-risk
          • Strings
          • Program-wrapper
          • Get-internal-time
          • Basics
          • Packages
          • Oracle-eval
          • Defmacro-untouchable
          • <<
          • Primitive
          • Revert-world
          • Unmemoize
          • Set-duplicate-keys-action
          • Symbols
          • Def-list-constructor
          • Easy-simplify-term
          • Defiteration
          • Fake-oracle-eval
          • Defopen
          • Sleep
        • Operational-semantics
        • Real
        • Start-here
        • Debugging
        • Miscellaneous
        • Output-controls
        • Macros
        • Interfacing-tools
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Cases
    • Char-upcase

    Upcase-char

    Convert a character to upper-case.

    Signature
    (upcase-char x) → char
    Returns
    char — Type (characterp 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.)

    Definitions and Theorems

    Function: upcase-char$inline

    (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: characterp-of-upcase-char

    (defthm characterp-of-upcase-char
      (b* ((char (upcase-char$inline x)))
        (characterp char))
      :rule-classes :type-prescription)

    Theorem: chareqv-implies-equal-upcase-char-1

    (defthm chareqv-implies-equal-upcase-char-1
      (implies (chareqv x x-equiv)
               (equal (upcase-char x)
                      (upcase-char x-equiv)))
      :rule-classes (:congruence))

    Theorem: upcase-char-does-nothing-unless-down-alpha-p

    (defthm upcase-char-does-nothing-unless-down-alpha-p
      (implies (not (down-alpha-p x))
               (equal (upcase-char x) (char-fix x))))

    Theorem: upcase-char-of-upcase-char

    (defthm upcase-char-of-upcase-char
      (equal (upcase-char (upcase-char x))
             (upcase-char x)))

    Theorem: char-upcase-is-upcase-char

    (defthm char-upcase-is-upcase-char
      (implies (standard-char-p x)
               (equal (common-lisp::char-upcase x)
                      (upcase-char (double-rewrite x)))))

    Theorem: not-down-alpha-p-of-upcase-char

    (defthm not-down-alpha-p-of-upcase-char
      (not (down-alpha-p (upcase-char x))))