Knowledge Representation with Propositional Logic

GATE DA — Moderate Importance

🎯 Learning Objectives

  • Use propositional logic to represent knowledge about the world
  • Work through the Wumpus World example in detail
  • Understand the limitations of propositional knowledge representation
  • See why first-order logic is needed for more expressive representations

1. Knowledge-Based Agents

A knowledge-based agent maintains a knowledge base (KB) — a set of sentences in a formal language. The agent can:

  • TELL: Add new sentences to the KB (based on percepts).
  • ASK: Query the KB to decide actions (using inference).

Propositional logic provides a simple language for building knowledge bases.

2. The Wumpus World

The Wumpus World is a classic AI example used to illustrate logical reasoning. It's a 4×4 grid cave where an agent hunts for gold while avoiding pits and a Wumpus monster.

Wumpus World Setup
  • Grid: 4×4 rooms. Agent starts at [1,1], facing right.
  • Wumpus: One room contains the Wumpus. If the agent enters, it dies.
  • Pits: Some rooms have bottomless pits. Falling in = death.
  • Gold: One room has gold. The agent wins if it grabs the gold and exits.

Percepts

  • Stench: Adjacent rooms to the Wumpus smell bad.
  • Breeze: Adjacent rooms to a pit have a breeze.
  • Glitter: The room with gold glitters.
  • Bump: Agent bumps when walking into a wall.
  • Scream: Wumpus screams when killed by the agent's arrow.

2.1 Propositional Variables

We define propositional variables for each cell [i,j]:

VariableMeaning
Pi,jThere is a pit in [i,j]
Wi,jThe Wumpus is in [i,j]
Bi,jThere is a breeze in [i,j]
Si,jThere is a stench in [i,j]
OKi,jRoom [i,j] is safe to enter

2.2 Encoding Rules

Breeze Rules

"There is a breeze in [1,1] if and only if there is a pit in an adjacent room."

B1,1 ↔ (P1,2 ∨ P2,1)

For a room [2,2] (which has 4 neighbors):

B2,2 ↔ (P1,2 ∨ P2,1 ∨ P2,3 ∨ P3,2)

Safety Rules

"Room [i,j] is OK if there is no pit and no Wumpus there."

OKi,j ↔ (¬Pi,j ∧ ¬Wi,j)

Exactly One Wumpus

The Wumpus is in exactly one room. This requires:

At least one: W1,1 ∨ W1,2 ∨ ... ∨ W4,4

At most one: For every pair (i,j) ≠ (k,l): ¬Wi,j ∨ ¬Wk,l

This produces 16 + C(16,2) = 16 + 120 = 136 clauses just for this constraint!

2.3 Reasoning Example

Scenario: Agent is at [1,1], perceives no breeze, no stench.

Known: ¬B1,1 and ¬S1,1

From breeze rule: B1,1 ↔ (P1,2 ∨ P2,1)

Since ¬B1,1: ¬(P1,2 ∨ P2,1) → ¬P1,2 ∧ ¬P2,1

Similarly, from stench rule: ¬W1,2 ∧ ¬W2,1

Conclusion: Both [1,2] and [2,1] are safe! The agent can move to either room.

3. Limitations of Propositional Logic

⚠️ Key Limitations

LimitationExplanation
No variables or quantifiers Cannot say "for all rooms" — must enumerate each room individually. The Wumpus World needs hundreds of ground propositions for a 4×4 grid.
No objects or relations Cannot express "Room X is adjacent to Room Y" as a general relation. Must create separate propositions for each pair.
Exponential blowup Constraints like "exactly one Wumpus" require O(n²) clauses for n rooms. Larger worlds become impractical.
No functions Cannot express mathematical relationships or computed values. "The distance from A to B is 3" needs a separate proposition.
No temporal reasoning Basic propositional logic does not natively handle time. Need time-stamped variables like P1,2t for each time step.

📝 Why This Matters

These limitations motivate the move to first-order predicate logic (Chapter 6), which adds variables, quantifiers (∀, ∃), relations, and functions. In first-order logic, the breeze rule becomes a single sentence:

∀x,y [ Breeze(x,y) ↔ ∃a,b (Adjacent(x,y,a,b) ∧ Pit(a,b)) ]

This single sentence replaces 16 separate propositional sentences in the 4×4 grid.

4. Other Applications of Propositional KR

Despite its limitations, propositional logic is practical for:

  • Circuit verification: Hardware circuits are naturally propositional (Boolean).
  • Planning: SATPLAN encodes planning problems as SAT instances.
  • Constraint solving: Sudoku, scheduling, and combinatorial puzzles can be encoded as SAT.
  • Software verification: Model checking and bounded model checking use SAT/SMT solvers.

5. GATE Exam Tips

🎯 What to Know

  • Understand the Wumpus World as a standard example — frequently referenced in GATE AI questions.
  • Know how to encode rules as propositional sentences.
  • Be able to explain why propositional logic is insufficient for general knowledge representation.
  • Understand the difference between knowledge base and inference engine.