Extract a variable from a path.
(path-to-var path) → var
As in the static semantics, also in the dynamic semantics we require a path to consist of a single identifier. This ACL2 function makes that check, returning the identifier. This is the variable denoted by the path.
Function:
(defun path-to-var (path) (declare (xargs :guard (pathp path))) (let ((__function__ 'path-to-var)) (declare (ignorable __function__)) (b* ((idens (path->get path)) ((unless (consp idens)) (reserrf (list :empty-path (path-fix path)))) ((unless (endp (cdr idens))) (reserrf (list :non-singleton-path (path-fix path)))) (var (car idens))) var)))
Theorem:
(defthm identifier-resultp-of-path-to-var (b* ((var (path-to-var path))) (identifier-resultp var)) :rule-classes :rewrite)
Theorem:
(defthm error-info-wfp-of-path-to-var (b* ((?var (path-to-var path))) (implies (reserrp var) (error-info-wfp var))))
Theorem:
(defthm path-to-var-of-path-fix-path (equal (path-to-var (path-fix path)) (path-to-var path)))
Theorem:
(defthm path-to-var-path-equiv-congruence-on-path (implies (path-equiv path path-equiv) (equal (path-to-var path) (path-to-var path-equiv))) :rule-classes :congruence)