You are on page 1of 3

//Sanjana Chatterjee

//7CTB-131
AI PRACTICAL 1

Aim: Write a family tree program to include following rules


1. M is the mother of P if she is a parent of P and is female
2. F is the father of P if he is a parent of P and is male
3. X is a sibling of Y if they both have the same parent.
4. Then add rules for grandparents, uncle-aunt, sister and brother.

Theory:
Artificial intelligence (AI): Artificial intelligence (AI) refers to the simulation of human
intelligence in machines that are programmed to think like humans and mimic their
actions. The term may also be applied to any machine that exhibits traits associated
with a human mind such as learning and problem-solving.
There are 3 types of artificial intelligence (AI):
1) narrow or weak AI
2) general or strong AI
3) artificial superintelligence.

Prolog: Prolog is a logic programming language that is used to create artificial


intelligence. In order to come up with a query or end goal, an artificial intelligence
written in Prolog will analyze the relationship between a fact, a statement that is
true, and a rule, which is a conditional statement.
It has important role in artificial intelligence. Unlike many other programming
languages, Prolog is intended primarily as a declarative programming language. In
prolog, logic is expressed as relations (called as Facts and Rules). Core heart of prolog
lies at the logic being applied. Formulation or Computation is carried out by running
a query over these relations.
In prolog, we declare some facts. These facts constitute the Knowledge Base of the
system. We can query against the Knowledge Base. We get output as affirmative if
our query is already in the knowledge Base or it is implied by Knowledge Base,
otherwise we get output as negative. So, Knowledge Base can be considered similar
to database, against which we can query.
Prolog facts are expressed in definite pattern. Facts contain entities and their
relation. Entities are written within the parenthesis separated by comma (,). Their
relation is expressed at the start and outside the parenthesis. Every fact/rule ends
with a dot (.).

Code:
Output:

Conclusion: Thus, creation of family tree using SWI Prolog has been successfully
completed.

You might also like