Logo 
Search:

Artificial Intelligence Articles

Submit Article
Home » Articles » Artificial Intelligence » ProLogRSS Feeds

Prolog program of Parent Tree

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

Prolog program of Parent Tree

Code for Prolog program of Parent Tree in Artificial Intelligence

predicates
    parent(symbol,symbol)
    male(symbol)
    female(symbol)
    grandparent(symbol,symbol)
    grandfather(symbol,symbol)
    grandmother(symbol,symbol)
    father(symbol,symbol)
    mother(symbol,symbol)
    sister(symbol,symbol)
    brother(symbol,symbol)
    uncle(symbol,symbol)
    aunt(symbol,symbol)
    offspring(symbol,symbol)


clauses    
    parent(pam,bob).
    parent(tom,bob).
    parent(tom,liz).
    parent(bob,ann).
    parent(bob,pat).
    parent(pat,jim).
    male(tom).
    male(bob).
    male(jim).
    female(pam).
    female(liz).
    female(ann).
    female(pat).

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

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

mother(X,Y) :-
        parent(X,Y),
        female(X).            
        
grandparent(X,Y) :-
        parent(X,Z),
        parent(Z,Y).
        
grandfather(X,Y) :-
        parent(X,Z),
        parent(Z,Y),
        male(X).
        
grandmother(X,Y) :-
        parent(X,Z),
        parent(Z,Y),
        female(X).
                                    
sister(X,Y) :-
        parent(Z,X),
        parent(Z,Y),
        female(X),
        not(X=Y).
        
        
brother(X,Y) :-
        parent(Z,X),
        parent(Z,Y),
        male(X),
        not(X=Y).
        
        
uncle(X,Y) :-
        parent(Z,Y),
        brother(X,Z).                        
        
aunt(X,Y) :-
        parent(Z,Y),
        sister(X,Z).        
  
Share: 


Didn't find what you were looking for? Find more on Prolog program of Parent Tree Or get search suggestion and latest updates.

Milind Mishra
Milind Mishra author of Prolog program of Parent Tree 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!