Read a variable value from the computation state.
(read-var-value var cstate) → val
An error is returned if the variable does not exist.
Function:
(defun read-var-value (var cstate) (declare (xargs :guard (and (identifierp var) (cstatep cstate)))) (let ((__function__ 'read-var-value)) (declare (ignorable __function__)) (b* ((lstate (cstate->local cstate)) (var-val (omap::assoc (identifier-fix var) lstate)) ((unless (consp var-val)) (reserrf (list :variable-not-found (identifier-fix var))))) (value-fix (cdr var-val)))))
Theorem:
(defthm value-resultp-of-read-var-value (b* ((val (read-var-value var cstate))) (value-resultp val)) :rule-classes :rewrite)
Theorem:
(defthm error-info-wfp-of-read-var-value (b* ((?val (read-var-value var cstate))) (implies (reserrp val) (error-info-wfp val))))
Theorem:
(defthm read-var-value-of-identifier-fix-var (equal (read-var-value (identifier-fix var) cstate) (read-var-value var cstate)))
Theorem:
(defthm read-var-value-identifier-equiv-congruence-on-var (implies (identifier-equiv var var-equiv) (equal (read-var-value var cstate) (read-var-value var-equiv cstate))) :rule-classes :congruence)
Theorem:
(defthm read-var-value-of-cstate-fix-cstate (equal (read-var-value var (cstate-fix cstate)) (read-var-value var cstate)))
Theorem:
(defthm read-var-value-cstate-equiv-congruence-on-cstate (implies (cstate-equiv cstate cstate-equiv) (equal (read-var-value var cstate) (read-var-value var cstate-equiv))) :rule-classes :congruence)