AI Lecture 4

You might also like

You are on page 1of 40

Previous Lecture

 Definitions
 History
 Three Phases (initial, Learning, Discovery)
 Searching
 Robotics
Problem Solving
 Historically people viewed the phenomena of
intelligence as strongly related to problem
solving
Classical Approach
 Simple
 hit and trial method
Examples of Classical Approach
 Consider maze searching problem
 Consider that a toddler is to switch on the

light in a dark room.


 combinational lock of a briefcase.
Common Thing
 similar approach to solve the problem at
hand.
 Technically called this hit and trial approach

the “Generate and Test” approach.


Generate and Test
 Technical name
 different combinations to solve problem
 correct solution and incorrect solutions.
Generate and Test
Problem Representation
 Trivial in nature
 Natural representation
Example
Components of Problem Solving
 Problem Statement
 Goal State
 Solution Space
 Operators.
Problem Statement
 essential component
 “infinite amount of time
Problem Solution
 ultimate aim.
 output of our procedure
 Goal State
Solution space
 The set of the start state, the goal state and
all the intermediate states constitutes
something which is called a solution space.
Traveling in the solution space
 The traveling inside a solution space requires
something called as “operators”.
 sequence of operators is actually the solution

to problem.
Categories of Problem
 Structured ( Straight Forward, Farmer goose
problem, Maximum Number Finding)
 ILL Structured ( Not Straight Forward, Limited

Characteristics,
Approaches to Solve Problem
 Solution Focused
 Problem Focused
 Satisfying terminology
Graphical Representation of Problem
 Initial State
 Goal State
 Intermediate State ( Should Be Linked)
 Combination of all solution space
Previous Lecture
 We saw generate and test example
 We generate some solution without any

planning
 Problem space /solution space
Two – One Problem
Start Goal
11 ? 2 2 22 ? 1 1

Legal Moves:
Rules: • Slide
• 1s’ move right
• 2s’ move left
• Only one move at a • Hop
time
• No backing up
Two – One Problem
Trials to solve the problem

Trial One Trial Two

11 ? 2 2 11 ? 2 2

11 2 ? 2 1? 1 2 2

1? 2 1 2 ?1 1 2 2

12 ? 1 2 Stuck!!!

12 2 1 ?

12 2 ? 1

Stuck!!!
Two – One Problem
Five States
Two – One Problem
Solution Space
H H
?1 1 2 2 1 1?2 2 1122 ?
S S

1 ?1 2 2 1 1 2? 2
S H H S

?1122 1 2 1?2 1 ?2 1 2 1122 ?


S S S S

1212 ? 1 2 ?1 2 ?1 2 1 2
H
H H H

1 2?2 1 ?2 1 1 2 1 2 2 1? 2 1?1 2
S H S S H S

1 2 2? 1 ?2 1 2 1 2 ?1 1 2 1 2 2 ?1 2112 ? 2 ?1 1 2
S
S

2 ?1 2 1 212 ?1
H H

2 2 1? 1 2 ?2 1 1
S S

2 2?1 1
 Informed way for problem solving
 Systematic approach (initial state, goal state,

intermediate states , dead ends, limitations,


Representation of problem
 Graph,
 Tree
 Powerful representation
 Roadmap example
Searching
 Huge component of AI.
 We check all possibilities of problem
 Tree and graph terminology
 Root node
 Ancestor
 Descendent
 Nodes represent different states
 Edges represent the operator
 Without exploring child node that node will
be open node.
 Closed node
 Directed graph
 Undirected graph
 Blocks example
 Map example
 Tree conversion
Solution to Problem Solving : Searching
H H
?1 1 2 2 11 ? 22 1122 ?
S S
Airport
1 ?1 2 2 112 ? 2

S H H S
?1122 121 ? 2 1 ?212 1122 ?
Q1 Q2
S S S S
1212 ? 12 ? 12 ?1 2 1 2
H H H H
12 ?21 ?2 1 1 2 1221 ? 21 ? 12 Q4
Q3
Q5
S H S S H S
122 ? 1 ?2 1 2 1 2 ?1 1 2 122 ? 1 2112 ? 2 ?112

S S Hotel

2 ?121 212 ? 1

Farmer
H H
Grain Goose 221 ? 1 2 ?211
Grain

S S
22 ? 11
Farmer
Fox Fox
Goose

Farmer
Farmer
Fox Fox Farmer
Fox Goose
Goose Grain Goose
Grain
Grain

Farmer
Farmer
Farmer Fox Fox
Goose Fox
Goose Grain Goose
Grain
Grain

Farmer
Fox Fox
Goose

Farmer
Goose Grain
Grain
Tree and Graph Terminology

B C

D E F G H

•“A” is the “root node”


I J
•“A, B, C …. J” are “nodes”
•“B” is a “child” of “A”
•“A” is ancestor of “D”
•“D” is a descendant of “A”
•“D, E, F, G, I, J” are “leaf nodes”
•Arrows represent “edges” or
“links”
Examples of Graphs
Problem Formulation using
Graphs
 The search methods we’ll be dealing with
are defined on trees and graphs

3 3
A B C
2

4
S G
4

3 2
D E F
1 3
Tree Search
 Graph search is really tree search

3 3
A B C A D
2

B D A E
4

S
G C E E B B F

3 2 D F B F C E A C G
D E F
1 3
G C G F

G
The 8-puzzle as a production system
Production System: Knight Tour

Institute of Computing, Bahauddin Zakariya


University, Multan.
Production rules for the 3 x 3 knight problem
Bridges of KÖnigsberg Problem

connect(i1,i2,b1) connect(i2,i1,b1)
connect(rb1,i1,b2) connect(i1,rb1,b2)
onnect(rb1,i1,b3) onnect(i1,rb1,b3)
connect(rb1,i2,b4) connect(i2,rb1,b4)
connect(rb2,i1,b5) connect(i1,rb2,b5)
connect(rb2,i1,b6) connect(i1,rb2,b6)
connect(rb2,i2,b7) connect(i2,rb2,b7)

Institute of Computing
Block World
on(c,a).
on(b,d).
ontable(a).
ontable(d).
clear(b).
clear(c).
hand_empty.

Institute of Computing
Types of search
 Blind or uninformed search (no knowledge
about place)
 Base on guess
 Another name brute

You might also like