wam icon indicating copy to clipboard operation
wam copied to clipboard

Exercise 2.8

Open ghost opened this issue 4 years ago • 2 comments

There is a typo, it should be: ?-p(f(X), h(Y, f(a)), Y). with a capital Y.

I think that would be indeed a leap (quite a big one). Not sure, does this work with the machine? Query: ?-p(f(X), h(Y, f(a)), Y).

put-structure f|1, A1
set-variable X4
put-structure h|2, A2
set-variable X5
set-variable X6
put-value X5, A3
put-structure f|1, X6
set-variable X7
put-structure a|0, X7
call p|3

Fact: p(Z, h(Z, W), f(W)).

get-variable X4, A1
get-structure h|2, A2
unify-value X4
unify-variable X5
get-structure f|1, A3
unify-value X5
proceed

Maybe it is a breadth-first tree walk algorithm for the conversion of terms to instructions.

Why is it page 18? Isn't the exercise at page 23?

ghost avatar Apr 09 '21 13:04 ghost

Ooh, good spot. I haven’t done much with this in the last few years, so I need to refamiliarize myself before responding definitively

rm-hull avatar Apr 12 '21 11:04 rm-hull

Take your time. After working some more with the paper, the query instructions are created with a post order tree walk algorithm (this query is wrong). But fact instructions are OK.

ghost avatar Apr 12 '21 15:04 ghost