Check if a term is a call of if.
(check-if-call term) → (mv yes/no test then else)
Function:
(defun check-if-call (term) (declare (xargs :guard (pseudo-termp term))) (let ((__function__ 'check-if-call)) (declare (ignorable __function__)) (b* (((when (variablep term)) (mv nil nil nil nil)) ((when (fquotep term)) (mv nil nil nil nil)) (fn (ffn-symb term)) ((unless (eq fn 'if)) (mv nil nil nil nil)) ((unless (= (len (fargs term)) 3)) (prog2$ (raise "Internal error: ~ the IF call ~x0 has arguments ~x1." term (fargs term)) (mv nil nil nil nil)))) (mv t (fargn term 1) (fargn term 2) (fargn term 3)))))
Theorem:
(defthm booleanp-of-check-if-call.yes/no (b* (((mv ?yes/no ?test ?then ?else) (check-if-call term))) (booleanp yes/no)) :rule-classes :rewrite)
Theorem:
(defthm pseudo-termp-of-check-if-call.test (implies (and (pseudo-termp term)) (b* (((mv ?yes/no ?test ?then ?else) (check-if-call term))) (pseudo-termp test))) :rule-classes :rewrite)
Theorem:
(defthm pseudo-termp-of-check-if-call.then (implies (and (pseudo-termp term)) (b* (((mv ?yes/no ?test ?then ?else) (check-if-call term))) (pseudo-termp then))) :rule-classes :rewrite)
Theorem:
(defthm pseudo-termp-of-check-if-call.else (implies (and (pseudo-termp term)) (b* (((mv ?yes/no ?test ?then ?else) (check-if-call term))) (pseudo-termp else))) :rule-classes :rewrite)
Theorem:
(defthm acl2-count-of-check-if-call.test (b* (((mv ?yes/no ?test ?then ?else) (check-if-call term))) (implies yes/no (< (acl2-count test) (acl2-count term)))) :rule-classes :linear)
Theorem:
(defthm acl2-count-of-check-if-call.then (b* (((mv ?yes/no ?test ?then ?else) (check-if-call term))) (implies yes/no (< (acl2-count then) (acl2-count term)))) :rule-classes :linear)
Theorem:
(defthm acl2-count-of-check-if-call.else (b* (((mv ?yes/no ?test ?then ?else) (check-if-call term))) (implies yes/no (< (acl2-count else) (acl2-count term)))) :rule-classes :linear)