Validate a unary expression, given the type of the sub-expression.
The
The
The
The
The
The
The
The
Function:
(defun valid-unary (expr op type-arg ienv) (declare (xargs :guard (and (exprp expr) (unopp op) (typep type-arg) (ienvp ienv)))) (declare (xargs :guard (expr-case expr :unary))) (let ((__function__ 'valid-unary)) (declare (ignorable __function__)) (b* (((reterr) (irr-type)) ((when (type-case type-arg :unknown)) (retok (type-unknown))) (msg (msg "In the unary expression ~x0, ~ the sub-expression has type ~x1." (expr-fix expr) (type-fix type-arg)))) (case (unop-kind op) (:address (retok (type-pointer))) (:indir (b* ((type (type-fpconvert (type-apconvert type-arg))) ((unless (type-case type :pointer)) (reterr msg))) (retok (type-unknown)))) ((:plus :minus) (b* (((unless (type-arithmeticp type-arg)) (reterr msg))) (retok (type-promote type-arg ienv)))) (:bitnot (b* (((unless (type-integerp type-arg)) (reterr msg))) (retok (type-promote type-arg ienv)))) (:lognot (b* ((type (type-fpconvert (type-apconvert type-arg))) ((unless (type-scalarp type)) (reterr msg))) (retok (type-sint)))) ((:preinc :predec :postinc :postdec) (b* (((unless (or (type-realp type-arg) (type-case type-arg :pointer))) (reterr msg))) (retok (type-fix type-arg)))) (:sizeof (b* (((when (type-case type-arg :function)) (reterr msg))) (retok (type-unknown)))) (t (prog2$ (impossible) (reterr t)))))))
Theorem:
(defthm typep-of-valid-unary.type (b* (((mv acl2::?erp ?type) (valid-unary expr op type-arg ienv))) (typep type)) :rule-classes :rewrite)
Theorem:
(defthm valid-unary-of-expr-fix-expr (equal (valid-unary (expr-fix expr) op type-arg ienv) (valid-unary expr op type-arg ienv)))
Theorem:
(defthm valid-unary-expr-equiv-congruence-on-expr (implies (expr-equiv expr expr-equiv) (equal (valid-unary expr op type-arg ienv) (valid-unary expr-equiv op type-arg ienv))) :rule-classes :congruence)
Theorem:
(defthm valid-unary-of-unop-fix-op (equal (valid-unary expr (unop-fix op) type-arg ienv) (valid-unary expr op type-arg ienv)))
Theorem:
(defthm valid-unary-unop-equiv-congruence-on-op (implies (unop-equiv op op-equiv) (equal (valid-unary expr op type-arg ienv) (valid-unary expr op-equiv type-arg ienv))) :rule-classes :congruence)
Theorem:
(defthm valid-unary-of-type-fix-type-arg (equal (valid-unary expr op (type-fix type-arg) ienv) (valid-unary expr op type-arg ienv)))
Theorem:
(defthm valid-unary-type-equiv-congruence-on-type-arg (implies (type-equiv type-arg type-arg-equiv) (equal (valid-unary expr op type-arg ienv) (valid-unary expr op type-arg-equiv ienv))) :rule-classes :congruence)
Theorem:
(defthm valid-unary-of-ienv-fix-ienv (equal (valid-unary expr op type-arg (ienv-fix ienv)) (valid-unary expr op type-arg ienv)))
Theorem:
(defthm valid-unary-ienv-equiv-congruence-on-ienv (implies (ienv-equiv ienv ienv-equiv) (equal (valid-unary expr op type-arg ienv) (valid-unary expr op type-arg ienv-equiv))) :rule-classes :congruence)