Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Write a PROLOG program that investigates family relationships using 1ists. Th

ID: 3729564 • Letter: 1

Question

1. Write a PROLOG program that investigates family relationships using 1ists. The facts should be organized as follows: m([first male name, second male name, , last male name] ). f([first female name, second female name, family father, mother, [child_1, child_2, . . . , child_n] ..., last female name]) . Write rules that define the following relations: male (X) female (X) father, mother, parent sibling, siblings2 brother, brother2 sister1, sister2 uncle, aunt grandchild, grandson, granddaughter greatgrandparent ancestor For each of these rules show an example of its use.

Explanation / Answer

ANSWER:

y.trace

Predicates

Father(symbol,symbol)

Mother(symbol,symbol)

Male(symbol)

Female(symbol)

Sister(symbol,symbol)

Brother(symbol,symbol)

Uncle(symbol,symbol)

Wife(symbol,symbol)

Aunty(symbol,symbol)

Bhabi(symbol,symbol)

Cousine(symbol, symbol)

Nephew(symbol, symbol)

Grandson(symbol, symbol)

Grand daughter(symbol, symbol)

                Clauses

Sister(x,y):-father(X,A),father(Y,A),female(Y)

Father(male1,male2)

Father(male3,male4)

Father(male5,male6)

Mother(female1,female2)

Mother(X,Y):-father(X,Z),wife(Y,Z)

Brother(X,Y):-father(X,A),father(Y,A)male(X)

Brother(X,Y):-brother(Y,X)

Male(male1)

Male(male2)

Male(male3)

Male(male4)

Female(female1)

Female(female2)

Female(female3)

Female(female4)

Wife(male1,female1)

Wife2(male2,female2)

Wife(male3,female3)

Grandson(x,x):father(A,Y),father(X,A),male(X)

Uncle(X,Y):-father(X,Z)

Aunty(X,Y):-wife(Y,Z);

                                Brother(Z,W);

                     Father(X,W);

Cousin(X,Y)

Nephew(X,Y):-wife(Y,A),male(X)