Problem Characteristics

Unit 1
Definition's of AI
 AI is a branch of Computer Science concerned with the study and creation of computer systems.
 The science and engineering of making intelligent machines", especially intelligent computer
programs.
 Artificial Intelligence (AI) is the intelligence of machines and the branch of computer science that
aims to create it.

AI is study of how to make computers do things which at a moment, people do better.
Why Artificial Intelligence?
Motivation...
Computers are fundamentally well suited to performing mechanical computations, using fixed
programmed rules. This allows artificial machines to perform simple monotonous tasks efficiently
and reliably, which humans are ill-suited to. For more complex problems, things get more difficult...
Unlike humans, computers have trouble understanding specific situations, and adapting to new
situations. Artificial Intelligence aims to improve machine behavior in tackling such complex tasks.
Together with this, much of AI research is allowing us to understand our intelligent behavior.
Humans have an interesting approach to problem-solving, based on abstract thought, high-level
deliberative reasoning and pattern recognition. Artificial Intelligence can help us understand this
process by recreating it, then potentially enabling us to enhance it beyond our current capabilities.
When will Computers become truly Intelligent?
Limitations...
To date, all the traits of human intelligence have not been captured and applied together to spawn an
intelligent artificial creature. Currently, Artificial Intelligence rather seems to focus on
lucrative domain specific applications, which do not necessarily require the full extent of AI
capabilities. This limit of machine intelligence is known to researchers as narrow intelligence.
There is little doubt among the community that artificial machines will be capable of intelligent
thought in the near future. It's just a question of what and when... The machines may be pure silicon,
quantum computers or hybrid combinations of manufactured components and neural tissue. As for the
date, expect great things to happen within this century!
How does Artificial Intelligence work?
Technology...
There are many different approaches to Artificial Intelligence, none of which are either completely
right or wrong. Some are obviously more suited than others in some cases, but any working
alternative can be defended. Over the years, trends have emerged based on the state of mind of
influential researchers, funding opportunities as well as available computer hardware.
Over the past five decades, AI research has mostly been focusing on solving specific problems.
Numerous solutions have been devised and improved to do so efficiently and reliably. This explains
why the field of Artificial Intelligence is split into many branches, ranging from Pattern
Recognition to Artificial Life, including Evolutionary Computation and Planning.
Who uses Artificial Intelligence?
Applications...
The potential applications of Artificial Intelligence are abundant. They stretch from the military for
autonomous control and target identification, to the entertainment industry for computer games and
robotic pets. Lets also not forget big establishments dealing with huge amounts of information such
as hospitals, banks and insurances, who can use AI to predict customer behavior and detect trends.
As you may expect, the business of Artificial Intelligence is becoming one of the major driving forces
for research. With an ever growing market to satisfy, there's plenty of room for more personnel. So if
you know what you're doing, there's plenty of money to be made from interested big companies!
Areas of Artificial Intelligence






Perception
 Machine vision
 Speech understanding
 Touch ( tactile or haptic) sensation
Robotics
Natural Language Processing
 Natural Language Understanding
 Speech Understanding
 Language Generation
 Machine Translation
Planning
Expert Systems
Machine Learning



Theorem Proving
Symbolic Mathematics
Game playing
Intelligence
 ability to learn, understand and think”
 Examples: creativity, solving problem, pattern recognition, classification, learning , language
processing , optimization.
 Intelligence is the computational part of the ability to achieve goals.
 A mechanism which
a) Stimulates – action, speech, further thought,
generation.
information
generation,
b) Triggered by external and internal stimulates.
c) Acts through: - present environment or past memory.
d) Stored as- charged/discharged state of neurons or electromagnetic waves
e) Does not possess any physical or chemical properties
Intelligence Behaviour








Perceiving ones environment .
Acting in complex environment .
Learning and understanding from experience,
Reasoning to solve problems and discover hidden knowledge.
Knowledge applying successfully in new situations .
Thinking abstractly.
Communicating with others , and more like,
Creativity , expressiveness, curiosity.
knowledge
Difference between Human brain & Computer
Human Brain
Computer
Living device
Non-Living device
Self-willing & creative
Dependent & must be programmed
Has continuous in nature
Discrete in nature
Basic unit is neuron
Basic units is RAM cell
Storage devices are electro-chemical in nature
Storage devices are electronic & magnetic
Speed of transmission is of the order 50-100 m/s
Speed of transmission is approx the speed of light
Has inductive and detective reasoning capability
No reasoning power
Has emotions
No emotions
Has the capacity to learn
Must be programmed
Most Sophisticated device & highly advanced with Only retention & recall have achieved a certain
degree of sophistication
respect to intelligence
Typical AI Problems tasks involve both :


Mundane tasks which people can do very easily ( understanding language)
Expert tasks that require specialist knowledge ( medical diagnosis)
Mundane tasks correspond to the following AI problems areas:


Planning : The ability to decide on a good sequence of actions to achieve our goals.
Vision: The ability to make sense of what we see.


Robotics: The ability to move and act in the world, possibly responding to new perceptions.
Natural language: The ability to communicate with others in any human language.
Experts tasks (require specialized skills and training) include :
 Medical diagnosis
 Equipment repair
 Computer configuration
 Financial planning
Mundane tasks are generally much harder to automate. AI is concerned with automating both mundane
and expert tasks.
AI Technique


Intelligence requires Knowledge.
Knowledge possesses less desirable properties such as:
 Voluminous
 Hard to characterize accurately
 Constantly changing
 Differs from data that can be used
 AI technique is a method that exploits knowledge that should be represented in such a way that:
 Knowledge captures generalization
 It can be understood by people who must provide it
 It can be easily modified to correct errors.
 It can be used in variety of situations
Intelligent System Should do:




In practical terms, intelligent systems:
Should have the ability to automatically perform tasks that normally require a human expert.
Should have more autonomy; less requirement for human intervention or monitoring.
Should have Flexibility in dealing with variability in the environment in an appropriate
manner.
 Are easier to use: able to understand what the user wants from limited instructions.
 Can improve their performance by learning from experience.
Tic Tac Toe
 Two players
 human
 computer.
 The objective is to write a computer program in such a way that computer wins most of the time.
 Three approaches are presented to play this game which increase in
 Complexity
 Use of generalization
 Clarity of their knowledge
 Extensibility of their approach
 These approaches will move towards being representations of what we will call AI techniques.
It is two players, X and O, game who take turns marking the spaces in a 3×3 grid. The player who
succeeds in placing three respective marks in a horizontal, vertical, or diagonal row wins the game.
Approach 1



Data Structure
 Consider a Board having nine elements vector.
 Each element will contain
 0 for blank
 1 indicating X player move
 2 indicating O player move
 Computer may play as X or O player.
 First player who so ever is always plays X.
MT is a vector of 39 elements, each element of which is a nine element vector representing board
position.
Total of 39 (19683) elements in MT.
Index
0
1
2
3

Current Board position
000000000
000000001
000000002
000000010
New Board position
000010000
020000001
000100002
002000010
To make a move, do the following:
 View the vector (board) as a ternary number and convert it to its corresponding decimal
number.
 Use the computed number as an index into the MT and access the vector stored there.
 The selected vector represents the way the board will look after the move.
 Set board equal to that vector.
Comments
 Very efficient in terms of time but has several disadvantages.
 Lot of space to store the move table.
 Lot of work to specify all the entries in move table.
 Highly error prone as the data is voluminous.
 Poor extensibility
 3D tic-tac-toe = 327 board position to be stored.
 Not intelligent at all.
Approach 2
 Board: A nine-element vector representing the board: B[1..9]
 Following conventions are used
2
indicates blank
3
X
5
0
 Turn: An integer
1
First move
9
Last move
Procedures Used




Make_2  Tries to make valid 2
 Make_2 first tries to play in the center if free and returns 5 (square number).
 If not possible, then it tries the various suitable non corners square and returns square
number.
Go(n)  makes a move in square ‘n’ which is blank represented by 2.
PossWin (P)  Returns
 0, if player P cannot win in its next move,
 otherwise the number of square that constitutes a winning move for P.
Rule
 If PossWin (P) = 0 {P can not win} then find whether opponent can win. If so, then block it.
Strategy used by PosWin

PosWin checks one at a time, for each rows /columns and diagonals as follows.
 If 3 * 3 * 2 = 18 then player X can win
 else if 5 * 5 * 2 = 50 then player O can win

These procedures are used in the algorithm on the next slide.
Algorithm
Assumptions
 The first player always uses symbol X.
 There are in all 8 moves in the worst case.
 Computer is represented by C and Human is represented by H.
 Convention used in algorithm on next slide
 If C plays first (Computer plays X, Human plays O) - Odd moves
 If H plays first (Human plays X, Computer plays O) - Even moves
 For the sake of clarity, we use C and H.
Algo - Computer plays first – C plays odd moves




Move 1: Go (5)
Move 2: H plays
Move 3: If B[9] is blank, then Go(9) else Go(3) {make 2}
Move 4: H plays
 Move 5: {By now computer has played 2 chances}
 If PossWin(C) then {won} Go(PossWin(C))
 else {block H} if PossWin(H) then Go(PossWin(H)) else if B[7] is blank then Go(7) else
Go(3)
 Move 6: H plays
 Moves 7 & 9 :
 If PossWin(C) then {won} Go(PossWin(C))
 else {block H} if PossWin(H) then Go(PossWin(H)) else Go(Anywhere)
 Move 8: H plays
Algo - Human plays first – C plays even moves








Move 1: H plays
Move 2: If B[5] is blank, then Go(5) else Go(1)
Move 3: H plays
Move 4: {By now H has played 2 chances}
 If PossWin(H) then {block H} Go (PossWin(H))
 else Go (Make_2)
Move 5: H plays
Move 6: {By now both have played 2 chances}
 If PossWin(C) then {won} Go(PossWin(C))
 else {block H} if PossWin(H) then Go(PossWin(H)) else Go(Make_2)
Moves 7 & 9 : H plays
Move 8: {By now computer has played 3 chances}
 If PossWin(C) then {won} Go(PossWin(C))
 else {block H} if PossWin(H) then Go(PossWin(H)) else Go(Anywhere)
Complete Algorithm – Odd moves or even moves for C playing first or second




Move 1: go (5)
Move 2: If B[5] is blank, then Go(5) else Go(1)
Move 3: If B[9] is blank, then Go(9) else Go(3) {make 2}
Move 4: {By now human (playing X) has played 2 chances} If PossWin(X) then {block H} Go
(PossWin(X)) else Go (Make_2)
 Move 5: {By now computer has played 2 chances} If PossWin(X) then {won} Go(PossWin(X))
else {block H} if PossWin(O) then Go(PossWin(O)) else if B[7] is blank then Go(7) else Go(3)
 Move 6: {By now both have played 2 chances} If PossWin(O) then {won} Go(PossWin(O)) else
{block H} if PossWin(X) then Go(PossWin(X)) else Go(Make_2)
 Moves 7 & 9 : {By now human (playing O) has played 3 chances} If PossWin(X)
then
{won} Go(PossWin(X)) else {block H} if PossWin(O) then Go(PossWin(O)) else Go(Anywhere)
 Move 8: {By now computer has played 3 chances} If PossWin(O) then {won} Go(PossWin(O))
else {block H} if PossWin(X) then Go(PossWin(X)) else Go(Anywhere)
Comments





Not as efficient as first one in terms of time.
Several conditions are checked before each move.
It is memory efficient.
Easier to understand & complete strategy has been determined in advance
Still can not generalize to 3-D.
Approach 3


Same as approach 2 except for one change in the representation of the board.
 Board is considered to be a magic square of size 3 X 3 with 9 blocks numbered by
numbers indicated by magic square.
This representation makes process of checking for a possible win more simple.
Strategy for possible win for one player
 Maintain the list of each player’s blocks in which he has played.
 Consider each pair of blocks that player owns.
 Compute difference D between 15 and the sum of the two blocks.
 If D < 0 or D > 9 then
 these two blocks are not collinear and so can be ignored
 otherwise if the block representing difference is blank (i.e., not in either list) then
a move in that block will produce a win.
 Assume that the following lists are maintained up to 3rd move.
 Consider the magic block shown in slide 18.
 First Player X (Human)
8
3
 Second Player O (Computer)
5
 Strategy is same as in approach 2
 First check if computer can win.
 If not then check if opponent can win.
 If so, then block it and proceed further.
 Steps involved in the play are:
 First chance, H plays in block numbered as 8
 Next C plays in block numbered as 5
 H plays in block numbered 3
 Now there is a turn of computer.
 Strategy by computer: Since H has played two turns and C has played only one turn, C checks if
H can win or not.
 Compute sum of blocks played by H
 S = 8 + 3 = 11
 Compute D = 15 – 11 = 4
 Block 4 is a winning block for H.
 So block this block and play in block numbered 4.
 The list of C gets updated with block number 4 as follows:
H 8 3
C 5 4
 Assume that H plays in block numbered 6.
 Now it’s a turn of C.
 C checks, if C can win as follows:
 Compute sum of blocks played by C
 S=5+4=9
 Compute D = 15 – 9 = 6
 Block 6 is not free, so C can not win at this turn.
 Now check if H can win.
 Compute sum of new pairs (8, 6) and (3, 6) from the list of H
 S = 8 + 6 = 14
 Compute D = 15 – 14 = 1
 Block 1 is not used by either player, so C plays in block numbered as 1
 The updated lists at 6th move looks as follows:
 First Player H
8
3
6
 Second Player C
5
4
1
 Assume that now H plays in 2.
 Using same strategy, C checks its pair (5, 1) and
(4, 1) and finds bock numbered as 9 {15-6 =
9}.
 Block 9 is free, so C plays in 9 and win the game.
Comments
 This program will require more time than two others as
 it has to search a tree representing all possible move sequences before making each
move.
 This approach is extensible to handle
 3-dimensional tic-tac-toe.
 games more complicated than tic-tac-toe.
Problems, Problem Spaces and Search
To build a system to solve a problem
1. Define the problem precisely
2. Analyse the problem
3. Isolate and represent the task knowledge that is necessary to solve the problem
4. Choose the best problem-solving techniques and apply it to the particular problem.
Example: Playing Chess
• To build a program that could “play chess”, we could first have to specify the starting position of
the chess board, the rules that define the legal moves, and the board positions that represent a win
for one side or the other.
• In addition, we must make explicit the previously implicit goal of not only playing the legal game
of chess but also winning the game, if possible.
Defining chess problem as State Space search
• We need to write the rules describing the legal moves in as general a way as possible.
• For example:
– White pawn at Square( file e, rank 2) AND Square( File e, rank 3) is empty AND
Square(file e, rank 4) is empty, - move the pawn from Square( file e, rank 2) to Square(
file e, rank 4).
• In general, the more succintly we can describe the rules we need, the less work we will have to do
to provide them and more efficient the program.
• The state space representation forms the basis of most of the AI methods.
• Its structure corresponds to the structure of problem solving in two important ways:
– It allows for a formal definition of a problem as the need to convert some given situation
into some desired situation using a set of permissible operations.
– It permits us to define the process of solving a particular problem as a combination of
known techniques (each represented as a rule defining a single step in the space) and
search, the general technique of exploring the space to try to find some path from current
state to a goal state.
– Search is a very important process in the solution of hard problems for which no more
direct techniques are available.
Water Jug Problem
• The state space for this problem can be described as the set of ordered pairs of integers (x,y) such
that x = 0, 1,2, 3 or 4 and y = 0,1,2 or 3; x represents the number of gallons of water in the 4gallon jug and y represents the quantity of water in 3-gallon jug
• The start state is (0,0)
• The goal state is (2,n)
• The operators to be used to solve the problem can be described as follows:
•
•
•
Required a control structure that loops through a simple cycle in which some rule whose left side
matches the current state is chosen, the appropriate change to the state is made as described in the
corresponding right side, and the resulting state is checked to see if it corresponds to goal state.
One solution to the water jug problem
Shortest such sequence will have a impact on the choice of appropriate mechanism to guide the
search for solution.
Formal Description of the problem
1. Define a state space that contains all the possible configurations of the relevant objects.
2. Specify one or more states within that space that describe possible situations from which the
problem solving process may start ( initial state)
3. Specify one or more states that would be acceptable as solutions to the problem. ( goal states)
4. Specify a set of rules that describe the actions ( operations) available.
Production Systems
A production system consists of:
• A set of rules, each consisting of a left side that determines the applicability of the rule
and a right side that describes the operation to be performed if that rule is applied.
• One or more knowledge/databases that contain whatever information is appropriate for
the particular task. Some parts of the database may be permanent, while other parts of it
may pertain only to the solution of the current problem.
• A control strategy that specifies the order in which the rules will be compared to the
database and a way of resolving the conflicts that arise when several rules match at once.
Inorder to solve a problem:
• We must first reduce it to one for which a precise statement can be given. This can be
done by defining the problem’s state space ( start and goal states) and a set of operators
for moving that space.
• The problem can then be solved by searching for a path through the space from an initial
state to a goal state.
• The process of solving the problem can usefully be modeled as a production system.
Control Strategies
•
•
How to decide which rule to apply next during the process of searching for a solution to a
problem?
The two requirements of good control strategy are that
– it should cause motion.
– It should be systematic
Breadth First Search
• Algorithm:
1. Create a variable called NODE-LIST and set it to initial state
2. Until a goal state is found or NODE-LIST is empty do
a. Remove the first element from NODE-LIST and call it E. If NODE-LIST was
empty, quit
b. For each way that each rule can match the state described in E do:
i.
Apply the rule to generate a new state
ii.
If the new state is a goal state, quit and return this state
iii.
Otherwise, add the new state to the end of NODE-LIST
Depth First Search
1. If the initial state is a goal state, quit and return success
2. Otherwise, do the following until success or failure is signaled:
a. Generate a successor, E, of initial state. If there are no more successors, signal failure.
b. Call Depth-First Search, with E as the initial state
c. If success is returned, signal success. Otherwise continue in this loop.
Backtracking
• In this search, we pursue a singal branch of the tree until it yields a solution or until a decision to
terminate the path is made.
• It makes sense to terminate a path if it reaches dead-end, produces a previous state. In such a state
backtracking occurs
• Chronological Backtracking: Order in which steps are undone depends only on the temporal
sequence in which steps were initially made.
• Specifically most recent step is always the first to be undone.
• This is also simple backtracking.
Advantages of Depth-First Search
• DFS requires less memory since only the nodes on the current path are stored.
• By chance, DFS may find a solution without examining much of the search space at all.
Advantages of BFS
• BFS will not get trapped exploring a blind alley.
• If there is a solution, BFS is guarnateed to find it.
• If there are multiple solutions, then a minimal solution will be found.
Traveling Salesmen Problem TSP
• A simple motion causing and systematic control structure could solve this problem.
• Simply explore all possible paths in the tree and return the shortest path.
• If there are N cities, then number of different paths among them is 1.2….(N-1) or (N-1)!
• The time to examine single path is proportional to N
• So the total time required to perform this search is proportional to N!
• For 10 cities, 10! = 3,628,800
• This phenomenon is called Combinatorial explosion.
Branch and Bound
• Begin generating complete paths, keeping track of the shortest path found so far.
• Give up exploring any path as soon as its partial length becomes greater than the shortest path
found so far.
• Using this algorithm, we are guaranteed to find the shortest path.
• It still requires exponential time.
• The time it saves depends on the order in which paths are explored.
Heuristic Search
•
A Heuristic is a technique that improves the efficiency of a search process, possibly by sacrificing
claims of completeness.
• Heuristics are like tour guides
• They are good to the extent that they point in generally interesting directions;
• They are bad to the extent that they may miss points of interest to particular individuals.
• On the average they improve the quality of the paths that are explored.
• Using Heuristics, we can hope to get good ( though possibly nonoptimal ) solutions to hard
problems such asa TSP in non exponential time.
• There are good general purpose heuristics that are useful in a wide variety of problem domains.
• Special purpose heuristics exploit domain specific knowledge
Nearest Neighbor Heuristic
• It works by selecting locally superior alternative at each step.
• Applying to TSP:
1. Arbitrarily select a starting city
2. To select the next city, look at all cities not yet visited and select the one closest to the
current city. Go to next step.
3. Repeat step 2 until all cities have been visited.
– This procedure executes in time proportional to N2
It is possible to prove an upper bound on the error it incurs. This provides reassurance that one is not
paying too high a price in accuracy for speed.
Problem Characteristics
•
Inorder to choose the most appropriate method for a particular problem, it is necessary to analyze
the problem along several key dimensions:
– Is the problem decomposable into a set of independent smaller or easier subproblems?
–
–
–
Can solution steps be ignored or at least undone if they prove unwise?
Is the problem’s universe predictable?
Is a good solution to the problem obvious without comparison to all other possible
solutions?
Is the problem Decomposable?
• Whether the problem can be decomposed into smaller problems?
• Using the technique of problem decomposition, we can often solve very large problems easily.
Blocks World Problem
• Following operators are available:
• CLEAR(x) [ block x has nothing on it]-> ON(x, Table)
• CLEAR(x) and CLEAR(y) -> ON(x,y) [ put x on y]
Start: ON(C,A)
Goal: ON(B,C) and ON(A,B)
Can Solution Steps be ignored or undone?
Theorem Proving: Ignorable problem
A lemma that has been proved can be ignored for next steps.
The 8-Puzzle: Recoverable problem
Moves can be undone and backtracked.
Playing Chess: Irrecoverable problem
Moves cannot be retracted.
•
•
•
Ignorable problems can be solved using a simple
control structure that never backtracks.
Recoverable problems can be solved using backtracking.
Irrecoverable problems can be solved by recoverable style methods via planning.
Is the universe predictable?
The 8-Puzzle: problem with Certain outcome
Every time we make a move, we know exactly what will
happen.
Playing Bridge: problem with Uncertain outcome
We cannot know exactly where all the cards are or what the other players will do on their turns.
•
•
For certain-outcome problems, planning can used to generate a sequence of operators that is
guaranteed to lead to a solution.
For uncertain-outcome problems, a sequence of generated operators can only have a good
probability of leading to a solution.
Plan revision is made as the plan is carried out and the necessary feedback is provided.
Is a good solution absolute or relative?
Ex.
1. Marcus was a man.
2. Marcus was a Pompeian.
3. Marcus was born in 40 A.D.
4. All men are mortal.
5. All Pompeians died when the volcano erupted in 79 A.D.
6. No mortal lives longer than 150 years.
7. It is now 2004 A.D.
Is Marcus alive?
Different reasoning paths lead to the answer. It does not matter which path we follow.
The Travelling Salesman Problem
We have to try all paths to find the shortest one.
• Any-path problems can be solved using heuristics that suggest good paths to explore.
• For best-path problems, much more exhaustive search will be performed.
Questions
1. Analyze each of the following problem with respect to four problem characteristics discussed
• Chess
• 8-puzzle
• Missionaries and cannibals
• Monkey and banana
• Bridge
• Water Jug
• Travelling salesman
• Tower of Honoi
2. What is AI? Give its important.
3. Describe AI technique with Tic-tac-toe problem.
4. Describe Pattern Recognition problem and its approaches.
5. Explain success criteria in detail.
6. Define Water Jug problem as a state space search and generate one solution sequence.
7. Explain production system with one example.
8. Explain control strategy for Water Jug problem using Depth first search and Breath first search.