Is Lab
Is Lab
LAB MANUAL
Semester: VII
3. Course Objectives v
4. PSO & PO vi
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.
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
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.
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.
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.
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
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
Intelligent System 10
Experiment No. 1
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
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.
Intelligent System 11
T
CE
GM
Operators we must define a set of operators that will take us from one state to another:
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
T
4 0
6. Pour 4 into 3 to fill
1 3
4
0
1
CE 4. Empty 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
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 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:-
Intelligent System 15
Experiment No. 3
Program to solve eight queens problem.
Aim:- Program to solve eight queens problem.
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
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:-
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.
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:
Intelligent System 18
sister(sue,bill)
parent(ann,sam)
male(jo)
female(riya)
b)RULES:
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 serves as a powerful language in designing expert systems because of its following features:
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?
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).
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
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:-
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.
.
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
Experiment No. 7
Union and intersection of two lists (PROLOG).
Aim:- Program to find out union and intersection of two lists (PROLOG).
Intelligent System 24
Theory:-
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
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:-
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?
10. How will you check whether the list is a sublist of another list or not?
T
CE
GM
M
Experiment No. 8
Intelligent System 27
Resources Required:- Equipments/Machines - P I and Above, Dot Matrix Printer
Theory:-
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).
• Parent
M
– parent(X,Y) :- father(X,Y).
– parent(X,Y) :- mother(X,Y).
• Grandparent
• Great-grandparent
• Ancestor
Intelligent System 28
– ancestor(X,Y) :- parent(X,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
– no solution: “false”
– 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?
3. Define rule.
4. Define fact.
5. Define relation.
CE
GM
6. What does a production rule consist of?
8. What is an agent?
References
Intelligent System 30
T
CE
GM
M
Intelligent System 31