TAOCP 2.1 Exercise 2
We have $\operatorname{LOC}(\operatorname{CONTENTS}(V)) = V$ precisely when $V$ is itself the location of some variable.
Exercise 2. [10] The text points out that in many cases CONTENTS(LOC(V)) = V. Under what conditions do we have LOC(CONTENTS(V)) = V?
Verified: no
Solve time: -
We have $\operatorname{LOC}(\operatorname{CONTENTS}(V)) = V$ precisely when $V$ is itself the location of some variable. In other words, there must exist a variable $W$ such that
$$ V=\operatorname{LOC}(W). $$
Then
$$ \operatorname{CONTENTS}(V) = \operatorname{CONTENTS}(\operatorname{LOC}(W)) = W, $$
by the definition of $\operatorname{LOC}$. Hence
$$ \operatorname{LOC}(\operatorname{CONTENTS}(V)) = \operatorname{LOC}(W) = V. $$
If $V$ is not a location corresponding to any variable, then $\operatorname{CONTENTS}(V)$ does not determine a variable whose location is necessarily $V$, and the equation need not hold. Thus the condition is that $V$ be the location of a variable, that is, $V$ must lie in the range of the function $\operatorname{LOC}$. ∎