Exercise · Volume 1 · 2.1-2
Exercise 2.1-2
not stated yet in Lean solution written
| Rating | 10 |
|---|---|
| Kind | K3, find a value: compute a number, a set or a closed form from the written solution |
| Section | Section 2.1 of Volume 1 |
The task
State when LOC(CONTENTS(V)) = V holds, as a counterpart of the rule CONTENTS(LOC(V)) = V.
The exact wording is in your copy of the book.
Hints
Open one hint at a time. Try the exercise again after each.
Hint 1
Think about what each of the two operations needs as its argument: a value, or an address.
Solution
Show the solution
CONTENTS(V) is defined only when V is a link to a one-word node, that is, when is the address of a memory word. Then CONTENTS(V) is the variable that sits in the word at address . LOC of a variable is the address of the word that holds it, and this address is . So the identity holds whenever V is a link variable whose value is not and is the address of a word.
If , no word has this address, and CONTENTS(V) has no meaning. If is not a link, for example a plain number that is not an address, the same is true.
Check
Take . Then CONTENTS(V) is the word in location , and the address of this word is .
Remarks
The rule CONTENTS(LOC(V)) = V holds for every variable that fills a whole word, with no condition on its value. The rule of this exercise needs a condition on the value. The section advises to avoid LOC in contexts of this kind.
This solution is drafted, and a person has not reviewed it yet. The source.
In Lean
not stated yet The exercise is not stated in Lean yet.
The status is computed from the Lean build. The node of the map.
Something is wrong? Report it.