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

    Parse a range numeric value consisting of given minimum and maximum.

    Signature
    (parse-range min max input) → (mv tree rest-input)
    Arguments
    min — Guard (natp min).
    max — Guard (natp max).
    input — Guard (nat-listp input).
    Returns
    tree — Type (tree-resultp tree).
    rest-input — Type (nat-listp rest-input).

    Definitions and Theorems

    Function: parse-range

    (defun parse-range (min max input)
      (declare (xargs :guard (and (natp min)
                                  (natp max)
                                  (nat-listp input))))
      (declare (xargs :guard (<= min max)))
      (let ((__function__ 'parse-range))
        (declare (ignorable __function__))
        (b* (((mv nat? input1) (parse-next input))
             ((when (reserrp nat?))
              (mv (reserrf-push nat?)
                  (nat-list-fix input)))
             (nat nat?)
             ((unless (and (<= (lnfix min) nat)
                           (<= nat (lnfix max))))
              (mv (reserrf (list :found nat :required (lnfix min)
                                 (lnfix max)))
                  (nat-list-fix input))))
          (mv (tree-leafterm (list nat))
              input1))))

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

    (defthm tree-resultp-of-parse-range.tree
      (b* (((mv ?tree ?rest-input)
            (parse-range min max input)))
        (tree-resultp tree))
      :rule-classes :rewrite)

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

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

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

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

    Theorem: len-of-parse-range-<

    (defthm len-of-parse-range-<
      (b* (((mv ?tree ?rest-input)
            (parse-range min max input)))
        (implies (not (reserrp tree))
                 (< (len rest-input) (len input))))
      :rule-classes :linear)

    Theorem: parse-range-of-nfix-min

    (defthm parse-range-of-nfix-min
      (equal (parse-range (nfix min) max input)
             (parse-range min max input)))

    Theorem: parse-range-nat-equiv-congruence-on-min

    (defthm parse-range-nat-equiv-congruence-on-min
      (implies (acl2::nat-equiv min min-equiv)
               (equal (parse-range min max input)
                      (parse-range min-equiv max input)))
      :rule-classes :congruence)

    Theorem: parse-range-of-nfix-max

    (defthm parse-range-of-nfix-max
      (equal (parse-range min (nfix max) input)
             (parse-range min max input)))

    Theorem: parse-range-nat-equiv-congruence-on-max

    (defthm parse-range-nat-equiv-congruence-on-max
      (implies (acl2::nat-equiv max max-equiv)
               (equal (parse-range min max input)
                      (parse-range min max-equiv input)))
      :rule-classes :congruence)

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

    (defthm parse-range-of-nat-list-fix-input
      (equal (parse-range min max (nat-list-fix input))
             (parse-range min max input)))

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

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