• 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

    Find-substr

    Signature
    (find-substr target x index) → pos
    Arguments
    target — Guard (stringp target).
    x — Guard (stringp x).
    index — Guard (natp index).
    Returns
    pos — Type (maybe-natp pos).

    Definitions and Theorems

    Function: find-substr

    (defun find-substr (target x index)
      (declare (xargs :guard (and (stringp target)
                                  (stringp x)
                                  (natp index))))
      (declare (xargs :guard (<= index (strlen x))))
      (let ((__function__ 'find-substr))
        (declare (ignorable __function__))
        (str::strpos-fast (lstrfix target)
                          (lstrfix x)
                          (lnfix index)
                          (strlen target)
                          (strlen x))))

    Theorem: maybe-natp-of-find-substr

    (defthm maybe-natp-of-find-substr
      (b* ((pos (find-substr target x index)))
        (maybe-natp pos))
      :rule-classes :type-prescription)

    Theorem: new-index-of-find-substr

    (defthm new-index-of-find-substr
      (b* ((?pos (find-substr target x index)))
        (implies pos (<= (nfix index) pos)))
      :rule-classes :linear)

    Theorem: new-index-of-find-substr-less-than-length

    (defthm new-index-of-find-substr-less-than-length
      (b* ((?pos (find-substr target x index)))
        (implies (and pos
                      (<= (nfix index)
                          (len (acl2::explode x))))
                 (<= pos
                     (- (len (acl2::explode x))
                        (len (acl2::explode target))))))
      :rule-classes :linear)

    Theorem: find-substr-of-str-fix-target

    (defthm find-substr-of-str-fix-target
      (equal (find-substr (acl2::str-fix target)
                          x index)
             (find-substr target x index)))

    Theorem: find-substr-streqv-congruence-on-target

    (defthm find-substr-streqv-congruence-on-target
      (implies (acl2::streqv target target-equiv)
               (equal (find-substr target x index)
                      (find-substr target-equiv x index)))
      :rule-classes :congruence)

    Theorem: find-substr-of-str-fix-x

    (defthm find-substr-of-str-fix-x
      (equal (find-substr target (acl2::str-fix x)
                          index)
             (find-substr target x index)))

    Theorem: find-substr-streqv-congruence-on-x

    (defthm find-substr-streqv-congruence-on-x
      (implies (acl2::streqv x x-equiv)
               (equal (find-substr target x index)
                      (find-substr target x-equiv index)))
      :rule-classes :congruence)

    Theorem: find-substr-of-nfix-index

    (defthm find-substr-of-nfix-index
      (equal (find-substr target x (nfix index))
             (find-substr target x index)))

    Theorem: find-substr-nat-equiv-congruence-on-index

    (defthm find-substr-nat-equiv-congruence-on-index
      (implies (acl2::nat-equiv index index-equiv)
               (equal (find-substr target x index)
                      (find-substr target x index-equiv)))
      :rule-classes :congruence)