• 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-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)