Logo 
Search:

Artificial Intelligence Articles

Submit Article
Home » Articles » Artificial Intelligence » ProLogRSS Feeds

ProLog Program to find relations

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

Program to find relations.

Code for ProLog Program to find relations in Artificial Intelligence

%trace
predicates
    
    father(symbol,symbol)
    mother(symbol,symbol)
    male(symbol)
    female(symbol)
%    uncle(symbol,symbol)
    husband(symbol,symbol)
    
    sister(symbol,symbol)
    brother(symbol,symbol)
    grandfather(symbol,symbol)
    grandmother(symbol,symbol)
    aunty(symbol,symbol)
    
clauses

    father(satishbhai,dhirajlal).
    father(bharatbhai,dhirajlal).
    father(hemal,satishbhai).
    father(neha,satishbhai).
    father(nirav,bharatbhai).
    father(bhavanaben,kantilal).
    father(gitaben,keshavbhai).
    
    mother(hemal,bhavanaben).
    mother(neha,bhavanaben).
    mother(bhavanaben,vasumatiben).
    mother(nirav,gitaben).
    mother(pintu,gitaben).
    mother(gitaben,sharadaben).
    mother(satishbhai,sharadaben).
    mother(bharatbhai,sharadaben).
    
    male(hemal).
    male(nirav).
    male(satishbhai).
    male(bharatbhai).
    male(dhirajlal).
    male(kantilal).
    male(keshavbhai).
    
    female(neha).
    female(pintu).
    female(bhavanaben).
    female(bijal).
    female(gitaben).
    female(vasumatiben).
    female(sharadaben).

    husband(bhavanaben,satishbhai).
    husband(gitaben,bharatbhai).
    husband(bijal,nirav).

    uncle(hemal,bharatbhai).
    uncle(nirav,satishbhai).
    
    brother(X,Y) :- father(X,A),father(Y,A),male(X),male(Y).
%    brother(X,Y) :- brother(Y,X),male(X),male(Y).
    
    sister(X,Y) :- father(X,A),father(Y,A),female(Y).
    
    aunty(X,Y) :- husband(Y,Z),
              brother(Z,W),
              Z <> W,
              father(X,W).

    grandfather(X,Y) :-
        male(Y), 
        father(X,W),
        father(W,Y).

    grandfather(X,Y) :-
        male(Y),
        mother(X,W),
        father(W,Y).

    grandmother(X,Y) :-
        female(Y), 
        father(X,W),
        mother(W,Y).

    grandmother(X,Y) :-
        female(Y),
        mother(X,W),
        mother(W,Y).
  
Share: 


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

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

 
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!