AI (Assignment - 7)

profilepinky143
Assignment-7-HW.docx

Artificial Intelligence Methods ASSIGNMENT 7

The following graph shows some part of the parent relationship. For example, jan is a parent of feb

and mar.

jan aaa

feb mar bba bbc bbd

apr may cca ccb ccd

jun dda ddb ddc ddd

eee eeb

(1). Write a Prolog program to include the above information and save it as yourlastname.pl. If your last name is John, then save it as john.pl. You also need to add the followings into yourlastname.pl.

male(aaa). female(bba). male(bbc). female(bbd). male(cca). male(ccb). male(ccd). female(dda). male(ddb). female(ddc). male(ddd). female(eee). male(eeb). male(jan). female(feb). female(mar). female(apr). female(may). female(jun). husband(ccd, may).

(2) Write the following four rules into yourlastname.pl.

· ancestor(X, Y) : X is an ancestor of Y.

( 1 )

· descendent(X,Y): X is a descendent of Y.

· motherinlaw(X,Y): X is a mother-in-law of Y.

· nephew(X,Y): X is a nephew of Y.

If you want, you can make your rules and use them. For example, “grandparent(X, Y) :- parent(X, Y), parent(Y, Z)”. But, you can not have “grandparent(aaa, cca)”, “grandparent(aaa, ccb),…”.

After you add the required rules, run (test) the followings and submit the results.

· Run ancestor(bbd, Y). Submit all generated result for Y by running your program.

· Run descendent(eee, Y). Submit all generated result for Y by running your program.

· Run motherinlaw(X, Y). Submit all generated result for X and Y by running your program.

· Run nephew(X, Y). Submit all generated result for X and Y by running your program.

If you need an operation not, use the operator “not” ( \== ), like X\==Y.

You need to submit the followings:

1. a printed source program list

2. a printed output by running the required questions in (2)

3. your source program file