Computer Science, asked by dhipinsahni3614, 1 year ago

Write a prolog programme that answers questions about family members and relationships.

Answers

Answered by classysmruti06
1
%trace
predicates

     father(symbol,symbol)
     mother(symbol,symbol)
     male(symbol)
     female(symbol)
     sister(symbol,symbol)
     brother(symbol,symbol)
     uncle(symbol,symbol)
     wife(symbol,symbol)
     aunty(symbol,symbol)
     bhabhi(symbol,symbol)
     cousin(symbol,symbol)
     nephew(symbol,symbol)
     grand_son(symbol,symbol)
     grand_duaghter(symbol,symbol)

  clauses

      sister(X,Y) :- father(X,A),father(Y,A),female(Y).                      father(dhanjiBhai,vithhaldas).
      father(chuniBhai,vithhaldas).
      father(harshad,dhanjibhai).
      father(darshan,dhanjibhai).
      father(nilam,dhanjibhai).
      father(kiran,dhanjibhai).
      father(kamleshbhai,chunibhai).

      mother(harshad,prabhaben).
      mother(X,Y) :- father(X,Z),wife(Y,Z).

      brother(X,Y) :- father(X,A),father(Y,A),male(X).

%   brother(X,Y) :- brother(Y,X).         
      male(harshad).
      male(darshan).
      male(dhanjibhai).
      male(chunibhai).

      female(nilam).
      female(kiran).
      female(prabhaben).
      female(nimishaben).
      female(kokilaben).

       wife(prabhaben,dhanjibhai).
       wife(nimishaben,kamleshbhai).
       Wife(kokilaben,chunibhai).


       grand_son(X,Y) :- father(A,Y),father(X,A),male(X).
       grand_duaghter(X,Y) :- father(A,Y),father(X,A),female(Y).

       uncle(X,Y) :- father(X,Z),brother(Y,Z).

       aunty(X,Y) :- wife(Y,Z),
                            brother(Z,W),
                            father(X,W).

       bhabhi(X,Y) :- wife(X,Z),cousin(Y,Z),female(X).


       cousin(X,Y) :- father(X,A),father(Y,B),brother(A,B).

       nephew(X,Y) :- wife(Y,A),brother(A,B),father(X,B),male(X).
Similar questions