Add a variable to a variable table.
(add-var var varset) → varset?
If a variable with the same name is already in the table, an error is returned.
If this function does not return an error, it is equivalent to insert.
Function:
(defun add-var (var varset) (declare (xargs :guard (and (identifierp var) (identifier-setp varset)))) (let ((__function__ 'add-var)) (declare (ignorable __function__)) (b* ((var (identifier-fix var)) (varset (identifier-set-fix varset))) (if (in var varset) (reserrf (list :duplicate-variable var)) (insert var varset)))))
Theorem:
(defthm identifier-set-resultp-of-add-var (b* ((varset? (add-var var varset))) (identifier-set-resultp varset?)) :rule-classes :rewrite)
Theorem:
(defthm add-var-to-set-insert (b* ((varset1 (add-var var varset))) (implies (not (reserrp varset1)) (equal varset1 (insert (identifier-fix var) (identifier-set-fix varset))))))
Theorem:
(defthm add-var-of-identifier-fix-var (equal (add-var (identifier-fix var) varset) (add-var var varset)))
Theorem:
(defthm add-var-identifier-equiv-congruence-on-var (implies (identifier-equiv var var-equiv) (equal (add-var var varset) (add-var var-equiv varset))) :rule-classes :congruence)
Theorem:
(defthm add-var-of-identifier-set-fix-varset (equal (add-var var (identifier-set-fix varset)) (add-var var varset)))
Theorem:
(defthm add-var-identifier-set-equiv-congruence-on-varset (implies (identifier-set-equiv varset varset-equiv) (equal (add-var var varset) (add-var var varset-equiv))) :rule-classes :congruence)