Prolog program that stores information about your family, and will answer queries about relationships.


% Prolog program that store information about my family

% Alamgir, CSE, JUST

% Facts

father(mosiur, sharmin).

father(mosiur, rawshanara).                            

father(mosiur, alamgir). 

father(mosiur, rahim).                              

father(auncle, liza).                            

father(auncle, robin).                           

father(robin, abid).                            

father(robin, snigdho). 

father(sumon, apu).
                         
mother(morium, sharmin).                           

mother(morium, alamgir).

mother(morium, rahim).                            

mother(aunty, liza).                              

mother(aunty, robin).                              

mother(sharmin, abid).                          

mother(sharmin, snigdho).

mother(rawshanara, apu).                   
% Rules-------

parent(X, Y) :- father(X, Y).                  

parent(X, Y) :- mother(X, Y).               
grandfather(X, Y) :- father(X, Z), parent(Z, Y).
grandmother(X, Y) :- mother(X, Z), parent(Z, Y).
mama(X, Y) :- mother(X, Z), father(Z, Y).   
huswife(X, Y) :- father(X, Z), mother(Y, Z).
brothersistertr(Y, Z) :- father(X, Y), father(X, Z). 
mamavagne(Z, Y) :- father(X, Z),grandfather(X, Y).
% End of code

% Output---------------
Start from here....You can check with another rules...

parent(X, Y).

X = mosiur
Y = sharmin ? ;

X = mosiur
Y = rawshanara ? ;

X = mosiur
Y = alamgir ? ;

X = mosiur
Y = rahim ? ;

or check by parent(mosiur, alamgir).

No comments:

Post a Comment