• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
          • Omaps
          • Directed-untranslate
          • Include-book-paths
          • Ubi
          • Numbered-names
          • Digits-any-base
          • Context-message-pair
          • With-auto-termination
          • Make-termination-theorem
          • Theorems-about-true-list-lists
          • Checkpoint-list
          • Sublis-expr+
          • Integers-from-to
          • Prove$
          • Defthm<w
          • System-utilities-non-built-in
          • Integer-range-fix
          • Minimize-ruler-extenders
          • Add-const-to-untranslate-preprocess
          • Unsigned-byte-fix
          • Signed-byte-fix
          • Defthmr
          • Paired-names
          • Unsigned-byte-list-fix
          • Signed-byte-list-fix
          • Show-books
          • Skip-in-book
          • Typed-tuplep
          • List-utilities
          • Checkpoint-list-pretty
          • Defunt
          • Keyword-value-list-to-alist
          • Magic-macroexpand
          • Top-command-number-fn
          • Bits-as-digits-in-base-2
          • Show-checkpoint-list
          • Ubyte11s-as-digits-in-base-2048
          • Named-formulas
          • Bytes-as-digits-in-base-256
          • String-utilities
          • Make-keyword-value-list-from-keys-and-value
          • Defmacroq
          • Integer-range-listp
          • Apply-fn-if-known
          • Trans-eval-error-triple
          • Checkpoint-info-list
          • Previous-subsumer-hints
          • Fms!-lst
          • Zp-listp
          • Trans-eval-state
          • Injections
          • Doublets-to-alist
          • Theorems-about-osets
          • Typed-list-utilities
          • Book-runes-alist
          • User-interface
          • Bits/ubyte11s-digit-grouping
          • Bits/bytes-digit-grouping
          • Message-utilities
            • Msg-downcase-first
              • Maybe-msgp
              • Msg-listp
              • Msg-upcase-first
            • Subsetp-eq-linear
            • Oset-utilities
            • Strict-merge-sort-<
            • Miscellaneous-enumerations
            • Maybe-unquote
            • Thm<w
            • Defthmd<w
            • Io-utilities
          • Set
          • Soft
          • C
          • Bv
          • Imp-language
          • Event-macros
          • Java
          • Bitcoin
          • Ethereum
          • Yul
          • Zcash
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Lists-light
          • Axe
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Message-utilities

    Msg-downcase-first

    Convert the first character of a structured message to lower case.

    Signature
    (msg-downcase-first msg) → new-msg
    Arguments
    msg — Guard (msgp msg).
    Returns
    new-msg — Type (msgp new-msg), given the guard.

    If the message is a string, we use str::downcase-first on the string.

    Otherwise, if the format string of the message does not start with a tilde-directive (see fmt), we use str::downcase-first on the format string.

    Otherwise, we need to look at the tilde-directive that starts the format string of the message, and possibly modify the tilde-directive and the corresponding value in the alist, in order to suitably convert the first character of the resulting formatted string to lower case. This is done as follows:

    • If the command character of the tilde-directive is x, y, X, Y, f, or F, we leave the message unchanged because these directives prints all the ACL2 values in a way that capitalization does not really apply: numbers are not words, symbols are in all caps or start with |, characters start with #, strings start with ", and cons pairs start with (.
    • If the command character of the tilde-directive is t, c, space, _, newline, %, |, ~, or -, we leave the message unchanged because these directives do not print words.
    • If the command character of the tilde-directive is n, we leave the message unchanged because that directive already prints words that start with lower case characters.
    • If the command character of the tilde-directive is N, we replace it with n.
    • If the command character of the tilde-directive is @, we find the corresponding message in the alist and we recursively process it with this function.
    • If the command character of the tilde-directive is s or S, we find the corresponding string or symbol in the alist, and if it is a string we use str::downcase-first on it. If instead it is a symbol, we leave the message unchanged because symbols are in all caps or start with | (as in the case of the x and other command characters above).
    • If the command character of the tilde-directive is #, *, &, or v, we stop with an error: these directives are currently not supported by the implementation.

    Since msgp is a weak recognizer for messages, there is no guarantee that the format string is followed by an alist, and that the values in the alist have the appropriate types. This function leaves the message unchanged if some of these properties do not hold.

    Definitions and Theorems

    Function: msg-downcase-first

    (defun msg-downcase-first (msg)
     (declare (xargs :guard (msgp msg)))
     (let ((__function__ 'msg-downcase-first))
      (declare (ignorable __function__))
      (b*
       (((when (stringp msg))
         (str::downcase-first msg))
        ((cons string alist) msg)
        ((unless (and (> (length string) 0)
                      (eql (char string 0) #\~)))
         (cons (str::downcase-first string)
               alist))
        ((unless (and (>= (length string) 3)
                      (member (char string 1)
                              (list #\@ #\# #\* #\& #\v #\N #\s #\S))))
         msg))
       (case (char string 1)
        (#\@ (b* (((unless (alistp alist)) msg)
                  (value (cdr (assoc (char string 2) alist)))
                  ((unless (msgp value)) msg)
                  (new-alist (acons (char string 2)
                                    (msg-downcase-first value)
                                    alist)))
               (cons string new-alist)))
        (#\N (b* ((new-string (concatenate 'string
                                           "~n" (subseq string 2 nil))))
               (cons new-string alist)))
        ((#\s #\S)
         (b* (((unless (alistp alist)) msg)
              (value (cdr (assoc (char string 2) alist)))
              ((unless (stringp value)) msg)
              (new-alist (acons (char string 2)
                                (str::downcase-first value)
                                alist)))
           (cons string new-alist)))
        (otherwise (prog2$ (raise "Message not supported: ~x0" msg)
                           msg))))))

    Theorem: msgp-of-msg-downcase-first

    (defthm msgp-of-msg-downcase-first
      (implies (and (msgp msg))
               (b* ((new-msg (msg-downcase-first msg)))
                 (msgp new-msg)))
      :rule-classes :rewrite)