• 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
          • Parse-schars
          • Parse-ichars
          • Parse-direct
          • Parse-range
          • Parse-next
          • Parsing-primitives-seq
          • Operations
          • Examples
          • Differences-with-paper
          • Constructor-utilities
          • Grammar-printer
          • Parsing-tools
        • Vwsim
        • Isar
        • Wp-gen
        • Dimacs-reader
        • Pfcs
        • 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
    • Parsing-primitives-defresult

    Parse-next

    Obtain the next natural number from the input.

    Signature
    (parse-next input) → (mv nat rest-input)
    Arguments
    input — Guard (nat-listp input).
    Returns
    nat — Type (nat-resultp nat).
    rest-input — Type (nat-listp rest-input).

    Definitions and Theorems

    Function: parse-next

    (defun parse-next (input)
      (declare (xargs :guard (nat-listp input)))
      (let ((__function__ 'parse-next))
        (declare (ignorable __function__))
        (if (consp input)
            (mv (lnfix (car input))
                (nat-list-fix (cdr input)))
          (mv (reserrf :end-of-input) nil))))

    Theorem: nat-resultp-of-parse-next.nat

    (defthm nat-resultp-of-parse-next.nat
      (b* (((mv acl2::?nat ?rest-input)
            (parse-next input)))
        (nat-resultp nat))
      :rule-classes :rewrite)

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

    (defthm nat-listp-of-parse-next.rest-input
      (b* (((mv acl2::?nat ?rest-input)
            (parse-next input)))
        (nat-listp rest-input))
      :rule-classes :rewrite)

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

    (defthm len-of-parse-next-<=
      (b* (((mv acl2::?nat ?rest-input)
            (parse-next input)))
        (<= (len rest-input) (len input)))
      :rule-classes :linear)

    Theorem: len-of-parse-next-<

    (defthm len-of-parse-next-<
      (b* (((mv acl2::?nat ?rest-input)
            (parse-next input)))
        (implies (not (reserrp nat))
                 (< (len rest-input) (len input))))
      :rule-classes :linear)

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

    (defthm parse-next-of-nat-list-fix-input
      (equal (parse-next (nat-list-fix input))
             (parse-next input)))

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

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