Cause an error if a function does not have a given number of results.
(ensure-function-number-of-results fn n description error-erp error-val ctx state) → (mv erp val state)
The function must not be one whose stobjs-out are invalid.
Function:
(defun ensure-function-number-of-results (fn n description error-erp error-val ctx state) (declare (xargs :stobjs (state))) (declare (xargs :guard (and (posp n) (msgp description) (and (function-namep fn (w state)) (not (member-eq fn *stobjs-out-invalid*)))))) (b* (((unless (= (number-of-results fn (w state)) n)) (er-soft+ ctx error-erp error-val "~@0 must return ~x1 ~@2." description n (if (= n 1) "result" "results")))) (value nil)))
Theorem:
(defthm return-type-of-ensure-function-number-of-results.erp (b* (((mv ?erp ?val ?state) (ensure-function-number-of-results fn n description error-erp error-val ctx state))) (implies erp (equal erp error-erp))) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-ensure-function-number-of-results.val (b* (((mv ?erp ?val ?state) (ensure-function-number-of-results fn n 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)