52 lines
1.2 KiB
Prolog
52 lines
1.2 KiB
Prolog
:- discontiguous male/1, female/1, parent/2.
|
|
male(dicky).
|
|
male(randy).
|
|
male(mike).
|
|
male(don).
|
|
male(elmer).
|
|
female(anne).
|
|
female(rosie).
|
|
female(esther).
|
|
female(mildred).
|
|
female(greatgramma).
|
|
male(blair).
|
|
|
|
parent(don,randy).
|
|
parent(don,mike).
|
|
parent(don,anne).
|
|
parent(rosie,randy).
|
|
parent(rosie,mike).
|
|
parent(rosie,anne).
|
|
parent(elmer,don).
|
|
parent(mildred,don).
|
|
parent(esther,rosie).
|
|
parent(esther,dicky).
|
|
parent(greatgramma,esther).
|
|
parent(randy,blair).
|
|
parent(mike,juliet).
|
|
|
|
male(mel).
|
|
male(teo).
|
|
parent(melsr,mel).
|
|
parent(melsr,teo).
|
|
|
|
father(X,Y) :- male(X),parent(X,Y).
|
|
mother(X,Y) :- female(X),parent(X,Y).
|
|
son(X,Y) :- male(X),parent(Y,X).
|
|
dauther(X,Y) :- female(X),parent(Y,X).
|
|
uncle(X,Y) :- male(X),brother(X,Z),parent(Z,Y).
|
|
aunt(X,Y) :- female(X),sister(X,Z),parent(Z,Y).
|
|
|
|
grandmother(X,Y) :- mother(Z,Y),mother(X,Z).
|
|
grandmother(X,Y) :- father(Z,Y),mother(X,Z).
|
|
|
|
grandmother(X,Y) :- female(X),parent(Z,Y),parent(X,Z).
|
|
|
|
%grandfather
|
|
sister(X,Y) :- female(X),parent(Z,X),parent(Z,Y),X\=Y.
|
|
brother(X,Y) :- male(X),parent(Z,X),parent(Z,Y),X\=Y.
|
|
cousin(X,Y) :- uncle(Z,Y),parent(Z,X).
|
|
cousin(X,Y) :- aunt(Z,Y),parent(Z,X).
|
|
|
|
ancestor(X,Y) :- parent(X,Y).
|
|
ancestor(X,Y) :- parent(X,Z),ancestor(Z,Y). |