Cause an error if a function does not have a given arity.
(ensure-function-arity fn n description error-erp error-val ctx state) → (mv erp val state)
Function:
(defun ensure-function-arity (fn n description error-erp error-val ctx state) (declare (xargs :stobjs (state))) (declare (xargs :guard (and (natp n) (msgp description) (function-namep fn (w state))))) (b* (((unless (= (arity fn (w state)) n)) (er-soft+ ctx error-erp error-val "~@0 must take ~x1 ~@2." description n (if (= n 1) "argument" "arguments")))) (value nil)))
Theorem:
(defthm return-type-of-ensure-function-arity.erp (b* (((mv ?erp ?val ?state) (ensure-function-arity 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-arity.val (b* (((mv ?erp ?val ?state) (ensure-function-arity 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)