dev/prolog/parents2.pl

25 lines
617 B
Prolog

parent(abraam,isaak).
parent(abraam,petr).
parent(isaak,havriil).
parent(isaak,olga).
parent(petr,stefan).
parent(rohima,havriil).
parent(rohima,olga).
parent(havriil,masha).
parent(masha,rustam).
parent(lucefer,rustam).
grandparent(X,Z):-parent(X,Y),parent(Y,Z).
gender(abraam,male).
gender(isaak,male).
gender(petr,male).
gender(rohima,female).
gender(stefan,male).
gender(havriil,male).
gender(olga,female).
gender(masha,female).
gender(lucefer,male).
gender(rustam,male).
brother(X,Y):-parent(Z,X),parent(Z,Y),gender(X,male),gender(Y,female).
predok(X,Y):-parent(X,Y).
predok(X1,XN):-predok(X1,X2),predok(X2,XN).