• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Debugging
    • Projects
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Abnf
          • Defdefparse
          • Deftreeops
          • Defgrammar
          • Notation
          • Grammar-parser
          • Meta-circular-validation
          • Parsing-primitives-defresult
            • Parse-schars
              • Parse-ichars
              • Parse-direct
              • Parse-range
              • Parse-next
            • Parsing-primitives-seq
            • Operations
            • Examples
            • Differences-with-paper
            • Grammar-printer
            • Parsing-tools
          • Fty-extensions
          • Isar
          • Kestrel-utilities
          • Pfcs
          • Soft
          • Bv
          • Imp-language
          • Event-macros
          • Java
          • Bitcoin
          • Ethereum
          • Yul
          • Zcash
          • ACL2-programming-language
          • Prime-fields
          • C
          • Syntheto
          • File-io-light
          • Number-theory
          • Cryptography
          • Lists-light
          • Json
          • Axe
          • Builtins
          • Solidity
          • Std-extensions
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Parsing-primitives-defresult

    Parse-schars

    Parse a case-sensitive character value consisting of a given string of characters.

    Signature
    (parse-schars chars input) → (mv tree rest-input)
    Arguments
    chars — Guard (common-lisp::stringp chars).
    input — Guard (nat-listp input).
    Returns
    tree — Type (tree-resultp tree).
    rest-input — Type (nat-listp rest-input).

    Definitions and Theorems

    Function: parse-schars-aux

    (defun parse-schars-aux (chars input)
      (declare (xargs :guard (and (character-listp chars)
                                  (nat-listp input))))
      (let ((__function__ 'parse-schars-aux))
        (declare (ignorable __function__))
        (b* (((when (endp chars))
              (mv nil (nat-list-fix input)))
             ((mv nat? input1) (parse-next input))
             ((when (reserrp nat?))
              (mv (reserrf-push nat?)
                  (nat-list-fix input)))
             (nat nat?)
             ((unless (nat-match-sensitive-char-p nat (car chars)))
              (mv (reserrf (list :found nat
                                 :required (char-fix (car chars))))
                  (nat-list-fix input)))
             ((mv nats? input2)
              (parse-schars-aux (cdr chars) input1))
             ((when (reserrp nats?))
              (mv (reserrf-push nats?) input1))
             (nats nats?))
          (mv (cons nat nats) input2))))

    Theorem: nat-list-resultp-of-parse-schars-aux.nats

    (defthm nat-list-resultp-of-parse-schars-aux.nats
      (b* (((mv ?nats ?rest-input)
            (parse-schars-aux chars input)))
        (nat-list-resultp nats))
      :rule-classes :rewrite)

    Theorem: nat-listp-of-parse-schars-aux.rest-input

    (defthm nat-listp-of-parse-schars-aux.rest-input
      (b* (((mv ?nats ?rest-input)
            (parse-schars-aux chars input)))
        (nat-listp rest-input))
      :rule-classes :rewrite)

    Theorem: len-of-parse-schars-aux-<=

    (defthm len-of-parse-schars-aux-<=
      (b* (((mv ?nats ?rest-input)
            (parse-schars-aux chars input)))
        (<= (len rest-input) (len input)))
      :rule-classes :linear)

    Theorem: len-of-parse-schars-aux-<

    (defthm len-of-parse-schars-aux-<
      (b* (((mv ?nats ?rest-input)
            (parse-schars-aux chars input)))
        (implies (and (not (reserrp nats)) (consp chars))
                 (< (len rest-input) (len input))))
      :rule-classes :linear)

    Theorem: parse-schars-aux-of-make-character-list-chars

    (defthm parse-schars-aux-of-make-character-list-chars
      (equal (parse-schars-aux (make-character-list chars)
                               input)
             (parse-schars-aux chars input)))

    Theorem: parse-schars-aux-charlisteqv-congruence-on-chars

    (defthm parse-schars-aux-charlisteqv-congruence-on-chars
      (implies (str::charlisteqv chars chars-equiv)
               (equal (parse-schars-aux chars input)
                      (parse-schars-aux chars-equiv input)))
      :rule-classes :congruence)

    Theorem: parse-schars-aux-of-nat-list-fix-input

    (defthm parse-schars-aux-of-nat-list-fix-input
      (equal (parse-schars-aux chars (nat-list-fix input))
             (parse-schars-aux chars input)))

    Theorem: parse-schars-aux-nat-list-equiv-congruence-on-input

    (defthm parse-schars-aux-nat-list-equiv-congruence-on-input
      (implies (acl2::nat-list-equiv input input-equiv)
               (equal (parse-schars-aux chars input)
                      (parse-schars-aux chars input-equiv)))
      :rule-classes :congruence)

    Function: parse-schars

    (defun parse-schars (chars input)
      (declare (xargs :guard (and (common-lisp::stringp chars)
                                  (nat-listp input))))
      (let ((__function__ 'parse-schars))
        (declare (ignorable __function__))
        (b* (((mv nats input)
              (parse-schars-aux (explode chars)
                                input))
             ((when (reserrp nats))
              (mv (reserrf-push nats) input)))
          (mv (tree-leafterm nats) input))))

    Theorem: tree-resultp-of-parse-schars.tree

    (defthm tree-resultp-of-parse-schars.tree
      (b* (((mv ?tree ?rest-input)
            (parse-schars chars input)))
        (tree-resultp tree))
      :rule-classes :rewrite)

    Theorem: nat-listp-of-parse-schars.rest-input

    (defthm nat-listp-of-parse-schars.rest-input
      (b* (((mv ?tree ?rest-input)
            (parse-schars chars input)))
        (nat-listp rest-input))
      :rule-classes :rewrite)

    Theorem: len-of-parse-schars-<=

    (defthm len-of-parse-schars-<=
      (b* (((mv ?tree ?rest-input)
            (parse-schars chars input)))
        (<= (len rest-input) (len input)))
      :rule-classes :linear)

    Theorem: len-of-parse-schars-<

    (defthm len-of-parse-schars-<
      (b* (((mv ?tree ?rest-input)
            (parse-schars chars input)))
        (implies (and (not (reserrp tree))
                      (consp (explode chars)))
                 (< (len rest-input) (len input))))
      :rule-classes :linear)

    Theorem: parse-schars-of-str-fix-chars

    (defthm parse-schars-of-str-fix-chars
      (equal (parse-schars (acl2::str-fix chars)
                           input)
             (parse-schars chars input)))

    Theorem: parse-schars-streqv-congruence-on-chars

    (defthm parse-schars-streqv-congruence-on-chars
      (implies (acl2::streqv chars chars-equiv)
               (equal (parse-schars chars input)
                      (parse-schars chars-equiv input)))
      :rule-classes :congruence)

    Theorem: parse-schars-of-nat-list-fix-input

    (defthm parse-schars-of-nat-list-fix-input
      (equal (parse-schars chars (nat-list-fix input))
             (parse-schars chars input)))

    Theorem: parse-schars-nat-list-equiv-congruence-on-input

    (defthm parse-schars-nat-list-equiv-congruence-on-input
      (implies (acl2::nat-list-equiv input input-equiv)
               (equal (parse-schars chars input)
                      (parse-schars chars input-equiv)))
      :rule-classes :congruence)