Artificial Intelligence
Artificial Intelligence
Artificial Intelligence
Anamitra Deshmukh-Nimbalkar
CTO & Chief Software Trainer, Mentor
(PGDBM, PGDPC, NET, SET, MCS)
® ®
TECHNICAL
PUBLICATIONS
SINCE 1993 An Up-Thrust for Knowledge
(i)
Artificial Intelligence
Subject Code : 310253
Published by :
® ® Amit Residency, Office No.1, 412, Shaniwar Peth,
TECHNICAL Pune - 411030, M.S. INDIA Ph.: +91-020-24495496/97
PUBLICATIONS
SINCE 1993 An Up-Thrust for Knowledge Email : [email protected] Website : www.technicalpublications.org
Printer :
Yogiraj Printers & Binders
Sr. No. 10/1A,
Ghule Industrial Estate, Nanded Village Road,
Tal. - Haveli, Dist. - Pune - 411041.
ISBN 978-93-5585-014-0
9 789355 850140
SPPU 19
The book uses plain, lucid language to explain fundamentals of this subject. The book
provides logical method of explaining various complicated concepts and stepwise methods
to explain the important topics. Each chapter is well supported with necessary illustrations,
practical examples and solved problems. All the chapters in the book are arranged in a
proper sequence that permits each topic to build upon earlier studies. All care has been
taken to make students comfortable in understanding the basic concepts of the subject.
Representative questions have been added at the end of each chapter to help the
students in picking important points from that chapter.
The book not only covers the entire scope of the subject but explains the philosophy of
the subject. This makes the understanding of this subject more clear and makes it more
interesting. The book will be very useful not only to the students but also to the subject
teachers. The students have to omit nothing and possibly have to cover nothing more.
We wish to express our profound thanks to all those who helped in making this book a
reality. Much needed moral support and encouragement is provided on numerous
occasions by our whole family. We wish to thank the Publisher and the entire team of
Technical Publications who have taken immense pain to get this book in time with quality
printing.
Any suggestion for the improvement of the book will be acknowledged and well
appreciated.
Authors
Anamitra Deshmukh - Nimbalkar
Dr. Vaishali P. Vikhe
(iii)
Dedicated to my first love,
My father shri. Prakash Deshmukh,
On his 61st Birthday,
who put all his efforts and went through huge mental and
emotional pains, in making me a decisive decision maker
so that I grow up to become an independent person on
whom people can bank on.
Anamitra Deshmukh-Nimbalkar
Dedication
This book is dedicated to my family and parents who
always support me and inspired me in every stage.
Dr. Vaishali P. Vikhe
(iv)
Syllabus
Artificial Intelligence - (310253)
Credit : Examination Scheme :
Unit I Introduction
Introduction to Artificial Intelligence, Foundations of Artificial Intelligence, History of Artificial
Intelligence, State of the Art, Risks and Benefits of AI, Intelligent Agents, Agents and Environments, Good
Behavior : Concept of Rationality, Nature of Environments, Structure of Agents. (Chapter - 1)
Unit II Problem-solving
Solving Problems by Searching, Problem-Solving Agents, Example Problems, Search Algorithms,
Uninformed Search Strategies, Informed (Heuristic) Search Strategies, Heuristic Functions, Search in
Complex Environments, Local Search and Optimization Problems. (Chapters - 2, 3)
Unit IV Knowledge
Logical Agents, Knowledge-Based Agents, The Wumpus World, Logic, Propositional Logic : A Very
Simple Logic, Propositional Theorem Proving, Effective Propositional Model Checking, Agents Based on
Propositional Logic, First-Order Logic, Representation Revisited, Syntax and Semantics of First-Order
Logic, Using First-Order Logic, Knowledge Engineering in First-Order Logic. (Chapters - 6, 7, 8)
Unit V Reasoning
Inference in First-Order Logic, Propositional vs. First-Order Inference, Unification and First-Order
Inference, Forward Chaining, Backward Chaining, Resolution, Knowledge Representation, Ontological
Engineering, Categories and Objects, Events, Mental Objects and Modal Logic, Reasoning Systems for
Categories, Reasoning with Default Information. (Chapters - 9, 10)
Unit VI Planning
Automated Planning, Classical Planning, Algorithms for Classical Planning, Heuristics for Planning,
Hierarchical Planning, Planning and Acting in Nondeterministic Domains, Time, Schedules, and
Resources, Analysis of Planning Approaches, Limits of AI, Ethics of AI, Future of AI, AI Components, AI
Architectures. (Chapters - 11, 12)
(v)
Table of Contents
Unit I
Chapter - 1 Artificial Intelligence - The Concept (1 - 1) to (1 - 46)
1.1 The Concept of Artificial Intelligence (AI) ....................................................... 1 - 2
1.1.1 Introduction .................................................................................................. 1 - 2
1.1.2 Various Definitions of AI ............................................................................... 1 - 2
1.1.3 The Foundation of AI .................................................................................... 1 - 4
1.1.4 The Strong and Weak AI ............................................................................... 1 - 5
1.1.4.1 Strong AI ..................................................................................................... 1 - 5
1.1.4.2 Weak AI ....................................................................................................... 1 - 5
(vi)
1.7 History of Artificial Intelligence..................................................................... 1 - 13
1.8 AI Terms ........................................................................................................ 1 - 15
1.8.1 Agents and it's Environment....................................................................... 1 - 15
1.8.2 The AI Terminology ..................................................................................... 1 - 16
1.8.3 Architecture of Agent ................................................................................. 1 - 17
1.8.4 Schematic of AI's Agent Performing Action ................................................ 1 - 17
1.8.5 Role of An Agent Program .......................................................................... 1 - 18
1.8.6 Simple Example for Tabulation of a Agent ................................................. 1 - 18
1.8.7 The Weak and Strong Agent ....................................................................... 1 - 18
1.8.7.1 Weak Agent............................................................................................... 1 - 19
1.8.7.2 Strong Agent ............................................................................................. 1 - 19
(vii)
1.10.2 Different Forms of Agents : (Types of Agents) ........................................... 1 - 31
1.10.2.1 Agent Type 1 ............................................................................................. 1 - 31
(viii)
2.2.1 Construction of State Space ....................................................................... 2 - 10
2.2.2 Terminology used in Search Trees .............................................................. 2 - 10
2.2.3 Node Representation in a Search - Tree ..................................................... 2 - 12
2.2.4 The Node Searching and Expansion Algorithms ........................................ 2 - 12
2.2.4.1 Algorithm Tree Search ................................................................................. 2 - 12
(ix)
2.7 Example Problems......................................................................................... 2 - 32
2.7.1 Toy Problem................................................................................................ 2 - 32
2.7.2 Real World Problem.................................................................................... 2 - 33
2.7.3 Problem Formulation for Toy Problems ..................................................... 2 - 33
2.7.4 Real - World Problem Examples ................................................................. 2 - 37
Review Questions .................................................................................................. 2 - 41
Multiple Choice Questions with Answers ............................................................. 2 - 43
(x)
3.2.3 Simulated Annealing Search ....................................................................... 3 - 17
3.2.4 Local Beam Search ...................................................................................... 3 - 18
3.2.5 Stochastic Beam Search .............................................................................. 3 - 18
3.2.6 Genetic Algorithms ..................................................................................... 3 - 19
3.2.6.1 Term used in Genetic Algorithm ............................................................... 3 - 19
(xi)
4.8 Types of Games ............................................................................................... 4 - 6
4.9 Formal Representation of a Game as a Problem ............................................ 4 - 7
4.9.1 A Game is Essentially a Kind of a Search Problem ! ....................................... 4 - 7
4.9.2 Game Playing Strategies ................................................................................ 4 - 8
4.9.3 The Game Tree .............................................................................................. 4 - 9
4.10 Major Components of Game Playing Program ............................................. 4 - 11
4.11 Mini-Max Algorithm ...................................................................................... 4 - 11
4.11.1 The Algorithm .............................................................................................. 4 - 11
4.11.2 Properties of Mini-Max................................................................................ 4 - 12
4.11.3 Problem Associated with Mini-Max............................................................. 4 - 12
4.11.4 Game Playing with Mini-Max-Tic-Tac-Toe
[Noughts and crosses] Example ................................................................... 4 - 12
4.11.5 Example to show how Mini-Max Algorithm Works ..................................... 4 - 13
4.11.6 The 'made-up' Games and Concept of 'ply' ................................................. 4 - 16
4.11.7 Mini-Max Algorithm for Playing Multiplayer Games ................................... 4 - 17
4.12 Alpha-Beta Pruning ....................................................................................... 4 - 18
4.12.1 Motivation for - Pruning........................................................................ 4 - 18
4.12.2 Steps in Alpha-Beta Pruning ........................................................................ 4 - 19
4.12.3 Alpha Cutoff ................................................................................................. 4 - 20
4.12.4 Beta-Cutoff .................................................................................................. 4 - 20
4.12.5 Algorithm of Alpha-Beta Pruning ................................................................. 4 - 20
4.12.6 Example of Alpha-Beta Pruning (Upto 3rd Ply)............................................ 4 - 21
4.12.7 Why is it Called - ? ................................................................................ 4 - 24
4.12.8 Heuristic Function that can be used in Cutting Off Search .......................... 4 - 25
4.12.8.1 Evaluation Functions .................................................................................. 4 - 25
4.12.8.2 Imperfect and Real-time Decisions ............................................................ 4 - 25
4.12.8.3 Cutting Off Search ...................................................................................... 4 - 25
4.12.8.4 Forward Pruning ........................................................................................ 4 - 27
(xii)
4.16 Stochastic Games .......................................................................................... 4 - 34
Solved Example ..................................................................................................... 4 - 40
Review Questions .................................................................................................. 4 - 43
Multiple Choice Questions with Answers ............................................................. 4 - 44
(xiii)
Review Questions .................................................................................................. 5 - 27
Multiple Choice Questions with Answers ............................................................. 5 - 27
Unit IV
Chapter - 6 Knowledge Representation Issues (6 - 1) to (6 - 24)
6.1 Representation and Mappings ........................................................................ 6 - 2
6.1.1 Introduction .................................................................................................. 6 - 2
6.1.2 Issues in Knowledge Representation ............................................................ 6 - 2
6.1.3 The Techniques of Representation and Mappings ....................................... 6 - 3
6.2 Approaches to Knowledge Representation .................................................... 6 - 6
6.2.1 Inferential Knowledge .................................................................................. 6 - 8
6.2.2 Procedural Knowledge .................................................................................. 6 - 8
6.2.2.1 Advantages of Procedural Knowledge ....................................................... 6 - 8
6.2.2.2 Disadvantages of Procedural Knowledge ................................................... 6 - 8
(xiv)
7.4.3 Truth Table.................................................................................................. 7 - 10
7.4.4 Validity ........................................................................................................ 7 - 11
7.4.5 Satisfiability................................................................................................. 7 - 11
7.4.6 A Complete Example of Knowledge-based Agent ...................................... 7 - 12
7.5 Reasoning Patterns in Propositional Logic .................................................... 7 - 14
7.5.1 The Concept of Monotonicity ..................................................................... 7 - 15
7.5.2 Inference Rules ........................................................................................... 7 - 15
7.6 Forward and Backward Chaining .................................................................. 7 - 18
7.6.1 The Horn Clause .......................................................................................... 7 - 18
7.6.2 Forward Chaining Method .......................................................................... 7 - 18
7.6.3 The Backward Chaining Algorithm.............................................................. 7 - 20
7.7 Effective Propositional Inference .................................................................. 7 - 21
7.7.1 A Complete Backtracking Algorithm
[Davis Putnam Logmann-Loveland Algorithm-(DPLL)]................................ 7 - 21
7.8 Local Search Algorithms for Inferencing in Propositional Logic ................... 7 - 23
7.8.1 Local Search Algorithms Characteristics ..................................................... 7 - 23
7.8.2 Local Search Algorithm for Checking Satisfiability...................................... 7 - 23
7.8.3 Steps in WALKSAT Algorithm ...................................................................... 7 - 24
7.8.4 Hard Satisfiability Problems ........................................................................ 7 - 24
7.9 Knowledge based Agents .............................................................................. 7 - 25
7.9.1 Inference based Agent in Wumpus World - Agent based
on Propositional Logic................................................................................ 7 - 25
7.9.2 Circuit based Agent in Wumpus World ...................................................... 7 - 27
7.9.3 Comparison between Inference Based Agent (IBA)
and Circuit Based Agent (CBA) .................................................................... 7 - 28
Review Questions .................................................................................................. 7 - 29
Multiple Choice Questions with Answers ............................................................. 7 - 30
(xv)
8.1.2 Properties of First Order Logic ...................................................................... 8 - 2
8.1.3 First Order Logic-Extension to Propositional Logic ....................................... 8 - 3
8.1.4 Variations of First Order Logic ...................................................................... 8 - 3
8.1.5 Characteristics of Logic ................................................................................. 8 - 3
8.1.6 Formal Languages and their Ontological
and Epistemological Commitments .............................................................. 8 - 4
8.1.7 Higher - Order Logic ...................................................................................... 8 - 4
8.1.8 Syntax for First Order Logic .......................................................................... 8 - 4
8.1.9 Sentence in First Order Logic ........................................................................ 8 - 7
8.1.10 Semantic of First Order Logic........................................................................ 8 - 8
8.1.11 Quantifiers .................................................................................................... 8 - 9
8.1.11.1 Universal Quantifier () ............................................................................ 8 - 9
8.1.11.2 Existential Quantifier () .......................................................................... 8 - 10
8.1.16.3 Model Based Reasoning Systems and Diagnostic Reasoning Systems ..... 8 - 19
8.2 The Wumpus World Represented using First Order Logic ........................... 8 - 20
8.2.1 Wumpus World Revisited ........................................................................... 8 - 20
8.2.2 Reasoning in Wumpus World using First Order Logic ................................ 8 - 20
8.3 Knowledge Engineering in First Order Logic ................................................. 8 - 21
(xvi)
8.3.1 We have Two Types of Knowledge Base .................................................... 8 - 21
8.3.2 Steps in Knowledgebase Engineering Process ............................................ 8 - 21
8.3.3 Knowledge Engineering in First Order Logic
for the Electronic Circuits Domain .............................................................. 8 - 23
Review Questions .................................................................................................. 8 - 25
Multiple Choice Questions with Answers ............................................................. 8 - 29
Unit V
Chapter - 9 Reasoning and Inferencing using
First Order Logic (9 - 1) to (9 - 68)
9.1 Inference in First Order Logic .......................................................................... 9 - 2
9.1.1 Inferencing in First Order Logic..................................................................... 9 - 2
9.1.2 Definition of Various Terms used in Inference Theory ................................ 9 - 2
9.1.3 Inference Rules ............................................................................................ 9 - 3
9.1.4 Reducing First Order Logic Inferences to Propositional Inferences ............. 9 - 5
9.1.5 Concept of Lifting.......................................................................................... 9 - 6
9.1.6 Unification .................................................................................................... 9 - 7
9.1.7 Storage and Retrieval of Data from Knowledge Base................................. 9 - 10
9.1.8 First Order Definite Clauses ........................................................................ 9 - 14
9.1.9 Inferencing Algorithm for First Order Logic ................................................ 9 - 14
9.1.9.1 Forward Chaining (Lifted Forward Chaining) ............................................ 9 - 14
(xviii)
Unit VI
Chapter - 11 AI Planning (11 - 1) to (11 - 40)
11.1 Planning......................................................................................................... 11 - 2
11.1.1 Difficulties in Planning Problem................................................................... 11 - 2
11.1.2 The Comparison between Problem Solving and Planning ........................... 11 - 3
11.1.3 The Planning Problem.................................................................................. 11 - 3
11.1.4 Representation of Planning Problem........................................................... 11 - 3
11.1.5 Searching for Solution for Planning Problem............................................... 11 - 6
11.1.5.1 Forward State - Space Search (Progression Planner) ................................. 11 - 7
(xix)
Chapter - 12 Programming in AI using Prolog (12 - 1) to (12 - 14)
12.1 Temporal Planning in AI - Time, Schedules, Resources ................................ 12 - 2
12.2 Analysis of Planning Approaches .................................................................. 12 - 4
12.3 AI - Architecture, Components, Future, Limits and Ethics ............................ 12 - 6
12.3.1 AI Architecture ........................................................................................... 12 - 6
12.3.2 AI Components ........................................................................................... 12 - 7
12.3.3 AI Future ..................................................................................................... 12 - 9
12.3.4 Limits and Risks in AI................................................................................. 12 - 10
12.3.5 AI and Ethical Concerns ............................................................................ 12 - 11
Review Questions ................................................................................................ 12 - 12
Multiple Choice Questions with Answers ........................................................... 12 - 12
(xx)
5 th
[Environment]
[Percepts]
[Sensor]
? thinks
[Actuator]
[Action]
AI
Design
Agent program Agent program
architecture
Implements
Agent function
Maps
Perception
Leads to
Action
Good agent
Rational behaviour
Environment unknown
Bad agent
Irrational behaviour
Sequence Expected
Rationality
of percept Depends performance
Maximizes
on
is not same as
Actual
Perfection performance
Maximizes
https://www.youtube.com/watch?
v=yHXatUO6h28
tick-tack-toe Ludo
part picking robo and chess
crossword puzzal vs car triving
maze vs footboll
Rising order of
Low High
complexity
Enviroment
(world with agents)
Percept
through actuators
Action
World
without
agent
Intelligent agent
is
An entity
which perform?
1. Perception
2. Action
S
M
G
U
/
`S
N
G
U
https://www.youtube.com/watch?v=WNrymh1jzGk
Sensor
What the
world is like
now?
What action
Condition - action rule I should do
now?
Actuator
Environment
LIMITION
VERY LESS EFFFICENT
can stuck in loop
limition
Sensor
privious state State
What action I
Condition-action rule
should do now?
Actuators
Environment
Environment
Sensor
pervious State
How the world What the world
evolves? is like now?
What action I
Goals
should do now?
Actuators
limition
not flixable -only move toword single goal
Environment
Sensor
What the
State world is like
now?
What action I
should do now?
Actuator
Performance
standard
Sensors
Critic
Feedback
Changes
Learning Performance
element element
Knowledge
Learning
Goals
Problem
generator
Actuators
Environment Sensors
https://www.youtube.com/watch?v=LAkscQo_Cak
Aurangabad
100
Mumbai
85
190 A. Nagar
120
Beed
Pune 90
Osmanabad
242
65
110
60 110
Satara 305
Phaltan Solapur Hyderabad
Vijapur Vijaywada
Kolhapur
160 190
125
Dharwad Ongala
Koppal
200 150
175 120
Guti 165
Chitradurg 155 Nellore
200 Kodappa
270
145
Banglore 250
Tirupati
150
Chennai
100 Vellore
105 160
Krushagiri 165
480
Puducherri
Madurai
c (x, a, y)
3 10 14
3 10 14
3 10 14
Generate Act
Problem
solving Sequence of Successful
agent actions states
Problem
{ Set of goals }
Goal information
Performace measure
Action, states
Execution
Goal satisfied
Pune
Solapur A. Nagar
Node
Pune
Satara Mumbai
Solapur A. Nagar
Kolhapur
Pune
Phaltan
Leaf node
Fringe
Parent
Q node
Q
Action = Place
Q Queen 4
Q in cell ( 4, 3 )
State Depth = 4
Node
Path cost = 4
Leaf
node
8 Queen problem - some
state configuration
(b d 1 )
Level
2 3 d d+1
b + b + b + b + (b –b)
d+1
=O(b )
107
O (b d 1 )
O (b d 1 )
1 A
2 B C 3
4 5 6 7
D E F G
8 9 10 11
H I J K
O (b [C*/] ) bd
O (b C/)
O (b C/)
1 A
25
10
2 B C
5 5 9
18
3
D E F G
7 8
4
H I J K
O (b d )
O (b d 1)
O (b l )
O (b l )
1 A
2 B C 3
4 5 6 7
D E F G
8 9 10 11
H I J K
1 A
2 B C 5
3 4 6 7
D E F G
H I J K Unexpanded node
O (b d )
Limit = 0 1 A
Limit = 1 1 A
2 B C 3
Limit = 2 1 A
2 B C
3
D E F G
Start Goal
O (b d/2 )
O (b d/2 )
O (b d/2 )
O (b d/2 )
A
B B
C C C C
2d
2d
c)
4d
2 d2
O (b d )
2s
22 (Two possibities)
RB
LB RB
LB
P P
LB RB LB RB
RB RB
LB LB
P P P P
RB
LB RB
LB
P P
8 8
64 63 ... 57 3 10 14
3 10 14
3 3
2 1 3 1 2 3
8 6 4 8 – 4
7 – 5 7 6 5