Question: Programming in Prolog Write a Prolog relation remove(E,L,R) that is true if R is the list which results from removing one instance of E from
Programming in Prolog
Write a Prolog relation remove(E,L,R) that is true if R is the list which results from removing one instance of E from list L. The relation is false if E isnt a member of L.
What are 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).
3. Write a Prolog relation subsequence(L1,L2) that is true if list L1 contains a subset of the elements of L2 in the same order.
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 Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
