Collect a subset of a vl-portdecllist-p by their names, according to a given name ordering.
(vl-reorder-portdecls names x) → sublist
This is a basic reordering function; see reordering-by-name.
Function:
(defun vl-reorder-portdecls (names x) (declare (xargs :guard (and (string-listp names) (vl-portdecllist-p x)))) (let ((__function__ 'vl-reorder-portdecls)) (declare (ignorable __function__)) (mbe :logic (b* (((when (atom names)) nil) (decl (vl-find-portdecl (car names) x)) ((when decl) (cons decl (vl-reorder-portdecls (cdr names) x)))) (vl-reorder-portdecls (cdr names) x)) :exec (b* (((unless (and (longer-than-p 6 names) (acl2::worth-hashing x))) (vl-slow-reorder-portdecl names x)) (fal (make-fast-alist (vl-portdecllist-alist x nil))) (ans (vl-fast-reorder-portdecl names x fal))) (fast-alist-free fal) ans))))
Theorem:
(defthm vl-portdecllist-p-of-vl-reorder-portdecls (b* ((sublist (vl-reorder-portdecls names x))) (vl-portdecllist-p sublist)) :rule-classes :rewrite)
Theorem:
(defthm vl-slow-reorder-portdecl-removal (equal (vl-slow-reorder-portdecl names x) (vl-reorder-portdecls names x)))
Theorem:
(defthm vl-fast-reorder-portdecl-removal (implies (and (string-listp names) (vl-portdecllist-p x) (equal fal (vl-portdecllist-alist x nil))) (equal (vl-fast-reorder-portdecl names x fal) (vl-reorder-portdecls names x))))
Theorem:
(defthm vl-reorder-portdecls-of-string-list-fix-names (equal (vl-reorder-portdecls (string-list-fix names) x) (vl-reorder-portdecls names x)))
Theorem:
(defthm vl-reorder-portdecls-string-list-equiv-congruence-on-names (implies (str::string-list-equiv names names-equiv) (equal (vl-reorder-portdecls names x) (vl-reorder-portdecls names-equiv x))) :rule-classes :congruence)
Theorem:
(defthm vl-reorder-portdecls-of-vl-portdecllist-fix-x (equal (vl-reorder-portdecls names (vl-portdecllist-fix x)) (vl-reorder-portdecls names x)))
Theorem:
(defthm vl-reorder-portdecls-vl-portdecllist-equiv-congruence-on-x (implies (vl-portdecllist-equiv x x-equiv) (equal (vl-reorder-portdecls names x) (vl-reorder-portdecls names x-equiv))) :rule-classes :congruence)
We prove some basic correctness properties. To start, the list we get back is always a subset of the original list (modulo fixing).
Theorem:
(defthm subsetp-of-vl-reorder-portdecls (subsetp (vl-reorder-portdecls names x) (vl-portdecllist-fix x)))
Furthermore, the names we get back for are the names we asked for.
Theorem:
(defthm vl-portdecllist->names-of-vl-reorder-portdecls (implies (subsetp (double-rewrite names) (vl-portdecllist->names x)) (equal (vl-portdecllist->names (vl-reorder-portdecls names x)) (list-fix names))))
Theorem:
(defthm vl-portdecllist->names-of-vl-reorder-portdecls-bounded (subsetp (vl-portdecllist->names (vl-reorder-portdecls names x)) (string-list-fix names)))
For stronger correctness properties, we need to know that the names in
Theorem:
(defthm member-of-vl-reorder-portdecls (implies (and (no-duplicatesp-equal (vl-portdecllist->names x)) (force (vl-portdecllist-p x))) (iff (member a (vl-reorder-portdecls names x)) (and (member a x) (member (vl-portdecl->name a) (string-list-fix names))))))
Theorem:
(defthm vl-reorder-portdecls-under-set-equiv (implies (and (no-duplicatesp-equal (vl-portdecllist->names x)) (set-equiv (double-rewrite (string-list-fix names)) (vl-portdecllist->names x))) (set-equiv (vl-reorder-portdecls names x) (vl-portdecllist-fix x))))