• 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
        • 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
          • Std/strings
            • Pretty-printing
            • Printtree
            • Base64
            • Charset-p
            • Strtok!
            • Cases
              • Icharlisteqv
              • Upcase-charlist
              • Downcase-charlist
              • Upcase-string
              • Istreqv
              • Downcase-char
              • Upcase-char
              • Ichareqv
              • Downcase-string
              • Upcase-first-charlist
              • Downcase-first-charlist
              • Downcase-first
                • Upcase-first
                • Down-alpha-p
                • Up-alpha-p
                • Upcase-char-str
                • Downcase-char-str
                • Upcase-string-list
                • Downcase-string-list
              • Concatenation
              • Html-encoding
              • Character-kinds
              • Substrings
              • Strtok
              • Equivalences
              • Url-encoding
              • Lines
              • Explode-implode-equalities
              • Ordering
              • Numbers
              • Pad-trim
              • Coercion
              • Std/strings/digit-to-char
              • Substitution
              • Symbols
            • String-listp
            • Stringp
            • Length
            • Search
            • Remove-duplicates
            • Position
            • Coerce
            • Concatenate
            • Reverse
            • String
            • Subseq
            • Substitute
            • String-upcase
            • String-downcase
            • Count
            • Char
            • String<
            • String-equal
            • String-utilities
            • String-append
            • String>=
            • String<=
            • String>
            • Hex-digit-char-theorems
            • String-downcase-gen
            • String-upcase-gen
          • 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

    Downcase-first

    Convert the first character of a string to lower case.

    Signature
    (downcase-first x) → downcased
    Returns
    downcased — Type (stringp downcased).

    (downcase-first x) returns a copy of the string x except that the first character is downcased using downcase-char. If the string is empty, we return it unchanged.

    For sometimes-better performance, we avoid consing and simply return x unchanged when its first character is not an upper-case letter.

    Definitions and Theorems

    Function: downcase-first

    (defun downcase-first (x)
      (declare (type string x))
      (let ((acl2::__function__ 'downcase-first))
        (declare (ignorable acl2::__function__))
        (mbe :logic
             (implode (downcase-first-charlist (explode x)))
             :exec
             (if (eql (length x) 0)
                 x
               (let ((c (char x 0)))
                 (if (up-alpha-p c)
                     (cat (downcase-char-str c)
                          (subseq x 1 nil))
                   x))))))

    Theorem: stringp-of-downcase-first

    (defthm stringp-of-downcase-first
      (b* ((downcased (downcase-first x)))
        (stringp downcased))
      :rule-classes :type-prescription)

    Theorem: streqv-implies-equal-downcase-first-1

    (defthm streqv-implies-equal-downcase-first-1
      (implies (streqv x x-equiv)
               (equal (downcase-first x)
                      (downcase-first x-equiv)))
      :rule-classes (:congruence))

    Theorem: istreqv-implies-istreqv-downcase-first-1

    (defthm istreqv-implies-istreqv-downcase-first-1
      (implies (istreqv x x-equiv)
               (istreqv (downcase-first x)
                        (downcase-first x-equiv)))
      :rule-classes (:congruence))