• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
        • Deftreeops
        • Defdefparse
        • Defgrammar
        • Tree-utilities
        • Notation
        • Grammar-parser
        • Meta-circular-validation
        • Parsing-primitives-defresult
        • Parsing-primitives-seq
          • Parse-exact-list
            • Parse-in-range
            • Parse-exact
            • Parse-any
          • Operations
          • Examples
          • Differences-with-paper
          • Constructor-utilities
          • Grammar-printer
          • Parsing-tools
        • 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
        • 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
    • Parsing-primitives-seq

    Parse-exact-list

    Parse zero or more given natural numbers into a tree that matches a direct numeric value notation that consists of that list of numbers.

    Signature
    (parse-exact-list nats input) → (mv error? tree? rest-input)
    Arguments
    nats — Guard (nat-listp nats).
    input — Guard (nat-listp input).
    Returns
    error? — Type (maybe-msgp error?).
    tree? — Type (and (tree-optionp tree?) (implies (not error?) (treep tree?)) (implies error? (not tree?))) .
    rest-input — Type (nat-listp rest-input).

    Definitions and Theorems

    Function: parse-exact-list-aux

    (defun parse-exact-list-aux (nats input)
      (declare (xargs :guard (and (nat-listp nats)
                                  (nat-listp input))))
      (let ((__function__ 'parse-exact-list-aux))
        (declare (ignorable __function__))
        (b* (((when (endp nats))
              (mv nil (nat-list-fix input)))
             (nat (lnfix (car nats)))
             ((mv error? input-nat input)
              (parse-any input))
             ((when error?) (mv error? input))
             ((unless (= input-nat nat))
              (mv (msg "Failed to parse ~x0: found ~x1 instead."
                       nat input-nat)
                  (cons input-nat input)))
             ((mv error? input)
              (parse-exact-list-aux (cdr nats) input))
             ((when error?) (mv error? input)))
          (mv nil input))))

    Theorem: maybe-msgp-of-parse-exact-list-aux.error?

    (defthm maybe-msgp-of-parse-exact-list-aux.error?
      (b* (((mv ?error? ?rest-input)
            (parse-exact-list-aux nats input)))
        (maybe-msgp error?))
      :rule-classes :rewrite)

    Theorem: nat-listp-of-parse-exact-list-aux.rest-input

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

    Theorem: len-of-parse-exact-list-aux-linear-<=

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

    Theorem: len-of-parse-exact-list-aux-linear-<

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

    Theorem: parse-exact-list-aux-of-nat-list-fix-nats

    (defthm parse-exact-list-aux-of-nat-list-fix-nats
      (equal (parse-exact-list-aux (nat-list-fix nats)
                                   input)
             (parse-exact-list-aux nats input)))

    Theorem: parse-exact-list-aux-nat-list-equiv-congruence-on-nats

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

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

    (defthm parse-exact-list-aux-of-nat-list-fix-input
      (equal (parse-exact-list-aux nats (nat-list-fix input))
             (parse-exact-list-aux nats input)))

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

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

    Function: parse-exact-list

    (defun parse-exact-list (nats input)
      (declare (xargs :guard (and (nat-listp nats)
                                  (nat-listp input))))
      (let ((__function__ 'parse-exact-list))
        (declare (ignorable __function__))
        (b* (((mv error? input)
              (parse-exact-list-aux nats input))
             ((when error?) (mv error? nil input)))
          (mv nil (tree-leafterm nats) input))))

    Theorem: maybe-msgp-of-parse-exact-list.error?

    (defthm maybe-msgp-of-parse-exact-list.error?
      (b* (((mv ?error? ?tree? ?rest-input)
            (parse-exact-list nats input)))
        (maybe-msgp error?))
      :rule-classes :rewrite)

    Theorem: return-type-of-parse-exact-list.tree?

    (defthm return-type-of-parse-exact-list.tree?
      (b* (((mv ?error? ?tree? ?rest-input)
            (parse-exact-list nats input)))
        (and (tree-optionp tree?)
             (implies (not error?) (treep tree?))
             (implies error? (not tree?))))
      :rule-classes :rewrite)

    Theorem: nat-listp-of-parse-exact-list.rest-input

    (defthm nat-listp-of-parse-exact-list.rest-input
      (b* (((mv ?error? ?tree? ?rest-input)
            (parse-exact-list nats input)))
        (nat-listp rest-input))
      :rule-classes :rewrite)

    Theorem: len-of-parse-exact-list-linear-<=

    (defthm len-of-parse-exact-list-linear-<=
      (b* (((mv ?error? ?tree? ?rest-input)
            (parse-exact-list nats input)))
        (<= (len rest-input) (len input)))
      :rule-classes :linear)

    Theorem: len-of-parse-exact-list-linear-<

    (defthm len-of-parse-exact-list-linear-<
      (b* (((mv ?error? ?tree? ?rest-input)
            (parse-exact-list nats input)))
        (implies (and (not error?) (consp nats))
                 (< (len rest-input) (len input))))
      :rule-classes :linear)

    Theorem: parse-exact-list-of-nat-list-fix-nats

    (defthm parse-exact-list-of-nat-list-fix-nats
      (equal (parse-exact-list (nat-list-fix nats)
                               input)
             (parse-exact-list nats input)))

    Theorem: parse-exact-list-nat-list-equiv-congruence-on-nats

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

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

    (defthm parse-exact-list-of-nat-list-fix-input
      (equal (parse-exact-list nats (nat-list-fix input))
             (parse-exact-list nats input)))

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

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