. 1. (a) Not unifiable (Z = f (f (f (Z))) fails)

advertisement
.
1. (a) Not unifiable (Z = f (f (f (Z))) fails)
(b) {X/W, Y /W, Z/f (W )}
(c) {X1/f (f (a, a), f (a, a)), X2/f (a, a), X3/a})
.
(d) Not unifiable (X = [X] fails)
2. I3 and I4 . (I1 is not a model for line 3 and I2 is not a model for line 4)
3.
← member(X, [a, b]).
??

??

??



← member(X, [b]).
??

??

??



← member(X, []).
FF
4.
← member(X, [a, b]), ¬member(X, [b, c]).
OOO
o
OOO
ooo
o
OOO
o
ooo
← ¬member(a, [b, c]). ← member(X, [b]), ¬member(X, [b, c]).
OOO
o
OOO
ooo
o
OOO
o
o
o
o
← member(X, []), ¬member(X, [b, c]).
← ¬member(b, [b, c]).
FF
FF
← member(a, [b, c]).
← member(a, [c]).
← member(b, [b, c]).
??

??

??



← member(b, [c].)
← member(a, []).
← member(b, []).
FF
FF
1
5.
replace(Xs, X, Y, Ys)
sublist(List,Sub)
Alternatively:
uniquify(List, UList)
Alternatively:
replace([], , ,[]).
replace([X|Xs],X,Y,[Y|Ys]) :replace(Xs,X,Y,Ys).
replace([Z|Xs],X,Y,[Z|Ys]) :Z \= X,
replace(Xs,X,Y,Ys).
sublist(Ls, Ss) :prefix(Ss,Ls).
sublist([X|Ls], Ss) :sublist(Ls,Ss).
prefix(Pre,List) :append(Pre, ,List).
slalt(L,S) :append(L1, , L),
append( , S, L1).
uniquify([], []).
uniquify([L|Ls], ULs) :uniquify(Ls, ULs),
member(L,ULs).
uniquify([L|Ls], [L|ULs]) :uniquify(Ls, ULs),
\+member(L,ULs).
ualt(L,UL) :setof(X, member(X,L), UL).
The negations guarantee that we only get one answer. Without them,
the first answer would be correct, but we would get further answers that
would be incorrect. Cuts in the right places would fill the same function.
Note that for the negations to work right, the terms need to be grounded.
6. Assume that we have a program P and a Herbrand interpretation I. Further assume that TP (I) 6⊆ I i.e. there exists some A ∈ TP (I) such
that A 6∈ I. By definition of TP (I), this means that there exists some
A ← A1 , . . . , Am in ground(P ) such that A1 , . . . , Am ∈ I. In other words,
there is an instance of a clause in P such that every part of the body is
true in I. Since A 6∈ I, I is not a model for this clause, and therefore not
a model for P .
7. The completeness theorem of SLD-resolution is found on page 51 of the
book. An example of a program P and a goal A as requested is found in
the example immediately afterwards. (The key is that Aσ might be more
general than Aθ, so that for instance Aσ contains a variable where Aθ
contains a constant.)
2
Download