7.1 Knowledge-Based Agents
A knowledge-based agent uses a knowledge base (KB) and inference. TELL adds percepts or actions; ASK queries what action or fact follows from the KB.
Knowledge, reasoning, and planning · Chapter 7
A knowledge-based agent stores facts about the world and derives what follows from them. Logical inference can support safe action even when the complete state is not directly observable.
A knowledge-based agent uses a knowledge base (KB) and inference. TELL adds percepts or actions; ASK queries what action or fact follows from the KB.
The Wumpus world is a grid containing hazards and a goal. Percepts such as breeze and stench are local clues from which an agent infers which squares may be dangerous.
A logic has a syntax for sentences and semantics that determine truth in a model. Entailment means every model satisfying the KB also satisfies the query.
Propositional logic combines Boolean symbols with connectives such as ¬, ∧, ∨, and ⇒. It is expressive for simple facts but cannot directly quantify over objects.
Inference rules derive consequences. Resolution is a sound and complete refutation method for propositional logic; truth-table entailment is simple but grows exponentially.
Model checking tests whether a sentence holds across models. SAT-solving techniques such as DPLL and CDCL make many practical propositional queries efficient.
A logical agent updates its KB with percepts, infers safe actions, acts, and records the result—alternating reasoning with interaction.
Syntax says which sentences are well formed; semantics says when they are true. A knowledge base (KB) is a set of sentences. KB entails α when every model satisfying the KB also satisfies α. Sound inference derives only entailed conclusions; complete inference can derive every entailed conclusion.
The initial square (row 1, column 1) has no breeze and no stench. Under the cave rules, ¬B₁,₁ rules out pits and ¬S₁,₁ rules out the Wumpus in its orthogonal neighbors (row 1, column 2 and row 2, column 1). Those cells become safe to enter; an unknown square is not automatically unsafe, it is simply not yet proved safe.
Interactive lab
Explore only squares proved safe. In this fixed 4×4 world, a breeze means an adjacent pit; a stench means an adjacent Wumpus. Negative clues rule hazards out in neighboring cells.
No breeze · no stench
¬B₁,₁ ⇒ adjacent squares contain no pit; ¬S₁,₁ ⇒ adjacent squares contain no Wumpus.
The two neighboring squares are safe.
Choose a glowing safe square to move.
The grid and accessible labels use one-based row/column coordinates; KB text and move status show zero-based array indices. The Wumpus and pit are fixed but hidden. This demo uses only sound local deductions: a negative percept rules out the corresponding hazard in orthogonal neighbors.
Inputs are the fixed cave grid Gₛ (side s, N=s² cells), current cell c, and its percept. This is not a general SAT solver: it applies only the local rule “no breeze/stench ⇒ no corresponding hazard in adjacent cells,” and it never marks a square safe from an unsupported guess. One observation examines at most four neighbors, O(1) inference time; rendering rebuilds N buttons, O(N) UI time. Stored visited/safe sets and observations use O(N) space, and the grid controls use O(N) visualization memory. The shown 4×4 world is fixed-size. The deduction assumes the stated percept rules and correctly observed clues.