15. The aim of this question is to get practice writing simple logic programs. (a) Write a...

Question:

15. The aim of this question is to get practice writing simple logic programs.

(a) Write a relation remove(E, L, R) that is true if R is the list resulting from removing one instance of E from list L. The relation is false if E is not a member of L.

(b) Give all of the answers to the following queries:

ask remove

(a, [b,

a, d, a], R) .

ask remove(E, [b,

a, d, a], R) .

ask remove(E, L, [b,

a, d]) .

ask remove(p(X), [a, p(a), p(p(a)), p(p(p(a)))], R) .

(c) Write a relation subsequence(L1, L2) that is true if list L1 contains a subset of the elements of L2 in the same order.

(d) How many different proofs are there for each of the following queries:

ask subsequence([a, d], [b,

a, d, a]) .

ask subsequence([b, a], [b,

a, d, a]) .

ask subsequence([X, Y], [b,

a, d, a]) .

ask subsequence(S, [b,

a, d, a]) .

Explain why there are that many.

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

Step by Step Answer:

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