Bcs515b - PPT - Dr. SBL
Bcs515b - PPT - Dr. SBL
Module -1
If we are going to say that a given program thinks like a human, we must have some way of
determining how humans think. We need to get inside the actual workings of human minds.
There are three ways to do this:
1. Through introspection—trying to catch our own thoughts as they go by;
2. Through psychological experiments—observing a person in action; and
3. Through brain imaging—observing the brain in action.
• The Greek philosopher Aristotle was one of the first to attempt to codify “right thinking,” that
is, irrefutable reasoning processes. His syllogisms provided patterns for argument structures
that always yielded correct conclusions when given correct premises.
• For example, “Socrates is a man; all men are mortal; therefore, Socrates is mortal.”
• These laws of thought were supposed to govern the operation of the mind; their study initiated
the field called logic.
• The so-called logicist tradition within artificial intelligence hopes to build on such programs to
create intelligent systems.
An example
⚫ crossing a street but died of the fallen
cargo door from 33,000ft → irrational?
Omniscience
Based on the circumstance, it is rational.
As rationality maximizes
⚫ Expected performance
Perfection maximizes
⚫ Actual performance
Hence rational agents are not omniscient.
Learning
Does a rational agent depend on
only current percept?
⚫ No, the past percept sequence should
also be used
⚫ This is called learning
⚫ After experiencing an episode, the
agent
⚫ should adjust its behaviors to perform
better for the same job next time.
Autonomy
If an agent just relies on the prior knowledge of
its designer rather than its own percepts then the
agent lacks autonomy
A rational agent should be autonomous- it should
learn what it can to compensate for partial or
incorrect prior knowledge.
E.g., a clock
⚫ No input (percepts)
⚫ Run only but its own algorithm (prior knowledge)
⚫ No learning, no experience, etc.
Software Agents
Sometimes, the environment may not be the
real world
⚫ E.g., flight simulator, video games, Internet
⚫ They are all artificial but very complex
environments
⚫ Those agents working in these environments
are called
⚫Softwareagent (softbots)
⚫Because all parts of the agent are software
Task environments
Task environments are the problems
⚫ While the rational agents are the solutions
Specifying the task environment
⚫ PEAS description as fully as possible
⚫ Performance
⚫ Environment
⚫ Actuators
⚫ Sensors
In designing an agent, the first step must always be
to specify the task environment as fully as possible.
Use automated taxi driver as an example
Task environments
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
Actuators (for outputs)
⚫ Control over the accelerator, steering, gear
shifting and braking
⚫ A display to communicate with the
customers
Sensors (for inputs)
⚫ Detect other vehicles, road situations
⚫ GPS (Global Positioning System) to know
where the taxi is
⚫ Many more devices are necessary
Task environments
A sketch of automated taxi driver
Properties of task environments
Fully observable vs. Partially
observable
⚫ Ifan agent’s sensors give it access to
the complete state of the environment
at each point in time then the
environment is effectively and fully
observable
⚫ if the sensors detect all aspects
⚫ That are relevant to the choice of action
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
Deterministic vs. stochastic
⚫ next state of the environment Completely determined by the current
state and the actions executed by the agent, then the environment
is deterministic, otherwise, it is Stochastic.
⚫ Strategic environment: deterministic except for actions of other
agents
-Cleaner and taxi driver are:
⚫Stochastic because of some unobservable aspects → noise or unknown
Properties of task environments
Episodic vs. sequential
⚫ An episode = agent’s single pair of perception & action
⚫ The quality of the agent’s action does not depend on other
episodes
⚫Every episode is independent of each other
⚫ Episodic environment is simpler
⚫The agent does not need to think ahead
Sequential
⚫ Current action may affect all future decisions
-Ex. Taxi driving and chess.
Properties of task environments
Static vs. dynamic
⚫ A dynamic environment is always changing over time
⚫E.g., the number of people in the street
⚫ While static environment
⚫E.g., the destination
Semidynamic
⚫ environment is not changed over time
⚫ but the agent’s performance score does
Properties of task environments
⚫ Goal-based agents
⚫ Utility-based agents
Simple reflex agents
It uses just condition-action rules
⚫ The rules are like the form “if … then …”
⚫ efficient but have narrow range of
applicability
⚫ Because knowledge sometimes cannot
be stated explicitly
⚫ Work only
⚫ if the environment is fully observable
Simple reflex agents
Simple reflex agents (2)
A Simple Reflex Agent in Nature
percepts
(size, motion)
RULES:
(1) If small moving object,
then activate SNAP
(2) If large moving object,
then activate AVOID and inhibit SNAP
ELSE (not moving) then NOOP
needed for
completeness Action: SNAP or AVOID or NOOP
Model-based Reflex Agents
For the world that is partially observable
⚫ the agent has to keep track of an internal
state
⚫ That depends on the percept history
⚫ Reflecting some of the unobserved aspects
⚫ E.g., driving a car and changing lane
Requiring two types of knowledge
⚫ How the world evolves independently of the
agent
⚫ How the agent’s actions affect the world
Example Table Agent
With Internal State
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
start
Module -2
• Achieving this is sometimes simplified if the agent can adopt a goal and aim at satisfying it.
• Goals help organize behaviour by limiting the objectives that the agent is trying to achieve and hence the
actions it needs to consider.
• Goal formulation, based on the current situation and the agent’s performance measure, is the first step in
problem solving.
• Problem formulation is the process of deciding what actions and states to consider, given a goal.
• The process of looking for a sequence of actions that reaches the goal is called search. A search algorithm
takes a problem as input and returns a solution in the form of an action sequence. Once a solution is found,
the actions it recommends can be carried out. This is called the execution phase.
PROBLEM SOLVING ➔ PROBLEM-SOLVING AGENTS
• Thus, we have a simple “formulate,
search, execute” design for the agent, as
shown in Figure 1.
• After formulating a goal and a problem
to solve, the agent calls a search
procedure to solve it.
• It then uses the solution to guide its
actions, doing whatever the solution
recommends as the next thing to do—
typically, the first action of the
sequence—and then removing that step
from the sequence. Figure 1 A simple problem-solving agent.
It first formulates a goal and a problem, searches for a
• Once the solution has been executed, the sequence of actions that would solve the problem, and then
agent will formulate a new goal. executes the actions one at a time. When this is complete, it
formulates another goal and starts over.
PROBLEM SOLVING ➔ PROBLEM-SOLVING AGENTS ➔ Well-defined Problems and Solutions
A problem can be defined formally by five components:
1. The initial state that the agent starts in. For example, the initial state for our agent in Romania might be described as
In(Arad).
2. A description of the possible actions available to the agent. Given a particular state s, ACTIONS(s) returns the set of
actions that can be executed in s. We say that each of these actions is applicable in s. For example, from the state In(Arad),
the applicable actions are {Go(Sibiu), Go(Timisoara), Go(Zerind)}.
3. A description of what each action does; the formal name for this is the transition model, specified by a function
RESULT(s, a) that returns the state that results from doing action a in state s. We also use the term successor to refer to
any state reachable from a given state by a single action. For example, we have
RESULT(In(Arad), Go(Zerind)) = In(Zerind)
Together, the initial state, actions, and transition model implicitly define the state space of the problem—the set of all
states reachable from the initial state by any sequence of actions. The state space forms a directed network or graph in
which the nodes are states and the links between nodes are actions. (The map of Romania shown in Figure 2 can be
interpreted as a state-space graph if we view each road as standing for two driving actions, one in each direction) A path
in the state space is a sequence of states connected by a sequence of actions.
PROBLEM SOLVING ➔ PROBLEM-SOLVING AGENTS ➔ Well-defined Problems and Solutions
4. The goal test, which determines whether a
given state is a goal state. Sometimes there
is an explicit set of possible goal states, and
the test simply checks whether the given
state is one of them. The agent’s goal in
Romania is the singleton set
{In(Bucharest)}.
5. A path cost function that assigns a numeric
cost to each path. The problem-solving
agent chooses a cost function that reflects
its own performance measure. For the agent
trying to get to Bucharest, time is of the
essence, so the cost of a path might be its
length in kilometers. The step cost of taking
action a in state s to reach state s` is denoted
by c(s, a, s`). The step costs for Romania Figure 1.2 A simplified road map of part of Romania.
are shown in Figure 2 as route distances.
We assume that step costs are nonnegative.
PROBLEM SOLVING ➔ EXAMPLE PROBLEMS
Figure 10 Nodes are the data structures from which the search tree is
constructed. Each has a parent, a state, and various bookkeeping fields.
Arrows point from child to parent.
PROBLEM SOLVING ➔ SEARCHING FOR SOLUTIONS ➔ Infrastructure for Search Algorithms
Breadth-first Search:
• Breadth-first search is a simple strategy in which the root node is expanded first, then all the successors of
the root node are expanded next, then their successors, and so on.
• In general, all the nodes are expanded at a given depth in the search tree before any nodes at the next level are
expanded.
• Breadth-first search is an instance of the general graph-search algorithm inwhich the shallowest unexpanded
node is chosen for expansion.
• This is achieved very simply by using a FIFO queue for the frontier. Thus, new nodes (which are always
deeper than their parents) go to the back of the queue, and old nodes, which are shallower than the new nodes,
get expanded first.
• Pseudocode is given in Figure 11 and Figure 12 shows the progress of the search on a simple binary tree.
• The time complexity of BFS is 𝑂 𝑏𝑑 , and space complexity is also𝑂 𝑏𝑑 , where b is a branching factor and d
is a depth.
PROBLEM SOLVING ➔ UNINFORMED SEARCH STRATEGIES
Module -3
• The next node to be expanded will be Fagaras because it is closest. Fagaras in turn generates Bucharest, which
is the goal.
• For this particular problem, greedy best-first search using hSLD finds a solution without ever expanding a node
that is not on the solution path; hence, its search cost is minimal.
INFORMED (HEURISTIC) SEARCH STRATEGIES ➔ Greedy best-first search
Figure 2.3 Stages in an A* search for Bucharest. Nodes are labeled with f = g +h. The h values are the
straight-line distances to Bucharest taken from Figure 2.1.
INFORMED (HEURISTIC) SEARCH STRATEGIES ➔ A* search: Minimizing the total estimated solution cost
Following is a sample diagram for representing the Wumpus world. It is showing some
rooms with Pits, one room with Wumpus and one agent at (1, 1) square location of the
world.
There are also some components which
can help the agent to navigate the cave. • The rooms adjacent to the Wumpus room are
These components are given as follows: smelly, so that it would have some stench.
WUMPUS WORLD • The room adjacent to PITs has a breeze, so if
the agent reaches near to PIT, then he will
perceive the breeze.
• There will be glitter in the room if and only if
the room has gold.
• The Wumpus can be killed by the agent if the
agent is facing to it, and Wumpus will emit a
horrible scream which can be heard anywhere
in the cave.
PEAS description of Wumpus world:
PERFORMANCE MEASURE ENVIRONMENT
Now we will explore the Wumpus world and will determine how the agent will
find its goal by applying logical reasoning.
At the third step, now agent will move to the room [1,2] which is OK. In the room [1,2] agent perceives a stench which means there must
be a Wumpus nearby. But Wumpus cannot be in the room [1,1] as by rules of the game, and also not in [2,2] (Agent had not detected any
stench when he was at [2,1]). Therefore agent infers that Wumpus is in the room [1,3], and in current state, there is no breeze which means
in [2,2] there is no Pit and no Wumpus. So it is safe, and we will mark it OK, and the agent moves further in [2,2].
Agent's fourth step:
At room [2,2], here no stench and no breezes present so let's suppose agent
decides to move to [2,3]. At room [2,3] agent perceives glitter, so it should
grab the gold and climb out of the cave.
Wumpus-world using propositional.
As in the previous topic we have learned about the wumpus world and how a knowledge-based
agent evolves the world. Now in this topic, we will create a knowledge base for the wumpus world,
and will derive some proves for the Wumpus-world using propositional.
The agent starts visiting from first square [1, 1], and
we already know that this room is safe for the agent.
To build a knowledge base for wumpus world, we will
use some rules and atomic propositions. We need
symbol [i, j] for each location in the wumpus world,
where i is for the location of rows, and j for column
location.
• Atomic proposition variable for Wumpus world:
• Let Pi,j be true if there is a Pit in the room [i, j].
• Let Bi,j be true if agent perceives breeze in [i, j],
(dead or alive).
• Let Wi,j be true if there is wumpus in the
square[i, j].
• Let Si,j be true if agent perceives stench in the
square [i, j].
• Let Vi,j be true if that square[i, j] is visited.
• Let Gi,j be true if there is gold (and glitter) in the
square [i, j].
• Let OKi,j be true if the room is safe.
Some Propositional Rules for the wumpus world:
Representation of Knowledgebase for Wumpus world:
• Following is the Simple KB for wumpus world
when an agent moves from room [1, 1], to
room [2,1]:
➢ Here in the first row, we have mentioned propositional variables for room[1,1], which is showing that
room does not have wumpus(¬ W11), no stench (¬S11), no Pit(¬P11), no breeze(¬B11), no gold (¬G11), visited
(V11), and the room is Safe(OK11).
➢ In the second row, we have mentioned propositional variables for room [1,2], which is showing that there
is no wumpus, stench and breeze are unknown as an agent has not visited room [1,2], no Pit, not visited
yet, and the room is safe.
➢ In the third row we have mentioned propositional variable for room[2,1], which is showing that there is
no wumpus(¬ W21), no stench (¬S21), no Pit (¬P21), Perceives breeze(B21), no glitter(¬G21), visited (V21),
and room is safe (OK21).
Prove that Wumpus is in the room (1, 3)
We can prove that wumpus is in the room (1, 3) using propositional rules which we
have derived for the wumpus world and using inference rule.
Apply Modus Ponens with ¬S11 and R1:
We will firstly apply MP rule with R1 which is ¬S11 → ¬ W11 ^ ¬ W12 ^ ¬ W21,
and ¬S11 which will give the output ¬ W11 ^ W12 ^ W12.
•Apply And-Elimination Rule:
After applying And-elimination rule to ¬ W11 ∧ ¬ W12 ∧ ¬ W21,
we will get three statements:
¬ W11, ¬ W12, and ¬W21.
•Apply Modus Ponens to ¬S21, and R2:
Now we will apply Modus Ponens to ¬S21 and R2 which is
¬S21 → ¬ W21 ∧¬ W22 ∧ ¬ W31, which will give the Output as ¬
W21 ∧ ¬ W22 ∧¬ W31
•Apply And -Elimination rule:
Now again apply And-elimination rule to ¬ W21 ∧ ¬ W22 ∧¬ W31, We will get three
statements:
¬ W21, ¬ W22, and ¬ W31.
•Apply MP to S12 and R4:
Apply Modus Ponens to S12 and R4 which is S12 → W13 ∨. W12 ∨. W22 ∨.W11, we will
get the output as W13∨ W12 ∨ W22 ∨.W11.
•Apply Unit resolution on W13 ∨ W12 ∨ W22 and ¬ W22 :
After applying Unit resolution on W13 ∨ W12 ∨ W22, and ¬W22, we will get W13 ∨ W12 as
output.
•Apply Unit Resolution on W13 ∨ W12 and ¬ W12 :
After Applying Unit resolution on W13 ∨ W12 and ¬ W12, we will get W13 as an output, hence it
is proved that the Wumpus is in the room [1, 3].
THANK YOU