0% found this document useful (0 votes)
159 views

Unit-3 AI

The document discusses knowledge representation and knowledge-based agents. It describes different types of knowledge, techniques for knowledge representation including logical, semantic network, frame and production rule representation. It also explains the architecture, components and functioning of knowledge-based agents.

Uploaded by

2111cs030057
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
159 views

Unit-3 AI

The document discusses knowledge representation and knowledge-based agents. It describes different types of knowledge, techniques for knowledge representation including logical, semantic network, frame and production rule representation. It also explains the architecture, components and functioning of knowledge-based agents.

Uploaded by

2111cs030057
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 98

Unit-3

Propositional Logic
Propositional Theorem Proving
Contents:
• Propositional Logic:
– Knowledge-Based Agents,
– The Wumpus World,
– Logic,
– Propositional Logic
• Propositional Theorem Proving:
– Inference and proofs,
– Proof by resolution, Horn clauses and definite clauses,
– Forward and backward chaining,
– Effective Propositional Model Checking,
– Agents Based on Propositional Logic.
Knowledge-Based Agent
• An intelligent agent needs
– knowledge about the real world for taking decisions and
– reasoning to act efficiently.
• Knowledge-based agents are those agents who have
the capability of
– maintaining an internal state of knowledge,
– reason over that knowledge,
– update their knowledge after observations and
– take actions.
These agents can represent the world with some formal
representation and act intelligently.
• Knowledge-based agents are composed of 2 main parts:
– Knowledge-base(Domain Specific) and
– Inference system(Domain Independent Algorithm)
A knowledge-based agent(KBA) must able to do the
following:

• An agent should be able to represent states, actions,


etc.
• An agent should be able to incorporate new percepts
• An agent can update the internal representation of
the world
• An agent can deduce the internal representation of
the world
• An agent can deduce appropriate actions.
The architecture of knowledge-based agent(KBA):

• The knowledge-based agent (KBA) take input from the


environment by perceiving the environment.
• The input is taken by the inference engine of the agent and
which also communicate with KB to decide as per the
knowledge store in KB.
• The learning element of KBA regularly updates the KB by
learning new knowledge.
Knowledge base(KB):
• Knowledge-base is a central component of a
KBA.
• It is a collection of sentences (here 'sentence'
is a technical term and it is not identical to
sentence in English).
• These sentences are expressed in a language
which is called a knowledge representation
language.
• The Knowledge-base of KBA stores fact about
the world.
Why use a knowledge base?
• Knowledge-base is required for updating
knowledge for an agent to learn with
experiences and take action as per the
knowledge.
Inference system
• Inference means deriving new sentences from old.
• Inference system allows us to add a new sentence
to the knowledge base.
• A sentence is a proposition about the world.
• Inference system applies logical rules to the KB to
deduce new information.
• Inference system generates new facts so that an
agent can update the KB.
• An inference system works mainly in 2 rules:
– Forward chaining
– Backward chaining
• Forward chaining starts from known facts and
applies inference rule to extract more data unit
it reaches to the goal.
– Data-driven inference technique
– Forward chaining is suitable for the planning,
monitoring, control, and interpretation application.
• Backward chaining starts from the goal and
works backward through inference rules to find
the required facts that support the goal.
– Goal-driven technique
– Backward chaining is suitable for diagnostic,
prescription, and debugging application.
Operations Performed by KBA which are
performed by KBA in order to show the intelligent
behavior:
• TELL: This operation tells the knowledge base
what it perceives from the environment.
• ASK: This operation asks the knowledge base
what action it should perform.
• Perform: It performs the selected action.
Various Levels of Knowledge-Based Agent
Knowledge-based agents can be classified into 3 levels:

• Knowledge Level

• Logical Level

• Implementation Level
1. Knowledge Level
• The knowledge level is the highest level of abstraction in
a knowledge-based agent.
• It describes what the agent knows and how it uses it to
perform tasks.
• The knowledge level, concerns the representation and
organization of knowledge rather than the
implementation details.

2. Logical Level
• The logical level is the intermediate level of abstraction
in a knowledge-based agent.
• It describes how the knowledge is represented and
manipulated by the inference engine.
• The logical story concerns the formal logic used to
represent knowledge and make inferences.
3. Implementation Level
• The implementation level is the lowest level of
abstraction in a knowledge-based agent.
• It describes how the knowledge and inference
engine is implemented using a programming
language.
• The implementation level is concerned with
the details of the programming language and
the algorithms used to implement the
knowledge and inference engine.
Approaches to Designing a Knowledge-Based Agent

There are 2 main approaches to designing a


knowledge-based agent:

Declarative Approach

Procedural Approach
Declarative Approach
• The declarative approach to designing a
knowledge-based agent focuses on
representing knowledge in a declarative
form, such as rules or facts.
• The knowledge is represented independently
of the algorithms used to manipulate it.
Procedural Approach
• The procedural approach to designing a
knowledge-based agent focuses on
representing knowledge in a procedural form,
such as a sequence of instructions.
• The knowledge is represented in terms of the
algorithms used to manipulate it.
• The inference engine uses these algorithms
to make inferences from the knowledge.
Knowledge Representation
• Humans are best at understanding, reasoning,
and interpreting knowledge.
• Human knows things, which is knowledge and
as per their knowledge they perform various
actions in the real world.
• But how machines do all these things comes
under knowledge representation and
reasoning.
• Knowledge representation provides a
framework for
– representing, organizing, and manipulating
knowledge
that can be used
– to solve complex problems,
– make decisions, and
– learn from data.
• For example, when you see a hot tea cup, a
signal immediately comes from your brain
cautioning you against picking it up.
What to Represent:
Following are the kind of knowledge which needs to be
represented in AI systems:
• Object: All the facts about objects in our world domain.
E.g., Guitars contains strings, trumpets are brass
instruments.
• Facts: Facts are the truths about the real world and
what we represent.
• Events: Events are the actions which occur in our
world.
• Performance: It describe behavior which involves
knowledge about how to do things.
• Meta-knowledge: It is knowledge about what we
know.
Knowledge-Base: The central component of the
knowledge-based agents is the knowledge base.
• Knowledge: Knowledge is awareness or familiarity
gained by experiences of facts, data, and situations.
• Following are the types of knowledge in artificial
intelligence:

Types of
knowledge
1. Declarative Knowledge:
• Declarative knowledge is to know about
something.

It includes concepts, facts, and objects.

• It is also called descriptive knowledge and


expressed in declarative sentences.
2. Procedural Knowledge
• It is also known as imperative knowledge.
• Procedural knowledge is a type of knowledge
which is responsible for knowing how to do
something.
• It can be directly applied to any task.

It includes rules, strategies, procedures, agendas, etc.

• Procedural knowledge depends on the task on


which it can be applied.
3. Meta-knowledge:
• Knowledge about the other types of
knowledge is called Meta-knowledge.
4. Heuristic knowledge:
• Heuristic knowledge is representing
knowledge of some experts in a field or
subject.
• Heuristic knowledge is rules of thumb based
on previous experiences, awareness of
approaches, and which are good to work but
not guaranteed.
5. Structural knowledge:
• Structural knowledge is basic knowledge to
problem-solving.
• It describes relationships between various
concepts such as kind of, part of, and grouping
of something.
It describes the relationship that exists
between concepts or objects.
Techniques of knowledge representation
There are mainly 4 ways of knowledge
representation which are given as
follows:
• Logical Representation
• Semantic Network
Representation
• Frame Representation
• Production Rules
1. Logical Representation
• In AI, we communicate using formal logic, much like following a
rulebook.
• Imagine AI as a student following a strict set of rules in a school.
• These rules ensure that information is shared with minimal mistakes
and that AI’s conclusions are either true or false.
• Though it can be tricky, logical representation is like the foundation of
many programming languages, helping AI think logically.

• Logical representation is a language with some concrete rules


which deals with propositions and has no ambiguity in
representation.
• Logical representation means drawing a conclusion based on
various conditions.
• It consists of precisely defined syntax and semantics which
supports the sound inference.
• Each sentence can be translated into logics using syntax and
semantics.
Syntax:
• Syntaxes are the rules which decide how we can
construct legal sentences in the logic.
• It determines which symbol we can use in
knowledge representation.
• How to write those symbols.
Semantics:
• Semantics are the rules by which we can interpret
the sentence in the logic.
• Semantic also involves assigning a meaning to
each sentence.
Logical representation can be categorized into mainly two
logics:
• Propositional Logics
• Predicate logics
Advantages of logical representation:
• Logical representation enables us to do logical reasoning.
• Logical representation is the basis for the programming
languages.
Disadvantages of logical Representation:
• Logical representations have some restrictions and are
challenging to work with.
• Logical representation technique may not be very natural,
and inference may not be so efficient.

• Logical representation and logical reasoning as logical representation


is a representation language and reasoning is a process of thinking
logically.
2. Semantic Network Representation
• Semantic networks are alternative of predicate logic for
knowledge representation.
• In Semantic networks, we can represent our knowledge
in the form of graphical networks.
• This network consists of nodes representing objects
and arcs which describe the relationship between
those objects.
• Semantic networks can categorize the object in different
forms and can also link those objects.
• Semantic networks are easy to understand and can be
easily extended.
• This representation consist of mainly 2 types of relations:
– IS-A relation (Inheritance)
– Kind-of-relation
Example: Following are some statements which we need to represent in the form of nodes
and arcs.
Statements:
• Jerry is a cat.
• Jerry is a mammal
• Jerry is owned by Priya.
• Jerry is white colored.
• All Mammals are animal.

• In the above diagram, we have represented the different type of knowledge in the
form of nodes and arcs.
• Each object is connected with another object by some relation.
Drawbacks in Semantic representation:
• Semantic networks take more computational time at runtime as we
need to traverse the complete network tree to answer some
questions.
• It might be possible in the worst case scenario that after traversing
the entire tree, we find that the solution does not exist in this
network.
• Semantic networks try to model human-like memory (Which has 1015
neurons and links) to store the information, but in practice, it is not
possible to build such a vast semantic network.
• These types of representations are inadequate as they do not have
any equivalent quantifier, e.g., for all, for some, none, etc.
• Semantic networks do not have any standard definition for the link
names.
• These networks are not intelligent and depend on the creator of the
system.
Advantages of Semantic network:
• Semantic networks are a natural representation of knowledge.
• Semantic networks convey meaning in a transparent manner.
• These networks are simple and easily understandable.
3. Frame Representation
• A frame is a record like structure which consists of a
collection of attributes and its values to describe an
entity in the world.
• It consists of a collection of slots and slot values.
• These slots may be of any type and sizes.
• Slots have names and values which are called facets.
Facets: The various aspects of a slot is known
as Facets.
A frame is also known as slot-filter knowledge
representation in artificial intelligence.
• Frames are derived from semantic networks and
later evolved into our modern-day classes and
objects.
• A single frame is not much useful. Frames system
consist of a collection of frames which are
connected.
• In the frame, knowledge about an object or event
can be stored together in the knowledge base.
• The frame is a type of technology which is widely
used in various applications including Natural
language processing and machine visions.
Let's take an example of a frame for a book Slots Filters

Title Artificial Intelligence


Genre Computer Science
Author Peter Norvig
Edition Third Edition
Year 1996
Page 1152

Example 2:
Let's suppose we are taking an entity, Peter. Peter is an engineer as a profession, and his age
is 25, he lives in city London, and the country is England. So following is the frame
representation for this:

Slots Filter

Name Peter
Profession Doctor
Age 25
Marital status Single
Weight 78
Advantages of frame representation:
• The frame knowledge representation makes the
programming easier by grouping the related data.
• The frame representation is comparably flexible and used by
many applications in AI.
• It is very easy to add slots for new attribute and relations.
• It is easy to include default data and to search for missing
values.
• Frame representation is easy to understand and visualize.
Disadvantages of frame representation:
• In frame system inference mechanism is not be easily
processed.
• Inference mechanism cannot be smoothly proceeded by
frame representation.
• Frame representation has a much generalized approach.
4. Production Rules
• Production rules system consist of (condition,
action) pairs which mean,
– "If condition then action".

• It has mainly 3 parts:


– The set of production rules
– Working Memory
– The recognize-act-cycle
• In production rules, agent checks for the
condition and if the condition exists then
production rule fires and corresponding action is
carried out.
– The condition part of the rule determines which rule
may be applied to a problem.
– And the action part carries out the associated
problem-solving steps.
• This complete process is called a recognize-act
cycle.
• The working memory contains the description
of the current state of problems-solving and
rule can write knowledge to the working
memory.
– This knowledge match and may fire other rules.
• If there is a new situation (state) generates,
then multiple production rules will be fired
together, this is called conflict set.
– In this situation, the agent needs to select a rule
from these sets, and it is called a conflict resolution.
Example:
• IF (at bus stop AND bus arrives) THEN action
(get into the bus)
• IF (on the bus AND paid AND empty seat)
THEN action (sit down).
• IF (on bus AND unpaid) THEN action (pay
charges).
• IF (bus arrives at destination) THEN action
(get down from the bus).
Advantages of Production rule:
• The production rules are expressed in natural
language.
• The production rules are highly modular, so we
can easily remove, add or modify an individual
rule.
Disadvantages of Production rule:
• Production rule system does not exhibit any
learning capabilities, as it does not store the result
of the problem for the future uses.
• During the execution of the program, many rules
may be active hence rule-based production
systems are inefficient.
Propositional logic
Logical representation can be categorized into mainly two logics:
– Propositional Logics
– Predicate logics
2. Propositional logic (PL) is the simplest form of logic where all the
statements are made by propositions.
• A proposition is a declarative statement which is either true or
false.
• It is a technique of knowledge representation in logical and
mathematical form.

Example:
a) It is Sunday.

b) The Sun rises from West (False proposition)

c) 3+3= 7(False proposition)

d) 5 is a prime number.
2. Predicate Logic :
Predicates are properties, additional information
to better express the subject of the sentence.
A quantified predicate is a proposition , that is,
when you assign values to a predicate with
variables it can be made a proposition.
Difference between Propositional Logic and Predicate Logic

Propositional Logic Predicate Logic


Predicate logic is an expression consisting of
Propositional logic is the logic that deals with
variables with a specified domain. It consists
a collection of declarative statements which
of objects, relations and functions between
have a truth value, true or false.
the objects.

It is an extension of propositional logic


Also known as Boolean logic.
covering predicates and quantification.

A proposition has a specific truth value, A predicate’s truth value depends on the
either true or false. variables’ value.

Propositions are combined with Logical


Operators or Logical Connectives like
Predicate Logic adds by introducing
Negation(¬), Disjunction(∨), Conjunction(∧),
quantifiers to the existing proposition.
Exclusive OR(⊕), Implication(⇒), Bi-
Conditional or Double Implication(⇔).

It is a more generalized representation. It is a more specialized representation.


Following are some basic facts about propositional
logic:
• Propositional logic is also called Boolean logic as it
works on 0 and 1.
• In propositional logic, we use symbolic variables to
represent the logic, such as A, B, C, P, Q, R, etc.
• Propositions can be either true or false, but it cannot be
both.
• Propositional logic consists of an object, relations or
function, and logical connectives.
• These connectives are also called logical operators.
• The propositions and connectives are the basic
elements of the propositional logic.
• Connectives can be said as a logical operator which
connects two sentences.

• A proposition formula which is always true is


called tautology, and it is also called a valid sentence.

• A proposition formula which is always false is


called Contradiction.

• Statements which are questions, commands, or


opinions are not propositions such as "Where is Rohini",
"How are you", "What is your name", are not
propositions.
Syntax of propositional logic:
• The syntax of propositional logic defines the
allowable sentences for the knowledge
representation.
• There are two types of Propositions:
– Atomic Propositions
– Compound propositions
• Atomic Proposition:
– Atomic propositions are the simple, consists of a
single proposition symbol.
– These are the sentences which must be either true
or false.

Example:

a) 2+2 is 4, it is an atomic proposition as it is a true fact.

b) "The Sun is cold" is also a proposition as it is a false fact.


• Compound proposition:
– Compound propositions are constructed by combining
atomic propositions, using parenthesis and logical
connectives.

Example:

a) "It is raining today, and street is wet."

b) "Ankit is a doctor, and his clinic is in Mumbai."


Logical Connectives
• Logical connectives are used to connect two
simpler propositions or representing a sentence
logically.
• We can create compound propositions with the
help of logical connectives.
• There are mainly 5 connectives:
• Negation:
– A sentence such as ¬ P is called negation of P.
– A literal can be either Positive literal or negative
literal.
• Conjunction:
– A sentence which has ∧ connective such as, P ∧
Q is called a conjunction.
Example: Rohan is intelligent and hardworking. It
can be written as,
P= Rohan is intelligent,
Q= Rohan is hardworking. → P∧
Q
• Disjunction:
– A sentence which has ∨ connective, such as P ∨ Q. is
called disjunction, where P and Q are the propositions.
– Example: "Ritika is a doctor or Engineer",
Here
– P= Ritika is Doctor.
– Q= Ritika is Engineer,
– so we can write it as P∨Q
• Implication:
– A sentence such as P → Q, is called an implication.
– Implications are also known as if-then rules.
– It can be represented as
If it is raining, then the street is wet.
Let P= It is raining, and Q= Street is wet,
so it is represented as P→Q
• Biconditional:
– A sentence such as P⇔ Q is a Biconditional
sentence,
– Example:
If I am breathing, then I am alive
P= I am breathing,
Q= I am alive,
it can be represented as P ⇔ Q.

Note: Implication is one-way, whereas the


biconditional is two-way.
Truth Table:
• In propositional logic, we need to know the
truth values of propositions in all possible
scenarios.
• We can combine all the possible combination
with logical connectives, and the
representation of these combinations in a
tabular format is called Truth table.
Truth table for all logical connectives
Truth table with 3 propositions:
• We can build a proposition composing three
propositions P, Q, and R.
• This truth table is made-up of 8n Tuples as we have
taken 3 proposition symbols.
Precedence of connectives:
• Just like arithmetic operators, there is a precedence order for
propositional connectors or logical operators.
• This order should be followed while evaluating a propositional problem.

Precedence Operators
First Precedence Parenthesis- ()
Second Precedence Negation- ~
Third Precedence Conjunction(AND) - ^
Fourth Precedence Disjunction(OR) - v
Fifth Precedence Implication - ->
Six Precedence Biconditional - ⬄

Note:
For better understanding use parenthesis to make sure of the correct
interpretations.
Such as ¬R∨ Q, It can be interpreted as (¬R) ∨ Q
Logical equivalence:
• Logical equivalence is one of the features of propositional logic.

• Two propositions are said to be logically equivalent if and only if


the columns in the truth table are identical to each other.

• Let's take two propositions A and B, so for logical equivalence, we


can write it as A⇔B. In below truth table we can see that column
for ¬A∨ B and A→B, are identical hence A is Equivalent to B
Properties of Operators:
Commutativity:
P∧ Q= Q ∧ P, or
P ∨ Q = Q ∨ P.
Associativity:
(P ∧ Q) ∧ R= P ∧ (Q ∧ R),
(P ∨ Q) ∨ R= P ∨ (Q ∨ R)
Identity element:
P ∧ True = P,
P ∨ True= True.
Distributive:
P∧ (Q ∨ R) = (P ∧ Q) ∨ (P ∧ R).
P ∨ (Q ∧ R) = (P ∨ Q) ∧ (P ∨ R).
DE Morgan's Law:
¬ (P ∧ Q) = (¬P) ∨ (¬Q)
¬ (P ∨ Q) = (¬ P) ∧ (¬Q).
Double-negation elimination:
¬ (¬P) = P.
Limitations of Propositional logic:
• We cannot represent relations like ALL, some, or none
with propositional logic.
• Example:
All the girls are intelligent.
Some apples are sweet.

• Propositional logic has limited expressive power.

• In propositional logic, we cannot describe statements in


terms of their properties or logical relationships.
Rules of Inference in AI
Inference:
• In AI, we need intelligent computers which can create
new logic from old logic or by evidence, so generating
the conclusions from evidence and facts is termed as
Inference.
Inference rules:
• Inference rules are the templates for generating valid
arguments.
• Inference rules are applied to derive proofs in AI, and
the proof is a sequence of the conclusion that leads to
the desired goal.
• In inference rules, the implication among all the
connectives plays an important role.
Some terminologies related to inference rules:
• Implication:
– It is one of the logical connectives which can be
represented as P→Q
– It is a Boolean expression.
• Converse:
– The converse of implication, which means the right-
hand side proposition goes to the left-hand side and
vice-versa.
– It can be written as
Q→P
• Contrapositive:
– The negation of converse is termed as
contrapositive.
– It can be represented as
¬Q→¬P
• Inverse:
– The negation of implication is called inverse.
– It can be represented as
¬P→¬Q
• From the above term some of the compound statements are equivalent to each other,
which we can prove using truth table:

• Hence from the above truth table, we can prove that

P → Q is equivalent to ¬ Q → ¬ P,

and

Q→ P is equivalent to ¬ P → ¬ Q.
Types of Inference rules
1. Modus Ponens:
• The Modus Ponens rule states that if P and P → Q is true, then we can
infer that Q will be true .
• It can be represented as:

Example:
Statement-1: "If I am sleepy then I go to bed" ==> P→ Q
Statement-2: "I am sleepy" ==> P
Conclusion: "I go to bed." ==> Q.
Hence, we can say that, if P→ Q is true and P is true then Q will be true.

Proof by Truth table


2. Modus Tollens:
The Modus Tollens rule state that if P→ Q is true and ¬ Q is true, then ¬ P will
also true.
It can be represented as:

Example:
Statement-1: "If I am sleepy then I go to bed" ==> P→ Q
Statement-2: "I do not go to the bed."==> ~Q
Statement-3: Which infers that "I am not sleepy" => ~P

Proof by Truth table


3. Hypothetical Syllogism:
• The Hypothetical Syllogism rule state that if P→R is true whenever
P→Q is true, and Q→R is true.
• It can be represented as the following notation:

Example:
Statement-1: If you have my home key then you can unlock my home. P→Q
Statement-2: If you can unlock my home then you can take my money. Q→R
Conclusion: If you have my home key then you can take my money. P→R

Proof by Truth table


4. Disjunctive Syllogism:
• The Disjunctive syllogism rule state that if P∨Q is true, and ¬P is true,
then Q will be true.
• It can be represented as:

Example:
Statement-1: Today is Sunday or Monday. ==>P∨Q
Statement-2: Today is not Sunday. ==> ¬P
Conclusion: Today is Monday. ==> Q

Proof by Truth table


5. Addition:
• The Addition rule states that If P is true, then P∨Q will be true.

Example:
Statement: I have a vanilla ice-cream. ==> P
Statement-2: I have Chocolate ice-cream.
Conclusion: I have vanilla or chocolate ice-cream. ==> (P∨Q)

Proof by Truth table


6. Simplification:
• The simplification rule state that if P∧ Q is true, then Q or P will
also be true.
• It can be represented as:

Proof by Truth table


7. Resolution:
• The Resolution rule state that if P∨Q and ¬ P∧R is true, then Q∨R will also
be true.
• It can be represented as

Proof by Truth table


The Wumpus World
The Wumpus World
• The Wumpus World’s agent is an example of a
KBA that represents Knowledge
representation, reasoning and planning.
• KBA links general knowledge with current
percepts to infer hidden characters of current
state before selecting actions.
• Its necessity is vital in partially observable
environments.
• It was inspired by a video game Hunt the
Wumpus by Gregory Yob in 1973.
Problem Statement:
• The Wumpus world is a cave with 16 rooms (4×4).
• Each room is connected to others through walkways (no
rooms are connected diagonally).
• The knowledge-based agent starts from Room[1, 1].
• The cave has – some pits, a treasure and a beast
named Wumpus.
• The Wumpus can not move but eats the one who enters its
room.
• If the agent enters the pit, it gets stuck there.
• The goal of the agent is to take the treasure and come out
of the cave.
• The agent is rewarded, when the goal conditions are met.
• The agent is penalized, when it falls into a pit or being eaten
by the Wumpus.
• Some elements support the agent to explore
the cave, like
– The wumpus’s adjacent rooms are stenchy.
– The agent is given one arrow which it can use to
kill the wumpus when facing it (Wumpus screams
when it is killed).
– The adjacent rooms of the room with pits are
filled with breeze.
– The treasure room is always glittery.
• PEAS represents “Performance Measures,
Environment, Actuators, and Sensors”, helps in
grouping the agents.
PEAS Description for the Wumpus World problem:
• Performance measures:
– Agent gets the gold and return back safe = +1000
points
– Agent dies = -1000 points
– Each move of the agent = -1 point
– Agent uses the arrow = -10 points
• Environment:
– A cave with 16(4×4) rooms
– Rooms adjacent (not diagonally) to the Wumpus are
stinking
– Rooms adjacent (not diagonally) to the pit are breezy
– The room with the gold glitters
– Agent’s initial position – Room[1, 1] and facing right
side
– Location of Wumpus, gold and 3 pits can be anywhere,
except in Room[1, 1].
• Actuators: Devices that allow the agent to perform the
following actions in the environment.
– Move forward
– Turn right
– Turn left
– Shoot
– Grab
– Release
• Sensors: Devices which helps the agent in sensing the
following from the environment.
– Breeze
– Stench
– Glitter
– Scream (When the Wumpus is killed)
– Bump (when the agent hits a wall
Wumpus World Characterization:
• Partially Observable: knows only the local
perceptions
• Deterministic: outcome is precisely specified
• Sequential: subsequent level of actions
performed
• Static: Wumpus, pits are immobile
• Discrete: discrete environment
• Single-agent: The knowledge-based agent is the
only agent whereas the wumpus is considered
as the environment’s feature.
Exploring the Wumpus world:
• Now we will explore the Wumpus world and will determine
how the agent will find its goal by applying logical
reasoning.
Agent's First step:
• Initially, the agent is in the first room or on the square [1,1],
and we already know that this room is safe for the agent,
so to represent on the below diagram (a) that room is safe
we will add symbol OK. Symbol A is used to represent agent,
symbol B for the breeze, G for Glitter or gold, V for the
visited room, P for pits, W for Wumpus.
• At Room [1,1] agent does not feel any breeze or any Stench
which means the adjacent squares are also OK.
Agent's second Step:
• Now agent needs to move forward, so it will either
move to [1, 2], or [2,1]. Let's suppose agent moves
to the room [2, 1], at this room agent perceives
some breeze which means Pit is around this room.
The pit can be in [3, 1], or [2,2], so we will add
symbol P? to say that, is this Pit room?
• Now agent will stop and think and will not make
any harmful move. The agent will go back to the [1,
1] room. The room [1,1], and [2,1] are visited by
the agent, so we will use symbol V to represent the
visited squares.
Agent's third step:
• 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.
Knowledge-base for Wumpus world

• Lets create a knowledge base for the wumpus


world, and will derive some proves for the
Wumpus-world using propositional logic.
• 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 (¬S 11), no Pit(¬P 11), no breeze(¬B 11), 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 (¬S 21), 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 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

You might also like