Question: Assume we have the following knowledge base in a Prolog program: man(jack). man(peter). woman(rebeca). woman(julia). woman(maria). hasWand(rebeca). hasWand(maria). hasWand(jack). quidditchPlayer(jack). quidditchPlayer(rebeca). quidditchPlayer(maria). quidditchPlayer(peter). playsAirGuitar(julia). playsAirGuitar(adam).
Assume we have the following knowledge base in a Prolog program:
man(jack).
man(peter).
woman(rebeca).
woman(julia).
woman(maria).
hasWand(rebeca).
hasWand(maria).
hasWand(jack).
quidditchPlayer(jack).
quidditchPlayer(rebeca).
quidditchPlayer(maria).
quidditchPlayer(peter).
playsAirGuitar(julia).
playsAirGuitar(adam).
playsAirGuitar(rebeca).
playsAirGuitar(mary).
playsAirGuitar(jack).
wizard (jack).
hasBroom(X) :- quidditchPlayer(X).
warlock(X) :- man(X), hasBroom(X), hasWand(X).
witch(X) :- woman(X), hasBroom(X), hasWand(X).
wizard(X):- warlock(X) ; witch(X). % note: semicolon was used here
Determine the type of each of the following queries (ground/non-ground), and explain what will Prolog respond for each of these queries (write all the steps of unifications and resolutions for each query)?
?-wizard(jack).
?-witch(jack).
?-warlock(jack).
?-witch(maria).
?-warlock(Y).
?-witch(Y).
?-wizard(X).
?-hasBroom(X).
?-playsAirGuitar(Y), witch(Y).
?-witch(Y), witch(maria).
?-hasBroom(X), !, playsAirGuitar(Y) % note there is a cut (!) here
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
