Add a namespace to a variable so that it can be referenced from a lower hierarchy level.
(svar-add-namespace namespace x) → x
If the scope modifier of the address is
Function:
(defun svar-add-namespace (namespace x) (declare (xargs :guard (and (name-p namespace) (svar-p x)))) (declare (xargs :guard (svar-addr-p x))) (let ((__function__ 'svar-add-namespace)) (declare (ignorable __function__)) (b* (((svar x) (svar-addr-fix x)) ((address x.name)) ((when (eq x.name.scope :root)) (mbe :logic (change-svar x :name (change-address x.name)) :exec x)) (new-addr (if (eql 0 x.name.scope) (change-address x.name :path (make-path-scope :namespace namespace :subpath x.name.path)) (change-address x.name :scope (1- x.name.scope))))) (change-svar x :name new-addr))))
Theorem:
(defthm return-type-of-svar-add-namespace (b* ((x (svar-add-namespace namespace x))) (and (svar-p x) (svar-addr-p x))) :rule-classes :rewrite)
Theorem:
(defthm svar-add-namespace-of-name-fix-namespace (equal (svar-add-namespace (name-fix namespace) x) (svar-add-namespace namespace x)))
Theorem:
(defthm svar-add-namespace-name-equiv-congruence-on-namespace (implies (name-equiv namespace namespace-equiv) (equal (svar-add-namespace namespace x) (svar-add-namespace namespace-equiv x))) :rule-classes :congruence)
Theorem:
(defthm svar-add-namespace-of-svar-fix-x (equal (svar-add-namespace namespace (svar-fix x)) (svar-add-namespace namespace x)))
Theorem:
(defthm svar-add-namespace-svar-equiv-congruence-on-x (implies (svar-equiv x x-equiv) (equal (svar-add-namespace namespace x) (svar-add-namespace namespace x-equiv))) :rule-classes :congruence)