% -----------------------------------------
% Logische Programmierung, ueb 1, 4.11.2002
% (c)Marc Dörflinger, Roger, Philip Iezzi
% -----------------------------------------

male(paul).
male(sidney).
male(sam).
male(robert).
female(beverley).
female(fay).
female(mary).
female(lena).
female(pamela).           % NEW!
female(heidi).            % NEW!
female(heather).          % NEW!
father(sam, paul).
father(sidney, beverley).
father(sidney, heidi).    % NEW!
father(sam, fay).
father(paul, mary).
father(sam, robert).      % NEW!
mother(beverley, mary).
mother(lena, paul).
mother(pamela,fay).       % NEW!
mother(lena, robert).     % NEW!
mother(heather,heidi).    % NEW!
mother(heather,beverley). % NEW!



% ----------------
% Parents
% ----------------

parent(Parent, Child) :- 	% a parent is
	father(Parent,Child). 	% a father, or
	
parent(Parent, Child) :-
	mother(Parent,Child). 	% a mother
	

% ----------------
% Ancestors
% ----------------

ancestor(X,Y) :- 		% an ancestor is
	parent(X,Y). 		% a parent, or
	
ancestor(X,Y) :-
	parent(X,Z), 		% the parent of
	ancestor(Z,Y). 		% an ancestor

% ----------------
% Brother / Sister
% ----------------

brother(X,Y) :-			% X is brother of Y
	male(X),
	father(F,X),
	father(F,Y),
	mother(M,X),
	mother(M,Y),
	X \= Y.

sister(X,Y) :-			% X is sister of Y
	female(X),
	father(F,X),
	father(F,Y),
	mother(M,X),
	mother(M,Y),
	X \= Y.

brosis(X,Y) :-
	brother(X,Y).
brosis(X,Y) :-
	sister(X,Y).


% ----------------
% Aunt
% ----------------

aunt(X,Y) :-			% X is Y's aunt if she's 
	parent(Z,Y),		% his/her parent's sister
	sister(X,Z).



% ----------------
% Halfbrother
% ----------------

halfbrother(X,Y) :-		% X and Y got the same father
	male(X),		% but Y's mother isn't X's mother
	father(F,X),
	father(F,Y),
	mother(M,Y),
	\+ mother(M,X).

halfbrother(X,Y) :-		% X and Y got the same mother
	male(X),		% but Y's father isn't X's father
	mother(F,X),
	mother(F,Y),
	father(M,Y),
	\+ father(M,X).

