Ai Module 1 PPT 1
Ai Module 1 PPT 1
MODULE 1
SYLLABUS
• Introduction: What is AI
• The foundations of AI
• History and applications
• Production systems.
• Structures and strategies for state space search.
• Informed and Uninformed searches.
Prepared by Sharika T R, SNGCE
Aritificial Intelligence
The AI problems
Cont..
• AI is a system that acts like human beings
– Natural language processing
• To enable it to communicate successfully in English.
– Knowledge representation
• To store what it knows or hears.
– Automated reasoning
• To use the stored information to answer questions and to draw new
conclusions.
– Machine learning
• To adapt to new circumstances and to detect and extrapolate patterns.
– Computer vision:To perceive objects.
– Robotics: To manipulate objects and move about. 5
Cont..
Cont..
AI Application Areas
• Game Playing
• Heuristics
• Automated Reasoning and Theorem Proving
• Expert Systems
• Natural Language Understanding and Semantic Modeling
• Modeling Human Performance
Cont..
• To build a program
– Specify the starting position of the chess board
– The rules that define the legal moves
– The board positions that represent a win for one side or other
• Set of rules consisting of two parts:
– A left side that serves as a pattern to be matched against the
current board position
– A right side that describe the change to be made to the board
position to reflect the move
Cont..
Cont..
Cont..
• state space
– set of ordered pair of integers(x,y) such that
– x=0,1,2,3 or 4 and y=0,1,2 or 3.
– x represent number of gallon of water in the 4 gallon jug
– y represent number of gallon of water in the 3 gallon jug
• Start state is (0,0).
• Goal state is (2,n) n can be any value.
• Production rules
1 (x,y) -----> (4,y)If x<4 Fill the 4 gallon jug
2 (x,y) -----> (x,3)If y<3 Fill the 3 gallon jug
3 (x,y) -----> (x-d,y)If x>0 Pour some water out of 4 gallon jug
4 (x,y) -----> (x,y-d)If y>0 Pour some water out of 3 gallon jug
Cont..
7 (x,y) -----> ( 4, y-(4-x) ) If Pour water from 3 gallon jug into 4 gallon jug until 4
x+y>=4 and y>0 gallon jug is fill
8 (x,y) -----> ( x-(3-y), 3 ) If x+y>=4 Pour water from 4 gallon jug into 3 gallon jug until 3
and y>0 gallon jug is fill
9 (x,y) -----> (x+y,0) If x+y<=4 and Pour all water from 3 gallon jug into 4 gallon jug
y>0
10 (x,y) -----> (0,x+y) If x+y<=4 and Pour all water from 4 gallon jug into 3 gallon jug
y>0
11 (0,2) -----> (2,0) If x+y<=4 and Pour the 2 gallon from 3 gallon jug into 4 gallon jug.
y>0
12 (2,y) -----> (0,y) If x+y<=4 and Empty the 2 gallon in the 4 gallon on the ground
Prepared by Sharika T R, SNGCE 19
y>0
Solution
Gallon in 4 gallon Gallon in 3 gallon Rule Applied
Jug Jug
Cont..
• Production System
– A set of rules each contsisting of a
• left side that determines the applicability of the rule and
• right side that describes the operation to be performed if rule is applied.
– One or more knowledge/database that contain whatever
information is appropriate for the particular task.
– A control stratergy 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
– A rule applier.
Prepared by Sharika T R, SNGCE 22
Prepared by Sharika T R, SNGCE
Problem Charateristics
• Decomposable problems
• Non Decomposable problems
1. Decomposable problems
Cont..
Cont..
Ignorable Problem
Recoverable Problems
• eg, 8 Puzzle
• 8-puzzle solver can keep track of the order in which
operations are performed so that the operations can be
undone one at a time if necessary.
Irrecoverable problems
• eg. Chess
• Suppose a chess playing program makes a stupid move
and realizes it a couple of moves later.
• It cannot simply play as though it had never made the
stupid move.
• Nor can it simply back up and start the game over from
that point.
• All it can do is to try to make the best of the current
situation and go from there.
Prepared by Sharika T R, SNGCE 33
Cont..
• 8 puzzle problem.
• Every time we make a move, we know exactly what will
happen.
• This means that it is possible to plan an entire sequence
of moves and be confident that we know what the
resulting state will be.
• Bridge
– planning may not be possible.
– One of the decisions we will have to
make is which card to play on the first
trick.
– it is not possible to do such planning
with certainty since we cannot know
exactly where all the cards are or
what the other players will do on their
turns.
Solutions Axiom
1 Marcus was a man. 1
4 All men are mortal. 4
3 Marcus was born in 40 A.D. 3
7 It is now 2017 A. D. 7
9 Marcus’ age is 1977 years. 3,7
6 no mortal lives longer than 150 years. 6
10 Marcus is dead. 8,6,9
Prepared by Sharika T R, SNGCE 40
Prepared by Sharika T R, SNGCE
• Solitary problems
– Here the computer is given a problem description and produces
an answer with no intermediate communication and with no
demand for an explanation for the reasoning process.
– Consider the problem of proving mathematical theorems. If
• All we want is to know that there is a proof.
• The program is capable of finding a proof by itself.
– Then it does not matter what strategy the program takes to find
the proof.
Cont..
• Conversational problems
– In which there is intermediate communication between a
person and the computer, either to provide additional
assistance to the computer or to provide additional information
to the user.
• Eg. Suppose we are trying to prove some new, very difficult theorem.
• Then the program may not know where to start.
• At the moment, people are still better at doing the high level strategy
required for a proof.
• So the computer might like to be able to ask for advice.
• To exploit such advice, the computer’s reasoning must be analogous
to that of its human advisor, at least on a few levels.
Prepared by Sharika T R, SNGCE 45
SEARCHING
• search algorithm takes a problem as input and returns the solution
in the form of an action sequence.
• Once the solution is found the execution phase starts.
• After formulating a goal and problem to solve the agent cells a
search procedure to solve it.
• A problem can be defined by 5 components.
a) The initial state: The state from which agent will start.
b) The goal state: The state to be finally reached.
c) The current state: The state at which the agent is present after starting
from the initial state.
d) Successor function: It is the description of possible actions and their
outcomes.
e) Path cost: It is a function that assigns a numeric cost to each path.
Prepared by Sharika T R, SNGCE
Informed Search
Control Stratergies
• Requirments
– cause motion
– it must be systematic
• Control stratergies that do not cause motion will never
lead to a solution.
• The requirement that a control stratergy be systemtic
corresponds to the need for global motion as well as for
local motion.
UNINFORMED SEARCH
BFS & DFS, Generate and test, Plan Generate and test
DFS Algorithm
loop.
Advantages of BFS
Generate-and-Test Algorithm
Cont..
• If the generation of possible solution is done
systematically, then this procedure will find a solution
eventually if one exists.
• If the problem space is very large eventually may be a
very long time.
• It is a depth first search procedure since complete
solutions must be generated before they can be tested.
• It can also operate by generating solutions randomly but
then there is no guarentee that a solution will ever be
found. Prepared by Sharika T R, SNGCE
Cont..
Plan-Generate-Test
• Dendral uses plan-generate test
stratergy in which a planing process
that uses constraint-satisfaction
techniques creates list of recommended
and contraindicated substructures.
• The generate-and-test procedure then
uses those lists so that it can explore
only a fairly limited set of structures.
• Constrained in this way generate-and-
test procedure has proved highly
effective.
Prepared by Sharika T R, SNGCE 60
Prepared by Sharika T R, SNGCE
Cont..
Cont..
• Strategy 1
– It would simply explore all possible path in the tree and return
the one with the shortest length.
– This approach will even work in practice for every short list of
cities.
– If there are N cities then the number of different path among
them is 1,2, . . . (N-1) or (N-1)!
– Not a feasible solution
Cont..
• Strategy
– branch and bound.
– Being generating complete paths keeping track of shortest path
found so far
– give up exploring any path as soon as its partial length become
greater than the shortest path found so far .
– Using this technique we are still guarenteed to find the shortest
path.
Heuristic Search
Cont..
Cont..
Cont..
Hill Climbing
Cont..
Cont..
Local Maximum
Plateau
Ridge
Example
• Local Heuristic function:
– Add one point for every
block that is resting on the
thing it is supposed to be
resting on.
– Substract one point for
every block that is sitting on
wrong thing
– Goal Score=8
– Initial Score=4 (6-2)
Cont..
-7 +7
-6 +6
-5 +5
-4 +4
-3 +3
-2 +2
-1 +1
-0 +0
Prepared by Sharika T R, SNGCE
Cont..
Cont..
Simulated Annealing
• Simulated annealing is a variation of hill climbing in which
at the begining of the process, some downhill moves may
be made.
do enough exploration of whole space early on so that the
final solution is relatively insensitive to starting state
• This should lower the chances of getting caught at a local
maximum, a plateau, or a ridge.
Cont..
Physical Anealing
• Metals melted and then gradually cooled until some solid
state is reached
• But there is some probability that a transition to higher
energy state will occur,
Cont..
Cont..
Cont..
4. Loop until a solution is found or until there are no new operators
left to be applied in the current state.
a) Select an operator that has not yet been applied to the current state and apply
it to produce a new state
b) Evaluate the new state compute (Value of current) - (value of new )
• If the new state is a goal state, then return it and quit
• If it is not a goal state but it is better then make it the current state. Also set
BEST_SO_FAR to this new state
• If it is not better than the current state, then make it the current state with
probability p’ as defined above. This step is usually implemented by invoking
a random number generator to produce a number in the range [0,1]. if that
number is less than p’, then the move is accepted. Otherwise do nothing.
c) revise T as necessary according to the annealing schedule.
5. Return BEST_SO_FAR as the answer.
Prepared by Sharika T R, SNGCE 95
Cont..
• The annealing schedule has three components.
1. the initial value to be used for temprature.
2. the criteria that will be used to decide when the temprature of the system
should be reduced.
3. the amount by which the temprature will be reduced each time it is
changed.
4. There may also be a fourth component of the schedule, when to quit.
• T starts out high and gradually decreases towards 0.
• The higher the temprature the more likely it is that a bad move
can be made.
• As T tends to zero, this probability tends to zero and simulated
annealing become morePrepared
like byhill climbing
Sharika T R, SNGCE 96