V 1.0

Knowledge & Inference

Introduction to AI (I2AI)

Deinera Jechle    Neu-Ulm University of Applied Sciences
April 16, 2026

Warm Up

Discussion
🪐 Imagine

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:

  • Can humans say "no" to AI? Can AI say "no" to humans?1
  • What will win the day: growth & productivity — or joy & love?1
  • Will AI lead to "privacy nightmares"?1
  • How will jobs change? According to WEF, 65% of today's children will work in jobs that don't exist yet.2
  • What will democracy look like?
  • What values will AI reflect? Or should reflect?
  • If AI does most of our work, how do we find purpose?
1 Imagining the Digital Future — AI Impact by 2040 2 World Economic Forum (2016). The Future of Jobs.

Knowledge-Based Agents

From reactive rules to explicit knowledge — why search-based agents fall short and what we need instead.

01

Recap: Search Algorithms

Discussion
💬 Recap

What is a search algorithm — and what are its key limitations?

Answer

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:

  • They are aware of available actions and consequences, but do not possess general facts about the world.
  • They use atomic representations — requiring all possible concrete states to be enumerated.
  • Goals can only be described as an explicit set of states — no general rules or relations are possible.

Knowledge-Based Agents

To overcome the limitations of search-based agents, we introduce knowledge-based agents with three core components:

  • Knowledge base (KB): Central repository where the agent stores its understanding of the world — its memory and model of reality, used to make decisions.
  • Sentences: The KB contains sentences — formal statements about the world in a knowledge representation language with defined syntax and semantics.
  • TELL and ASK operations: Two fundamental ways the agent interacts with its KB:
    • TELL — update the KB with new knowledge.
    • ASK — query the KB for guidance on what action to take.

Example: Wumpus World

Discussion
💬 Discussion

How is the Wumpus World characterized in terms of its task environment dimensions?

  1. B = Breeze
  2. S = Stench
  3. G = Glitter
  4. P = Pit
  5. A = Agent
  6. W = Wumpus
  7. OK = Safe Square
Wumpus World

Example: Wumpus World

Discussion
Answer
PropertyCharacterization
ObservabilityPartial — agent only perceives its current square
AgentsSingle agent
DeterminismDeterministic — actions have fixed outcomes
EpisodesSequential — earlier moves affect future options
DynamicsStatic — world does not change while agent deliberates
ContinuityDiscrete — finite grid of cells and discrete actions

Navigating this world requires some form of logic to store and reason over accumulated knowledge.

Logic & Reasoning

The formal building blocks agents use to represent knowledge and derive new facts from existing ones.

02

Syntax and Semantics

Discussion
💬 Discussion

What is the difference between the syntax and semantics of a language?

Answer
  • Syntax — the formal structure of sentences and the rules governing how they can be constructed and manipulated.
  • Semantics — the meaning of sentences; how sentences relate to the world they describe.

Agents follow syntactic rules to derive new knowledge from existing sentences — and these derivations preserve semantic meaning.

Types of Sentences in a KB

A knowledge base can contain two types of sentences:

  • Axioms — sentences taken as given, without being derived from other sentences.
  • Inferences — sentences derived from existing sentences using rules of reasoning.
Example

Axiom: If it is raining, the ground gets wet.
It is raining.

Inference: The ground is wet.

Modes of Reasoning

Discussion
💬 Discussion

Knowledge comprises facts and rules. Given a rule A ⇒ B, what are the different modes of reasoning?

Answer
TypeYou knowYou deriveExample
DeductiveRule + AB (certain)It is raining → ground is wet
AbductiveRule + BA (best guess)Ground is wet → probably rained (could be a sprinkler)
InductiveMany A⇒B pairsThe rule itselfEvery time it rains, ground is wet → rain makes ground wet
CausalThe causeThe effectRain causes the ground to be wet
DiagnosticThe effectThe causeGround is wet → what caused it? Must have rained

Propositional Logic

Zero-order logic — the simplest formal system for encoding knowledge and deriving conclusions.

03

Propositional Logic — Overview

Propositional logic (also called zero-order logic) is the simplest form of logic for knowledge representation.

  • Objects — sentences or formulae that encode information and denote statements about the world.
  • Atoms — basic sentences; the building blocks of propositional logic, denoted P, Q, R, S, …
  • Logical connectives — connect atoms to form compound formulae (e.g., if-then, and, or).
  • Inference — derive new information from existing knowledge using syntactic rules.

Syntax of Propositional Logic

ConnectiveNotationMeaning
Negation¬Snot S
ConjunctionS₁ ∧ S₂S1 and S2
DisjunctionS₁ ∨ S₂S1 or S2
ImplicationS₁ → S₂if S1 then S2
BiconditionalS₁ ↔ S₂S1 if and only if S2
Binding order — tightest to loosest

AP | ¬ | ∧ | ∨ | → | ↔ | (S)   where AP denotes an atomic proposition (e.g., true, false, A, B, …)

Exercise: Valid Formulae?

Discussion
✏️ Exercise

Which of the following are syntactically correct propositional logic formulae?

  1. True
  2. True (∧ S2) ✗ — (∧ AP) is not a valid connective
  3. S1 →→ S2 ✗ — →→ is not a valid connective
  4. ¬¬S1
  5. S1 → ¬S2
  6. S1 ¬→ S2 ✗ — ¬→ is not a valid connective

Exercise: Truth Table

Exercise
✏️ Exercise

Complete the truth table for the following formulae:

AB¬A(A ∧ B) ∨ BA → BA ↔ BB → (A ∧ B)A → (A ↔ B)
FF T F T T T T
FT T T T F F T
TF F F F F T F
TT F T T T T T

Simple Inference

From knowing facts to deriving conclusions — entailment, model checking, and what it means for KB to guarantee a sentence.

04

Key Concepts

  • Entailment (α ⊨ β) — the truth of one sentence requires the truth of another. In every model where α is true, β must also be true.
  • Satisfaction — sentence α is true in model m. We write M(α) for the set of all models of α.
  • Model checking — determine whether KB ⊨ α, i.e. M(KB) ⊆ M(α): in every model where KB is true, α must also be true.

Model Checking — Procedure

To check whether KB ⊨ α:

  1. Identify all propositional symbols appearing in KB and α.
  2. Construct a complete truth table listing all 2ⁿ possible truth value combinations for n symbols.
  3. Evaluate both KB and α in each row.
  4. Select the models where KB is true — this is M(KB).
  5. Check whether α is also true in all those models:
    • If yes: KB ⊨ α (entailment holds).
    • If no: KB ⊭ α (entailment does not hold).

Example: Model Checking

Example

KB = P ∧ Q,   α = P ↔ Q.   Does KB ⊨ α?

PQP ∧ QKB true?P ↔ Q
TTTTT
TFFFF
FTFFF
FFFFT

M(KB) = {(T,T)} ⊆ {(T,T),(F,F)} = M(α)  →  KB ⊨ α ✓

Exercise: Wumpus World — Model Checking

Exercise

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.

✏️ Exercise

Construct all 32 possible worlds (2³ pit combos × 4 wumpus placements) and use model checking to determine whether the KB entails:

  • α₂: "There is no pit in [2,2]"
  • α₃: "The wumpus is in [1,3]"
Wumpus World

Solution: Wumpus World — Model Checking

What the KB encodes:

  • Nothing in [1,1] → no adjacent pit or wumpus
  • Breeze in [2,1] → P₂,₂ ∨ P₃,₁
  • Stench in [1,2] → W₁,₃ ∨ W₂,₂

A world is KB-consistent iff both conditions hold: Breeze in [2,1] and Stench in [1,2].

Solution: Wumpus World — Step 1 / 6

Step by Step
Setup: Cells [1,3], [2,2], [3,1] are unknown — 8 pit combinations × 4 wumpus placements = 32 worlds. Worlds are grouped by wumpus location (matching R&N Fig. S7.1). Propositions not listed are false. All values are ?.
ModelKBα₂α₃
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₂,₂ ???
ModelKBα₂α₃
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₂,₂ ???

Solution: Wumpus World — Step 2 / 8

Step by Step
Constraint — Stench in [1,2]:  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.
ModelKBα₂α₃
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₂,₂
ModelKBα₂α₃
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₂,₂ ???
16 worlds eliminated 16 remaining — W₁,₃ and W₂,₂ groups

Solution: Wumpus World — Step 3 / 8

Step by Step
Constraint — No stench in [2,1]:  ¬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:

ModelKBα₂  (¬P₂,₂)α₃  (W₁,₃)
W₂,₂
W₂,₂, P₁,₃
W₂,₂, P₂,₂
W₂,₂, P₃,₁
W₂,₂, P₁,₃, P₂,₂
W₂,₂, P₂,₂, P₃,₁
W₂,₂, P₃,₁, P₁,₃
W₂,₂, P₁,₃, P₃,₁, P₂,₂
8 more worlds eliminated 8 remaining — W₁,₃ group only

Solution: Wumpus World — Step 4 / 8

Step by Step
Interim result — wumpus location established: combining steps 2 and 3, the wumpus must be at [1,3]. Only the W₁,₃ group survives. All 8 worlds in this group still differ in their pit assignments.

8 surviving worlds — pit constraints still to be applied:

ModelKBα₂  (¬P₂,₂)α₃  (W₁,₃)
W₁,₃ ??
W₁,₃, P₁,₃ ??
W₁,₃, P₂,₂ ?
W₁,₃, P₃,₁ ?
W₁,₃, P₁,₃, P₂,₂ ?
W₁,₃, P₂,₂, P₃,₁ ?
W₁,₃, P₃,₁, P₁,₃ ?
W₁,₃, P₁,₃, P₃,₁, P₂,₂ ?
α₃ already established as true in all 8 remaining worlds

Solution: Wumpus World — Step 5 / 8

Step by Step
Constraint — Breeze in [2,1]:  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₃,₁):

ModelKBα₂  (¬P₂,₂)α₃  (W₁,₃)
W₁,₃
W₁,₃, P₁,₃
2 more worlds eliminated 6 remaining

Solution: Wumpus World — Step 6 / 8

Step by Step
Constraint — No breeze in [1,2]:  ¬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:

ModelKBα₂  (¬P₂,₂)α₃  (W₁,₃)
W₁,₃, P₂,₂
W₁,₃, P₁,₃, P₂,₂
W₁,₃, P₂,₂, P₃,₁
W₁,₃, P₃,₁, P₁,₃
W₁,₃, P₁,₃, P₃,₁, P₂,₂
5 more worlds eliminated 1 remaining

Solution: Wumpus World — Step 7 / 8

Step by Step
Result: After applying all four KB constraints, exactly one world remains consistent: it has P₃,₁ (satisfying the breeze), W₁,₃ (satisfying the stench), no P₁,₃ or P₂,₂ (satisfying the no-breeze in [1,2]), and W not at [2,2] or [3,1] (satisfying the no-stench in [2,1]).
ModelKBα₂  (¬P₂,₂)α₃  (W₁,₃)
W₁,₃, P₃,₁
Unique KB-consistent world: W₁,₃ ∧ P₃,₁
Key insight

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.

Solution: Wumpus World — Step 8 / 8

Step by Step
Entailment check: KB ⊨ α holds iff α is true in every model where KB is true — M(KB) ⊆ M(α). Since M(KB) = {W₁,₃ ∧ P₃,₁}, we evaluate α₂ and α₃ in that single world.
ModelKBα₂  (¬P₂,₂)α₃  (W₁,₃)
W₁,₃, P₃,₁
α₂ — No pit in [2,2]
No breeze in [1,2] eliminates P₂,₂ directly (step 6).
In the unique KB world, P₂,₂ = false → α₂ is true.
KB  ⊨  α₂  ✓
α₃ — Wumpus in [1,3]
Stench in [1,2] required W₁,₃ or W₂,₂ (step 2).
No stench in [2,1] ruled out W₂,₂ (step 3) → only W₁,₃ remains.
KB  ⊨  α₃  ✓
Definition — Entailment

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. ∎

Propositional Proofs

Theorem proving — deriving entailments directly from sentences using inference rules, without enumerating all models.

05

Theorem Proving — Key Concepts

Theorem proving applies inference rules directly to sentences in the KB to construct a proof — without enumerating models.

  • Logical equivalence (≡): α ≡ β iff α and β are true in the same set of models. Standard equivalences apply (e.g., commutativity of ∧).
  • Validity: A sentence is valid if it is true in all models (e.g., P ∨ ¬P).
  • Deduction theorem: α ⊨ β iff the sentence (α → β) is valid.
  • Satisfiability: A sentence is satisfiable if it is true in at least one model.
Key connection

α ⊨ β   iff   (α ∧ ¬β) is unsatisfiable.

How Are Equivalences Proven?

Discussion
💬 Discussion

How can we prove logical equivalences?

a) By using other (yet-to-be-proven) equivalences from the list
b) By enumeration (truth tables)

Answer

b — truth tables. Proving equivalences by other unproven equivalences would lead to circular reasoning.

Inference Rules

Sound inference rules derive new sentences without enumerating models:

  • Modus Ponens (α → β, α | β): If α → β and α are both given, then β can be inferred.
  • And-Elimination (α ∧ β | β): From a conjunction, any conjunct can be inferred individually.
  • Biconditional elimination: α ↔ β ≡ (α → β) ∧ (β → α)
  • Contraposition: (α → β) ≡ (¬β → ¬α)
  • De Morgan: ¬(α ∧ β) ≡ (¬α ∨ ¬β)  and  ¬(α ∨ β) ≡ (¬α ∧ ¬β)
  • All logical equivalences can be used as inference rules in either direction.

Example: Fire Alarm World

Scenario

"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:

  • R1: SA ↔ AA
  • R2: SB ↔ AB
  • R3: ¬AA
  • R4: ¬AB

Fire Alarm World — Proof

  1. Biconditional elimination on R1: SA ↔ AA ≡ (SA → AA) ∧ (AA → SA) → R5
  2. And-Elimination on R5: extract AA → SA → R6
  3. Contraposition on R6: AA → SA ≡ ¬AA → ¬SA → R7
  4. Modus Ponens with R7 and R3 (¬AA): derive ¬SA → R8
  5. Apply same steps for room B → derive ¬SB → R9: ¬SA ∧ ¬SB
  6. De Morgan: ¬SA ∧ ¬SB ≡ ¬(SA ∨ SB)
Conclusion

There is no smoke in room A or B.

Questions?

What remains unclear — about knowledge-based agents, logic, or inference?

?

Exercises

Ex

Additional exercise for practice

Recap: Search Algorithms

Exercise
✏️ Exercise

Recap the definition of search algorithms and explain what their key limitations are when compared to knowledge-based agents.

Knowledge-Based Agent Components

Exercise
✏️ Exercise

Explain in your own words the following terms:

  • Knowledge base (KB)
  • Sentence
  • Axiom
  • Inference
  • TELL operation
  • ASK operation

Modes of Reasoning

Exercise
✏️ Exercise

For each of the following, identify the mode of reasoning and justify your answer.

  1. A doctor observes a patient has a fever and concludes they likely have an infection.
  2. Every time a server is overloaded, response time increases. A developer concludes high load causes slow responses.
  3. A fire alarm is sounding. The safety officer concludes there is probably smoke somewhere.
  4. If the database is locked, queries will fail. The database is locked — therefore queries will fail.
  5. Overloading a CPU causes it to throttle. The CPU is overloaded — therefore it will throttle.

Propositional Logic — Syntax

Exercise
✏️ Exercise

Which of the following are syntactically correct propositional logic formulae?

  1. True
  2. True ∧ S2
  3. S1 →→ S2
  4. ¬¬S1
  5. S1 → ¬S2
  6. S1 ¬→ S2

Truth Table

Exercise
✏️ Exercise

Construct the truth table for the following formulae and determine for which truth value assignments they are satisfied:

  1. A → (B ∨ ¬A)
  2. (A ↔ B) ∧ ¬B
  3. ¬(A ∧ B) ↔ (¬A ∨ ¬B)

Model Checking

Exercise
✏️ Exercise

Use model checking to determine whether the following entailments hold.

  1. KB = {P → Q, P},   α = Q.   Does KB ⊨ α?
  2. KB = {P ∨ Q, ¬P},   α = Q.   Does KB ⊨ α?
  3. KB = {P ↔ Q},   α = P ∧ Q.   Does KB ⊨ α?

Propositional Proof — Fire Alarm

Exercise
✏️ Exercise

A building has the following rules and percepts. Use inference rules to derive conclusions about smoke in rooms A and B.

  • R1: SA ↔ AA   (smoke in A iff alarm in A sounds)
  • R2: SB ↔ AB   (smoke in B iff alarm in B sounds)
  • R3: AA   (alarm in A is sounding)
  • R4: ¬AB   (alarm in B is not sounding)