Checked By Dr.
Avinash Golande
Sign
Date
Grade
Experiment No.1
Name: Hiren Daxeshbhai Patel Roll No.: 07
Objective: Create a SWI Prolog program to represent the family tree.
Resources used:
• Windows 10, 11.
• PC i5 or greater.
• Software SWI Prolog.
Theory:
Family Tree: Family tree is a graphical representation of familial relationships, often created
using AI tools to simplify and enchance the process.These AI-powered tools can help you build
detailed family trees by:
a) Inputting Family information: You provide names and relationships, or upload
documents containing family history details.
b) Generating the Tree: The AI processes the information to create a visual
representation of your family ttree.
c) Refining and Expanding: You can review and refine the AI-generated tree, adding
missing information or making corrections.
Syntax of Family Tree:
Source Code:
/* Facts */ male(jack).
male(oliver). male(ali).
male(james).
male(simon).
male(harry).
female(helen).
female(sophie).
female(jess).
female(lily).
parent_of(jack,jess).
parent_of(jack,lily).
parent_of(helen, jess).
parent_of(helen, lily).
parent_of(oliver,james).
parent_of(sophie, james).
parent_of(jess, simon).
parent_of(ali, simon).
parent_of(lily, harry).
parent_of(james, harry).
/* Rules */ father_of(X,Y):-
male(X), parent_of(X,Y).
mother_of(X,Y):- female(X), parent_of(X,Y).
grandfather_of(X,Y):- male(X),
parent_of(X,Z), parent_of(Z,Y).
grandmother_of(X,Y):-
female(X), parent_of(X,Z),
parent_of(Z,Y). sister_of(X,Y):-
%(X,Y or Y,X)% female(X),
father_of(F, Y), father_of(F,X),X
\= Y.
sister_of(X,Y):- female(X), mother_of(M, Y),
mother_of(M,X),X \= Y. aunt_of(X,Y):-
female(X), parent_of(Z,Y), sister_of(Z,X),!.
brother_of(X,Y):- %(X,Y or Y,X)%
male(X), father_of(F, Y), father_of(F,X),X
\= Y. brother_of(X,Y):- male(X),
mother_of(M, Y), mother_of(M,X),X \= Y.
uncle_of(X,Y):- parent_of(Z,Y),
brother_of(Z,X). ancestor_of(X,Y):-
parent_of(X,Y). ancestor_of(X,Y):-
parent_of(X,Z), ancestor_of(Z,Y).
Output:
Conclusions:
Succeccfully implemented the family tree in SWI Prolog.