Untitled
unknown
prolog
3 years ago
1.4 kB
21
Indexable
mother(X,Y):- /* mother of X is Y */
parent(X,Y),
female(Y).
father(X,Y):- /* father of X is Y */
parent(X,Y),
male(Y).
son(X,Y):-
parent(Y,X),
male(X).
daughter(X,Y):-
parent(Y,X),
female(X).
husbandwife(X,Y) :- /* X is a husband of Y wife */
father(Z,X),
mother(Z,Y),
X \= Y.
sibling(X,Y) :- /* X is a sibling of Y */
father(X,Z),
father(Y,Z),
X \= Y.
grandfather(X,Y):- /* X is grandfather of Y */
parent(Y,Z),
parent(Z,X),
male(X).
grandmother(X,Y):-
parent(Y,Z),
parent(Z,X),
female(X).
aunt(X,C,Y):-
cousin(Y,C),
mother(C,X),
aunt(X,Y) \= aunt(X,C,Y).
uncle(X,C,Y):- /* X = person to be checked for being uncle
C = son of X,
Y = nephew/niece of the uncle X.
query example:- uncle(possibleUncle,p_Uncle's_Child,possibleNephew/Niece)
same goes with aunt
*/
cousin(Y,C),
father(C,X).
cousinbrother(X,Y):- /* X is cousin brother of Y */
parent(X,Z),
parent(Y,W),
sibling(Z,W),
male(X).
cousinsister(X,Y):- /* X is cousin sister of Y */
parent(X,Z),
parent(Y,W),
sibling(Z,W),
female(X).
cousin(X,Y):- /* X is cousin of Y */
parent(X,Z),
parent(Y,W),
sibling(Z,W).
Editor is loading...