• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
        • Deftreeops
        • Defdefparse
        • Defgrammar
        • Tree-utilities
        • Notation
        • Grammar-parser
          • Grammar-parser-implementation
            • Parse-grammar-from-file
            • Parse-ichar2
            • Parse-ichar
            • Parse-in-either-range
            • Parse-*-in-either-range
              • Parse-bit
              • Parse-equal-/-equal-slash
              • Parse-wsp
              • Parse-*digit-star-*digit
              • Parse-hexdig
              • Parse-cwsp
              • Parse-concatenation
              • Parse-case-insensitive-string
              • Parse-alpha
              • Parse-dot-1*bit
              • Parse-case-sensitive-string
              • Parse-bin/dec/hex-val
              • Parse-alpha/digit/dash
              • Parse-rule
              • Parse-repeat
              • Parse-cnl
              • Parse-sp
              • Parse-rule-/-*cwsp-cnl
              • Parse-element
              • Parse-dec-val
              • Parse-bin-val
              • Parse-alternation
              • Parse-*cwsp-cnl
              • Parse-*bit
              • Parse-wsp/vchar
              • Parse-quoted-string
              • Parse-prose-val
              • Parse-hex-val
              • Parse-grammar
              • Parse-elements
              • Parse-defined-as
              • Parse-dash-1*hexdig
              • Parse-comment
              • Parse-char-val
              • Parse-1*bit
              • Parse-rulename
              • Parse-num-val
              • Parse-htab
              • Parse-hex-val-rest
              • Parse-dot-1*hexdig
              • Parse-dot-1*digit
              • Parse-digit
              • Parse-dec-val-rest
              • Parse-dash-1*digit
              • Parse-dash-1*bit
              • Parse-crlf
              • Parse-cr
              • Parse-conc-rest-comp
              • Parse-cnl-wsp
              • Parse-bin-val-rest
              • Parse-alt-rest-comp
              • Parse-*cwsp
              • Parse-vchar
              • Parse-rulelist
              • Parse-option
              • Parse-group
              • Parse-1*-dot-1*hexdig
              • Parse-1*-dot-1*digit
              • Parse-1*-dot-1*bit
              • Parse-*-rule-/-*cwsp-cnl
              • Parse-*-alpha/digit/dash
              • Parse-lf
              • Parse-dquote
              • Parse-1*hexdig
              • Parse-1*cwsp
              • Parse-?repeat
              • Parse-*-dot-1*hexdig
              • Parse-*-dot-1*digit
              • Parse-*-dot-1*bit
              • Parse-repetition
              • Parse-1*digit
              • Parse-?%i
              • Parse-*wsp/vchar
              • Parse-*hexdig
              • Parse-*digit
              • Parse-alt-rest
              • Parse-conc-rest
              • *grammar-parser-error-msg*
            • Grammar-parser-correctness
          • Meta-circular-validation
          • Parsing-primitives-defresult
          • Parsing-primitives-seq
          • 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
    • Grammar-parser-implementation

    Parse-*-in-either-range

    Parse zero or more natural numbers, each of which in one of two given ranges, into a list of trees that matches the repetition of zero or more alternations of the corresponding range numeric value notations.

    Signature
    (parse-*-in-either-range min1 max1 min2 max2 input) 
      → 
    (mv error? trees rest-input)
    Arguments
    min1 — Guard (natp min1).
    max1 — Guard (natp max1).
    min2 — Guard (natp min2).
    max2 — Guard (natp max2).
    input — Guard (nat-listp input).
    Returns
    error? — Type (not error?).
    trees — Type (tree-listp trees).
    rest-input — Type (nat-listp rest-input).

    Definitions and Theorems

    Function: parse-*-in-either-range

    (defun parse-*-in-either-range (min1 max1 min2 max2 input)
     (declare (xargs :guard (and (natp min1)
                                 (natp max1)
                                 (natp min2)
                                 (natp max2)
                                 (nat-listp input))))
     (declare (xargs :guard (and (<= min1 max1)
                                 (< max1 min2)
                                 (<= min2 max2))))
     (seq-backtrack
         input
         ((tree := (parse-in-either-range min1 max1 min2 max2 input))
          (trees := (parse-*-in-either-range min1 max1 min2 max2 input))
          (return (cons tree trees)))
         ((return-raw (mv nil nil (nat-list-fix input))))))

    Theorem: not-of-parse-*-in-either-range.error?

    (defthm not-of-parse-*-in-either-range.error?
      (b* (((mv ?error? ?trees ?rest-input)
            (parse-*-in-either-range min1 max1 min2 max2 input)))
        (not error?))
      :rule-classes :rewrite)

    Theorem: tree-listp-of-parse-*-in-either-range.trees

    (defthm tree-listp-of-parse-*-in-either-range.trees
      (b* (((mv ?error? ?trees ?rest-input)
            (parse-*-in-either-range min1 max1 min2 max2 input)))
        (tree-listp trees))
      :rule-classes :rewrite)

    Theorem: nat-listp-of-parse-*-in-either-range.rest-input

    (defthm nat-listp-of-parse-*-in-either-range.rest-input
      (b* (((mv ?error? ?trees ?rest-input)
            (parse-*-in-either-range min1 max1 min2 max2 input)))
        (nat-listp rest-input))
      :rule-classes :rewrite)

    Theorem: parse-*-in-either-range-of-nat-list-fix-input

    (defthm parse-*-in-either-range-of-nat-list-fix-input
      (equal
           (parse-*-in-either-range min1
                                    max1 min2 max2 (nat-list-fix input))
           (parse-*-in-either-range min1 max1 min2 max2 input)))

    Theorem: parse-*-in-either-range-nat-list-equiv-congruence-on-input

    (defthm parse-*-in-either-range-nat-list-equiv-congruence-on-input
     (implies
      (acl2::nat-list-equiv input input-equiv)
      (equal (parse-*-in-either-range min1 max1 min2 max2 input)
             (parse-*-in-either-range min1 max1 min2 max2 input-equiv)))
     :rule-classes :congruence)

    Theorem: len-of-parse-*-in-either-range-linear

    (defthm len-of-parse-*-in-either-range-linear
      (b* (((mv ?error? ?trees ?rest-input)
            (parse-*-in-either-range min1 max1 min2 max2 input)))
        (<= (len rest-input) (len input)))
      :rule-classes :linear)