Logo 
Search:

Artificial Intelligence Articles

Submit Article
Home » Articles » Artificial Intelligence » ProLogRSS Feeds

ProLog Program to find relations in family

Posted By: Milind Mishra     Category: Artificial Intelligence     Views: 8647

Program to find relations.............

Code for ProLog Program to find relations in family in Artificial Intelligence

%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).
  
Share: 


Didn't find what you were looking for? Find more on ProLog Program to find relations in family Or get search suggestion and latest updates.

Milind Mishra
Milind Mishra author of ProLog Program to find relations in family is from India.
 
View All Articles

 

Other Interesting Articles in Artificial Intelligence:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!