• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Debugging
    • Projects
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Error-checking
        • Apt
        • 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
            • Differences-with-paper
            • Examples
            • Grammar-printer
            • Parsing-tools
          • Fty-extensions
          • Isar
          • Kestrel-utilities
          • Prime-field-constraint-systems
          • Soft
          • Bv
          • Imp-language
          • Event-macros
          • Bitcoin
          • Ethereum
          • Yul
          • Zcash
          • ACL2-programming-language
          • Prime-fields
          • Java
          • C
          • Syntheto
          • Number-theory
          • Cryptography
          • Lists-light
          • File-io-light
          • Json
          • Built-ins
          • Solidity
          • Axe
          • Std-extensions
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Execloader
        • Axe
      • Testing-utilities
      • Math
    • 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)