Question: 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)
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 if you were 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.]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
