(vl-module-elim-unused-vars x) → new-x
Function:
(defun vl-module-elim-unused-vars (x) (declare (xargs :guard (vl-module-p x))) (let ((__function__ 'vl-module-elim-unused-vars)) (declare (ignorable __function__)) (b* ((x (vl-module-fix x)) ((vl-module x) x) ((unless (consp x.vardecls)) x) (used (vl-exprlist-names (vl-module-allexprs x))) (new-vars (vl-keep-vardecls used x.vardecls)) ((when (same-lengthp new-vars x.vardecls)) x) (warnings x.warnings) (old-varnames (mergesort (vl-vardecllist->names x.vardecls))) (new-varnames (mergesort (vl-vardecllist->names new-vars))) (unused-varnames (difference old-varnames new-varnames)) (warnings (if unused-varnames (warn :type :vl-warn-unused-var :msg "In ~m0, eliminating spurious variables ~&1." :args (list (vl-module->name x) unused-varnames)) warnings)) (new-x (change-vl-module x :vardecls new-vars :warnings warnings))) new-x)))
Theorem:
(defthm vl-module-p-of-vl-module-elim-unused-vars (b* ((new-x (vl-module-elim-unused-vars x))) (vl-module-p new-x)) :rule-classes :rewrite)
Theorem:
(defthm vl-module-elim-unused-vars-of-vl-module-fix-x (equal (vl-module-elim-unused-vars (vl-module-fix x)) (vl-module-elim-unused-vars x)))
Theorem:
(defthm vl-module-elim-unused-vars-vl-module-equiv-congruence-on-x (implies (vl-module-equiv x x-equiv) (equal (vl-module-elim-unused-vars x) (vl-module-elim-unused-vars x-equiv))) :rule-classes :congruence)