Exercise 12.15 The aim of this question is to get practice writing simple logic programs. (a) Write
Question:
Exercise 12.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 resulting list of 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.
Step by Step Answer:
Artificial Intelligence Foundations Of Computational Agents
ISBN: 9780521519007
1st Edition
Authors: David L. Poole, Alan K. Mackworth