Cause an error if a term includes free variables outside a given set.
(ensure-term-free-vars-subset term vars description error-erp error-val ctx state) → (mv erp val state)
Function:
(defun ensure-term-free-vars-subset (term vars description error-erp error-val ctx state) (declare (xargs :stobjs (state))) (declare (xargs :guard (and (pseudo-termp term) (symbol-listp vars) (msgp description)))) (b* (((unless (subsetp-eq (all-vars term) vars)) (er-soft+ ctx error-erp error-val "~@0 must contain no free variables other than ~&1, ~ but it contains the ~@2." description vars (let ((extra (set-difference-eq (all-vars term) vars))) (if (= (len extra) 1) (msg "variable ~x0" (car extra)) (msg "variables ~&0" extra)))))) (value nil)))
Theorem:
(defthm return-type-of-ensure-term-free-vars-subset.erp (b* (((mv ?erp ?val ?state) (ensure-term-free-vars-subset term vars description error-erp error-val ctx state))) (implies erp (equal erp error-erp))) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-ensure-term-free-vars-subset.val (b* (((mv ?erp ?val ?state) (ensure-term-free-vars-subset term vars description error-erp error-val ctx state))) (and (implies erp (equal val error-val)) (implies (and (not erp) error-erp) (not val)))) :rule-classes :rewrite)