Propositional logic is a fundamental tool used by logical agents in AI to represent and reason about knowledge. It deals with propositions (statements that are either true or false) and logical connectives. You can refer to our logic refresher for more information on propositional logic: Logic Refresher.
In the context of the Wumpus World:
P(x,y)
represent "There is a pit in room (x,y)"W(x,y)
represent "The Wumpus is in room (x,y)"B(x,y)
represent "There is a breeze in room (x,y)"S(x,y)
represent "There is a stench in room (x,y)"Example propositions:
¬P(1,1)
: "There is no pit in room (1,1)"B(1,1) ↔ (P(1,2) ∨ P(2,1))
: "There is a breeze in (1,1) if and only if there is a pit in (1,2) or (2,1)"Inference is the process of deriving new knowledge from existing knowledge using logical rules.
Modus Ponens:
A → B
is true, and A
is true, then B
must be trueExample:
S(1,1) → W(1,2) ∨ W(2,1)
S(1,1)
is trueW(1,2) ∨ W(2,1)
is trueModus Tollens:
A → B
is true, and B
is false, then A
must be falseExample:
B(1,1) → P(1,2) ∨ P(2,1)
¬P(1,2) ∧ ¬P(2,1)
¬B(1,1)
Other inference rules can be found in the table below:
A logical agent's knowledge base (KB) is constructed using propositional logic statements. For the Wumpus World:
¬P(1,1)
: The starting room has no pit¬W(1,1)
: The starting room has no WumpusB(x,y) ↔ (P(x-1,y) ∨ P(x+1,y) ∨ P(x,y-1) ∨ P(x,y+1))
: A room is breezy if and only if there's an adjacent pitS(x,y) ↔ (W(x-1,y) ∨ W(x+1,y) ∨ W(x,y-1) ∨ W(x,y+1))
: A room has a stench if and only if there's an adjacent WumpusAs the agent explores the Wumpus World, it:
Example:
¬B(1,1)
and ¬S(1,1)
¬P(1,2) ∧ ¬P(2,1) ∧ ¬W(1,2) ∧ ¬W(2,1)