Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
15CS562
Module I
Syllabus
Ch 1, 2 and 3
What is AI?
Intelligence
Denition
1
Articial Intelligence 15CS562
AI is the study of how to make computers do things which at the moment people
do better.
AI applications in use
Brief history
Alan Turing
Task domains of AI
AI Questions
2. AI Technique
A physical symbol system has the necessary and sucient means for general intel-
ligent action.
AI Technique
The "standard interpretation" of the Turing Test, in which player C, the interroga-
tor, is given the task of trying to determine which player - A or B - is a computer
and which is a human.
The interrogator is limited to using the responses to written questions to make the
determination. If the interrogator cannot make out the dierence between A and
B then computer passes the turing test.
Case study
1. Tic-Tac-Toe game
2. Question answering
Tic-Tac-Toe
player 1 - X, player 2 - O
Three solutions to Tic-Tac-Toe game are provided below, each one with
1. increased complexity
2. use of generalization
3. clarity of knowledge
Program I
1 - X, 2 - O
Data structure:
Board - 9 element vector with 1-9 for each square. An element contain 0 if it is
blank, 1 if it is lled by X or 2 if it is lled with O.
Algorithm:
2. Use the computed number as an index into movetable and access the vector
stored there.
Comments:
3. Dicult to extend.
Program 2
Data structure:
Turn:
Algorithm:
Make2: procedure return 5 if the center square s blank. Else any other non blank
square (2, 4, 6, 8).
Posswin(p): procedure returns 0 if the player p cannot win on his next move;
otherwise it returns the number of the square that constitutes a winning move. If
the product is 18(3x3x2), then X can win. If the product is 50(5x5x2) then O can
win.
Go(n): procedure makes a move in the square n. Set board[n] to 3 if turn is odd
otherwise 5.
The algorithm has a built in strategy for each move. It makes the odd numbered
moves if it is playing X. The strategy for each turn is as follows:
Turn=1, Go(1)
Turn=2, if board[5] is blank Go(5) else Go(1)
Turn=3, if board[9] is blank Go(9) else Go(3)
Turn=4, if Posswin(X) is not 0 then Go(Posswin(X)) else Go(Make2)
...
Comments:
1. Not ecient in time, as it has to check several conditions before making each
move.
3. Hard to generalize.
Program 3
To decide on the next move, look ahead at the board positions that result from
each possible move. Decide which position is best as described below.
2. Otherwise, consider all the moves the opponent could make next. Assume
the opponent will make the move that is worst for us. Assign the rating of
that move to the current node.
3. The best node is then the one with the highest rating.
Comments:
Mary went shopping for a new coat. She found a red one she really liked. When
she got it home, she discovered that it went perfectly with her favourite dress.
Program 1
Program 2
Program 3:
Dene a state space that contains all the possible congurations of the rele-
vant objects.
Specify one or more states within that space that describe possible situations
from which the problem solving process may start ( initial state)
problem analysis
knowledge representation
e.g use graph or tree to illustrate start state, goal state, successor function, and
one or more solutions.
Playing Chess
Goal position is any position in which the opponent does not have a legal
move and his king is under attack.
Legal moves can be described by a set of rules: Left sides are matched against
the current state, Right sides describe the new resulting state.
e.g searching for AI notes in google, where you restrict your search space to AI
subject.
Problem specication
Rules
Solution
Search Trees
Production Systems
3. A control strategy that determines the order in which the rules are applied
to the database, and provides a way of resolving any conicts that can arise
when several rules match at once.
4. A rule applier which is the computational system that implements the control
strategy and applies the rules.
e.g.,
Control strategies
Good control strategy must i) cause motion ii) be systematic iii) Ecient. The
various search algorithms, shown below, are used as control strategies.
BFS Algorithm
DFS Algorithm
BFS will not get trapped exploring a blind alley unlike DFS. BFS nds minimal
solution if there are multiple solutions. BFS will cover tree up to level n before
level n+1 is explored.
DFS will nd solution without traversing the whole tree and is space ecient.
Heuristic search
and there are dierent ways of using h to decide which node is "best".
Example
A salesman has a list of cities, each of which he must visit exactly once. These are
direct roads between each pair of cities on the list. Find the rute salesman follow
for the shortest possible round trip that starts and nishes at any one of the cities.
O(n2 ) vs o(n!)
Problem Characteristics
Is Marcus alive?
OR
Dierent reasonng paths lead to the answer. It does not matter which path
we follow.
Traveling salesman problem - We have to try all paths to nd the shortest
one.
These two problems illustrates the dierence between any-path and best-
path problems. any-path problems can be solved in reasonable amount of
time.
Monotonic Nonmonotonic
Partially commutative Theorem proving Robot navigation
Not partially commutative Chemical synthesis Bridge
3. Matching
5. Heuristic Methods
6. etc.
Hill Climbing
OR Graphs
A* Algorithm
Agendas
Problem reduction
AND-OR Graphs
AO* Algorithm
Constraint satisfaction
Means-ends analysis
2. Test to see it for solution (compare the end points of the path or compare
the points).
This method is basically a depth rst search as complete solutions must be created
before testing.
If the generation of the possible solution is done systematically, then this procedure
will nd a 'good' if it exists.
In case of the large problem space, this might takes a long time.
Even if with the help of heuristic function, this algorithm is not very eective, so
most of the time it is used to restrict the search space.
The key dierence in the generate and test and this hill climbing one is the
use of an evaluation function.
It is also possible to consider all the moves from the current state and a best
among them is selected. This is Steepest-Ascent Hill Climbing.
1. Evaluate the initial state. If it is a goal state, then return it and quit.
Otherwise continue with the initial state as current state.
a. Let SUCC be a state such that any possible successor of the current
state will be better than SUCC.
b. For each operator that applies to the current state do:
i. Apply the operator and generate a new state.
ii. Evaluate a new state. If it is a goal state, then return it and
quit. If not, compare it to SUCC. If it is better, then set SUCC to
this state. If it is not better, leave SUCC alone.
c. If the SUCC is better than current state, then set current state to
SUCC.
Simulated Annealing
p = e-∆ E/kT
p = [1,0] when T=[∞, 0]
Decreasing temperature schedule
Evaluate the initial state. If it is goal state then quit otherwise make the
current state this initial state and proceed.
Repeat
∆ E dierence between the values of current and new states
Observations
The central idea of best-rst search based on heuristic is to expand the path
that seems most promising.
This is the way of combining the advantages of depth rst and breadth rst
search into a single method
OPEN - nodes that have been generated and have had the heuristic function
applied to them but which have not yet been examined.
OPEN is actually a priority queue in which the elements with the highest priority
are those with the most promising value of the heuristic function.
CLOSED - nodes that have been examined. We need to keep these nodes in
memory if we want to search a graph rather than a tree, since whenever a new
node is generated, we need to check whether it has been generated before.
BFS Algorithm
Best-rst search: A*
f(n) is evaluation function that estimates least cost solution through node n.
g(n) gives the path cost from the start node to node n
h(n) names as heuristic function is the estimated cost of the cheapest path
from n to the goal node.
Example 1
Example 2
Example
A* Algorithm
3. Select the rst node on OPEN and put it into CLOSED. Call this node n.
A* Algorithm
Dijkstra;s algorithm
BFS
g(n) = 1, h(n) = 0
Applications
Network routing
AI path nding
Image processing
2. Expand nodes in the least cost path and estimate h of the newly generated
children.
AO* Algorithm
2. Expand nodes in the least cost path and estimate h of the newly generated
children.
Constraint Satisfaction
Examples of this technique are design problem, labelling graphs, robot path
planning and cryptarithmetic puzzles (see last year).
Map coloring
Cryptarithmetic
S E N D 9 5 6 7
+ M O R E + 1 0 8 5
------------- ----------
M O N E Y 1 0 6 5 2
Variables D, E, M, N, O, R, S, Y
Constraints
Constraint propagation
1. M=1
Since two single digit numbers plus a carry cannot total more than 19
2. S = 8 or 9
3. O = 0
M is already 1
S = 8 or 9
4. N = E or E+1
Guess
Then to make progress from here, we must guess. Suppose E=2 (we choose to
guess a value for E because it occurs three times). Now the next cycle begins
Constraint propagation
1. N = 3
N=E+1
2. R = 8 or 9
R + N(3) + C1 (1 or 0) = 2 or 12
R + 3 + (0 or 1) = 12 since N is already 3 otherwise sum is -ve
3. 2 + D = Y or 2 + D = 10 + Y
Guess
1. C1 = 1, we eventually reach dead ends. The process will backtrack and try
C1 =0
Algorithm:
Means-Ends Analysis
MEA operations
MEA progress
MEA Algorithm
Describe the current state, the goal state and the dierences between
the two.
Use the dierence the describe a procedure that will hopefully get nearer
to goal.
Use the procedure and update current state.
Observations
Assignment
8. What is the dierences between generate & test and hill climbing. How
simulated annealing overcome the problems in hill climbing.
10. What is the objective function used in A* search. Find the path between 0
and 3 for the following graph.
.
Use h(n) < Min( cost( path(n, goal))).