• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
        • Proof-support
        • Abstract-syntax
        • R1cs-subset
        • Semantics
        • Abstract-syntax-operations
        • Indexed-names
        • Well-formedness
        • Concrete-syntax
          • Lexer
          • Grammar
          • Parser
            • Parse-separator
            • Parse-operator
            • Parse-definition
            • Parse-relation-constraint
            • Parse-equality-constraint
            • Parse-*-comma-identifier
            • Parse-*-comma-expression
            • Parse-*-comma-constraint
            • Parse-system
            • Parse-identifier
            • Parse-pfcs-integer
            • Parse-constraint
            • Parse-*-definition
            • Parse-*-constraint
            • Parsize
            • Check-token-string
              • Check-token-root
              • Parse-token
              • Token-stringp
              • Token-rootp
              • Patbind-pok<
              • Parse-multiplication-expression-rest
              • Parse-addition-expression-rest
              • Parse-primary-expression
              • Parse-multiplication-expression
              • Parse-addition-expression
              • Parse-expression
              • Patbind-pok
              • Perr
            • Tokenizer
          • R1cs-bridge
          • Parser-interface
        • Legacy-defrstobj
        • Proof-checker-array
        • Soft
        • C
        • Farray
        • Rp-rewriter
        • Instant-runoff-voting
        • Imp-language
        • Sidekick
        • Leftist-trees
        • Java
        • Taspi
        • Bitcoin
        • Riscv
        • Des
        • Ethereum
        • X86isa
        • Sha-2
        • Yul
        • Zcash
        • Proof-checker-itp13
        • Regex
        • ACL2-programming-language
        • Json
        • Jfkr
        • Equational
        • Cryptography
        • Poseidon
        • Where-do-i-place-my-book
        • Axe
        • Bigmems
        • Builtins
        • Execloader
        • Aleo
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Parser

    Check-token-string

    Check if the given token is present and has the given string as fringe.

    Signature
    (check-token-string string token) → tree
    Arguments
    string — Guard (stringp string).
    token — Guard (abnf::tree-optionp token).
    Returns
    tree — Type (abnf::tree-resultp tree).

    If the check is successful, return the token. Using this function ensures that we get a CST tree or reserr.

    Definitions and Theorems

    Function: check-token-string

    (defun check-token-string (string token)
      (declare (xargs :guard (and (stringp string)
                                  (abnf::tree-optionp token))))
      (let ((__function__ 'check-token-string))
        (declare (ignorable __function__))
        (abnf::tree-option-case
             token :some
             (if (token-stringp string token.val)
                 token.val
               (reserrf (list :required (str-fix string)
                              :found token.val)))
             :none (reserrf (list :required (str-fix string)
                                  :found nil)))))

    Theorem: tree-resultp-of-check-token-string

    (defthm tree-resultp-of-check-token-string
      (b* ((tree (check-token-string string token)))
        (abnf::tree-resultp tree))
      :rule-classes :rewrite)

    Theorem: check-token-string-of-str-fix-string

    (defthm check-token-string-of-str-fix-string
      (equal (check-token-string (str-fix string)
                                 token)
             (check-token-string string token)))

    Theorem: check-token-string-streqv-congruence-on-string

    (defthm check-token-string-streqv-congruence-on-string
      (implies (acl2::streqv string string-equiv)
               (equal (check-token-string string token)
                      (check-token-string string-equiv token)))
      :rule-classes :congruence)

    Theorem: check-token-string-of-tree-option-fix-token

    (defthm check-token-string-of-tree-option-fix-token
      (equal (check-token-string string (abnf::tree-option-fix token))
             (check-token-string string token)))

    Theorem: check-token-string-tree-option-equiv-congruence-on-token

    (defthm check-token-string-tree-option-equiv-congruence-on-token
      (implies (abnf::tree-option-equiv token token-equiv)
               (equal (check-token-string string token)
                      (check-token-string string token-equiv)))
      :rule-classes :congruence)