Knowledge, reasoning, and planning · Chapter 7

Logical Agents

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.

Chapter guide

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.

7.2 The Wumpus World

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.

7.3 Logic

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.

7.4 Propositional Logic: A Very Simple Logic

Propositional logic combines Boolean symbols with connectives such as ¬, ∧, ∨, and ⇒. It is expressive for simple facts but cannot directly quantify over objects.

7.5 Propositional Theorem Proving

Inference rules derive consequences. Resolution is a sound and complete refutation method for propositional logic; truth-table entailment is simple but grows exponentially.

7.6 Effective Propositional Model Checking

Model checking tests whether a sentence holds across models. SAT-solving techniques such as DPLL and CDCL make many practical propositional queries efficient.

7.7 Agents Based on Propositional Logic

A logical agent updates its KB with percepts, infers safe actions, acts, and records the result—alternating reasoning with interaction.

Key terms and an inference example

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

Infer safe squares in a cave

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.

Current percept

No breeze · no stench

Knowledge base

¬B₁,₁ ⇒ adjacent squares contain no pit; ¬S₁,₁ ⇒ adjacent squares contain no Wumpus.

Inference

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.

Inference scope and complexity

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.