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

AI Propositional Logic

Uploaded by

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

AI Propositional Logic

Uploaded by

pramodhinis2323
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

The Wumpus World in Artificial intelligence

Wumpus world:

The Wumpus world is a simple world example to illustrate the worth of a knowledge-based
agent and to represent knowledge representation. It was inspired by a video game Hunt the
Wumpus by Gregory Yob in 1973.

The Wumpus world is a cave which has 4/4 rooms connected with passageways. So there are
total 16 rooms which are connected with each other. We have a knowledge-based agent who
will go forward in this world. The cave has a room with a beast which is called Wumpus,
who eats anyone who enters the room. The Wumpus can be shot by the agent, but the agent
has a single arrow. In the Wumpus world, there are some Pits rooms which are bottomless,
and if agent falls in Pits, then he will be stuck there forever. The exciting thing with this cave
is that in one room there is a possibility of finding a heap of gold. So, the agent goal is to find
the gold and climb out the cave without fallen into Pits or eaten by Wumpus. The agent will
get a reward if he comes out with gold, and he will get a penalty if eaten by Wumpus or falls
in the pit.

Note: Here Wumpus is static and cannot move

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 agents to navigate the cave. These
components are given as follows:

1. The rooms adjacent to the Wumpus room are smelly, so that it would have some
stench.
2. The room adjacent to PITs has a breeze, so if the agent reaches near to PIT, then he
will perceive the breeze.
3. There will be glitter in the room if and only if the room has gold.
4. 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:

To explain the Wumpus world we have given PEAS description as below:

Performance measure:

o +1000 reward points if the agent comes out of the cave with the gold.

o -1000 points penalty for being eaten by the Wumpus or falling into the pit.

o -1 for each action, and -10 for using an arrow.

o The game ends if either agent dies or came out of the cave.

Environment:

o A 4*4 grid of rooms.

o The agent initially in room square [1, 1], facing toward the right.

o Location of Wumpus and gold are chosen randomly except the first square [1,1].

o Each square of the cave can be a pit with probability 0.2 except the first square.

Actuators:

o Left turn,

o Right turn

o Move forward

o Grab
o Release

o Shoot.

Sensors:

o The agent will perceive the stench if he is in the room adjacent to the Wumpus. (Not
diagonally).

o The agent will perceive breeze if he is in the room directly adjacent to the Pit.

o The agent will perceive the glitter in the room where the gold is present.

o The agent will perceive the bump if he walks into a wall.

o When the Wumpus is shot, it emits a horrible scream which can be perceived
anywhere in the cave.

o These percepts can be represented as five element list, in which we will have different
indicators for each sensor.

o Example if agent perceives stench, breeze, but no glitter, no bump, and no scream
then it can be represented as:
[Stench, Breeze, None, None, None].

The Wumpus world Properties:

o Partially observable: The Wumpus world is partially observable because the agent
can only perceive the close environment such as an adjacent room.

o Deterministic: It is deterministic, as the result and outcome of the world are already
known.

o Sequential: The order is important, so it is sequential.

o Static: It is static as Wumpus and Pits are not moving.

o Discrete: The environment is discrete.

o One agent: The environment is a single agent as we have one agent only and
Wumpus is not considered as an agent.

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.

Agents’ 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.

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 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:

o Let Pi,j be true if there is a Pit in the room [i, j].

o Let Bi,j be true if agent perceives breeze in [i, j], (dead or alive).

o Let Wi,j be true if there is wumpus in the square[i, j].

o Let Si,j be true if agent perceives stench in the square [i, j].

o Let Vi,j be true if that square[i, j] is visited.

o Let Gi,j be true if there is gold (and glitter) in the square [i, j].

o Let OKi,j be true if the room is safe.

Note: For a 4 * 4 square board, there will be 7*4*4= 122 propositional variables.

Some Propositional Rules for the wumpus world:

Note: lack of variables gives us similar rules for each cell.

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(¬ W 11), 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).

Propositional logic in Artificial intelligence

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:

1. It is Sunday.
2. The Sun rises from West (False proposition)
3. 3+3= 7(False proposition)
4. 5 is a prime number.
Following are some basic facts about propositional logic:

o Propositional logic is also called Boolean logic as it works on 0 and 1.

o In propositional logic, we use symbolic variables to represent the logic, and we can
use any symbol for a representing a proposition, such A, B, C, P, Q, R, etc.

o Propositions can be either true or false, but it cannot be both.

o Propositional logic consists of an object, relations or function, and logical


connectives.
o These connectives are also called logical operators.

o The propositions and connectives are the basic elements of the propositional logic.

o Connectives can be said as a logical operator which connects two sentences.

o A proposition formula which is always true is called tautology, and it is also called a
valid sentence.

o A proposition formula which is always false is called Contradiction.

o A proposition formula which has both true and false values is called

o 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:

1. Atomic Propositions
2. Compound propositions

o Atomic Proposition: Atomic propositions are the simple propositions. It consists of a


single proposition symbol. These are the sentences which must be either true or false.
Example:

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


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

o Compound proposition: Compound propositions are constructed by combining


simpler or atomic propositions, using parenthesis and logical connectives.
Example:

1. "It is raining today, and street is wet."


2. "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 five connectives, which are given as follows:
1. Negation: A sentence such as ¬ P is called negation of P. A literal can be either

2. Conjunction: A sentence which has ∧ connective such as, P ∧ Q is called a


Positive literal or negative literal.

conjunction.
Example: Rohan is intelligent and hardworking. It can be written as,
P=Rohan is intelligent,

3. Disjunction: A sentence which has ∨ connective, such as P ∨ Q. is called


Q= Rohan is hardworking. → P∧ Q.

disjunction, where P and Q are the propositions.

Here P= Ritika is Doctor. Q= Ritika is Doctor, so we can write it as P ∨ Q.


Example: "Ritika is a doctor or Engineer",

4. 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
5. Biconditional: A sentence such as P⇔ Q is a Biconditional sentence, example If I

P= I am breathing, Q= I am alive, it can be represented as P ⇔ Q.


am breathing, then I am alive

Following is the summarized table for Propositional Logic Connectives:

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. Following are
the truth table for all logical connectives:
Truth table with three 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 three 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.
Following is the list of the precedence order for operators:

Precedence Operators
First Precedence Parenthesis
Second Precedence Negation
Third Precedence Conjunction (AND)
Fourth Precedence Disjunction (OR)
Fifth Precedence Implication
Sixth Precedence Biconditional

Such as ¬R∨ Q, It can be interpreted as (¬R) ∨ Q.


Note: For better understanding use parenthesis to make sure of the correct interpretations.

You might also like