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

    Parse a bit.

    Signature
    (parse-bit 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-bit

    (defun parse-bit (input)
      (declare (xargs :guard (nat-listp input)))
      (seq-backtrack
           input
           ((tree := (parse-ichar #\0 input))
            (return (make-tree-nonleaf :rulename? *bit*
                                       :branches (list (list tree)))))
           ((tree := (parse-ichar #\1 input))
            (return (make-tree-nonleaf :rulename? *bit*
                                       :branches (list (list tree)))))))

    Theorem: maybe-msgp-of-parse-bit.error?

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

    Theorem: return-type-of-parse-bit.tree?

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

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

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

    Theorem: len-of-parse-bit-linear

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

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

    (defthm parse-bit-of-nat-list-fix-input
      (equal (parse-bit (nat-list-fix input))
             (parse-bit input)))

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

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