Safely rename module instances, preferring names of the form
(vl-namemangle-modinsts prefix modinsts nf) → (mv new-modinsts new-nf)
Function:
(defun vl-namemangle-modinsts (prefix modinsts nf) (declare (xargs :guard (and (stringp prefix) (vl-modinstlist-p modinsts) (vl-namefactory-p nf)))) (let ((__function__ 'vl-namemangle-modinsts)) (declare (ignorable __function__)) (b* (((when (atom modinsts)) (mv nil (vl-namefactory-fix nf))) (instname1 (or (vl-modinst->instname (car modinsts)) "inst")) (want1 (cat prefix "_" instname1)) ((mv fresh1 nf) (vl-namefactory-plain-name want1 nf)) (inst1 (change-vl-modinst (car modinsts) :instname fresh1)) ((mv insts2 nf) (vl-namemangle-modinsts prefix (cdr modinsts) nf))) (mv (cons inst1 insts2) nf))))
Theorem:
(defthm vl-modinstlist-p-of-vl-namemangle-modinsts.new-modinsts (b* (((mv ?new-modinsts ?new-nf) (vl-namemangle-modinsts prefix modinsts nf))) (vl-modinstlist-p new-modinsts)) :rule-classes :rewrite)
Theorem:
(defthm vl-namefactory-p-of-vl-namemangle-modinsts.new-nf (b* (((mv ?new-modinsts ?new-nf) (vl-namemangle-modinsts prefix modinsts nf))) (vl-namefactory-p new-nf)) :rule-classes :rewrite)
Theorem:
(defthm vl-namemangle-modinsts-mvtypes-0 (true-listp (mv-nth 0 (vl-namemangle-modinsts prefix modinsts nf))) :rule-classes :type-prescription)
Theorem:
(defthm len-of-vl-namemangle-modinsts (b* (((mv new-modinsts ?new-nf) (vl-namemangle-modinsts loc modinsts nf))) (equal (len new-modinsts) (len modinsts))))
Theorem:
(defthm vl-namemangle-modinsts-of-str-fix-prefix (equal (vl-namemangle-modinsts (str-fix prefix) modinsts nf) (vl-namemangle-modinsts prefix modinsts nf)))
Theorem:
(defthm vl-namemangle-modinsts-streqv-congruence-on-prefix (implies (streqv prefix prefix-equiv) (equal (vl-namemangle-modinsts prefix modinsts nf) (vl-namemangle-modinsts prefix-equiv modinsts nf))) :rule-classes :congruence)
Theorem:
(defthm vl-namemangle-modinsts-of-vl-modinstlist-fix-modinsts (equal (vl-namemangle-modinsts prefix (vl-modinstlist-fix modinsts) nf) (vl-namemangle-modinsts prefix modinsts nf)))
Theorem:
(defthm vl-namemangle-modinsts-vl-modinstlist-equiv-congruence-on-modinsts (implies (vl-modinstlist-equiv modinsts modinsts-equiv) (equal (vl-namemangle-modinsts prefix modinsts nf) (vl-namemangle-modinsts prefix modinsts-equiv nf))) :rule-classes :congruence)
Theorem:
(defthm vl-namemangle-modinsts-of-vl-namefactory-fix-nf (equal (vl-namemangle-modinsts prefix modinsts (vl-namefactory-fix nf)) (vl-namemangle-modinsts prefix modinsts nf)))
Theorem:
(defthm vl-namemangle-modinsts-vl-namefactory-equiv-congruence-on-nf (implies (vl-namefactory-equiv nf nf-equiv) (equal (vl-namemangle-modinsts prefix modinsts nf) (vl-namemangle-modinsts prefix modinsts nf-equiv))) :rule-classes :congruence)