domains
person=symbol
predicates
male(person)
female(person)
mother(person,person)
father(person,person)
marryto(person,person)
sister(person,person)
uncle(person,person)
cousin(person,person)
grandfather(person,person)
fai(person,person)
motherinlow(person,person)
brotherinlow(person,person)
sisterinlow(person,person)
uncle1(person)
cousin1(person)
clauses
male(jayanti).
male(pravin).
male(prakash).
male(ravi).
male(kamalesh).
male(bharat).
female(champa).
female(geeta).
female(hiral).
female(hemina).
female(bina).
father(jayanti,pravin).
father(jayanti,prakash).
father(jayanti,kamalesh).
father(jayanti,bharat).
father(jayanti,bina).
father(pravin,hemina).
father(pravin,hiral).
father(pravin,ravi).
father(prakash,sani).
father(kamalesh,margi).
father(bharat,meshwa).
mother(geeta,hemina).
mother(geeta,hiral).
mother(geeta,ravi).
mother(champa,pravin).
mother(champa,prakash).
mother(champa,bina).
marryto(jayanti,champa).
marryto(pravin,geeta).
sister(X,Y):-
female(X),
father(Z,X),
father(Z,Y),
mother(M,X),
mother(M,Y),
marryto(Z,M),
X<>Y.
uncle(X,Y):-
male(X),
father(P,Y),
father(Z,P),
father(Z,X).
uncle1(X):-
father(J,P),
father(P,X),
father(J,K),
P<>K,
male(K),
write(K),nl,
fail.
cousin(X,Y):-
father(P,X),
father(Z,Y),
father(J,P),
father(J,Z),
marryto(J,C),
mother(C,P),
mother(C,Z),
X<>Y.
cousin1(X):-
father(P,X),
father(J,P),
father(J,K),
father(K,S),
X<>S, %will not display own name
P<>K, %will not display name of real brother,sister
write(S),nl,
fail.
grandfather(X,Y):-
male(X),
father(P,Y),
mother(G,Y),
marryto(P,G),
father(Z,P),
mother(M,P),
marryto(Z,M).
fai(X,Y):-
female(X),
father(J,X),
father(P,Y),
father(J,P),
marryto(J,C),
mother(C,X),
mother(C,P).
motherinlow(X,Y):-
female(X),
mother(X,P),
marryto(P,Y).
brotherinlow(X,Y):-
male(X),
marryto(P,Y),
father(J,P),
father(J,X).
sisterinlow(X,Y):-
female(X),
marryto(P,Y),
mother(C,P),
mother(C,X).
Output
Goal: cousin1(hiral)
sani
margi
meshwa
No
Goal: uncle1(hiral)
prakash
kamalesh
bharat
No
Goal: