Introduction to AI (I2AI)
Looking ahead 10-15 years - Where do you see AI becoming part in our everyday life? How do you imagine the future of AI?
Some ideas and questions to think about:
From reactive rules to explicit knowledge — why search-based agents fall short and what we need instead.
What is a search algorithm — and what are its key limitations?
Search algorithms take a search problem as input and return a solution, or an indication of failure (Russel & Norvig, 2022, p. 89).
Problem-solving agents based on search are limited in a very specific way:
To overcome the limitations of search-based agents, we introduce knowledge-based agents with three core components:
How is the Wumpus World characterized in terms of its task environment dimensions?
| Property | Characterization |
|---|---|
| Observability | Partial — agent only perceives its current square |
| Agents | Single agent |
| Determinism | Deterministic — actions have fixed outcomes |
| Episodes | Sequential — earlier moves affect future options |
| Dynamics | Static — world does not change while agent deliberates |
| Continuity | Discrete — finite grid of cells and discrete actions |
Navigating this world requires some form of logic to store and reason over accumulated knowledge.
The formal building blocks agents use to represent knowledge and derive new facts from existing ones.
What is the difference between the syntax and semantics of a language?
Agents follow syntactic rules to derive new knowledge from existing sentences — and these derivations preserve semantic meaning.
A knowledge base can contain two types of sentences:
Axiom: If it is raining, the ground gets wet.
It is raining.
Inference: The ground is wet.
Knowledge comprises facts and rules. Given a rule A ⇒ B, what are the different modes of reasoning?
| Type | You know | You derive | Example |
|---|---|---|---|
| Deductive | Rule + A | B (certain) | It is raining → ground is wet |
| Abductive | Rule + B | A (best guess) | Ground is wet → probably rained (could be a sprinkler) |
| Inductive | Many A⇒B pairs | The rule itself | Every time it rains, ground is wet → rain makes ground wet |
| Causal | The cause | The effect | Rain causes the ground to be wet |
| Diagnostic | The effect | The cause | Ground is wet → what caused it? Must have rained |
Zero-order logic — the simplest formal system for encoding knowledge and deriving conclusions.
Propositional logic (also called zero-order logic) is the simplest form of logic for knowledge representation.
| Connective | Notation | Meaning |
|---|---|---|
| Negation | ¬S | not S |
| Conjunction | S₁ ∧ S₂ | S1 and S2 |
| Disjunction | S₁ ∨ S₂ | S1 or S2 |
| Implication | S₁ → S₂ | if S1 then S2 |
| Biconditional | S₁ ↔ S₂ | S1 if and only if S2 |
AP | ¬ | ∧ | ∨ | → | ↔ | (S) where AP denotes an atomic proposition (e.g., true, false, A, B, …)
Which of the following are syntactically correct propositional logic formulae?
True ✓True (∧ S2) ✗ — (∧ AP) is not a valid connectiveS1 →→ S2 ✗ — →→ is not a valid connective¬¬S1 ✓S1 → ¬S2 ✓S1 ¬→ S2 ✗ — ¬→ is not a valid connectiveComplete the truth table for the following formulae:
| A | B | ¬A | (A ∧ B) ∨ B | A → B | A ↔ B | B → (A ∧ B) | A → (A ↔ B) |
|---|---|---|---|---|---|---|---|
| F | F | T | F | T | T | T | T |
| F | T | T | T | T | F | F | T |
| T | F | F | F | F | F | T | F |
| T | T | F | T | T | T | T | T |
From knowing facts to deriving conclusions — entailment, model checking, and what it means for KB to guarantee a sentence.
To check whether KB ⊨ α:
KB = P ∧ Q, α = P ↔ Q. Does KB ⊨ α?
| P | Q | P ∧ Q | KB true? | P ↔ Q |
|---|---|---|---|---|
| T | T | T | T | T |
| T | F | F | F | F |
| F | T | F | F | F |
| F | F | F | F | T |
M(KB) = {(T,T)} ⊆ {(T,T),(F,F)} = M(α) → KB ⊨ α ✓
The agent has perceived: nothing in [1,1], a breeze in [2,1], and a stench in [1,2]. Cells of interest: [1,3], [2,2], [3,1] — each may contain a pit; at most one contains the wumpus.
Construct all 32 possible worlds (2³ pit combos × 4 wumpus placements) and use model checking to determine whether the KB entails:
What the KB encodes:
A world is KB-consistent iff both conditions hold: Breeze in [2,1] and Stench in [1,2].
| Model | KB | α₂ | α₃ |
|---|---|---|---|
| No wumpus in cells of interest | |||
| (no pits) | ? | ? | ? |
| P₁,₃ | ? | ? | ? |
| P₂,₂ | ? | ? | ? |
| P₃,₁ | ? | ? | ? |
| P₁,₃, P₂,₂ | ? | ? | ? |
| P₂,₂, P₃,₁ | ? | ? | ? |
| P₃,₁, P₁,₃ | ? | ? | ? |
| P₁,₃, P₃,₁, P₂,₂ | ? | ? | ? |
| W₁,₃ | |||
| W₁,₃ | ? | ? | ? |
| W₁,₃, P₁,₃ | ? | ? | ? |
| W₁,₃, P₂,₂ | ? | ? | ? |
| W₁,₃, P₃,₁ | ? | ? | ? |
| W₁,₃, P₁,₃, P₂,₂ | ? | ? | ? |
| W₁,₃, P₂,₂, P₃,₁ | ? | ? | ? |
| W₁,₃, P₃,₁, P₁,₃ | ? | ? | ? |
| W₁,₃, P₁,₃, P₃,₁, P₂,₂ | ? | ? | ? |
| Model | KB | α₂ | α₃ |
|---|---|---|---|
| W₃,₁ | |||
| W₃,₁ | ? | ? | ? |
| W₃,₁, P₁,₃ | ? | ? | ? |
| W₃,₁, P₂,₂ | ? | ? | ? |
| W₃,₁, P₃,₁ | ? | ? | ? |
| W₃,₁, P₁,₃, P₂,₂ | ? | ? | ? |
| W₃,₁, P₂,₂, P₃,₁ | ? | ? | ? |
| W₃,₁, P₃,₁, P₁,₃ | ? | ? | ? |
| W₃,₁, P₁,₃, P₃,₁, P₂,₂ | ? | ? | ? |
| W₂,₂ | |||
| W₂,₂ | ? | ? | ? |
| W₂,₂, P₁,₃ | ? | ? | ? |
| W₂,₂, P₂,₂ | ? | ? | ? |
| W₂,₂, P₃,₁ | ? | ? | ? |
| W₂,₂, P₁,₃, P₂,₂ | ? | ? | ? |
| W₂,₂, P₂,₂, P₃,₁ | ? | ? | ? |
| W₂,₂, P₃,₁, P₁,₃ | ? | ? | ? |
| W₂,₂, P₁,₃, P₃,₁, P₂,₂ | ? | ? | ? |
W₁,₃ ∨ W₂,₂ —
adjacents of [1,2] are [1,1], [1,3], [2,2]. Since [1,1] is safe, the wumpus must be at [1,3] or [2,2].
Eliminates all worlds where the wumpus is neither at [1,3] nor [2,2] — i.e. the entire "no wumpus" group and the W₃,₁ group.
| Model | KB | α₂ | α₃ |
|---|---|---|---|
| No wumpus — eliminated (stench requires W) | |||
| (no pits) | ✗ | ||
| P₁,₃ | ✗ | ||
| P₂,₂ | ✗ | ||
| P₃,₁ | ✗ | ||
| P₁,₃, P₂,₂ | ✗ | ||
| P₂,₂, P₃,₁ | ✗ | ||
| P₃,₁, P₁,₃ | ✗ | ||
| P₁,₃, P₃,₁, P₂,₂ | ✗ | ||
| W₃,₁ — eliminated (not adjacent to [1,2]) | |||
| W₃,₁ | ✗ | ||
| W₃,₁, P₁,₃ | ✗ | ||
| W₃,₁, P₂,₂ | ✗ | ||
| W₃,₁, P₃,₁ | ✗ | ||
| W₃,₁, P₁,₃, P₂,₂ | ✗ | ||
| W₃,₁, P₂,₂, P₃,₁ | ✗ | ||
| W₃,₁, P₃,₁, P₁,₃ | ✗ | ||
| W₃,₁, P₁,₃, P₃,₁, P₂,₂ | ✗ | ||
| Model | KB | α₂ | α₃ |
|---|---|---|---|
| W₂,₂ — still open | |||
| W₂,₂ | ? | ? | ? |
| W₂,₂, P₁,₃ | ? | ? | ? |
| W₂,₂, P₂,₂ | ? | ? | ? |
| W₂,₂, P₃,₁ | ? | ? | ? |
| W₂,₂, P₁,₃, P₂,₂ | ? | ? | ? |
| W₂,₂, P₂,₂, P₃,₁ | ? | ? | ? |
| W₂,₂, P₃,₁, P₁,₃ | ? | ? | ? |
| W₂,₂, P₁,₃, P₃,₁, P₂,₂ | ? | ? | ? |
| W₁,₃ — still open | |||
| W₁,₃ | ? | ? | ? |
| W₁,₃, P₁,₃ | ? | ? | ? |
| W₁,₃, P₂,₂ | ? | ? | ? |
| W₁,₃, P₃,₁ | ? | ? | ? |
| W₁,₃, P₁,₃, P₂,₂ | ? | ? | ? |
| W₁,₃, P₂,₂, P₃,₁ | ? | ? | ? |
| W₁,₃, P₃,₁, P₁,₃ | ? | ? | ? |
| W₁,₃, P₁,₃, P₃,₁, P₂,₂ | ? | ? | ? |
¬W₂,₂ ∧ ¬W₃,₁ —
adjacents of [2,1] are [1,1], [2,2], [3,1]. No stench means the wumpus is in none of these.
Eliminates the entire W₂,₂ group — 8 more worlds.
Newly eliminated — all 8 worlds in the W₂,₂ group:
| Model | KB | α₂ (¬P₂,₂) | α₃ (W₁,₃) |
|---|---|---|---|
| W₂,₂ | ✗ | ||
| W₂,₂, P₁,₃ | ✗ | ||
| W₂,₂, P₂,₂ | ✗ | ||
| W₂,₂, P₃,₁ | ✗ | ||
| W₂,₂, P₁,₃, P₂,₂ | ✗ | ||
| W₂,₂, P₂,₂, P₃,₁ | ✗ | ||
| W₂,₂, P₃,₁, P₁,₃ | ✗ | ||
| W₂,₂, P₁,₃, P₃,₁, P₂,₂ | ✗ |
8 surviving worlds — pit constraints still to be applied:
| Model | KB | α₂ (¬P₂,₂) | α₃ (W₁,₃) |
|---|---|---|---|
| W₁,₃ | ? | ? | ✓ |
| W₁,₃, P₁,₃ | ? | ? | ✓ |
| W₁,₃, P₂,₂ | ? | ✗ | ✓ |
| W₁,₃, P₃,₁ | ? | ✓ | ✓ |
| W₁,₃, P₁,₃, P₂,₂ | ? | ✗ | ✓ |
| W₁,₃, P₂,₂, P₃,₁ | ? | ✗ | ✓ |
| W₁,₃, P₃,₁, P₁,₃ | ? | ✓ | ✓ |
| W₁,₃, P₁,₃, P₃,₁, P₂,₂ | ? | ✗ | ✓ |
P₂,₂ ∨ P₃,₁ —
adjacents of [2,1] are [1,1], [2,2], [3,1]; since [1,1] is safe, at least one of P₂,₂ or P₃,₁ must hold.
Eliminates W₁,₃ worlds where neither pit is present.
Newly eliminated from the 8 remaining W₁,₃ worlds (no P₂,₂ and no P₃,₁):
| Model | KB | α₂ (¬P₂,₂) | α₃ (W₁,₃) |
|---|---|---|---|
| W₁,₃ | ✗ | ||
| W₁,₃, P₁,₃ | ✗ |
¬P₁,₃ ∧ ¬P₂,₂ —
adjacents of [1,2] are [1,1], [1,3], [2,2]; since [1,1] is safe, no pit in [1,3] or [2,2].
Eliminates all remaining worlds where P₁,₃ = true or P₂,₂ = true.
Newly eliminated from the 6 remaining worlds:
| Model | KB | α₂ (¬P₂,₂) | α₃ (W₁,₃) |
|---|---|---|---|
| W₁,₃, P₂,₂ | ✗ | ||
| W₁,₃, P₁,₃, P₂,₂ | ✗ | ||
| W₁,₃, P₂,₂, P₃,₁ | ✗ | ||
| W₁,₃, P₃,₁, P₁,₃ | ✗ | ||
| W₁,₃, P₁,₃, P₃,₁, P₂,₂ | ✗ |
| Model | KB | α₂ (¬P₂,₂) | α₃ (W₁,₃) |
|---|---|---|---|
| W₁,₃, P₃,₁ | ✓ | ✓ | ✓ |
The negative percepts — no breeze in [1,2] and no stench in [2,1] — are just as informative as the positive ones. Without them, 12 worlds would remain consistent and neither α₂ nor α₃ could be entailed.
| Model | KB | α₂ (¬P₂,₂) | α₃ (W₁,₃) |
|---|---|---|---|
| W₁,₃, P₃,₁ | ✓ | ✓ | ✓ |
KB ⊨ α iff M(KB) ⊆ M(α) — α is true in every model where KB is true. Here M(KB) = {W₁,₃ ∧ P₃,₁}, and both α₂ and α₃ hold in that single world. ∎
Theorem proving — deriving entailments directly from sentences using inference rules, without enumerating all models.
Theorem proving applies inference rules directly to sentences in the KB to construct a proof — without enumerating models.
α ⊨ β iff (α ∧ ¬β) is unsatisfiable.
How can we prove logical equivalences?
a) By using other (yet-to-be-proven) equivalences from the list
b) By enumeration (truth tables)
b — truth tables. Proving equivalences by other unproven equivalences would lead to circular reasoning.
Sound inference rules derive new sentences without enumerating models:
"There is smoke in a room iff the alarm in that room sounds."
Agent perceives: no alarm in room A or B. Is there smoke in room A or B?
KB:
There is no smoke in room A or B.
What remains unclear — about knowledge-based agents, logic, or inference?
Additional exercise for practice
Recap the definition of search algorithms and explain what their key limitations are when compared to knowledge-based agents.
Explain in your own words the following terms:
For each of the following, identify the mode of reasoning and justify your answer.
Which of the following are syntactically correct propositional logic formulae?
TrueTrue ∧ S2S1 →→ S2¬¬S1S1 → ¬S2S1 ¬→ S2Construct the truth table for the following formulae and determine for which truth value assignments they are satisfied:
Use model checking to determine whether the following entailments hold.
A building has the following rules and percepts. Use inference rules to derive conclusions about smoke in rooms A and B.