• 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
        • 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
    • Grammar-parser-implementation

    Parse-num-val

    Parse a numeric value notation.

    Signature
    (parse-num-val input) → (mv error? tree? rest-input)
    Arguments
    input — Guard (nat-listp input).
    Returns
    error? — Type (maybe-msgp error?).
    tree? — Type (and (tree-optionp tree?) (implies (not error?) (treep tree?)) (implies error? (not tree?))) .
    rest-input — Type (nat-listp rest-input).

    Definitions and Theorems

    Function: parse-num-val

    (defun parse-num-val (input)
     (declare (xargs :guard (nat-listp input)))
     (seq
         input
         (tree-% := (parse-ichar #\% input))
         (tree-val := (parse-bin/dec/hex-val input))
         (return (make-tree-nonleaf
                      :rulename? *num-val*
                      :branches (list (list tree-%) (list tree-val))))))

    Theorem: maybe-msgp-of-parse-num-val.error?

    (defthm maybe-msgp-of-parse-num-val.error?
      (b* (((mv ?error? ?tree? ?rest-input)
            (parse-num-val input)))
        (maybe-msgp error?))
      :rule-classes :rewrite)

    Theorem: return-type-of-parse-num-val.tree?

    (defthm return-type-of-parse-num-val.tree?
      (b* (((mv ?error? ?tree? ?rest-input)
            (parse-num-val input)))
        (and (tree-optionp tree?)
             (implies (not error?) (treep tree?))
             (implies error? (not tree?))))
      :rule-classes :rewrite)

    Theorem: nat-listp-of-parse-num-val.rest-input

    (defthm nat-listp-of-parse-num-val.rest-input
      (b* (((mv ?error? ?tree? ?rest-input)
            (parse-num-val input)))
        (nat-listp rest-input))
      :rule-classes :rewrite)

    Theorem: len-of-parse-num-val-linear

    (defthm len-of-parse-num-val-linear
      (b* (((mv ?error? ?tree? ?rest-input)
            (parse-num-val input)))
        (and (<= (len rest-input) (len input))
             (implies (not error?)
                      (< (len rest-input) (len input)))))
      :rule-classes :linear)

    Theorem: parse-num-val-of-nat-list-fix-input

    (defthm parse-num-val-of-nat-list-fix-input
      (equal (parse-num-val (nat-list-fix input))
             (parse-num-val input)))

    Theorem: parse-num-val-nat-list-equiv-congruence-on-input

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