• 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
            • Check-numbered-name
              • Next-numbered-name
              • Resolve-numbered-name-wildcard
              • Set-numbered-name-index
              • Next-fresh-numbered-names
              • Global-numbered-name-index
              • Make-numbered-name
              • Make-numbered-name-list
              • Set-numbered-name-index-to-global
              • Numbered-names-in-use
              • Next-fresh-numbered-name
              • Numbered-name-index-wildcard
              • Numbered-name-index-start
              • Numbered-name-index-end
            • 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
            • 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
    • Numbered-names

    Check-numbered-name

    Check if a symbol is a numbered name.

    Signature
    (check-numbered-name name wrld) → (mv yes/no base index)
    Arguments
    name — Guard (symbolp name).
    wrld — Guard (plist-worldp wrld).
    Returns
    yes/no — t iff name is a numbered name.
        Type (booleanp yes/no).
    base — Base symbol of name, or nil if yes/no is nil.
        Type (symbolp base).
    index — Numeric index of name, or 0 if it is the wildcard, or nil if yes/no is nil.
        Type (maybe-natp index).

    If successful, return its base symbol and index (or wildcard).

    Definitions and Theorems

    Function: check-numbered-name

    (defun check-numbered-name (name wrld)
     (declare (xargs :guard (and (symbolp name)
                                 (plist-worldp wrld))))
     (let ((__function__ 'check-numbered-name))
      (declare (ignorable __function__))
      (b*
        ((name-chars (explode (symbol-name name)))
         (index-start-chars
              (explode (get-numbered-name-index-start wrld)))
         (index-end-chars (explode (get-numbered-name-index-end wrld)))
         (wildcard-chars
              (explode (get-numbered-name-index-wildcard wrld)))
         (len-of-name-without-end-marker (- (len name-chars)
                                            (len index-end-chars)))
         ((unless (and (> len-of-name-without-end-marker 0)
                       (equal (subseq name-chars
                                      len-of-name-without-end-marker
                                      (len name-chars))
                              index-end-chars)))
          (mv nil nil nil))
         (name-chars-without-end-marker
              (take len-of-name-without-end-marker
                    name-chars))
         (digits-of-index
              (reverse (str::take-leading-dec-digit-chars
                            (reverse name-chars-without-end-marker)))))
       (if digits-of-index
        (b*
         (((when (eql (car digits-of-index) #\0))
           (mv nil nil nil))
          (index (str::dec-digit-chars-value digits-of-index))
          (name-chars-without-index-and-end-marker
               (take (- (len name-chars-without-end-marker)
                        (len digits-of-index))
                     name-chars-without-end-marker))
          (len-of-base-of-name
               (- (len name-chars-without-index-and-end-marker)
                  (len index-start-chars)))
          ((unless
            (and
             (> len-of-base-of-name 0)
             (equal
                  (subseq name-chars-without-index-and-end-marker
                          len-of-base-of-name
                          (len name-chars-without-index-and-end-marker))
                  index-start-chars)))
           (mv nil nil nil))
          (base-chars (take len-of-base-of-name
                            name-chars-without-index-and-end-marker))
          ((unless base-chars) (mv nil nil nil)))
         (mv t
             (intern-in-package-of-symbol (implode base-chars)
                                          name)
             index))
        (b*
         ((len-of-name-without-wildcard-and-end-marker
               (- (len name-chars-without-end-marker)
                  (len wildcard-chars)))
          ((unless
            (and
              (> len-of-name-without-wildcard-and-end-marker
                 0)
              (equal (subseq name-chars-without-end-marker
                             len-of-name-without-wildcard-and-end-marker
                             (len name-chars-without-end-marker))
                     wildcard-chars)))
           (mv nil nil nil))
          (name-chars-without-wildcard-and-end-marker
               (take len-of-name-without-wildcard-and-end-marker
                     name-chars-without-end-marker))
          (len-of-base-of-name
               (- (len name-chars-without-wildcard-and-end-marker)
                  (len index-start-chars)))
          ((unless
            (and
             (> len-of-base-of-name 0)
             (equal
               (subseq name-chars-without-wildcard-and-end-marker
                       len-of-base-of-name
                       (len name-chars-without-wildcard-and-end-marker))
               index-start-chars)))
           (mv nil nil nil))
          (base-chars (take len-of-base-of-name
                            name-chars-without-wildcard-and-end-marker))
          ((unless base-chars) (mv nil nil nil)))
         (mv t
             (intern-in-package-of-symbol (implode base-chars)
                                          name)
             0))))))

    Theorem: booleanp-of-check-numbered-name.yes/no

    (defthm booleanp-of-check-numbered-name.yes/no
      (b* (((mv ?yes/no ?base ?index)
            (check-numbered-name name wrld)))
        (booleanp yes/no))
      :rule-classes :rewrite)

    Theorem: symbolp-of-check-numbered-name.base

    (defthm symbolp-of-check-numbered-name.base
      (b* (((mv ?yes/no ?base ?index)
            (check-numbered-name name wrld)))
        (symbolp base))
      :rule-classes :rewrite)

    Theorem: maybe-natp-of-check-numbered-name.index

    (defthm maybe-natp-of-check-numbered-name.index
      (b* (((mv ?yes/no ?base ?index)
            (check-numbered-name name wrld)))
        (maybe-natp index))
      :rule-classes :rewrite)