(match-add-backref name start-index match) → new-match
Function:
(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:
(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:
(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:
(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:
(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:
(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:
(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)