Transform a binary expression.
(simpadd0-expr-binary op arg1 arg1-new arg1-thm-name
arg2 arg2-new arg2-thm-name info gin)
→
(mv expr gout)First, we lift the equalities of the sub-expressions
to an equality for the binary expression.
Then we check whether the resulting binary expression
has the form
The proof for the original-to-simplified theorem makes use of
the supporting theorem
Function:
(defun simpadd0-expr-binary (op arg1 arg1-new arg1-thm-name arg2 arg2-new arg2-thm-name info gin) (declare (xargs :guard (and (binopp op) (exprp arg1) (exprp arg1-new) (symbolp arg1-thm-name) (exprp arg2) (exprp arg2-new) (symbolp arg2-thm-name) (expr-binary-infop info) (ginp gin)))) (declare (xargs :guard (and (expr-unambp arg1) (expr-annop arg1) (expr-unambp arg1-new) (expr-annop arg1-new) (expr-unambp arg2) (expr-annop arg2) (expr-unambp arg2-new) (expr-annop arg2-new)))) (let ((__function__ 'simpadd0-expr-binary)) (declare (ignorable __function__)) (b* (((mv expr-new (gout gout)) (xeq-expr-binary op arg1 arg1-new arg1-thm-name arg2 arg2-new arg2-thm-name info gin)) (simpp (and (binop-case op :add) (type-case (expr-type arg1-new) :sint) (expr-zerop arg2-new))) ((when (not simpp)) (mv expr-new gout)) (expr-new-simp (expr-fix arg1-new)) ((unless gout.thm-name) (mv expr-new-simp gout)) ((gin gin) (gin-update gin gout)) (expr (make-expr-binary :op op :arg1 arg1 :arg2 arg2 :info info)) ((mv & cexpr-new-simp) (ldm-expr expr-new-simp)) ((mv & czero) (ldm-expr arg2-new)) (hints (cons (cons '"Goal" (cons ':in-theory (cons ''((:e c::iconst-length-none) (:e c::iconst-base-oct) (:e c::iconst) (:e c::const-int) (:e c::expr-const) (:e c::binop-add) (:e c::expr-binary) (:e c::type-sint) (:e c::binop-strictp) (:e c::expr-purep) (:e c::binop-purep) expr-compustate-vars nfix) (cons ':use (cons (cons gout.thm-name (cons (cons ':instance (cons 'simpadd0-expr+zero-to-expr (cons (cons 'expr (cons (cons 'quote (cons cexpr-new-simp 'nil)) 'nil)) '((fenv old-fenv))))) (cons arg1-thm-name (cons (cons ':instance (cons 'expr-binary-pure-strict-errors (cons (cons 'op (cons (cons 'quote (cons (c::binop-add) 'nil)) 'nil)) (cons (cons 'arg1 (cons (cons 'quote (cons cexpr-new-simp 'nil)) 'nil)) (cons (cons 'arg2 (cons (cons 'quote (cons czero 'nil)) 'nil)) '((fenv old-fenv))))))) (cons (cons ':instance (cons 'c::exec-expr-limit-monotone (cons (cons 'e (cons (cons 'quote (cons cexpr-new-simp 'nil)) 'nil)) '((compst compst) (fenv old-fenv) (limit (1- limit)) (limit1 limit))))) 'nil))))) 'nil))))) 'nil)) ((mv thm-event thm-name thm-index) (gen-expr-thm expr expr-new-simp gin.vartys gin.const-new gin.thm-index hints))) (mv expr-new-simp (make-gout :events (cons thm-event gin.events) :thm-index thm-index :thm-name thm-name :vartys gin.vartys)))))
Theorem:
(defthm exprp-of-simpadd0-expr-binary.expr (b* (((mv ?expr ?gout) (simpadd0-expr-binary op arg1 arg1-new arg1-thm-name arg2 arg2-new arg2-thm-name info gin))) (exprp expr)) :rule-classes :rewrite)
Theorem:
(defthm goutp-of-simpadd0-expr-binary.gout (b* (((mv ?expr ?gout) (simpadd0-expr-binary op arg1 arg1-new arg1-thm-name arg2 arg2-new arg2-thm-name info gin))) (goutp gout)) :rule-classes :rewrite)
Theorem:
(defthm expr-unambp-of-simpadd0-expr-binary (implies (and (expr-unambp arg1-new) (expr-unambp arg2-new)) (b* (((mv ?expr ?gout) (simpadd0-expr-binary op arg1 arg1-new arg1-thm-name arg2 arg2-new arg2-thm-name info gin))) (expr-unambp expr))))
Theorem:
(defthm expr-annop-of-simpadd0-expr-binary (implies (and (expr-annop arg1-new) (expr-annop arg2-new) (expr-binary-infop info)) (b* (((mv ?expr ?gout) (simpadd0-expr-binary op arg1 arg1-new arg1-thm-name arg2 arg2-new arg2-thm-name info gin))) (expr-annop expr))))
Theorem:
(defthm expr-aidentp-of-simpadd0-expr-binary (implies (and (expr-aidentp arg1-new gcc) (expr-aidentp arg2-new gcc)) (b* (((mv ?expr ?gout) (simpadd0-expr-binary op arg1 arg1-new arg1-thm-name arg2 arg2-new arg2-thm-name info gin))) (expr-aidentp expr gcc))))
Theorem:
(defthm simpadd0-expr+zero-to-expr (b* ((zero (c::expr-const (c::const-int (c::make-iconst :value 0 :base (c::iconst-base-oct) :unsignedp nil :length (c::iconst-length-none))))) (expr+zero (c::expr-binary (c::binop-add) expr zero)) ((mv expr-eval expr-compst) (c::exec-expr expr compst fenv (1- limit))) (expr-val (c::expr-value->value expr-eval)) ((mv expr+zero-eval expr+zero-compst) (c::exec-expr expr+zero compst fenv limit)) (expr+zero-val (c::expr-value->value expr+zero-eval))) (implies (and (c::expr-purep expr) (not (c::errorp expr-eval)) expr-eval (equal (c::type-of-value expr-val) (c::type-sint))) (and (not (c::errorp expr+zero-eval)) expr+zero-eval (equal expr+zero-val expr-val) (equal expr+zero-compst expr-compst)))))