Exercise 12.14 Consider the following logic program: ap(emp, L, L). ap(c(H, T), L, c(H, R)) ap(T,

Question:

Exercise 12.14 Consider the following logic program:

ap(emp, L, L).

ap(c(H, T), L, c(H, R)) ←

ap(T, L, R).

adj(A, B, L) ←

ap(F, c(A, c(B, E)), L).

(a) Give a top-down derivation (including all substitutions) for one answer to the query ask adj

(b, Y, c

(a, c

(b, c

(b, c

(a, emp))))).

(b) Are there any other answers? If so, explain where a different choice could be made in the derivation in the previous answer, and continue the derivation, showing another answer. If there are no other answers, explain why not.

[You are meant to do this exercise as would a computer, without knowing what the symbols mean. If you want to give a meaning to this program, you could read ap as append, c as cons, emp as empty, and adj as adjacent.]

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: