• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
        • Acre-internals
          • Regex
          • Match-string-at
          • Matchstatelist-measure
          • Parse-primitive
          • Matches-remove-zero-length
          • Parse-repeatop
          • Parse-repeatbase
          • Matchstatelist-in-bounds
          • Parse-range
          • Parse-charset-set
          • Parse-charset-atom
          • Match-regex-locs
          • Parse-octal-charcode
          • Parse-k-backref
          • Parse-g-backref
          • Matchstatelist-all-have-backref
          • Parse-repeatmod
          • Parse-charset-elem
            • Parse-charset-aux
            • Parse-hex-charcode
            • Parse-charset
            • Matchstatelist-indices-lte
            • Matchstatelist-indices-gte
            • Match-exact
            • Matches-add-backref
            • Matchresult
            • Preproc-legible-aux
            • Maybe-backref
            • Match-charset
            • Undup-equiv
            • Find-substr
            • Maybe-backref-extract-substr
            • Matchstatelist-min-index
            • Matchstate-in-bounds
            • Match-add-backref
            • Undup
            • Backref-alist-in-bounds
            • Backref
            • Matchstate
            • Matchresult->matched-substr
            • Matchresult->captured-substr!
            • Matchresult->captured-substr
            • Maybe-backref-in-bounds
            • Matchmode
            • Backref-extract-substr
            • Charset-range
            • Matchstate-measure
            • Backref-in-bounds
            • Rev-keys
            • Parse-regex
            • Undup-exec
            • Get-charset
            • Regex-concat2
            • Preproc-legible
            • Matchresult-in-bounds
            • Regex-disjunct2
            • Backref-alist
            • Named-captures-bindings
            • Captures-bindings
            • Matchstatelist
            • Charset-char-regex
            • Repeatmod-p
          • Parse-and-match-regex
          • Match-regex
          • Parse
          • Matchresult->matchedp
          • Match
        • Milawa
        • Smtlink
        • Abnf
        • 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
    • Acre-internals

    Parse-charset-elem

    Signature
    (parse-charset-elem x index) → (mv err chars new-index)
    Arguments
    x — Guard (stringp x).
    index — Guard (natp index).
    Returns
    err — Type (acl2::maybe-stringp err).
    chars — Type (character-listp chars).
    new-index — Type (natp new-index).

    Definitions and Theorems

    Function: parse-charset-elem

    (defun parse-charset-elem (x index)
      (declare (xargs :guard (and (stringp x) (natp index))))
      (declare (xargs :guard (<= index (strlen x))))
      (let ((__function__ 'parse-charset-elem))
        (declare (ignorable __function__))
        (b* (((mv err set new-index)
              (parse-charset-set x index))
             ((unless err) (mv nil set new-index))
             ((mv err char1 index)
              (parse-charset-atom x index))
             ((when err) (mv err nil index))
             ((unless (< index (strlen x)))
              (mv "String ended inside charset"
                  nil index))
             (dash (char x index))
             ((unless (eql dash #\-))
              (mv nil (list char1) index))
             ((mv err char2 index)
              (parse-charset-atom x (+ 1 index)))
             ((when err) (mv err nil index))
             ((when (< (char-code char2) (char-code char1)))
              (mv "Invalid range" nil index)))
          (mv nil (charset-range char1 char2)
              index))))

    Theorem: maybe-stringp-of-parse-charset-elem.err

    (defthm maybe-stringp-of-parse-charset-elem.err
      (b* (((mv ?err ?chars ?new-index)
            (parse-charset-elem x index)))
        (acl2::maybe-stringp err))
      :rule-classes :type-prescription)

    Theorem: character-listp-of-parse-charset-elem.chars

    (defthm character-listp-of-parse-charset-elem.chars
      (b* (((mv ?err ?chars ?new-index)
            (parse-charset-elem x index)))
        (character-listp chars))
      :rule-classes :rewrite)

    Theorem: natp-of-parse-charset-elem.new-index

    (defthm natp-of-parse-charset-elem.new-index
      (b* (((mv ?err ?chars ?new-index)
            (parse-charset-elem x index)))
        (natp new-index))
      :rule-classes :type-prescription)

    Theorem: new-index-of-parse-charset-elem

    (defthm new-index-of-parse-charset-elem
      (b* (((mv ?err ?chars ?new-index)
            (parse-charset-elem x index)))
        (<= (nfix index) new-index))
      :rule-classes :linear)

    Theorem: new-index-of-parse-charset-elem-strong

    (defthm new-index-of-parse-charset-elem-strong
      (b* (((mv ?err ?chars ?new-index)
            (parse-charset-elem x index)))
        (implies (not err)
                 (< (nfix index) new-index)))
      :rule-classes :linear)

    Theorem: new-index-of-parse-charset-elem-less-than-length

    (defthm new-index-of-parse-charset-elem-less-than-length
      (b* (((mv ?err ?chars ?new-index)
            (parse-charset-elem x index)))
        (implies (<= (nfix index)
                     (len (acl2::explode x)))
                 (<= new-index (len (acl2::explode x)))))
      :rule-classes :linear)

    Theorem: parse-charset-elem-of-str-fix-x

    (defthm parse-charset-elem-of-str-fix-x
      (equal (parse-charset-elem (acl2::str-fix x)
                                 index)
             (parse-charset-elem x index)))

    Theorem: parse-charset-elem-streqv-congruence-on-x

    (defthm parse-charset-elem-streqv-congruence-on-x
      (implies (acl2::streqv x x-equiv)
               (equal (parse-charset-elem x index)
                      (parse-charset-elem x-equiv index)))
      :rule-classes :congruence)

    Theorem: parse-charset-elem-of-nfix-index

    (defthm parse-charset-elem-of-nfix-index
      (equal (parse-charset-elem x (nfix index))
             (parse-charset-elem x index)))

    Theorem: parse-charset-elem-nat-equiv-congruence-on-index

    (defthm parse-charset-elem-nat-equiv-congruence-on-index
      (implies (acl2::nat-equiv index index-equiv)
               (equal (parse-charset-elem x index)
                      (parse-charset-elem x index-equiv)))
      :rule-classes :congruence)