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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!