Add a variable with a value to the computation state.
(add-var-value var val cstate) → new-cstate
An error is returned if the variable already exists.
Function:
(defun add-var-value (var val cstate) (declare (xargs :guard (and (identifierp var) (valuep val) (cstatep cstate)))) (let ((__function__ 'add-var-value)) (declare (ignorable __function__)) (b* ((lstate (cstate->local cstate)) (var-val (omap::assoc (identifier-fix var) lstate)) ((when (consp var-val)) (reserrf (list :variable-already-exists (identifier-fix var)))) (new-lstate (omap::update (identifier-fix var) (value-fix val) lstate)) (new-cstate (change-cstate cstate :local new-lstate))) new-cstate)))
Theorem:
(defthm cstate-resultp-of-add-var-value (b* ((new-cstate (add-var-value var val cstate))) (cstate-resultp new-cstate)) :rule-classes :rewrite)
Theorem:
(defthm error-info-wfp-of-add-var-value (b* ((?new-cstate (add-var-value var val cstate))) (implies (reserrp new-cstate) (error-info-wfp new-cstate))))
Theorem:
(defthm add-var-value-of-identifier-fix-var (equal (add-var-value (identifier-fix var) val cstate) (add-var-value var val cstate)))
Theorem:
(defthm add-var-value-identifier-equiv-congruence-on-var (implies (identifier-equiv var var-equiv) (equal (add-var-value var val cstate) (add-var-value var-equiv val cstate))) :rule-classes :congruence)
Theorem:
(defthm add-var-value-of-value-fix-val (equal (add-var-value var (value-fix val) cstate) (add-var-value var val cstate)))
Theorem:
(defthm add-var-value-value-equiv-congruence-on-val (implies (value-equiv val val-equiv) (equal (add-var-value var val cstate) (add-var-value var val-equiv cstate))) :rule-classes :congruence)
Theorem:
(defthm add-var-value-of-cstate-fix-cstate (equal (add-var-value var val (cstate-fix cstate)) (add-var-value var val cstate)))
Theorem:
(defthm add-var-value-cstate-equiv-congruence-on-cstate (implies (cstate-equiv cstate cstate-equiv) (equal (add-var-value var val cstate) (add-var-value var val cstate-equiv))) :rule-classes :congruence)