Execute a unary operation on an expression value.
(exec-unary op arg compst) → eval
This ACL2 function
wraps eval-unary to take and return expression values,
and covers the remaining two unary operators
Before calling eval-unary,
we perform array-to-pointer conversion [C:5.3.2.1/3].
The functions handle
Function:
(defun exec-unary (op arg compst) (declare (xargs :guard (and (unopp op) (expr-valuep arg) (compustatep compst)))) (let ((__function__ 'exec-unary)) (declare (ignorable __function__)) (case (unop-kind op) (:address (exec-address arg)) (:indir (exec-indir arg compst)) (t (b* ((arg (apconvert-expr-value arg)) ((when (errorp arg)) arg) (val (eval-unary op (expr-value->value arg))) ((when (errorp val)) val)) (make-expr-value :value val :object nil))))))
Theorem:
(defthm expr-value-resultp-of-exec-unary (b* ((eval (exec-unary op arg compst))) (expr-value-resultp eval)) :rule-classes :rewrite)
Theorem:
(defthm exec-unary-of-unop-fix-op (equal (exec-unary (unop-fix op) arg compst) (exec-unary op arg compst)))
Theorem:
(defthm exec-unary-unop-equiv-congruence-on-op (implies (unop-equiv op op-equiv) (equal (exec-unary op arg compst) (exec-unary op-equiv arg compst))) :rule-classes :congruence)
Theorem:
(defthm exec-unary-of-expr-value-fix-arg (equal (exec-unary op (expr-value-fix arg) compst) (exec-unary op arg compst)))
Theorem:
(defthm exec-unary-expr-value-equiv-congruence-on-arg (implies (expr-value-equiv arg arg-equiv) (equal (exec-unary op arg compst) (exec-unary op arg-equiv compst))) :rule-classes :congruence)
Theorem:
(defthm exec-unary-of-compustate-fix-compst (equal (exec-unary op arg (compustate-fix compst)) (exec-unary op arg compst)))
Theorem:
(defthm exec-unary-compustate-equiv-congruence-on-compst (implies (compustate-equiv compst compst-equiv) (equal (exec-unary op arg compst) (exec-unary op arg compst-equiv))) :rule-classes :congruence)