taocp

This site has no text of the book. Keep your own copy of TAOCP next to it. See what is checked.

Exercise · Volume 1 · 2.1-2

Exercise 2.1-2

not stated yet in Lean solution written

Rating10
KindK3, find a value: compute a number, a set or a closed form from the written solution
SectionSection 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 VV is the address of a memory word. Then CONTENTS(V) is the variable that sits in the word at address VV. LOC of a variable is the address of the word that holds it, and this address is VV. So the identity holds whenever V is a link variable whose value is not Λ\Lambda and is the address of a word.

If V=ΛV = \Lambda, no word has this address, and CONTENTS(V) has no meaning. If VV is not a link, for example a plain number that is not an address, the same is true.

Check

Take V=1000V = 1000. Then CONTENTS(V) is the word in location 10001000, and the address of this word is 1000=V1000 = V.

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.