Cause an error if a term is not a call of if.
(ensure-term-if-call term description error-erp error-val ctx state) → (mv erp val state)
If the term is a call to if, return its test, `then' branch, and `else' branch.
Function:
(defun ensure-term-if-call (term description error-erp error-val ctx state) (declare (xargs :stobjs (state))) (declare (xargs :guard (and (pseudo-termp term) (msgp description)))) (b* (((unless (and (nvariablep term) (not (fquotep term)) (eq (ffn-symb term) 'if))) (er-soft+ ctx error-erp error-val "~@0 must be a call of IF." description))) (value (list (fargn term 1) (fargn term 2) (fargn term 3)))))
Theorem:
(defthm return-type-of-ensure-term-if-call.erp (b* (((mv ?erp ?val ?state) (ensure-term-if-call term description error-erp error-val ctx state))) (implies erp (equal erp error-erp))) :rule-classes :rewrite)
Theorem:
(defthm return-type-of-ensure-term-if-call.val (b* (((mv ?erp ?val ?state) (ensure-term-if-call term description error-erp error-val ctx state))) (and (implies erp (equal val error-val)) (implies (and (not erp) error-erp (pseudo-termp term)) (and (pseudo-term-listp val) (equal (len val) 3))))) :rule-classes :rewrite)