Check if an addition, substraction, or multiplication expression is well-formed.
(check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type arg1-obligs arg2-obligs err-keyword expr ctxt) → result
The operands must be integers, and the result is an integer.
Function:
(defun check-add/sub/mul-expression (arg1 arg2 arg1-type arg2-type arg1-obligs arg2-obligs err-keyword expr ctxt) (declare (xargs :guard (and (expressionp arg1) (expressionp arg2) (typep arg1-type) (typep arg2-type) (proof-obligation-listp arg1-obligs) (proof-obligation-listp arg2-obligs) (keywordp err-keyword) (expressionp expr) (contextp ctxt)))) (declare (ignorable expr)) (let ((__function__ 'check-add/sub/mul-expression)) (declare (ignorable __function__)) (b* (((mv okp obligs) (match-type arg1 arg1-type (type-integer) ctxt)) ((unless okp) (type-result-err (list err-keyword (expression-fix arg1) (expression-fix arg2) (type-fix arg1-type) (type-fix arg2-type) (type-integer)))) ((acl2::run-when (consp obligs)) (raise "Internal error: obligations ~x0 for the integer type." obligs)) ((mv okp obligs) (match-type arg2 arg2-type (type-integer) ctxt)) ((unless okp) (type-result-err (list err-keyword (expression-fix arg1) (expression-fix arg2) (type-fix arg1-type) (type-fix arg2-type) (type-integer)))) ((acl2::run-when (consp obligs)) (raise "Internal error: obligations ~x0 for the integer type." obligs))) (make-type-result-ok :types (list (type-integer)) :obligations (append arg1-obligs arg2-obligs)))))
Theorem:
(defthm type-resultp-of-check-add/sub/mul-expression (b* ((result (check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type arg1-obligs arg2-obligs err-keyword expr ctxt))) (type-resultp result)) :rule-classes :rewrite)
Theorem:
(defthm check-add/sub/mul-expression-of-expression-fix-arg1 (equal (check-add/sub/mul-expression (expression-fix arg1) arg2 arg1-type arg2-type arg1-obligs arg2-obligs err-keyword expr ctxt) (check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type arg1-obligs arg2-obligs err-keyword expr ctxt)))
Theorem:
(defthm check-add/sub/mul-expression-expression-equiv-congruence-on-arg1 (implies (expression-equiv arg1 arg1-equiv) (equal (check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type arg1-obligs arg2-obligs err-keyword expr ctxt) (check-add/sub/mul-expression arg1-equiv arg2 arg1-type arg2-type arg1-obligs arg2-obligs err-keyword expr ctxt))) :rule-classes :congruence)
Theorem:
(defthm check-add/sub/mul-expression-of-expression-fix-arg2 (equal (check-add/sub/mul-expression arg1 (expression-fix arg2) arg1-type arg2-type arg1-obligs arg2-obligs err-keyword expr ctxt) (check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type arg1-obligs arg2-obligs err-keyword expr ctxt)))
Theorem:
(defthm check-add/sub/mul-expression-expression-equiv-congruence-on-arg2 (implies (expression-equiv arg2 arg2-equiv) (equal (check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type arg1-obligs arg2-obligs err-keyword expr ctxt) (check-add/sub/mul-expression arg1 arg2-equiv arg1-type arg2-type arg1-obligs arg2-obligs err-keyword expr ctxt))) :rule-classes :congruence)
Theorem:
(defthm check-add/sub/mul-expression-of-type-fix-arg1-type (equal (check-add/sub/mul-expression arg1 arg2 (type-fix arg1-type) arg2-type arg1-obligs arg2-obligs err-keyword expr ctxt) (check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type arg1-obligs arg2-obligs err-keyword expr ctxt)))
Theorem:
(defthm check-add/sub/mul-expression-type-equiv-congruence-on-arg1-type (implies (type-equiv arg1-type arg1-type-equiv) (equal (check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type arg1-obligs arg2-obligs err-keyword expr ctxt) (check-add/sub/mul-expression arg1 arg2 arg1-type-equiv arg2-type arg1-obligs arg2-obligs err-keyword expr ctxt))) :rule-classes :congruence)
Theorem:
(defthm check-add/sub/mul-expression-of-type-fix-arg2-type (equal (check-add/sub/mul-expression arg1 arg2 arg1-type (type-fix arg2-type) arg1-obligs arg2-obligs err-keyword expr ctxt) (check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type arg1-obligs arg2-obligs err-keyword expr ctxt)))
Theorem:
(defthm check-add/sub/mul-expression-type-equiv-congruence-on-arg2-type (implies (type-equiv arg2-type arg2-type-equiv) (equal (check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type arg1-obligs arg2-obligs err-keyword expr ctxt) (check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type-equiv arg1-obligs arg2-obligs err-keyword expr ctxt))) :rule-classes :congruence)
Theorem:
(defthm check-add/sub/mul-expression-of-proof-obligation-list-fix-arg1-obligs (equal (check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type (proof-obligation-list-fix arg1-obligs) arg2-obligs err-keyword expr ctxt) (check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type arg1-obligs arg2-obligs err-keyword expr ctxt)))
Theorem:
(defthm check-add/sub/mul-expression-proof-obligation-list-equiv-congruence-on-arg1-obligs (implies (proof-obligation-list-equiv arg1-obligs arg1-obligs-equiv) (equal (check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type arg1-obligs arg2-obligs err-keyword expr ctxt) (check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type arg1-obligs-equiv arg2-obligs err-keyword expr ctxt))) :rule-classes :congruence)
Theorem:
(defthm check-add/sub/mul-expression-of-proof-obligation-list-fix-arg2-obligs (equal (check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type arg1-obligs (proof-obligation-list-fix arg2-obligs) err-keyword expr ctxt) (check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type arg1-obligs arg2-obligs err-keyword expr ctxt)))
Theorem:
(defthm check-add/sub/mul-expression-proof-obligation-list-equiv-congruence-on-arg2-obligs (implies (proof-obligation-list-equiv arg2-obligs arg2-obligs-equiv) (equal (check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type arg1-obligs arg2-obligs err-keyword expr ctxt) (check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type arg1-obligs arg2-obligs-equiv err-keyword expr ctxt))) :rule-classes :congruence)
Theorem:
(defthm check-add/sub/mul-expression-of-expression-fix-expr (equal (check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type arg1-obligs arg2-obligs err-keyword (expression-fix expr) ctxt) (check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type arg1-obligs arg2-obligs err-keyword expr ctxt)))
Theorem:
(defthm check-add/sub/mul-expression-expression-equiv-congruence-on-expr (implies (expression-equiv expr expr-equiv) (equal (check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type arg1-obligs arg2-obligs err-keyword expr ctxt) (check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type arg1-obligs arg2-obligs err-keyword expr-equiv ctxt))) :rule-classes :congruence)
Theorem:
(defthm check-add/sub/mul-expression-of-context-fix-ctxt (equal (check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type arg1-obligs arg2-obligs err-keyword expr (context-fix ctxt)) (check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type arg1-obligs arg2-obligs err-keyword expr ctxt)))
Theorem:
(defthm check-add/sub/mul-expression-context-equiv-congruence-on-ctxt (implies (context-equiv ctxt ctxt-equiv) (equal (check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type arg1-obligs arg2-obligs err-keyword expr ctxt) (check-add/sub/mul-expression arg1 arg2 arg1-type arg2-type arg1-obligs arg2-obligs err-keyword expr ctxt-equiv))) :rule-classes :congruence)