AI Unit 1 PPT (21CSC206T)
AI Unit 1 PPT (21CSC206T)
UNIT – 1
CLR1 : Provide a broad understanding of the basic techniques for building intelligent computer systems and an understanding of
how AI is applied to problems.
HUMA RATIONAL
N
Systems that act like humans:
Turing Test
HUMA RATIONAL
N
Systems that think like humans:
cognitive modeling
• Humans as observed from ‘inside’
• How do we know how humans think?
– Introspection vs. psychological experiments
• Cognitive Science
• “The exciting new effort to make computers
think … machines with minds in the full and
literal sense” (Haugeland)
• “The automation of] activities that we associate
with human thinking, activities such as decision-
making, problem solving, learning …” (Bellman)
What is Artificial Intelligence ?
HUMA RATIONAL
N
Systems that think ‘rationally’
"laws of thought"
HUMA RATIONAL
N
Systems that act rationally:
“Rational agent”
• Rational behavior: doing the right thing
• The right thing: that which is expected to
maximize goal achievement, given the
available information
• Giving answers to questions is ‘acting’.
• I don't care whether a system:
– replicates human thought processes
– makes the same decisions as humans
– uses purely logical reasoning
Systems that act rationally
• Philosophy
– At that time, the study of human intelligence
began with no formal expression
– Initiate the idea of mind as a machine and its
internal operations
The main topics in AI
– increased costs
– difficulty with software development - slow and
expensive
– few experienced programmers
– few practical products have reached the market
as yet.
AI – Social Companion
AI in Movies
AI Applications
AI Defined
● Textbook
definition:
• Heuristic Search
• Computer Vision
• Adversarial Search (Games)
• Fuzzy Logic
• Natural Language Processing
• Knowledge Representation
• Planning
• Learning
Examples
– Use of knowledge
– Abstraction
1. Search:-
• Search provides a way of solving problems for which no more direct approach is
available as well as a framework into which any direct techniques that are available
can be embedded. A search program finds a solutions for a problem by trying various
sequences of actions or operators until a solution is found.
Advantages
• It is the best way so far as no better way has been found to solve the problems.
• To solve a problem using search, it is only necessary to code the operator that can be
used; the search will find the sequence of actions that will provide the desired results.
Disadvantages
• Most problems have search spaces so large that it is impossible to search for the
whole space.
AI Techniques
2. Use of knowledge:-
• The use of knowledge provides a way of solving complicated problems by manipulating the
structures of the objects that are concerned.
• The way in which knowledge can be represented for usage in AI techniques:
• AI technique is a method that achieves knowledge that should be represented in such a way that:-
– Knowledge captures generalization. This meaning grouping situations that share important properties
rather than representing each situation separately with such an arrangement of knowledge, an
unreasonable amount of memory, and updating will no longer be required. Anything without this property
is called data rather than knowledge.
– It could easily be adjusted to correct errors end to demonstrate changes in the world.
3. Abstraction:-
• Abstraction finds a way of separating important features and notifications from the unimportant
ones that would otherwise confuse any process.
AI Techniques
AI technique is a method that exploits knowledge that should be
represented in such a way that:
• Problem
• Problems are the issues which
comes across any system. A solution
is needed to solve that particular
problem.
• Steps : Solve Problem Using Artificial
Intelligence
• The process of solving a problem
consists of five steps. These are:
Problem Solving In AI : Introduction
Structured Problem
Well structed – Yield a right answer
Ill structed – Do not yield a particular answer
Unstructured Problem
Very hard to formulate the problem
Ambiguous in nature
Linear Problem
Have clear solution
All kind of classification problems
Non linear Problem
Relationships between input and output is non linear
Further decision can’t be taken like in linear problem
42
Unit 1 List of Topics
• Introduction to AI-AI techniques • Types of agents
• Problem solving with AI • Other aspects of agents
44
AI Models
45
AI Models
46
AI Models
47
Unit 1 List of Topics
• Introduction to AI-AI techniques
• Problem solving with AI • Types of agents
• Other aspects of agents
• AI Models, Data acquisition and
learning aspects in AI • Constraint satisfaction
• Problem solving- Problem solving problems(CSP)
process, Formulating problems
• Crypto arithmetic puzzles
• Data Acquisition: - In this step, the data are being acquired from
different sources in digital form for storage and analysis purposes. It is
basically divided in three steps: - data collection, data transmission and
data preprocessing.
Data acquisition and learning aspects in AI
• (a) Data Collection: - In this phase, subsequent data or raw data are
collected from real world objects in a systematic manner. Otherwise,
collection of inaccurate data will lead to invalid results after the analysis
phase.
• The collections of data are being done from variety of sources, websites,
click streams, images, videos, etc. As a result, this step not only depends on
the physical characteristics of the data sources but also on the objective of
the data analysis. There are a lot of techniques used to collect accurate data.
• Ex: Log Files: - Web log file is one of the commonly used data collection
method. The purpose of this is to record activities of the Web user in the
form of data source in a specified file format for subsequent analysis.
• Sensors: - Sensors are often used to capture physical quantities which are
finally converted into different digital signals for storage and processing. It
may be further categorized into sound wave, voice, vibration, automobile,
chemical, pressure, weather, current, and temperature.
Data acquisition and learning aspects in AI
• The initial state that the agent starts in /Starting state which
agent knows itself.
• Ex- The initial state for our agent in Romania might be described as In(Arad)
• The step cost of taking action a to go from one state ‘s’ to reach state ‘y’ is
denoted by c(s, a, y).
Ex- For the agent trying to get to Bucharest, time is of the essence, so the cost of a
path might be its length in kilometres. We assume that the cost of a path can be
described as the sum of the costs of the individual actions along the path. The step
costs for Romania are shown in Figure as route distances. We assume that step costs
are nonnegative.
• A solution to a problem is an action sequence that leads from the initial state
to a goal state. Solution quality is measured by the path cost function, and an
optimal solution has the lowest path cost among all solutions.
Formulating Problems
65
Problem Types
2. Non-observable(Multiple-state problems) /
conformant problems
• Problem – solving agent does not have any
information about the state.
• Solution may or may not be reached.
• Ex- In case of vacuum cleaner , the goal state is to clean the floor rather
clean floor. Action is to suck if there is dirt. So , in non-observable
condition , as there is no sensor , it will have to suck the dirt , irrespective
of whether it is towards right or left . Here , the solution space is the states
specifying its movement across the floor.
Problem Types
3. Non-deterministic(partially observable) problem
• The effect of action is not clear.
• Percepts provide new information about the current
state.
• Ex- If we take Vacuum cleaner , and now assume that the
sensor is attached to it , then it will suck if there is dirt.
Movement of the cleaner will be based on its current
percept.
Problem Types
Competitive/ Cooperative
Problem Types
4. Unknown state space problems
• Typically exploration problems
• States and impact of actions are not
known
• Ex- online search that involves acting without compete knowledge
of the next state or scheduling without map.
Problem Characteristics
1. Is the problem decomposable ?
2. Can Solution steps be ignored or undone ?
3. Is the Universe Predictable?
4. Is a good solution absolute or relative ?
5. Is the solution a state or a path?
6. What is the role of knowledge?
7. Does the task require interaction with a
person ?
Problem Characteristics- 1. Is the problem decomposable ?
BLOCKS WORLD
Problem Characteristics: 2. Can Solution steps be ignored or undone ?
The 8 – Puzzle
Initial state:
monkey on
ground
with empty hand
bananas
suspended
Goal state:
monkey eating
Actions:
climb chair/get
off
Problem Solving
Function Reflex-Vacuum-Agent([location,status])
return an action
If status = Dirty then return Suck
else if location = A then return Right
else if location = B then return left
Toy Problems vs Real-world Problems
84
Toy Problem- 1
Vacuum Cleaner World -Problem Formulation
• Initial State
– Any one of 8 states
• Actions
– In this simple environment, each state has just three actions: Left , Right ,Suck.
Larger environments might also include Up , Down
Toy Problem- 1
Vacuum Cleaner World -Problem Formulation
• Transition model: The actions have their expected effects, except that
moving Left in the leftmost square, moving Right in the rightmost square,
and Sucking in a clean square have no effect. The complete state space is
shown in the figure .
• Goal Test
– This checks whether all the squares are clean
• Path Cost
– Number of steps (each step costs a value of 1)
Toy Problem- 2
The 8-Puzzle (Sliding Block Puzzle)
Where,
Note
0 ≤ X ≤ 4, and 0 ≤ Y ≤ 3
First solution
1. (x,y) -> (4,y) Fill x
2. (x,y) -> (x,3) Fill y
3. (x,y) -> (x-d, y) Pour water out from X
4. (x,y) -> (x,y-d) Pour water from y
Initial
5. (x,y) -> (0,y) Empty x
R2 6. (x,y) -> (x,0) Empty y
R9 7. (x,y) -> (4,y-(4-x)) Pour water from y into x until x
R2 is full
8. (x,y) -> (x – (3-y), 3) Pour water from x into y until y
R7
is full.
R5 9. (x,y) -> (x+y, 0) Pour all water from y to x
R9 10. (x,y) -> (0, x+y) Pour all water from x to y
11. (0,2) -> (2,0) Pour 2 Gallon of water from y to x
12. (2, y) -> (0,y) Pour 2 Gallon of water from x to
ground.
Toy Problem- 4(a)
4-queens problem
In figure , the possible board configuration for 8-queen problem has been
shown. The board has alternative black and white positions on it. The
different positions on the board hold the queens. The production rule for this
game is you cannot put the same queens in a same row or same column or in
same diagonal. After shifting a single queen from its position on the board,
the user have to shift other queens according to the production rule. Starting
from the first row on the board the queen of their corresponding row and
column are to be moved from their original positions to another position.
Finally the player has to be ensured that no rows or columns or diagonals of
on the table is same.
Toy Problem- 4(b)
8-queens problem
The first incremental formulation one might try is the following:
• States: Any arrangement of 0 to 8 queens on the board is a
state.
• Initial state: No queens on the board.
• Actions/Successor function : Add a queen to any empty
square.
• Transition model: Returns the board with a queen added to the
specified square.
• Goal test: 8 queens are on the board, none attacked.
• Path cost: Zero (search cost only exists)
In this formulation, we have 64 · 63 · · · 57 ≈ 1.8×10 14
possible
sequences to investigate.
Toy Problem- 5
BLOCK WORLD
What is the Blocks World? -- The world consists of:
• A flat surface such as a tabletop
• An adequate set of identical blocks which are
identified by letters.
• The blocks can be stacked one on one to form
towers of apparently unlimited height.
• The stacking is achieved using a robot arm which
has fundamental operations and states which can be
assessed using logic and combined using logical
operations.
• The robot can hold one block at a time and only one
block can be moved at a time.
Toy Problem- 5
Toy Problem- 5
Blocks World Problem – Ex .
hf = -10 hf = +10
Heuristic
Toy Problem- 5
Blocks World Problem – Ex .
Step 1
Toy Problem- 5
Blocks World Problem – Ex .
Step 2
Toy Problem- 5
Blocks World Problem – Ex .
Step 3
hf = -1
Toy Problem- 5
Blocks World Problem – Ex .
Step 4
Toy Problem- 5
Blocks World Problem – Ex .
Step 5
hf = +3
Toy Problem- 5
Blocks World Problem – Ex .
Step 6
hf = +10
• STRIPS - an action-centric
representation ,for each action ,
specifies the effect of an action.
Toy Problem- 5
BLOCK WORLD - STRIPS
(STanford Research Institute Problem Solver)
• STRIPS - an action-centric
representation ,for each action ,
specifies the effect of an action.
The STRIPS representation for an action consists of three lists,
• Pre_Cond list contains predicates which have to be true
before operation.
• ADD list contains those predicates which will be true after
operation
• DELETE list contain those predicates which are no longer true
after operation
Toy Problem- 6
Tic Tac Toe
The game Tic Tac Toe is also known as Noughts and Crosses or Xs
and Os ,the player needs to take turns marking the spaces in a 3x3 grid
with their own marks,
if 3 consecutive marks (Horizontal, Vertical,Diagonal) are formed
then the player who owns these moves get won.
Assume ,
So,a player who gets 3 consecutive
Player 1 - X marks first,they will win the game .
Player 2 - O
Toy Problem- 6
Tic Tac Toe
Toy Problem- 7
Missionaries and Cannibals
Let Missionary is denoted by ‘M’ and Cannibal, by ‘C’.
These rules are described below:
Monkey standing on the chair and catching the bananas with the
stick.
Summary of Problem Solving with
AI – Toy Problems
1. Block World
2. 4 Queens/ 8 Queens
3. Tic Tac Toe
4. Water Jug
5. Monkey Banana
6. 8 Puzzle
7. TSP
8. Vacuum Cleaner
9. Missionaries and Cannibals
Unit 1 List of Topics
• Introduction to AI-AI techniques
• Problem solving with AI • Types of agents
• Other aspects of agents
• AI Models, Data acquisition and
learning aspects in AI • Constraint satisfaction
• Problem solving- Problem solving problems(CSP)
process, Formulating problems
• Crypto arithmetic puzzles
What AI
should fill
Simple Terms
Percept
● Agent’s perceptual inputs at any given
instant
Percept sequence
● Complete history of everything that the
agent has ever perceived.
Unit 1 List of Topics
• Introduction to AI-AI techniques
• Problem solving with AI • Types of agents
• Other aspects of agents
• AI Models, Data acquisition and
learning aspects in AI • Constraint satisfaction
• Problem solving- Problem solving problems(CSP)
process, Formulating problems
• Crypto arithmetic puzzles
• An ideal rational agent is the one, which is capable of doing expected actions to
maximize its performance measure, on the basis of −
• Its percept sequence
• Its built-in knowledge base
• Rationality of an agent depends on the following −
• The performance measures, which determine the degree of success.
• Agent’s Percept Sequence till now.
• The agent’s prior knowledge about the environment.
• The actions that the agent can carry out.
• A rational agent always performs right action, where the right action means the
action that causes the agent to be most successful in the given percept sequence.
The problem the agent solves is characterized by Performance Measure,
Environment, Actuators, and Sensors (PEAS).
Rational Agents
• Omniscient agent
– Knows the actual outcome of its actions
– What information would a chess player need to
have to be omniscient?
• Omniscience is (generally) impossible
– A rational agent should do the right thing based
on the knowledge it has.
Rational Agents
• “Independence”
• A system is autonomous if its behavior is
determined by its own experience
– An alarm that goes off at a prespecified time is
not autonomous
– An alarm that goes off when smoke is sensed is
autonomous
• A system without autonomy lacks flexibility
Structure of Intelligent Agents
STATES,
● TSP - Naive Solution revisited:
OPERATORS,
GOAL TEST &
1) Consider city 1 as the starting and
PATH COST ending point.
2) Generate all (n-1)! Permutations
of cities.
3) Calculate cost of every permutation
and keep track of minimum cost
permutation.
• Rational agent
● One that does the right thing
● = every entry in the table for the agent
function is correct (rational).
• What is correct?
● The actions that cause the agent to be most
successful
● So we need ways to measure success.
Performance measure
• Performance measure
● An objective function that determines
● How the agent does successfully
● E.g., 90% or 30% ?
• An agent, based on its percepts
● action sequence :
if desirable, it is said to be performing well.
● No universal performance measure for all
agents
Performance measure
• A general rule:
● Design performance measures according to
● What one actually wants in the environment
● Rather than how one thinks the agent should
behave
• E.g., in vacuum-cleaner world
● We want the floor clean, no matter how the
agent behave
● We don’t restrict how the agent behaves
Rational agent
• Performance measure
● Awards one point for each clean square
● at each time step, over 10000 time steps
• Prior knowledge about the environment
● The geography of the environment
● Only two squares
● The effect of the actions
Example of a rational agent
• An omniscient agent
● Knows the actual outcome of its actions in
advance
● No other possible outcomes
● However, impossible in real world
• An example
● crossing a street but died of the fallen
cargo door from 33,000ft irrational?
Omniscience
• What is an agent ?
● An agent is anything that perceiving its
environment through sensors and acting upon
that environment through actuators
● Example:
● Human is an agent
● A robot is also an agent with cameras and motors
● A thermostat detecting room temperature.
Intelligent Agents
Diagram of an agent
What AI should
fill
Simple Terms
• Percept
● Agent’s perceptual inputs at any given instant
• Percept sequence
● Complete history of everything that the agent has ever
perceived.
Flexibility : Autonomy means “Independence”.
A system is autonomous if its behavior is determined by its
own experience.
A system without autonomy lacks flexibility.
Ex: An alarm that goes on when smoke is sensed is
autonomous.
Agent function & program
● Actuators
● Sensors
• Performance measure
● How can we judge the automated driver?
● Which factors are considered?
● getting to the correct destination
● minimizing fuel consumption
● minimizing the trip time and/or cost
● minimizing the violations of traffic laws
● maximizing the safety and comfort, etc.
Task environments
• Environment
● A taxi must deal with a variety of roads
● Traffic lights, other vehicles, pedestrians,
stray animals, road works, police cars, etc.
● Interact with the customer
Task environments
• Partially observable
An environment might be Partially observable
because of noisy and inaccurate sensors or
because parts of the state are simply missing
from the sensor data.
Example:
● A local dirt sensor of the cleaner cannot tell
● Whether other squares are clean or not
Properties of task environments
• Four types
● Simple reflex agents
● Model-based reflex agents
● Goal-based agents
● Utility-based agents
Simple reflex agents
percepts
(size,
motion)
RULES:
(1) If small moving object,
then activate SNAP
(2) If large moving object,
then activate AVOID and inhibit
SNAP
needed for
ELSE (not moving) then NOOP
completeness Action: SNAP or AVOID or
Model-based Reflex Agents
IF THEN
Saw an object ahead, Go straight
and turned right, and
it’s now clear ahead
Saw an object Ahead, Halt
turned right, and object
ahead again
See no objects ahead Go straight
Wall-Following
star
t
Actions: left, right, straight, open-door
Rules:
1. If open(left) & open(right) and open(straight) then
choose randomly between right and left
2. If wall(left) and open(right) and open(straight) then straight
3. If wall(right) and open(left) and open(straight) then straight
4. If wall(right) and open(left) and wall(straight) then left
5. If wall(left) and open(right) and wall(straight) then right
6. If wall(left) and door(right) and wall(straight) then open-door
7. If wall(right) and wall(left) and open(straight) then straight.
8. (Default) Move randomly
Model-based Reflex Agents
• Conclusion
● Goal-based agents are less efficient
● but more flexible
● Agent Different goals different tasks
● Search and planning
● two other sub-fields in AI
● to find out the action sequences to achieve its goal
Goal-based agents
Utility-based agents
► Types of Constraints
► Unary Constraints - Single variable
► Binary Constraints - Two Variables
► Higher Order Constraints - More than two variables
► CSP can be represented as Search Problem
► Initial state is empty assignment, while successor function is a non-
conflicting value assigned to an unassigned variables
► Goal test checks whether the current assignment is complete and path
cost is the cost for the path to reach the goal state
► CSP Solutions leads to the final and complete assignment with no
exception
Unit 1 List of Topics
• Flexibility and Intelligent agents
• Introduction to AI-AI techniques • Task environment and its
properties
• Problem solving with AI
• Types of agents
• AI Models, Data acquisition and • Other aspects of agents
learning aspects in AI
• Problem solving- Problem solving • Constraint satisfaction
process, Formulating problems problems(CSP)
• Crypto arithmetic puzzles
► Let K for Kitchen, D for Dining Room, H is for Hall, B 2 and B 3 are
bedrooms 2 and 3, MB1 is master bedroom, SR is the store Room, GR is
Guest Room and Lib is Library
► Constraints
► All bedrooms should not be colored red, only one can
► No two adjacent rooms can have the same color
► The colors available are red, blue, green and violet
► Kitchen should not be colored green
► Recommended to color the kitchen as blue
► Dining room should not have violet color
Room Coloring Problem – Representation as a
Search Tree
218
Backtracking example
219
Backtracking example
220
Algorithm for Backtracking
Pick initial state
R = set of all possible states
Select state with var assignment
Add to search space
check for con
If Satisfied
Continue
Else
Go to last Decision Point (DP)
Prune the search sub-space from DP
Continue with next decision option
If state = Goal State
Return Solution
Else
Continue
CSP-Backtracking, Role of heuristic
► Let K for Kitchen, D for Dining Room, H is for Hall, B 2 and B 3 are
bedrooms 2 and 3, MB1 is master bedroom, SR is the store Room, GR is
Guest Room and Lib is Library
► Constraints
► All bedrooms should not be colored red, only one can
► No two adjacent rooms can have the same color
► The colors available are red, blue, green and violet
► Kitchen should not be colored green
► Recommended to color the kitchen as blue
► Dining room should not have violet color
Forward Checking – Room Coloring
Problem
• Idea:
– Keep track of remaining legal values for unassigned variables
– Terminate search when any variable has no legal values
234
WA RGB
NT GB
SA B
Q R
NSW G
Y R
T RGB
Forward checking
• Idea:
– Keep track of remaining legal values for unassigned variables
– Terminate search when any variable has no legal values
236
Forward checking
• Idea:
– Keep track of remaining legal values for unassigned variables
– Terminate search when any variable has no legal values
237
Forward checking
• Idea:
– Keep track of remaining legal values for unassigned variables
– Terminate search when any variable has no legal values
238
Constraint propagation
239
Arc consistency
240
Arc consistency
241
Arc consistency
242
Arc consistency