• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • C
      • Proof-checker-array
      • Soft
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Ethereum
      • Leftist-trees
      • Java
      • Riscv
      • Taspi
      • Bitcoin
      • Zcash
      • Des
      • X86isa
      • Sha-2
      • Yul
      • Proof-checker-itp13
      • Regex
      • ACL2-programming-language
      • Json
      • Jfkr
      • Equational
      • Cryptography
      • Axe
      • Poseidon
      • Where-do-i-place-my-book
      • Aleo
        • Aleobft
        • Aleovm
        • Leo
          • Grammar
          • Early-version
            • Json2ast
            • Testing
            • Definition
              • Flattening
              • Abstract-syntax
              • Dynamic-semantics
              • Compilation
              • Static-semantics
              • Concrete-syntax
                • Pretty-printer
                • Grammar
                • Lexing-and-parsing
                  • Lexer
                    • Lex-symbol
                    • Lex-rest-of-block-comment-+-lex-rest-of-block-comment-after-star
                    • Lex-not-double-quote-or-backslash-or-line-feed-or-carriage-return
                    • Lex-not-star-or-slash-or-line-feed-or-carriage-return
                    • Lex-identifier/keyword/boolean/address
                      • Lex-simple-character-escape
                      • Lex-hexadecimal-digit
                      • Lex-token
                      • Lex-not-star-or-line-feed-or-carriage-return
                      • Lex-u8/16/32/64/128
                      • Lex-not-line-feed-or-carriage-return
                      • Lex-i8/16/32/64/128
                      • Lex-string-literal-element
                      • Lex-safe-ascii
                      • Lex-numeric-literal
                      • Lex-safe-nonascii
                      • Lex-letter/decdigit/underscore
                      • Lex-line-terminator
                      • Lex-unicode-character-escape
                      • Lex-ascii-character-escape
                      • Lex-1*6-hexadecimal-digit
                      • Lex-whitespace
                      • Lex-unsigned-literal
                      • Lex-lcletter/decdigit
                      • Lex-string-literal
                      • Lex-signed-literal
                      • Lex-product-group-literal
                      • Lex-lexeme
                      • Lex-single-quote-escape
                      • Lex-integer-literal
                      • Lex-double-quote-escape
                      • Lex-address-literal
                      • Lex-scalar-literal
                      • Lex-null-character-escape
                      • Lex-identifier
                      • Lex-horizontal-tab-escape
                      • Lex-carriage-return-escape
                      • Lex-line-comment
                      • Lex-letter
                      • Lex-field-literal
                      • Lex-comment
                      • Lex-block-comment
                      • Lex-uppercase-letter
                      • Lex-lowercase-letter
                      • Lex-line-feed-escape
                      • Lex-horizontal-tab
                      • Lex-carriage-return
                      • Lex-backslash-escape
                      • Lex-annotation
                      • Lex-visible-ascii
                      • Lex-single-quote
                      • Lex-octal-digit
                      • Lex-double-quote
                      • Lex-decimal-digit
                      • Lex-*-not-line-feed-or-carriage-return
                      • Lex-line-feed
                      • Lex-space
                      • Lex-numeral
                      • Lex-*-letter/decdigit/underscore
                      • Lex-*-string-literal-element
                      • Lex-58-lcletter/decdigit
                      • Lexemize-leo-from-string
                      • Lex-*-lcletter/decdigit
                      • Lex-*-hexadecimal-digit
                      • Lex-1*-decimal-digit
                      • Lex-*-decimal-digit
                      • Lex-*-lexeme
                      • Lexemize-leo-from-bytes
                      • Lexemize-leo
                      • *defparse-leo-repetition-table*
                      • *defparse-leo-group-table*
                      • Lex-generation-macros
                      • Lex-generation-tables
                      • *defparse-leo-option-table*
                    • Parser
                    • Token-fringe
                    • Longest-lexp
                    • Parser-interface
                    • Grammar-lexp
                    • Identifier-lexp
                    • Output-file-parsep
                    • Input-file-parsep
                    • File-lex-parse-p
                    • Filter-tokens
                    • Lexp
                    • File-parsep
                    • Input-parser
                    • Output-file-lex-parse-p
                    • Input-file-lex-parse-p
                    • Parser-abstractor-interface
                    • Identifier-abnf-stringp
                    • Symbol-abnf-stringp
                    • Keyword-abnf-stringp
                    • Output-parser
                    • Tokenizer
                  • Input-pretty-printer
                  • Output-pretty-printer
                  • Unicode-characters
                  • Concrete-syntax-trees
                  • Symbols
                  • Keywords
        • Bigmems
        • Builtins
        • Execloader
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Community
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Lexer

    Lex-identifier/keyword/boolean/address

    Lex an identifier or a keyword or a boolean-literal or an address-literal.

    Signature
    (lex-identifier/keyword/boolean/address input) 
      → 
    (mv tree rest-input)
    Arguments
    input — Guard (nat-listp input).
    Returns
    tree — Type (abnf::tree-resultp tree).
    rest-input — Type (nat-listp rest-input).

    Lexically, these are all identifiers, in the sense that they are instances of the identifier rule, on a purely grammatical basis. Thus, we start by lexing a (grammatical) identifier. Then we check whether it is a keyword, in which case we re-classify the ABNF tree as a keyword tree. Otherwise, we check whether it is a boolean literal, in which case we re-classify the ABNF tree as a boolean-literal). Otherwise, we check whether it is an address: in this case, we need to re-lex it, so that we can construct and return an @('address-literal. Otherwise, we return the identifier tree, unless it is or starts with aleo1.

    Note that keywords, boolean literals, and address literals are all disjoint.

    Definitions and Theorems

    Function: lex-identifier/keyword/boolean/address

    (defun lex-identifier/keyword/boolean/address (input)
      (declare (xargs :guard (nat-listp input)))
      (let ((__function__ 'lex-identifier/keyword/boolean/address))
        (declare (ignorable __function__))
        (b* (((mv tree input1)
              (lex-identifier input))
             ((when (reserrp tree))
              (mv (reserrf-push tree) input1))
             (nats (abnf::tree->string tree))
             ((unless (unsigned-byte-listp 8 nats))
              (mv (reserrf :impossible) input1))
             (str (nats=>string nats))
             ((when (member-equal str *keywords*))
              (mv (abnf-tree-wrap (abnf::tree-leafterm nats)
                                  "keyword")
                  input1))
             ((when (member-equal str (list "true" "false")))
              (mv (abnf-tree-wrap (abnf::tree-leafterm nats)
                                  "boolean-literal")
                  input1))
             ((when (address-string-p str))
              (b* (((mv tree input)
                    (lex-address-literal input))
                   ((when (reserrp tree))
                    (mv (reserrf :impossible) input)))
                (mv tree input)))
             ((when (and (>= (length str) 5)
                         (equal (subseq str 0 5) "aleo1")))
              (mv (reserrf (list :found str))
                  input1)))
          (mv tree input1))))

    Theorem: tree-resultp-of-lex-identifier/keyword/boolean/address.tree

    (defthm tree-resultp-of-lex-identifier/keyword/boolean/address.tree
      (b* (((mv ?tree ?rest-input)
            (lex-identifier/keyword/boolean/address input)))
        (abnf::tree-resultp tree))
      :rule-classes :rewrite)

    Theorem: nat-listp-of-lex-identifier/keyword/boolean/address.rest-input

    (defthm
         nat-listp-of-lex-identifier/keyword/boolean/address.rest-input
      (b* (((mv ?tree ?rest-input)
            (lex-identifier/keyword/boolean/address input)))
        (nat-listp rest-input))
      :rule-classes :rewrite)

    Theorem: len-of-lex-identifier/keyword/boolean/address-<=

    (defthm len-of-lex-identifier/keyword/boolean/address-<=
      (b* (((mv ?tree ?rest-input)
            (lex-identifier/keyword/boolean/address input)))
        (<= (len rest-input) (len input)))
      :rule-classes :linear)

    Theorem: len-of-lex-identifier/keyword/boolean/address-<

    (defthm len-of-lex-identifier/keyword/boolean/address-<
      (b* (((mv ?tree ?rest-input)
            (lex-identifier/keyword/boolean/address input)))
        (implies (not (reserrp tree))
                 (< (len rest-input) (len input))))
      :rule-classes :linear)

    Theorem: lex-identifier/keyword/boolean/address-of-nat-list-fix-input

    (defthm lex-identifier/keyword/boolean/address-of-nat-list-fix-input
      (equal
           (lex-identifier/keyword/boolean/address (nat-list-fix input))
           (lex-identifier/keyword/boolean/address input)))

    Theorem: lex-identifier/keyword/boolean/address-nat-list-equiv-congruence-on-input

    (defthm
     lex-identifier/keyword/boolean/address-nat-list-equiv-congruence-on-input
     (implies
          (acl2::nat-list-equiv input input-equiv)
          (equal (lex-identifier/keyword/boolean/address input)
                 (lex-identifier/keyword/boolean/address input-equiv)))
     :rule-classes :congruence)