Equality lifting transformation of a conditional expression.
(xeq-expr-cond test test-new test-thm-name
then then-new then-thm-name
else else-new else-thm-name gin)
→
(mv expr gou)The resulting expression is obtained by combining the possibly transformed argument expression.
We generate a theorem iff a theorem was generated for the argument expressions, and the argument expressions are pure. The theorem is proved via a few general ones that we prove below. These are a bit more complicated than for strict expressions, because conditional expressions are non-strict: the branch not taken could return an error while the conditional expression does not.
Function:
(defun xeq-expr-cond (test test-new test-thm-name then then-new then-thm-name else else-new else-thm-name gin) (declare (xargs :guard (and (exprp test) (exprp test-new) (symbolp test-thm-name) (expr-optionp then) (expr-optionp then-new) (symbolp then-thm-name) (exprp else) (exprp else-new) (symbolp else-thm-name) (ginp gin)))) (declare (xargs :guard (and (expr-unambp test) (expr-annop test) (expr-unambp test-new) (expr-annop test-new) (expr-option-unambp then) (expr-option-annop then) (expr-option-unambp then-new) (expr-option-annop then-new) (expr-unambp else) (expr-annop else) (expr-unambp else-new) (expr-annop else-new)))) (let ((__function__ 'xeq-expr-cond)) (declare (ignorable __function__)) (b* (((gin gin) gin) (expr (make-expr-cond :test test :then then :else else)) (expr-new (make-expr-cond :test test-new :then then-new :else else-new)) ((unless (and test-thm-name then-thm-name else-thm-name)) (mv expr-new (gout-no-thm gin))) ((mv & old-test) (ldm-expr test)) ((mv & old-then) (ldm-expr-option then)) ((mv & old-else) (ldm-expr else)) ((mv & new-test) (ldm-expr test-new)) ((mv & new-then) (ldm-expr-option then-new)) ((mv & new-else) (ldm-expr else-new)) (hints (cons (cons '"Goal" (cons ':do-not (cons ''(preprocess) (cons ':in-theory (cons ''((:e c::expr-cond) (:e c::type-nonchar-integerp) (:e c::expr-value->value) (:e c::type-of-value) expr-compustate-vars) (cons ':use (cons (cons (cons ':instance (cons test-thm-name '((limit (1- limit))))) (cons (cons ':instance (cons then-thm-name (cons (cons 'compst (cons (cons 'mv-nth (cons '1 (cons (cons 'c::exec-expr (cons (cons 'quote (cons old-test 'nil)) '(compst old-fenv (1- limit)))) 'nil))) 'nil)) '((limit (1- limit)))))) (cons (cons ':instance (cons else-thm-name (cons (cons 'compst (cons (cons 'mv-nth (cons '1 (cons (cons 'c::exec-expr (cons (cons 'quote (cons old-test 'nil)) '(compst old-fenv (1- limit)))) 'nil))) 'nil)) '((limit (1- limit)))))) (cons (cons ':instance (cons 'expr-cond-true-congruence (cons (cons 'old-test (cons (cons 'quote (cons old-test 'nil)) 'nil)) (cons (cons 'old-then (cons (cons 'quote (cons old-then 'nil)) 'nil)) (cons (cons 'old-else (cons (cons 'quote (cons old-else 'nil)) 'nil)) (cons (cons 'new-test (cons (cons 'quote (cons new-test 'nil)) 'nil)) (cons (cons 'new-then (cons (cons 'quote (cons new-then 'nil)) 'nil)) (cons (cons 'new-else (cons (cons 'quote (cons new-else 'nil)) 'nil)) 'nil)))))))) (cons (cons ':instance (cons 'expr-cond-false-congruence (cons (cons 'old-test (cons (cons 'quote (cons old-test 'nil)) 'nil)) (cons (cons 'old-then (cons (cons 'quote (cons old-then 'nil)) 'nil)) (cons (cons 'old-else (cons (cons 'quote (cons old-else 'nil)) 'nil)) (cons (cons 'new-test (cons (cons 'quote (cons new-test 'nil)) 'nil)) (cons (cons 'new-then (cons (cons 'quote (cons new-then 'nil)) 'nil)) (cons (cons 'new-else (cons (cons 'quote (cons new-else 'nil)) 'nil)) 'nil)))))))) (cons (cons ':instance (cons 'expr-cond-test-errors (cons (cons 'test (cons (cons 'quote (cons old-test 'nil)) 'nil)) (cons (cons 'then (cons (cons 'quote (cons old-then 'nil)) 'nil)) (cons (cons 'else (cons (cons 'quote (cons old-else 'nil)) 'nil)) '((fenv old-fenv))))))) (cons (cons ':instance (cons 'expr-cond-then-errors (cons (cons 'test (cons (cons 'quote (cons old-test 'nil)) 'nil)) (cons (cons 'then (cons (cons 'quote (cons old-then 'nil)) 'nil)) (cons (cons 'else (cons (cons 'quote (cons old-else 'nil)) 'nil)) '((fenv old-fenv))))))) (cons (cons ':instance (cons 'expr-cond-else-errors (cons (cons 'test (cons (cons 'quote (cons old-test 'nil)) 'nil)) (cons (cons 'then (cons (cons 'quote (cons old-then 'nil)) 'nil)) (cons (cons 'else (cons (cons 'quote (cons old-else 'nil)) 'nil)) '((fenv old-fenv))))))) 'nil)))))))) 'nil))))))) 'nil)) ((mv thm-event thm-name thm-index) (gen-expr-thm expr expr-new gin.vartys gin.const-new gin.thm-index hints))) (mv expr-new (make-gout :events (cons thm-event gin.events) :thm-index thm-index :thm-name thm-name :vartys gin.vartys)))))
Theorem:
(defthm exprp-of-xeq-expr-cond.expr (b* (((mv ?expr ?gou) (xeq-expr-cond test test-new test-thm-name then then-new then-thm-name else else-new else-thm-name gin))) (exprp expr)) :rule-classes :rewrite)
Theorem:
(defthm goutp-of-xeq-expr-cond.gou (b* (((mv ?expr ?gou) (xeq-expr-cond test test-new test-thm-name then then-new then-thm-name else else-new else-thm-name gin))) (goutp gou)) :rule-classes :rewrite)
Theorem:
(defthm expr-unambp-of-xeq-expr-cond (implies (and (expr-unambp test-new) (expr-option-unambp then-new) (expr-unambp else-new)) (b* (((mv ?expr ?gou) (xeq-expr-cond test test-new test-thm-name then then-new then-thm-name else else-new else-thm-name gin))) (expr-unambp expr))))
Theorem:
(defthm expr-annop-of-xeq-expr-cond (implies (and (expr-annop test-new) (expr-option-annop then-new) (expr-annop else-new)) (b* (((mv ?expr ?gou) (xeq-expr-cond test test-new test-thm-name then then-new then-thm-name else else-new else-thm-name gin))) (expr-annop expr))))
Theorem:
(defthm expr-aidentp-of-xeq-expr-cond (implies (and (expr-aidentp test-new gcc) (expr-option-aidentp then-new gcc) (expr-aidentp else-new gcc)) (b* (((mv ?expr ?gou) (xeq-expr-cond test test-new test-thm-name then then-new then-thm-name else else-new else-thm-name gin))) (expr-aidentp expr gcc))))