• 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

    Match-regex-locs

    Signature
    (match-regex-locs pat x index mode) → match
    Arguments
    pat — Guard (regex-p pat).
    x — Guard (stringp x).
    index — Guard (natp index).
    mode — Guard (matchmode-p mode).
    Returns
    match — Type (matchresult-p match).

    Definitions and Theorems

    Function: match-regex-locs

    (defun match-regex-locs (pat x index mode)
     (declare (xargs :guard (and (regex-p pat)
                                 (stringp x)
                                 (natp index)
                                 (matchmode-p mode))))
     (declare (xargs :guard (<= index (strlen x))))
     (let ((__function__ 'match-regex-locs))
       (declare (ignorable __function__))
       (b*
        ((matches1 (match-regex-rec pat x (make-matchstate :index index)
                                    mode))
         ((when matches1)
          (b* (((matchstate m1) (car matches1)))
            (make-matchresult :loc (lnfix index)
                              :len (- m1.index (lnfix index))
                              :str x
                              :backrefs m1.backrefs)))
         ((when (mbe :logic (zp (- (strlen x) (nfix index)))
                     :exec (eql (strlen x) (lnfix index))))
          (make-matchresult :loc nil
                            :len 0
                            :str x
                            :backrefs nil)))
        (match-regex-locs pat x (+ 1 (lnfix index))
                          mode))))

    Theorem: matchresult-p-of-match-regex-locs

    (defthm matchresult-p-of-match-regex-locs
      (b* ((match (match-regex-locs pat x index mode)))
        (matchresult-p match))
      :rule-classes :rewrite)

    Theorem: matchresult-in-bounds-of-match-regex-locs

    (defthm matchresult-in-bounds-of-match-regex-locs
      (b* ((?match (match-regex-locs pat x index mode)))
        (implies (<= (nfix index) (strlen x))
                 (matchresult-in-bounds match))))

    Theorem: matchresult->str-of-match-regex-locs

    (defthm matchresult->str-of-match-regex-locs
      (b* ((?match (match-regex-locs pat x index mode)))
        (equal (matchresult->str match)
               (lstrfix x))))

    Theorem: match-regex-locs-of-regex-fix-pat

    (defthm match-regex-locs-of-regex-fix-pat
      (equal (match-regex-locs (regex-fix pat)
                               x index mode)
             (match-regex-locs pat x index mode)))

    Theorem: match-regex-locs-regex-equiv-congruence-on-pat

    (defthm match-regex-locs-regex-equiv-congruence-on-pat
      (implies (regex-equiv pat pat-equiv)
               (equal (match-regex-locs pat x index mode)
                      (match-regex-locs pat-equiv x index mode)))
      :rule-classes :congruence)

    Theorem: match-regex-locs-of-str-fix-x

    (defthm match-regex-locs-of-str-fix-x
      (equal (match-regex-locs pat (acl2::str-fix x)
                               index mode)
             (match-regex-locs pat x index mode)))

    Theorem: match-regex-locs-streqv-congruence-on-x

    (defthm match-regex-locs-streqv-congruence-on-x
      (implies (acl2::streqv x x-equiv)
               (equal (match-regex-locs pat x index mode)
                      (match-regex-locs pat x-equiv index mode)))
      :rule-classes :congruence)

    Theorem: match-regex-locs-of-nfix-index

    (defthm match-regex-locs-of-nfix-index
      (equal (match-regex-locs pat x (nfix index)
                               mode)
             (match-regex-locs pat x index mode)))

    Theorem: match-regex-locs-nat-equiv-congruence-on-index

    (defthm match-regex-locs-nat-equiv-congruence-on-index
      (implies (acl2::nat-equiv index index-equiv)
               (equal (match-regex-locs pat x index mode)
                      (match-regex-locs pat x index-equiv mode)))
      :rule-classes :congruence)

    Theorem: match-regex-locs-of-matchmode-fix-mode

    (defthm match-regex-locs-of-matchmode-fix-mode
      (equal (match-regex-locs pat x index (matchmode-fix mode))
             (match-regex-locs pat x index mode)))

    Theorem: match-regex-locs-matchmode-equiv-congruence-on-mode

    (defthm match-regex-locs-matchmode-equiv-congruence-on-mode
      (implies (matchmode-equiv mode mode-equiv)
               (equal (match-regex-locs pat x index mode)
                      (match-regex-locs pat x index mode-equiv)))
      :rule-classes :congruence)