Professional Documents
Culture Documents
Ambo University Woliso Campus
Ambo University Woliso Campus
Email: misgenamuleta@gmail.com
Woliso, Ethiopia
Lab Exercise Assignment
Here from this tree, we can understand that there are many relationships. Here gemeda is a
child of keniniand debela, and gemedaalso has two children — ebisa and ebise. Ebisa has two
children,hawi and chala.Ebise also has two children,kume and kuma. So we want to make
predicates as follows:
parent(kenini,gemeda).
parent (debela,gemeda).
parent (gemeda,ebisa).
parent (gemeda,ebise).
parent (ebisa,hawi).
parent (ebisa,chala).
parent (ebise,kume).
parent (ebise,kuma).
Some facts can be written this ways, like sex of family members can be written
in this forms:
female(kenini).
male(debela).
male(gemeda).
male(ebisa).
female(ebise).
female(hawi).
male(chala).
female(kume).
male(kuma).
Prolog Rules
grandfather(X,Z):-parent(X,Y),parent(Y,Z),male(X).
grandmother(X,Z):-parent(X,Y),parent(Y,Z),female(X).
aunt(X,Y) :- female(X),sister(X,Y),parent(Y,Z).
uncle(X,Z):-brother(X,Y),parent(Y,Z).
2. Prolog query that check as:-
?- sister(ebise,ebisa).
?- cousin(kume,chala).
?- parent(Y, feyisa).
?- mother(Y, X).
?- brother(X,Y).
X = ebisa,
Y = ebise ;
X = chala,
Y = hawi ;
X = kuma,
Y = kume ;
?- sister(X,Y).
X = ebise,
Y = ebisa ;
X = hawi,
Y = chala ;
X = kume,
Y = kuma ;
X = ebise,
Y = ebisa.
?- grandfather(X,Y).
X = debela,
Y = ebisa ;
X = debela,
Y = ebise ;
X = gemeda,
Y = hawi ;
X = gemeda,
Y = chala ;
X = gemeda,
Y = kume ;
X = gemeda,
Y = kuma ;
?- grandmother(X,Y).
X = kenini,
Y = ebisa ;
X = kenini,
Y = ebise ;
?- uncle(X,Y).
X = ebisa,
Y = kume ;
X = ebisa,
Y = kuma ;
?- sister(X,Y).
X = ebise,
Y = ebisa