• 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-add-backref

    Signature
    (match-add-backref name start-index match) → new-match
    Arguments
    start-index — Guard (natp start-index).
    match — Guard (matchstate-p match).
    Returns
    new-match — Type (matchstate-p new-match).

    Definitions and Theorems

    Function: match-add-backref

    (defun match-add-backref (name start-index match)
     (declare (xargs :guard (and (natp start-index)
                                 (matchstate-p match))))
     (declare (xargs :guard (<= start-index (matchstate->index match))))
     (let ((__function__ 'match-add-backref))
      (declare (ignorable __function__))
      (b* (((matchstate match))
           (start-index (lnfix start-index))
           ((when (assoc-equal name match.backrefs))
            (matchstate-fix match)))
       (change-matchstate
            match
            :backrefs
            (cons (cons name
                        (make-backref :loc start-index
                                      :len (- match.index start-index)))
                  match.backrefs)))))

    Theorem: matchstate-p-of-match-add-backref

    (defthm matchstate-p-of-match-add-backref
      (b* ((new-match (match-add-backref name start-index match)))
        (matchstate-p new-match))
      :rule-classes :rewrite)

    Theorem: match-index-of-match-add-backref

    (defthm match-index-of-match-add-backref
      (b* ((?new-match (match-add-backref name start-index match)))
        (equal (matchstate->index new-match)
               (matchstate->index match))))

    Theorem: match-add-backref-of-nfix-start-index

    (defthm match-add-backref-of-nfix-start-index
      (equal (match-add-backref name (nfix start-index)
                                match)
             (match-add-backref name start-index match)))

    Theorem: match-add-backref-nat-equiv-congruence-on-start-index

    (defthm match-add-backref-nat-equiv-congruence-on-start-index
      (implies (acl2::nat-equiv start-index start-index-equiv)
               (equal (match-add-backref name start-index match)
                      (match-add-backref name start-index-equiv match)))
      :rule-classes :congruence)

    Theorem: match-add-backref-of-matchstate-fix-match

    (defthm match-add-backref-of-matchstate-fix-match
      (equal (match-add-backref name start-index (matchstate-fix match))
             (match-add-backref name start-index match)))

    Theorem: match-add-backref-matchstate-equiv-congruence-on-match

    (defthm match-add-backref-matchstate-equiv-congruence-on-match
      (implies (matchstate-equiv match match-equiv)
               (equal (match-add-backref name start-index match)
                      (match-add-backref name start-index match-equiv)))
      :rule-classes :congruence)