RESULTS FROM A.D.A. PROLOG – Prolog Assignment #2
?-consult assign2.
Compiling assign2.
Yes.
?-likes(mike,food).
No.
?-likes(mary,mike).
Yes.
?-likes(sarah,joe).
No.
?-likes(joe,What).
What = beer
More? (Y/N):y
What = sarah
More? (Y/N):y
No.
?-likes(Who,beer).
Who = mike
More? (Y/N):y
Who = joe
More? (Y/N):y
No.
?-likes(Who,What).
Who = sarah,
What = food
More? (Y/N):y
Who = mike,
What = beer
More? (Y/N):y
Who = joe,
What = beer
More? (Y/N):y
Who = joe,
What = sarah
More? (Y/N):y
Who = mary,
What = candy
More? (Y/N):y
Who = mary,
What = mike
?-likes(_,What).
What = food
More? (Y/N):y
What = beer
More? (Y/N):y
What = beer
More? (Y/N):y
What = sarah
More? (Y/N):y
What = candy
More? (Y/N):y
What = mike
?-likes(Z,_).
Z = sarah
More? (Y/N):y
Z = mike
More? (Y/N):y
Z = joe
More? (Y/N):y
Z = joe
More? (Y/N):y
Z = mary
More? (Y/N):y
Z = mary
/* Joe likes anything that
Sarah likes */
likes(joe,X) :-
likes(sarah,X).
/* Joe likes anyone who likes
beer */
likes(joe,X) :-
likes(X,beer).