**Artificial Intelligence (AI) Tutorial****Application of AI****History of Artificial Intelligence****Types of AI****Types of AI Agents****Agents in Artificial Intelligence****Turing Test in AI****Search Algorithms in Artificial Intelligence****Uninformed Search Algorithms****Informed Search Algorithms****Hill Climbing Algorithm in Artificial Intelligence****Means-Ends Analysis in Artificial Intelligence****Adversarial Search****Mini-Max Algorithm in Artificial Intelligence****Alpha-Beta Pruning****Knowledge-Based Agent in Artificial intelligence****What is knowledge representation?****Techniques of knowledge representation****Propositional logic in Artificial intelligence****Rules of Inference in Artificial intelligence****The Wumpus World in Artificial intelligence****Knowledge-base for Wumpus world****First-Order Logic in Artificial intelligence**

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 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
**P**be true if there is a Pit in the room [i, j]._{i,j} - Let
**B**be true if agent perceives breeze in [i, j], (dead or alive)._{i,j} - Let
**W**be true if there is wumpus in the square[i, j]._{i,j} - Let
**S**be true if agent perceives stench in the square [i, j]._{i,j} - Let
**V**be true if that square[i, j] is visited._{i,j} - Let
**G**be true if there is gold (and glitter) in the square [i, j]._{i,j} - Let
**OK**be true if the room is safe._{i,j}

#### 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 (**¬S _{11}**), no Pit(

**¬P**), no breeze(

_{11}**¬B**), no gold (

_{11}**¬G**), visited (

_{11}**V**), and the room is Safe(

_{11}**OK**).

_{11}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 (

**¬P**), Perceives breeze(

_{21}**B**), no glitter(

_{21}**¬G**), visited (

_{21}**V**), and room is safe (

_{21}**OK**).

_{21}## 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 ¬S_{11} → ¬ W_{11} ^ ¬ W_{12} ^ ¬ W_{21}, and **¬S _{11}** which will give the output ¬ W

_{11}^ W

_{12}^ W

_{12}.

**Apply And-Elimination Rule:**

After applying And-elimination rule to ¬ W_{11} ∧ ¬ W_{12} ∧ ¬ W_{21}, we will get three statements:**¬ W _{11}, ¬ W_{12}, and ¬W_{21}**.

**Apply Modus Ponens to ¬S**_{21}, and R2:

Now we will apply Modus Ponens to ¬S_{21} and R2 which is ¬S_{21} → ¬ W_{21} ∧¬ W_{22} ∧ ¬ W_{31}, which will give the Output as **¬ W _{21} ∧ ¬ W_{22} ∧¬ W_{31}**

**Apply And -Elimination rule:**

Now again apply And-elimination rule to **¬ W _{21} ∧ ¬ W_{22} ∧¬ W_{31}**, We will get three statements:

**¬ W**.

_{21}, ¬ W_{22}, and ¬ W_{31}**Apply MP to S**_{12}and R4:

Apply Modus Ponens to **S _{12}** and

**R**which is

_{4}**S**, we will get the output as

_{12}→ W_{13}∨. W_{12}∨. W_{22}∨.W_{11}**W**.

_{13}∨ W_{12}∨ W_{22}∨.W_{11}**Apply Unit resolution on W**_{13}∨ W_{12}∨ W_{22}∨W_{11}and ¬ W_{11}:

After applying Unit resolution formula on W_{13} ∨ W_{12} ∨ W_{22} ∨W_{11} and ¬ W_{11} we will get W_{13} ∨ W_{12} ∨ W_{22}.

**Apply Unit resolution on W**_{13}∨ W_{12}∨ W_{22}and ¬ W_{22}:

After applying Unit resolution on **W _{13} ∨ W_{12} ∨ W_{22}**, and

**¬W**, we will get

_{22}**W**as output.

_{13}∨ W_{12}**Apply Unit Resolution on W**_{13}∨ W_{12}and ¬ W_{12}:

After Applying Unit resolution on **W _{13} ∨ W_{12} and ¬ W_{12}**, we will get

**W**as an output, hence it is proved that the Wumpus is in the room [1, 3].

_{13}