0% found this document useful (0 votes)
80 views2 pages

Ai Assignment-10

This document contains a Prolog program that represents a family tree with parents, children, and gender relationships. It defines predicates for father, mother, brother, sister, grandfather, grandmother and others based on the parent and gender facts provided.

Uploaded by

Sumit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views2 pages

Ai Assignment-10

This document contains a Prolog program that represents a family tree with parents, children, and gender relationships. It defines predicates for father, mother, brother, sister, grandfather, grandmother and others based on the parent and gender facts provided.

Uploaded by

Sumit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

) Write a prolog program to represent a family tree and write the


predicates for different relationships like father, mother, brother, sister,
grandmother, grandfather, etc.

Program Code:
parent(pam,bob).
parent(tom,bob).
parent(tom,liz).
parent(bob,ann).
parent(bob,pat).
parent(pat,jim).

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

father(X,Y):- parent(X,Y),male(X).
mother(X,Y):- parent(X,Y),female(X).
bother(X,Y):- parent(Z,X),parent(Z,Y),male(X).
sister(X,Y):- parent(Z,X),parent(Z,Y),female(X).
grandfather(X,Z):-parent(X,Y),parent(Y,Z),male(X).
grandmother(X,Z):-parent(X,Y),parent(Y,Z),female(X).
Output:

You might also like