Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % parent(X,Y) means that person X is a parent (father or mother) of person Y
- parent(alex,julia).
- parent(alex,rosa).
- parent(robi,alex).
- parent(robi,jon).
- parent(lina,julia).
- parent(lina,rosa).
- parent(romeo,peter).
- parent(julia,peter).
- parent(rosa,silvia).
- parent(oscar,ida).
- parent(eva,ida).
- parent(eva,bruno).
- parent(peter,bruno).
- parent(peter,georg).
- parent(peter,irma).
- parent(ruth,georg).
- parent(ruth,irma).
- parent(silvia,otto).
- parent(silvia,pascal).
- parent(irma,olga).
- parent(irma,jean).
- parent(otto,olga).
- parent(otto,jean).
- parent(jean,tina).
- parent(marie,tina).
- % male(X) means that X is a male person
- male(alex).
- male(romeo).
- male(oscar).
- male(peter).
- male(bruno).
- male(georg).
- male(otto).
- male(pascal).
- male(jean).
- male(jon).
- % husband(X,Y) means that person X is the husband of person Y
- husband(alex,lina).
- husband(romeo,julia).
- husband(oscar,eva).
- husband(peter,ruth).
- husband(otto,irma).
- husband(jean,marie).
- % female
- female(X) :- \+ male(X).
- % father
- father(X,Y) :- parent(X,Y),male(X).
- % mother
- mother(X,Y) :- parent(X,Y),female(X).
- % son
- son(X,Y) :- male(X),parent(Y,X).
- % daughter
- daughter(X,Y) :- female(X),parent(Y,X).
- % sibling
- sibling(X,Y) :-
- parent(Z, X),
- parent(Z, Y),
- X \= Y.
- % Brother
- brother(X,Y) :-
- parent(Z, X),
- parent(Z, Y),
- X \= Y,
- male(X).
- % sister
- sister(X,Y) :-
- parent(Z, X),
- parent(Z, Y),
- X \= Y,
- female(X).
- % wife
- wife(X,Y) :-
- female(X),
- husband(Y,X).
- %married
- married(X,Y) :-
- husband(X,Y);
- wife(X,Y).
- % grandchild
- grandchild(X,Y) :-
- parent(Z, X),
- parent(Y, Z).
- % grandparent
- grandparent(X,Y) :-
- parent(X, Z),
- parent(Z, Y).
- % grandfather
- grandfather(X,Y) :-
- male(X),
- parent(X, Z),
- parent(Z, Y).
- % grandmother
- grandmother(X,Y) :-
- female(X),
- parent(X, Z),
- parent(Z, Y).
- % uncle
- uncle(X,Y) :-
- male(X),
- parent(Z, Y),
- brother(X, Z).
- % halfbrother
- commonmother(X,Y):-
- mother(Z,X),
- mother(Z,Y).
- commonfather(X,Y):-
- father(Z,X),
- father(Z,Y).
- halfbrother(X,Y) :-
- male(X),
- commonmother(X,Y),
- \+commonfather(X, Y);
- male(X),
- commonfather(X,Y),
- \+commonmother(X, Y).
- % halfsister
- halfsister(X,Y) :-
- female(X),
- commonmother(X,Y),
- \+commonfather(X, Y);
- female(X),
- commonfather(X,Y),
- \+commonmother(X, Y).
- % stepbrother
- stepbrother(X,Y) :-
- male(X),
- father(Z,X),
- mother(W,Y),
- married(Z,W);
- male(X),
- mother(Z,X),
- father(W,Y),
- married(Z,W).
- % stepsister
- stepsister(X,Y) :-
- female(X),
- father(Z,X),
- mother(W,Y),
- married(Z,W);
- female(X),
- mother(Z,X),
- father(W,Y),
- married(Z,W).
- % ancestor
- ancestor(X,Y) :- parent(X,Y).
- ancestor(X,Y) :- parent(X,Z),ancestor(Z,Y).
- % descendant
- descendant(X,Y) :- parent(Y,X).
- descendant(X,Y) :- parent(Z,X),ancestor(Y,Z).
- % Father-in-law
- fatherinlaw(X,Y) :-
- father(X,Z),
- husband(Z,Y);
- father(X,Z),
- wife(Z,Y).
- % mother-in-law
- motherinlaw(X,Y) :-
- mother(X,Z),
- married(Z,Y).
- % familycomn
- familycommon(X,Y):-
- father(X,Y);
- mother(X,Y);
- sister(X,Y);
- brother(X,Y);
- son(X,Y);
- daughter(X,Y);
- sibling(X,Y);
- married(X,Y);
- grandchild(X,Y);
- grandparent(X,Y);
- grandfather(X,Y);
- grandmother(X,Y);
- uncle(X,Y) ;
- halfbrother(X,Y);
- halfsister(X,Y);
- stepbrother(X,Y);
- stepsister(X,Y);
- ancestor(X,Y) ;
- fatherinlaw(X,Y);
- motherinlaw(X,Y);
- motherinlaw(Z,X),
- motherinlaw(Z,Y);
- fatherinlaw(Z,X),
- fatherinlaw(Z,Y).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement