Add Parents.pro
This commit is contained in:
parent
5bf394642c
commit
4b31764558
|
@ -0,0 +1,54 @@
|
|||
% create parent relation ship
|
||||
parent(adam, kain).
|
||||
parent(eva, kain).
|
||||
parent(adam, abel).
|
||||
parent(eva, abel).
|
||||
parent(adam, seth).
|
||||
parent(eva, seth).
|
||||
parent(sara, peter).
|
||||
parent(abel, peter).
|
||||
parent(sara, gunter).
|
||||
parent(abel, gunter).
|
||||
parent(seth, garfield).
|
||||
parent(hela, garfield).
|
||||
|
||||
parent(bor, odin).
|
||||
parent(odin, thor).
|
||||
parent(odin, loki).
|
||||
|
||||
% create sex relation ship
|
||||
male(adam).
|
||||
male(peter).
|
||||
male(gunter).
|
||||
male(kain).
|
||||
male(abel).
|
||||
female(eva).
|
||||
female(hela).
|
||||
female(sara).
|
||||
|
||||
male(odin).
|
||||
male(thor).
|
||||
male(loki).
|
||||
female(loki).
|
||||
|
||||
father(F,C):-parent(F,C),male(F).
|
||||
mother(M,C):-parent(M,C),female(M).
|
||||
|
||||
grandparent(G, C):-parent(P,C),parent(G,P).
|
||||
grandfather(G, C):-parent(P,C),parent(G,P),male(G).
|
||||
grandmother(G, C):-parent(P,C),parent(G,P),female(G).
|
||||
|
||||
related(A,A).
|
||||
related(A,B):-parent(A,B).
|
||||
related(A,B):-parent(P,A),related(P,B).
|
||||
|
||||
% if A and B are siblings
|
||||
siblings(A,B):-parent(P,A),parent(P,B).
|
||||
% true if S is the a sister of A
|
||||
sister(A,S):-siblings(A,S),female(S).
|
||||
% true if B is the a brother of A
|
||||
brother(A,B):-siblings(A,B),male(B).
|
||||
|
||||
aunt(A,B):-parent(P,B),sister(A,P).
|
||||
uncle(A,B):-parent(P,B),brother(A,P).
|
||||
|
Loading…
Reference in New Issue