(vl-namedb-indexed-name prefix db) constructs a fresh name that looks
like
(vl-namedb-indexed-name prefix db) → (mv fresh-name new-db)
Function:
(defun vl-namedb-indexed-name (prefix db) (declare (xargs :guard (and (stringp prefix) (vl-namedb-p db)))) (let ((__function__ 'vl-namedb-indexed-name)) (declare (ignorable __function__)) (b* ((prefix (string-fix prefix)) (names (vl-namedb->names db)) (pmap (vl-namedb->pmap db)) (pset (vl-namedb->pset db)) (lookup (hons-get prefix pmap)) (maxidx (if lookup (cdr lookup) (vl-pgenstr-highest-of-alist-keys prefix names))) (newidx (+ maxidx 1)) (newname (vl-pgenstr prefix newidx)) (names (hons-acons newname t names)) (pmap (hons-acons prefix newidx pmap)) (pset (if lookup pset (hons-acons prefix t pset))) (db (change-vl-namedb db :names names :pmap pmap :pset pset))) (mv newname db))))
Theorem:
(defthm stringp-of-vl-namedb-indexed-name (stringp (mv-nth 0 (vl-namedb-indexed-name prefix db))) :rule-classes :type-prescription)
Theorem:
(defthm vl-namedb-p-of-vl-namedb-indexed-name (vl-namedb-p (mv-nth 1 (vl-namedb-indexed-name prefix db))))
Theorem:
(defthm vl-namedb-allnames-of-vl-namedb-indexed-name (equal (vl-namedb-allnames (mv-nth 1 (vl-namedb-indexed-name prefix db))) (cons (mv-nth 0 (vl-namedb-indexed-name prefix db)) (vl-namedb-allnames db))))
Theorem:
(defthm vl-namedb->names-of-vl-namedb-indexed-name (vl-namedb->names (mv-nth 1 (vl-namedb-indexed-name prefix db))))
Theorem:
(defthm vl-namedb-indexed-name-is-fresh (b* (((mv fresh-name ?new-db) (vl-namedb-indexed-name prefix db))) (not (member-equal fresh-name (vl-namedb-allnames db)))))
Theorem:
(defthm vl-namedb-indexed-name-of-str-fix-prefix (equal (vl-namedb-indexed-name (str-fix prefix) db) (vl-namedb-indexed-name prefix db)))
Theorem:
(defthm vl-namedb-indexed-name-streqv-congruence-on-prefix (implies (streqv prefix prefix-equiv) (equal (vl-namedb-indexed-name prefix db) (vl-namedb-indexed-name prefix-equiv db))) :rule-classes :congruence)
Theorem:
(defthm vl-namedb-indexed-name-of-vl-namedb-fix-db (equal (vl-namedb-indexed-name prefix (vl-namedb-fix db)) (vl-namedb-indexed-name prefix db)))
Theorem:
(defthm vl-namedb-indexed-name-vl-namedb-equiv-congruence-on-db (implies (vl-namedb-equiv db db-equiv) (equal (vl-namedb-indexed-name prefix db) (vl-namedb-indexed-name prefix db-equiv))) :rule-classes :congruence)