1. Determine which of the following pairs of terms that... provide the mgu in case there is one:

advertisement
1. Determine which of the following pairs of terms that are unifiable, and
provide the mgu in case there is one:
(a) p(f(X),X,f(Y)) and p(Y,f(Z),Z)
(b) p(f(X),f(Y),X) and p(Z,Z,W)
(c) p(X1,X2,X3) and p(f(X2,X2),f(X3,X3),a)
(d) [X,Y|X] and [f(Z),X,X]
2. Consider the following definite program P:
p(X) :- r(X),p(X).
q(f(X),X).
r(a).
r(Y) :- q(Y,X),r(X)
Which of the following Herbrand interpretations are models of P?
I1
I2
I3
I4
= {q(f (x), x)|x ∈ UP }
= I1 ∪ {r(f 2n (a))|n ≥ 0}
= I1 ∪ {r(f n (a))|n ≥ 0}
= I1 ∪ {p(a)} ∪ {r(f n (a))|n ≥ 0}
3. Given the prolog program below, draw the complete SLD-tree for the
query :- member(X,[a,b]).
member(X,[X|_]).
member(X,[_|L]) :- member(X,L).
4. Given the same prolog program as in exercise 3, draw the complete SLDNFforest for the query:
:- member(X,[a,b]), \+ member(X,[b,c]).
5. Define the following relations on lists by means of Prolog programs. The
methods member(X,Xs) and append(X,Y,XY) may be used, if needed.
(Use of cut and/or negation is allowed, but not required.)
replace(Xs, X, Y, Ys)
sublist(List,Sub)
uniquify(List, UList)
Ys is the list Xs with all occurences of X replaced by Y.
List contains Sub as a sublist.
UList contains every element in List exactly
once (in any order).
6. Consider the immediate consequence operator TP . Prove that an Herbrand interpretation I cannot be a model of P unless TP (I) ⊆ I.
7. Formulate the completeness theorem of SLD-resolution and give an example of a definite program P and a definite goal ← A such that P |= Aθ,
but there is no computed answer substitution σ such that Aσ = Aθ.
1
Download