%#############################################
% Ex: 1.2
%#############################################
/*
male(albert).
male(edward).
female(alice).
female(alice).
parents(edward,victoria,albert).
parents(alice,victoria,albert).
sister_of(X,Y):-
female(X),
parents(X,M,F),
parents(Y,M,F).
*/
%---------------------------------------------
% use “;” to
give the next answer
/* ANSWER:
?-
sister_of(X,Y).
X = alice
Y = edward ;
X = alice
Y = alice ;
X = alice
Y = edward ;
X = alice
Y = alice ;
*/
%#############################################
% Ex: 1.3
%#############################################
/*********************************************
male(X).
female(X).
father(X,Y).
mother(X,Y).
parent(X,Y):-father(X,Y).
parent(X,Y):-mother(X,Y).
diff(X,Y):-not(X==Y)
*********************************************/
% test database
% jeo is the
father of adam and eve,grandfather of felix,kate
% adam, eve are
married
% felix,kate are
childrens
male(jeo).
male(adam).
male(felix).
female(eve).
female(kate).
father(jeo,adam).
father(jeo,eve).
father(adam,felix).
father(adam,kate).
mother(eve,felix).
mother(eve,kate).
parent(X,Y):-father(X,Y).
parent(X,Y):-mother(X,Y).
diff(X,Y):-not(X==Y).
%###########################################
% ANSWERS:
%###########################################
is_mother(X):-female(X),parent(X,_).
is_father(X):-male(X),parent(X,_).
is_son(X):-male(X),parent(_,X).
sister_of(X,Y):-female(Y),parent(_,Y),diff(X,Y).
grandpa_of(X,Y):-male(X),father(X,Z),parent(Z,Y).
sibling(X,Y):-parent(Z,X),parent(Z,Y),diff(X,Y).