0% found this document useful (0 votes)
32 views31 pages

Is Lab

The document is a lab manual for the course "Intelligent System" at MGM's College of Engineering and Technology. It includes the vision and mission statements of the college and IT department, the course objectives to introduce AI concepts and techniques to build simple intelligent systems, and the program outcomes related to applying engineering knowledge, problem analysis, design skills, and more. It also maps the course outcomes to the program outcomes and lists the experiments students will conduct.

Uploaded by

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

Is Lab

The document is a lab manual for the course "Intelligent System" at MGM's College of Engineering and Technology. It includes the vision and mission statements of the college and IT department, the course objectives to introduce AI concepts and techniques to build simple intelligent systems, and the program outcomes related to applying engineering knowledge, problem analysis, design skills, and more. It also maps the course outcomes to the program outcomes and lists the experiments students will conduct.

Uploaded by

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

MGM’s College of Engineering and Technology

Kamothe, Navi Mumbai – 410209

Department of Information Technology

LAB MANUAL

Course Name: Intelligent System

(Subject Code: BEITC703)

Year: Fourth Year (CBSGS)

Semester: VII

Academic Year: 2018-19


CONTENT

S.No. Topics PAGE


NO.
1. Vision and Mission of college and department iii

2. Examination Scheme and University Syllabus iv

3. Course Objectives v

4. PSO & PO vi

5. CO & PO Mapping and CO & PSO Mapping viii

6. List of Experiments ix
MGM’s College of Engineering and Technology

Vision:

To become one of the outstanding Engineering Institute in India by providing a conductive and
vibrant environment to achieve excellence in the field of Technology.

Mission:

To empower the aspiring professional students to be prudent enough to explore the world of
technology and mould them to be proficient to reach the pinnacle of success in the competitive
global economy.

Department of Information Technology

Vision:

To emerge out as a prominent department offering a programme in its pursuit for academic
excellence in order to develop professionally competent and socially responsible Information
Technologists capable of meeting industry demands and social obligations in a vibrant global
environment.

Mission:

To strive towards building an atmosphere that will be a catalyst for innovative ideas and learning.
Providing IT students with various opportunities and experiences that can help them to thrive and
prosper through a blend of academics, practical exposure and research programs. To pursue
successful careers in a global environment.

4
Examination Scheme

Course Teaching Scheme Credits Assigned


Code Course (Hrs./Week)
Name Theory Practical Tutorial Theory Practical/Oral Tutorial Total

Intelligent
System
BEITC703 04 02 --- 04 01 --- 05

Examination Scheme

Theory Marks
Course
Code Course Name Internal assessment
Term
Practical Oral Total
Avg. End Sem. Work
Test1 Test 2 of 2 Exam
Tests

Intelligent
BEITC703 System

20 20 20 80 25 --- 25 150

5
Course Objectives

1. To introduce the students’ with different issues involved in trying to define and simulate intelligence.
2. To familiarize the students’ with specific, well known Artificial Intelligence methods, algorithms and
knowledge representation schemes.
3. To introduce students’ different techniques which will help them build simple intelligent systems
based on AI/IA concepts.

Course Outcomes (CO)

Name of the course CO code Course outcome (CO)


1 Students will develop a basic understanding of the building blocks
of AI as presented in terms of intelligent agents.
2 Students will be able to choose an appropriate problem-solving
method and knowledge-representation scheme.
3 Students will develop an ability to analyze and formalize the
problem (as a state space, graph, etc.)

Intelligent System 4 Students will able to select the appropriate search method for the
formalized Problem.

5 Student will able to know about the Learning Models and its
various types.
6 Students will be able to develop/demonstrate/ build simple
intelligent systems or classical toy problems using different AI
techniques.

6
Program Specific Outcomes (PSO)

PSO1 Analyze real life problems and design user friendly solutions.

PSO2 To provide effective solutions for problems in sectors like healthcare, science,
commerce, e-governance etc., by employing right set of tools and methodologies.
PSO3 Design and implement right IT infrastructural setups for any organization.

Program Outcomes (PO)

Engineering Graduates will be able to:


PO1) Engineering knowledge: Apply the knowledge of mathematics, science, engineering
fundamentals, and an engineering specialization to the solution of complex engineering problems.

PO2) Problem Analysis: Identify, formulate, review research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principles of mathematics, natural
sciences, and engineering sciences.

PO3) Design/development of solutions: Design solutions for complex engineering problems and
design system components or processes that meet the specified needs with appropriate consideration for
the public health and safety, and the cultural, societal, and environmental considerations.

PO4) Conduct investigations of complex problems: Use research-based knowledge and research
methods including design of experiments, analysis and interpretation of data, and synthesis of the
information to provide valid conclusions.

PO5) Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering activities with an
understanding of the limitations.

PO6) The engineer and society: Apply reasoning informed by the contextual knowledge to assess
societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to the
professional engineering practice.

PO7) Environment and sustainability: Understand the impact of the professional engineering
solutions in societal and environmental contexts, and demonstrate the knowledge of, and need for
sustainable development.

PO8) Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms
of the engineering practice.

7
PO9) Individual and team work: Function effectively as an individual, and as a member or
leader in diverse teams, and in multidisciplinary settings.

PO10) Communication: Communicate effectively on complex engineering activities with


the engineering community and with society at large, such as, being able to comprehend and
write effective reports and design documentation, make effective presentations, and give and
receive clear instructions.

PO11) Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a member and
leader in a team, to manage projects and in multidisciplinary environments.

PO12) Life-long learning: Recognize the need for, and have the preparation and ability to
engage in independent and life-long learning in the broadest context of technological change.

T
CE
GM
M

Intelligent System 8
CO & PO Mapping:
Name of Program Outcomes (PO)
the course CO PO PO PO PO PO PO PO PO PO PO PO PO MAP
code 1 2 3 4 5 6 7 8 9 10 11 12
 _   _   _ _ _   strong
1
    _ _ _ _ _ _   strong
2
    _ _ _ _ _ _   strong
3
Intelligent
System     _ _ _ _ _    strong
4

T
        _    strong
5
 _    _ _  _    strong
6

CE
CO & PSO Mapping:
GM
Name of the PSO3
CO Code PSO1 PSO2 MAP
course
  _ medium
1

 _ _ medium
2

   strong
3
Intelligent System
   strong
M

  _ strong
5

  _ medium
6

Intelligent System 9
LIST OF EXPERIMENTS

Sr. No Name of Experiment CO PO PS Page


O No.

1 Program to solve water jug problem. 10

2 Program to solve eight puzzle problem. 13

3 Program to solve eight queens problem. 15

4 Introduction to PROLOG – solving basic 17


problems.
5 Program to calculate factorial of a given 20

T
number (PROLOG).
6 Implement Fibonacci of a given number 22
(PROLOG).
7

H/W
Requiremen
CE
Program to find out union and
intersection of two lists (PROLOG).
Implement family program using
PROLOG.
P-1 and above, RAM 128MB, Printer,
Cartridges
24

27
GM
t
S/W SWI Prolog ,Turbo C
Requiremen
t

Subject-Incharge Lab Incharge H.O.D.


M

Intelligent System 10
Experiment No. 1

Implementing Water Jug Problem using BFS.

Aim:- Program to solve water jug problem.

Resources Required:- Equipments/Machines - P I and Above, Dot Matrix Printer


Consumables – Printer Pages for printouts.

Theory:-

T
Consider the following problem:

A Water Jug Problem: You are given two jugs, a 4-gallon one and a 3-gallon one, a pump which

water in the 4-gallon jug?


CE
has unlimited water which you can use to fill the jug, and the ground on which water may be
poured. Neither jug has any measuring markings on it. How can you get exactly 2 gallons of

State Representation and Initial State we will represent a state of the problem as a tuple (x, y)
where x represents the amount of water in the 4-gallon jug and y represents the amount of water
GM
in the 3-gallon jug. Note 0 =< x =<4, and 0 =< y =< 3.

Our initial state: (0,0)

Goal Predicate state = (2,y) where 0 _ y _ 3.


M

Intelligent System 11
T
CE
GM
Operators we must define a set of operators that will take us from one state to another:

1. Fill 4-gal jug (x,y) → (4,y)


x<4
M

2. Fill 3-gal jug (x,y) → (x,3)


y<3

3. Empty 4-gal jug on ground (x,y) → (0,y)


x>0

4. Empty 3-gal jug on ground (x,y) → (x,0)


y>0

5. Pour water from 3-gal jug (x,y) → (4, y - (4 - x))


to fill 4-gal jug 0 < x+y >= 4 and y > 0

Intelligent System 12
6. Pour water from 4-gal jug (x,y) → (x - (3-y), 3)
to fill 3-gal-jug 0 < x+y >= 3 and x > 0

7. Pour all of water from 3-gal jug (x,y) → (x+y, 0)


into 4-gal jug 0 < x+y <= 4 and y =>0

8. Pour all of water from 4-gal jug (x,y) → (0, x+y)


into 3-gal jug 0 < x+y <= 3 and x =>0

Through Graph Search, the following solution is found :

Gals in 4-gal jug Gals in 3-gal jug Rule Applied


0 0
1. Fill 4

T
4 0
6. Pour 4 into 3 to fill
1 3

4
0

1
CE 4. Empty 3

8. Pour all of 4 into 3

1. Fill 4

6. Pour into 3
GM
2 3

Result:

Conclusion:

Questionnaire
M

1. What is DFS?
2. What do you mean by BFS?
3. Does AI aims at human-level intelligence?
4. What is the Turing test?
5. Which algorithm is used to solve any kind of problem?
6. Which search strategy is also called as blind search?
7. The characteristics of the computer system capable of thinking, reasoning and learning are called?
8. What is IS?
9. What languages are used in IS/AI?
10. What are prologs in AI?

Intelligent System 13
Experiment No. 2
Implementing eight puzzle problem

Aim:- Program to solve eight puzzle problem.

Resources Required:- Equipments/Machines - P I and Above, Dot Matrix Printer


Consumables – Printer Pages for printouts.

Theory:-

The 8-puzzle problem is a puzzle invented and popularized by Noyes Palmer Chapman in the
1870s. It is played on a 3-by-3 grid with 8 square blocks labeled 1 through 8 and a blank square.
Your goal is to rearrange the blocks so that they are in order. You are permitted to slide blocks
horizontally or vertically into the blank square. The following shows a sequence of legal moves

T
from an initial board position (left) to the goal position (right).

1 3

7 8 6

initial
1 3

7 8 6
1 2 3

7 8 6
1 2 3
4 2 5 => 4 2 5 => 4 5 => 4 5
7 8 6
1 2 3
=> 4 5 6
7 8

CEgoal
GM
The complexity of possible moves toward the final solution in a game like this is great. It can
take an average computer great lengths of time to find the correct sequences for a particular
configuration of the 8 puzzle game if the search method is "blind". The problem is how do you
make the computer order the moves intelligently to find the shortest path to the winning game
state? Solving a problem such as this can be done two ways:

1. Guess through every possible state by doing a blind search of the state space.
2. Implement a search operation that is guaranteed to find the shortest solution using
"informed methods" (How?).
M

Informed Search Strategies

Informed methods help us gain information about solving a problem through its current state
space. This keeps a program from blundering around blindly guessing. Informed search
strategies make use of information about the path of moves we took to get where we are
currently by using an "evaluation function".

A move transforms one problem state into another state. The 8-puzzle is conveniently interpreted
as having the following for moves. Move empty space (blank) to the left, move blank up, move
blank to the right and move blank down,. These moves are modeled by production rules that
operate on the state descriptions in the appropriate manner.

Intelligent System 14
The rules each have preconditions that must be satisfied by a state description in order for them
to be applicable to that state description. Thus the precondition for the rule associated with
“move blank up” is derived from the requirement that the blank space must not already be in the
top row.

The problem goal condition forms the basis for the termination condition of the production
system. The control strategy repeatedly applies rules to state descriptions until a description of a
goal state is produced. it also keep track of rules that have been applied so that it can compose
them into sequence representing the problem solution.

ALGORITHM
1. Add the original board to the open list.
2. Check the first Board on the open list, if it is a goal state, print the board and halt operation, otherwise

T
go to step 3.
3. Retrieve a list of children from the first Board on the open list.

CE
4. Move the first Board on the open list to the closed list.
5. If any of the children appear in the closed or open list, remove them.
6. Add the list of remaining children to the open list, which is sorted by the f() value of each board.
7. Go to step two.
GM
Result:-

Conclusion:-
M

Questionnaire:-

1. Which is the best way to go for Game playing problem?


2. A* algorithm is based on which search method?
3. What is eight puzzle problems?
4. What is best first search?
5. What is hamming function?
6. What is Manhattan distance?
7. Who invented eight puzzle problem?
8. What are the techniques to implement search in prologs?
9. What is the logic of eight puzzle problem?
10. What are the 2 states in eight puzzle problem?

Intelligent System 15
Experiment No. 3
Program to solve eight queens problem.
Aim:- Program to solve eight queens problem.

Resources Required:- Equipments/Machines - P I and Above, Dot Matrix Printer


Consumables – Printer Pages for printouts.

Theory:-
The eight queens puzzle is the problem of placing eight chess queens on
an 8×8 chessboard so that no two queens threaten each other. Thus, a solution requires that no
two queens share the same row, column, or diagonal. The eight queens puzzle is an example of
the more general n queens problem of placing n non-attacking queens on an n×n chessboard, for
which solutions exist for all natural numbers n with the exception of n=2 and n=3.

T
CE
GM
M

ALGORITHM TO SOLVE EIGHT QUEENS PROBLEM

Intelligent System 16
Start
Step1:Representtheboardpositionas8*8vector, i.e., [1, 2, 3, 4, 5, 6, 7, 8]. Store the set of
queens in the list ‘Queens’.
Step2: Calculate the permutation of the above eight numbers stored in set P.
Step3: Let the position where the first queen to be placed be (1,Y), for second be (2,Y1), and
soon and store the position in S.
Step4: Check for the safety of the queens through the predicate, ‘no attack()’.
Step5:CalculateY1-yandY-Y1.IfbotharenotequaltoXdist, which is theX-distance between the
first queen and others, then go to step 6 else go to step7.

T
Step6:IncrementXdistby1.
Step7: Repeat above for the rest of the queens, until the end of the list is reached.
Step8: Print S as answer.
Stop

Result:-
CE
GM
Conclusion:-

Questionnaire:-

1. What is eight queens problem?


2. What is the solution to this problem?
3. Who invented the eight queens problem?
4. How many distinct solutions does this problem have?
M

5. How many fundamental solutions does this problem have?


6. What is a domination number?
7. What is backtracking?
8. What the eight queens problem be an example of?
9. What are the types of solutions for this problem?
10. What is the permutation matrix?

Experiment No. 4
Introduction to PROLOG
Aim: - solving basic problems using PROLOG.

Intelligent System 17
Resources Required:- Equipments/Machines - P I and Above, Dot Matrix Printer,
Consumables – Printer Pages for printouts.

Theory:-
PROLOG-PROGRAMMING IN LOGIC

PROLOG stands for Programming In Logic – an idea that emerged in the early 1970’s to use logic as
programming language.The early developers of this idea included Robert Kowalski at Edinburgh ( on the
theoretical side ),Marrten van Emden at Edinburgh ( experimental demonstration) and AlianColmerauer
at Marseilles (implementation ).

David D.H. Warren’s efficient implementation at Edinburgh in the mid -1970’s greatly contributed to the
popularity of PROLOG.

PROLOG is a programming language centered around a small set of basic mechanisms, Including pattern
matching, tree based data structuring and automatic backtracking. This Small set constitutes a surprisingly

T
powerful and flexible programming framework.

PROLOG is especially well suited for problems that involve objects- in particular, structured objects- and
relations between them.

SYMBOLIC LANGUAGE

CE
PROLOG is a programming language for symbolic, non-numeric computation. It is especially well suited
for solving problems that involve objects and relations between objects.
GM
For example, it is an easy exercise in prolog to express spatial relationship between objects, such as the
blue sphere is behind the green one. It is also easy to state a more general rule: if object X is closer to the
observer than object Y, and object Y is closer than Z, then X must be closer than Z. PROLOG can reason
about the spatial relationships and their consistency with respect to the general rule. Features like this
make PROLOG a powerful language for Artificial Language (AI) and non- numerical programming.

There are well-known examples of symbolic computation whose implementation in other standard
languages took tens of pages of indigestible code. When the same algorithms were implemented in
PROLOG, the result was a crystal-clear program easily fitting on one page.

FACTS, RULES AND QUERIES


M

Programming in PROLOG is accomplished by creating a database of facts and rules about objects, their
properties, and their relationships to other objects. Queries then can

be posed about the objects and valid conclusions will be determined and returned by the program.
Responses to user queries are determined through a form of inferencing control known as resolution.

FOR EXAMPLE:

a) FACTS:

Some facts about family relationships could be written as :

Intelligent System 18
sister(sue,bill)

parent(ann,sam)
male(jo)
female(riya)

b)RULES:

To represent the general rule for grandfather, we write: grandfather(X,Z)


parent(X,Y)
parent(Y,Z)
male(X)

c)QUERIES:

T
Given a database of facts and rules such as that above, we may make queries by typing after a query a
symbol ‘?_’ statements such as:
?_ parent(X,sam) X=ann ?_grandfather(X,Y) X=jo, Y=sam

PROLOG IN DESIGINING EPERT SYSTEMS


CE
An expert system is a set of programs that manipulates encoded knowledge to solve problems in a
specialized domain that normally requires human expertise. An expert system’s knowledge is obtained
GM
from expert sources such as texts, journal articles, databases etc. and encoded in a form suitable for the
system to use in its inference or reasoning processes. Once a sufficient body of expert knowledge has
been acquired, it must be encoded in some form, loaded into knowledge base, then tested, and refined
continually throughout the life of the system.

PROLOG serves as a powerful language in designing expert systems because of its following features:

• Use of knowledge rather than data

• Modification of the knowledge base without recompilation of the control programs.


M

• Capable of explaining conclusion.

• Symbolic computations resembling manipulations of natural language.


• Reason with meta-knowledge.

META PROGRAMMING

A meta program is a program that takes other programs as data. Interpreters and compilers are examples
of meta-programs. Meta-interpreter is a particular kind of meta-program: an interpreter for a language
written in that language. So a PROLOG mete-interpreter is an interpreter for PROLOG, itself written in
PROLOG.

Due to its symbol- manipulation capabilities, PROLOG is a powerful language for meta-programming.
Therefore, it is often used as an implementation language for other languages. PROLOG is particularly

Intelligent System 19
suitable as a language for rapid prototyping where we are interested in implementing new ideas quickly.
New ideas are rapidly implemented and experimented with.

Result:-

Conclusion:-

Questionnaire:-

1. What is prolog?

2. What is the structure of a prolog program?

T
3. What are the different data types in prolog?
4. What are the features of prolog?

5.
6.
7.
8.
CE
What are the various built in predicates in prolog?
Difference between variable and constants representation in prolog?
Explain where you use \+ operator in Prolog?
Mention why you have to use “is” instead of “=” in Prolog when it comes to
applying calculation logic?
9. Explain what is SWI-Prolog?
GM
10. What are bound and free variables in prolog?
M

Experiment No. 5
Factorial of a given number using PROLOG
Aim:- Program to calculate factorial of a given number (PROLOG).

Resources Required:- Equipments/Machines - P I and Above, Dot Matrix Printer,


Consumables – Printer Pages for printouts.

Intelligent System 20
Theory:- The formula for calculating n! (factorial of n) is:

n! = n * (n-1)!

We can interpret this simple mathematical equation into a Prolog program. To do so, we must determine
the basis of the recursion,

0! = 1

We will use two predicates here,

factorial predicate with one argument N, that will calculate and N!


factorial predicate with two arguments N and X. This function is recursively used. It will also calculate
N!, but store it in the argument X in the process if recursion.

T
CE
GM
M

ALGORITHM

Step 1 : Start
Start 2 : Read n
Start 3 : Initialize counter variable i to 1 and fact to 1
Start 4 : if i <= n go to step 5 otherwise goto step 7
Start 5 : calculate fact = fact * i
Start 6 : increment counter variable i and goto step 4

Intelligent System 21
Start 7 : Write fact.
Start 8 : Stop

Result:-

Conclusion:-

Questionnaire:-

1. Explain what is backtracking in Prolog?


2. Write the algo for factorial?
3. What is prologs?

T
4. What is a recursive function?
5. What is stack overflow?
6. What is the definition of factorial program?

CE
7. What is the simple factorial program?
8. How is prolog different from a basic factorial program?
9. What does prolog stand for?
10. How it is different from other programming languages?
GM
M

Experiment No. 6
Implement Fibonacci of a given number (PROLOG).
Aim:- write a program for Fibonacci of a given number using PROLOG.
.

Resources Required:- Equipments/Machines - P I and Above, Dot Matrix Printer

Intelligent System 22
Consumables – Printer Pages for printouts.
Theory:-

Fibonacci series is defined as a sequence of numbers in which the first two numbers are 1 and
1, or 0 and 1, depending on the selected beginning point of the sequence, and each subsequent
number is the sum of the previous two. So, in this series, the nth term is the sum of (n-1)th term
and (n-2)th term.

T
CE
GM
M

Algorithm:

Start
Declare variables i, a,b , show
Initialize the variables, a=0, b=1, and show =0
Enter the number of terms of Fibonacci series to be printed

Intelligent System 23
Print First two terms of series
Use loop for the following steps
-> show=a+b
-> a=b
-> b=show
-> increase value of i each time by 1
-> print the value of show
End

T
Result:-

Conclusion:-

Questionnaire:-
CE
GM
1. What is a Fibonacci series?
2. What are the 2 possible combinations of numbers possible?
3. What is the logic of fib series?
4. Explain the structure of prolog function?
5. What is the basic fib series written as?
6. How it is written in prologs?
7. Why prologs are used?
8. What are the application areas of prologs?
9. What does prologs stand for?
M

10. What does a prolog program consists of?

Experiment No. 7
Union and intersection of two lists (PROLOG).
Aim:- Program to find out union and intersection of two lists (PROLOG).

Resources Required:- Equipments/Machines - P I and Above, Dot Matrix Printer

Consumables – Printer Pages for printouts.

Intelligent System 24
Theory:-

ALGORITHM TO FIND OUT UNION OF TWO LISTS.

Step 1. Start
Step 2. If first list is empty return second list as the union of two lists and goto step 6.
Step 3. If head of first list is not a member of second list add this element in the union of both
list produced by calling union function with and goto step 5.
Step 4. If head of first list is a member of second list call the union function for tail of first
list and second list
Step 5. Exit

T
CE
GM
M

ALGORITHM TO FIND OUT INTERSECTION OF TWO LISTS.

Step 1. Start
Step 2. If first list is empty return empty list as intersection of both lists. Step 3. If
head of first list is a member of second list then add the head to
the list obtained by calling intersection function with tail of first list and
second list and goto step 5.
Step 4. If head of first list is not a member of second list then call
Intelligent System 25
intersection function with tail of first list and second list.
Step 5. Exit

T
CE
GM
Result:-
M

Conclusion:-

Questionnaire:-

1. What is a list? How it can be manipulated?

2. What is the logic to insert a element in a list?

3. What is the logic to delete a element in a list?

Intelligent System 26
4. What is the logic to find the product of the elements in the given list?

5. What is the logic to find the largest number in the given list?

6. What is cut?

7. What are the uses of cut?

8. What are the advantages and disadvantages of cut?

9. What is the logic for concatenation of two list?

10. How will you check whether the list is a sublist of another list or not?

T
CE
GM
M

Experiment No. 8

Implement family program using PROLOG


Aim: - To Implement family program using PROLOG

Intelligent System 27
Resources Required:- Equipments/Machines - P I and Above, Dot Matrix Printer

Consumables – Printer Pages for printouts.

Theory:-

Prolog Representation of Family Tree

father(tony,abe).

father(tony,sarah).

father(abe,john).

father(bill,susan).

T
father(john,jill).

father(rob,phil).

mother(lisa,abe).

mother(lisa,sarah).

mother(nancy,john).

mother(sarah,susan).
CE
GM
mother(mary,jill).

mother(susan,phil).

Reasoning about Family Trees

• Parent
M

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

– parent(X,Y) :- mother(X,Y).

• Grandparent

– gp(X,Y) :- parent(X,Z), parent(Z,Y).

• Great-grandparent

– ggp(X,Y) :- gp(X,Z), parent(Z,Y).

• Ancestor

Intelligent System 28
– ancestor(X,Y) :- parent(X,Y).

– ancestor(X,Y) :- parent(X,Z), ancestor(Z,Y)

Query Examples

?- father(abe,john).

true.

?- father(tony,X).

X = abe ;

T
X = sarah.

?- parent(X,susan).

X = bill ;

X = sarah ;

false.

?-
CE
GM
Queries

• typed at Prolog prompt (not in external files)

• consist of a predicate possibly containing variables

– if no variables, result is either “true” or “false”


M

– otherwise, result is an instantiation of variables or “false”

• no solutions, one solution, or many solutions

– no solution: “false”

– after printing one solution, Prolog waits for user input

– type RETURN to stop search; Prolog says “true”

– type SEMICOLON to find more solutions; Prolog either finds another and waits for more input or says
“false”

Intelligent System 29
Result:-

Conclusion:-

Industrial Application:-

Questionnaire:-

T
1. What are the sections in the prolog program?

2. How to ask queries in prolog explain using examples?

3. Define rule.

4. Define fact.

5. Define relation.
CE
GM
6. What does a production rule consist of?

7. What do you mean by an Expert system?

8. What is an agent?

9. What are different notations used in prolog.

10. What is a family tree problem?


M

References

Intelligent System 30
T
CE
GM
M

Intelligent System 31

You might also like