Naive, O(n) lookup of a vl-package in a list by its name.
(vl-find-package name x) → package?
Function:
(defun vl-find-package (name x) (declare (xargs :guard (and (stringp name) (vl-packagelist-p x)))) (let ((__function__ 'vl-find-package)) (declare (ignorable __function__)) (cond ((atom x) nil) ((equal (string-fix name) (vl-package->name (car x))) (vl-package-fix (car x))) (t (vl-find-package name (cdr x))))))
Theorem:
(defthm return-type-of-vl-find-package (b* ((package? (vl-find-package name x))) (iff (vl-package-p package?) package?)) :rule-classes :rewrite)
Theorem:
(defthm vl-find-package-under-iff (iff (vl-find-package name x) (member-equal (string-fix name) (vl-packagelist->names x))))
Theorem:
(defthm vl-package->name-of-vl-find-package (implies (vl-find-package name x) (equal (vl-package->name (vl-find-package name x)) (string-fix name))))
Theorem:
(defthm tag-of-vl-find-package (equal (tag (vl-find-package name x)) (if (vl-find-package name x) :vl-package nil)))
Theorem:
(defthm member-equal-of-vl-find-package (implies (force (vl-packagelist-p x)) (iff (member-equal (vl-find-package name x) x) (vl-find-package name x))))
Theorem:
(defthm consp-of-vl-find-package-when-member-equal (implies (and (member-equal name (vl-packagelist->names x)) (force (stringp name))) (consp (vl-find-package name x))))
Theorem:
(defthm vl-find-package-of-str-fix-name (equal (vl-find-package (str-fix name) x) (vl-find-package name x)))
Theorem:
(defthm vl-find-package-streqv-congruence-on-name (implies (streqv name name-equiv) (equal (vl-find-package name x) (vl-find-package name-equiv x))) :rule-classes :congruence)
Theorem:
(defthm vl-find-package-of-vl-packagelist-fix-x (equal (vl-find-package name (vl-packagelist-fix x)) (vl-find-package name x)))
Theorem:
(defthm vl-find-package-vl-packagelist-equiv-congruence-on-x (implies (vl-packagelist-equiv x x-equiv) (equal (vl-find-package name x) (vl-find-package name x-equiv))) :rule-classes :congruence)