Artificial Intelligence · Unit III

Knowledge & Reasoning

A complete tutorial on knowledge representation issues, mapping, all major approaches, and fundamental representation problems — with worked examples and diagrams

TextbookRussell & Norvig — Chapters 7, 8, 9, 10
TopicsKR Issues · Representation & Mapping · Approaches to KR · Issues in KR
Section 01

What is Knowledge & Why Represent It?

A calculator can multiply 7,463 × 9,821 faster than any human — yet it knows nothing about why you need that product. A chess program can evaluate millions of positions per second — yet it has no idea that chess is a game. Knowledge is what distinguishes intelligent behaviour from mere computation. To build systems that reason, plan, and explain, we must first answer a deceptively difficult question: how do we represent what a system "knows" in a form a computer can use?

This question drives the field of Knowledge Representation and Reasoning (KR&R) — one of the oldest and most fundamental sub-fields of AI. Without good knowledge representation, expert systems cannot diagnose diseases, natural language systems cannot understand sentences, and planning systems cannot schedule factories.

The DIKW Pyramid — From Raw Data to Actionable Wisdom Wisdom Know WHY Knowledge Know HOW & patterns Information Processed, contextualised data Data Raw facts, numbers, symbols — no meaning yet "This drug will harm patient X" "Penicillin treats bacterial infections" "Patient X has strep throat" "Temp: 38.5°C, WBC: 14,000" Adding Context & Understanding
Figure 1.1 — The DIKW Pyramid. AI systems must operate at the Knowledge and Wisdom levels — they need to understand facts, relationships, and consequences, not merely store raw data.

Types of Knowledge in AI

Not all knowledge is the same. AI systems must handle several distinct categories, each requiring different representational tools. This classification is a commonly tested definition.

TypeDescriptionExample (Medical Domain)Representation
DeclarativeFacts about the world — "what is""Fever is a symptom of infection"Logic, frames, semantic networks
ProceduralHow to do something — step-by-step"To diagnose: first take temperature, then..."Production rules, scripts
HeuristicRules of thumb — expert shortcuts"If patient is elderly, suspect pneumonia first"IF-THEN rules, weighted rules
Meta-knowledgeKnowledge about knowledge itself"Blood culture results are more reliable than symptoms alone"Confidence weights, certainty factors
StructuralHow concepts relate to each other"Pneumonia is a subtype of lung disease"Ontologies, class hierarchies
Common-senseImplicit world knowledge humans take for granted"A dead patient cannot be treated"Difficult — requires large ontologies (CYC)
The Knowledge Representation Hypothesis

Proposed by Brian Cantwell Smith (1985): "Any mechanically embodied intelligent process will be comprised of structural ingredients that: (a) we as external observers naturally take to represent a propositional account of the domain the overall process is engaged in, and (b) that independent of such external semantic attribution, play a formal but causal and essential role in engendering the behaviour that constitutes the intelligence."

In plain terms: for a machine to behave intelligently, there must be internal structures we can interpret as representing knowledge about the world, and these structures must causally drive the intelligent behaviour. Intelligence requires explicit knowledge — not just programmed responses.

Running Example Medical Diagnosis — Used Throughout This Tutorial

We use a simplified medical diagnosis domain throughout. A doctor must diagnose a patient's illness from symptoms and tests. This domain is rich enough to illustrate all KR approaches yet compact enough for worked examples.

EntityKnown Facts
Patient: JohnAge 45, male, smoker. Symptoms: fever (38.5°C), cough (productive), chest pain, shortness of breath. Duration: 3 days.
Test ResultsWBC count: 14,000 (high). Chest X-ray: consolidation in right lower lobe. Sputum culture: Streptococcus pneumoniae.
Target DiagnosisBacterial pneumonia (community-acquired). Treatment: amoxicillin 500mg × 7 days.
ChallengeHow do we encode the doctor's expertise so a computer can replicate this reasoning — and explain it?

Each KR approach in Sections 3–4 will represent the same knowledge about this patient in a different formalism. Compare how each handles the same facts differently.

The Knowledge Representation & Reasoning Cycle

Real World Domain facts, events and relationships Knowledge Acquisition Elicit from experts Knowledge Base Formal representation Inference Engine Reasoning + answers encode store query answer User / Application Queries + results
Figure 1.2 — The KR&R Cycle. Domain knowledge is acquired from experts, encoded into a knowledge base using a formal representation, and then queried by an inference engine to answer questions from users or applications.

Knowledge Representation Issues — Overview

Building a usable knowledge representation system requires tackling five fundamental issues. These issues motivate every design decision in every KR formalism we study.

Expressiveness
What can be represented?
Can the language express all the knowledge needed? Propositional logic cannot express "all patients with fever have some infection" — first-order logic is needed. More expressive ≠ always better.
Inferential Adequacy
What can be derived?
Can the reasoner derive all conclusions that follow from the represented knowledge? A complete inference procedure derives every true consequence. Incompleteness means missing valid conclusions.
Inferential Efficiency
How fast can we reason?
Can queries be answered in reasonable time? First-order logic is semi-decidable. Description logics trade expressiveness for polynomial inference. This tension drives most KR design.
Acquisitional Efficiency
How easy to build the KB?
How easily can new knowledge be added without disrupting existing facts? The "knowledge acquisition bottleneck" — getting expert knowledge into the system — is the single hardest problem in expert system building.
Key Insight — The Central Trade-off

Every KR system must navigate a fundamental trade-off: expressiveness vs. computational tractability. More expressive languages (full first-order logic) can represent anything — but reasoning may be undecidable or impractically slow. Weaker languages (propositional logic) support fast, complete reasoning — but cannot express many real-world facts. This trade-off shapes every KR decision in this unit.

🎯 Quick Check: Which type of knowledge is hardest for AI systems to represent and is illustrated by the phrase "A dead patient cannot be treated"?
✅ Correct! Common-sense knowledge is the hardest category. Humans never explicitly state "dead patients cannot receive treatment" because it is so obvious — yet AI systems must be told this explicitly. The CYC project has spent decades encoding millions of such facts. Common-sense knowledge is implicit, vast, and context-dependent — making it extremely difficult to represent formally.
Section 02

Representation & Mapping

Building on the types of knowledge from Section 1, we now ask: how do we translate knowledge about the world into a form a computer can manipulate? This is the problem of representational mapping — choosing a formal structure that faithfully mirrors the relevant aspects of the world while remaining computationally tractable.

A knowledge representation is not just a storage format. It is a surrogate for the real world: a substitute for things and relationships that lets the system reason about them without direct access to reality. Every design choice for this surrogate has profound consequences for what the system can and cannot know.

Representational Mapping

A representational mapping is a correspondence between:

  1. The represented world: Objects, facts, relationships, and events in the domain of interest.
  2. The representing world: Symbols, structures, and procedures in the computational formalism.

The mapping must preserve the relevant structure: if "A is related to B" in the real world, the representing structure must capture this relationship so that any conclusion the system draws about the representing world corresponds to a true conclusion about the real world.

Representational Mapping — Real World to Formal Symbols Represented World (Domain) Patient John Disease Pneumonia Symptom Fever has_disease has_symptom indicates Representing World (Formal) Patient(John) constant / atom Disease(Pneum) predicate / atom Symptom(fever) ground atom hasDx(J,P) ENCODE INTERPRET
Figure 2.1 — Representational mapping. Real-world objects (Patient John, Pneumonia, Fever) are encoded into formal symbols (predicates, constants, atoms). Conclusions drawn in the formal world must map back to valid conclusions about the real world.

Properties of a Good Knowledge Representation Language

Not every formal language makes a good KR language. A good KR language needs four properties, defined by Brachman & Levesque (1985). These appear frequently in exam questions.

PropertyDefinitionImplication if Missing
Representational AdequacyCan represent all the knowledge needed for the taskSome facts cannot be stored — system gives wrong or no answers
Inferential AdequacyReasoning can derive all entailed conclusionsValid conclusions are missed (incomplete reasoner)
Inferential EfficiencyReasoning is computationally tractable in practiceSystem is too slow to use — answers arrive hours/days later
Acquisitional EfficiencyNew knowledge can be added easily without side effectsKnowledge base becomes unmaintainable — expert time consumed

The Ontological Commitment

Every KR scheme makes implicit ontological commitments — assumptions about the kinds of things that exist in the world. Choosing a representation is choosing what kinds of entities you believe the world contains.

LanguageOntological Commitment — What ExistsExample Entities
Propositional LogicFacts — true or false propositionsJohnHasFever, IsPneumonia
First-Order LogicObjects, their properties, and relations between themJohn, Pneumonia, hasFever(John)
Higher-Order LogicObjects + relations + relations over relationsBelieves(Doctor, Diagnosis(John, Pneumonia))
Probabilistic LogicObjects + degrees of belief (probabilities)P(Pneumonia | Fever, Cough) = 0.72
Temporal LogicObjects + facts + time — things can changeHasFever(John, t) ∧ t > Day3 → WorseSituation

Representation as a Set of Surrogate Commitments

Davis, Shrobe & Szolovits (1993) identified five roles that any KR scheme plays simultaneously. Understanding these roles explains why KR is hard — a design choice that helps one role often hurts another.

1. Surrogate
Substitute for reality
KR structures stand in for real-world entities. We reason about the symbols, not the world directly. Good surrogates faithfully model the relevant aspects of reality.
2. Ontological Commitment
What categories exist?
Every language makes assumptions about the kinds of things that exist. These commitments shape what can and cannot be expressed. Wrong ontology → expressiveness failure.
3. Fragmentary Theory of Intelligence
Theory of reasoning
Every KR scheme embeds assumptions about how intelligent agents reason. Logic assumes monotonic inference. Production rules assume forward/backward chaining. These are theories of cognition.
4. Medium of Efficient Computation
Must be computable
The representation must enable efficient inference. Purely expressive but computationally intractable languages are useless in practice. This forces design tradeoffs.
5. Medium of Human Expression
Must be understandable
Humans must be able to read, write, and verify the knowledge base. A representation too alien to human thought patterns will be error-prone to encode and impossible to debug.
Note — The Mapping Must Be Faithful

A representational mapping is only useful if it is semantically faithful — conclusions drawn in the formal system must correspond to true conclusions in the real world. A system that concludes "John has malaria" because the formal encoding was wrong is worse than useless. This faithfulness requirement is why knowledge engineering (building knowledge bases) is more art than science.

🎯 Quick Check: A hospital's AI system can only represent facts as true/false propositions (propositional logic). A doctor asks: "Do all patients over 65 with fever have a higher risk of sepsis?" The system cannot answer this correctly. Which property of a good KR language is being violated?
✅ Correct! Representational Adequacy is violated. Propositional logic has no variables or quantifiers — it cannot express "∀x Patient(x) ∧ Age(x)>65 ∧ HasFever(x) → HighSepsisRisk(x)." This requires First-Order Logic (FOL). The system's failure isn't about speed (efficiency) or reasoning ability — the knowledge simply cannot be encoded in propositional logic at all. This is why FOL is the dominant language for most KR tasks.
Section 03

Logic-Based Approaches to Knowledge Representation

Logic was the first formal language proposed for AI knowledge representation, and it remains the gold standard for precision and rigour. A logical knowledge base is a set of sentences in a formal language; a logical inference procedure derives new sentences guaranteed to be true whenever the premises are. Logic gives us both expressiveness (what can be said) and soundness (what can safely be derived).

Two levels of logic dominate AI: Propositional Logic (simple but limited) and First-Order Predicate Logic (powerful and expressive). We also touch on Horn Clauses — the efficient subset used in Prolog and expert systems.

Propositional Logic

Propositional Logic

Propositional logic deals with propositions — statements that are either true or false. Complex statements are built from atomic propositions using connectives: ¬ (not), ∧ (and), ∨ (or), → (implies), ↔ (iff).

A model is a truth-value assignment to all propositions. A sentence is valid if true in all models, satisfiable if true in some model, and unsatisfiable if true in no model.

Propositional Logic — Syntax and Semantics Atomic propositions: P, Q, R, HasFever, IsPneumonia Complex sentences: HasFever ∧ HasCough → SuspectPneumonia ¬HasAntibiotics → ¬CuredBacterial Inference rule (Modus Ponens): α → β, α ⊢ β Completeness: YES Decidability: YES (propositional SAT) Limitation: NO variables, NO quantifiers, NO objects or relations
Worked Example Medical Diagnosis in Propositional Logic

Knowledge Base (KB)

-- Facts about John (given) --
HasFever         -- John has fever
HasCough         -- John has cough
HasChestPain     -- John has chest pain
XRayPositive     -- consolidation on X-ray

-- Rules (domain knowledge) --
HasFeverHasCoughXRayPositiveSuspectPneumonia
SuspectPneumoniaHasChestPainDiagnosePneumonia
DiagnosePneumoniaTreatWithAntibiotics

Inference Chain (Modus Ponens)

StepFromRule AppliedDerived
1HasFever ∧ HasCough ∧ XRayPositiveRule 1SuspectPneumonia ✓
2SuspectPneumonia ∧ HasChestPainRule 2DiagnosePneumonia ✓
3DiagnosePneumoniaRule 3TreatWithAntibiotics ✓
Limitation of Propositional Logic

This knowledge base only works for John specifically. To represent the same rules for patient Mary, we need entirely new propositions: MaryHasFever, MaryHasCough, etc. With 1,000 patients, the KB grows 1,000×. There is no way to express "for all patients..." — we need First-Order Logic.

First-Order Predicate Logic (FOL)

First-Order Predicate Logic (First-Order Logic, FOL)

FOL extends propositional logic with objects (constants, variables), predicates (relations over objects), functions, and quantifiers (∀ universal, ∃ existential). These additions make FOL dramatically more expressive — capable of representing most human knowledge.

FOL Syntax Elements Constants: john, pneumonia, fever (specific objects) Variables: x, y, p (placeholders for any object) Predicates: HasFever(x), Patient(x) (properties and relations) Functions: motherOf(john), doseOf(drug) (object-valued) Quantifiers: ∀x (universal — "for all x") ∃x (existential — "there exists an x") Connectives: ¬ ∧ ∨ → ↔ (same as propositional)
Worked Example Medical Diagnosis in First-Order Logic — Full FOL KB

Ontology (object categories)

-- Object sorts (types) --
Patient(john)      -- john is a patient
Disease(pneumonia) -- pneumonia is a disease
Symptom(fever)     -- fever is a symptom
Drug(amoxicillin)  -- amoxicillin is a drug

Facts (ground atoms)

HasSymptom(john, fever)
HasSymptom(john, cough)
HasSymptom(john, chest_pain)
TestResult(john, xray, positive)
Age(john, 45)
Smoker(john)

General Rules (with variables — work for ANY patient)

-- Rule 1: Pneumonia diagnostic criteria --
∀x [Patient(x) ∧ HasSymptom(x, fever) ∧ HasSymptom(x, cough)
     ∧ TestResult(x, xray, positive)
     → SuspectDisease(x, pneumonia)]

-- Rule 2: Confirm diagnosis with chest pain --
∀x [SuspectDisease(x, pneumonia) ∧ HasSymptom(x, chest_pain)
     → Diagnosis(x, pneumonia)]

-- Rule 3: Treatment protocol --
∀x ∀d [Diagnosis(x, d) ∧ BacterialDisease(d)
        → Prescribe(x, amoxicillin)]

-- Fact: pneumonia is bacterial --
BacterialDisease(pneumonia)

-- Rule 4: Elderly patients need extra care (quantified!) --
∀x [Patient(x) ∧ Age(x, ?a) ∧ ?a > 65Diagnosis(x, pneumonia)
     → HighRisk(x)]

Inference (Unification + Modus Ponens)

Applying Rule 1 with x = john: the system unifies the variable x with the constant john, checks all conditions against the KB, and derives SuspectDisease(john, pneumonia). This works for ANY patient — Mary, Bob, Alice — using the same rules.

Advantage over Propositional Logic

One FOL rule handles all patients. Add 1,000 patients — the rules stay exactly the same. The KB grows only with new patient facts, not new rules. Quantification is the key power of FOL.

FeaturePropositional LogicFirst-Order Logic (FOL)
Variables❌ None — only named propositions✅ Variables ranging over objects
Quantifiers❌ None✅ ∀ and ∃
Objects & relations❌ No objects — only truth values✅ Objects, predicates, functions
ExpressivenessLimited — grows linearly with domainHigh — one rule covers all objects
Decidability✅ Decidable (exponential)❌ Semi-decidable (can loop forever)
Inference speedFast (SAT solvers, resolution)Slower (unification, theorem proving)
Practical useHardware verification, simple rule enginesExpert systems, ontologies, Prolog, OWL

Horn Clauses — The Efficient Subset

Horn Clause

A Horn clause is a disjunction of literals with at most one positive literal. Equivalently: B₁ ∧ B₂ ∧ … ∧ Bₙ → H — a conjunction of conditions implies a single head. Horn clauses are a proper subset of FOL that supports efficient reasoning via SLD resolution (used in Prolog).

Advantages: linear-time inference (vs. exponential for full FOL); complete for Horn theories; forms the basis of Prolog and Datalog. Limitation: cannot express disjunctions in the head (you cannot say "diagnosis is either X or Y").

-- Horn clause knowledge base for medical diagnosis --
% Facts (unit clauses — head only)
patient(john).
has_symptom(john, fever).
has_symptom(john, cough).
test_positive(john, xray).
bacterial_disease(pneumonia).

% Rules (definite clauses — body → head)
suspect_pneumonia(X) :-
    patient(X),
    has_symptom(X, fever),
    has_symptom(X, cough),
    test_positive(X, xray).

diagnose(X, pneumonia) :-
    suspect_pneumonia(X).

prescribe(X, amoxicillin) :-
    diagnose(X, D),
    bacterial_disease(D).

% Query: ?- prescribe(john, What).
% Answer: What = amoxicillin  ✓
🎯 Quick Check: A doctor wants to encode the rule: "A patient has pneumonia OR tuberculosis if they have a chronic cough lasting more than 3 weeks." Why can this NOT be directly represented as a Horn clause?
✅ Correct! Horn clauses have the form Body → Head, where Head is a single positive literal. The rule "cough>3weeks → Pneumonia ∨ Tuberculosis" would require a disjunctive head (Pneumonia OR Tuberculosis), which violates the Horn clause restriction. Full FOL can express this: ChronicCough(x) → HasDisease(x, pneumonia) ∨ HasDisease(x, tb). This is a common exam question — remember "at most one positive literal in the head."
Section 04

Structured Approaches to Knowledge Representation

Logic is precise but verbose — representing a doctor's knowledge about pneumonia in FOL requires dozens of atomic sentences for what a physician grasps intuitively as a unified concept. Structured representations package related knowledge into coherent units that mirror how humans organise knowledge: as networks of related concepts, as stereotyped descriptions, or as templated event sequences.

The four major structured approaches are: Semantic Networks, Frames, Production Rules (IF-THEN), and Scripts. Each offers a different trade-off between expressiveness, naturalness, and computational efficiency.

Semantic Networks

Semantic Network

A semantic network is a directed graph where:

  • Nodes represent concepts, objects, or events.
  • Labelled arcs represent relationships between nodes.

Key relationship types: is-a (class membership — John is-a Patient), kind-of / a-kind-of (AKO) (class hierarchy — Pneumonia kind-of Lung-Disease), has-property, part-of. Inheritance propagates properties along is-a and AKO links.

Semantic Network — Medical Diagnosis Domain Disease (abstract class) Lung Disease organ: lung Infectious Disease cause: pathogen Pneumonia treatment: antibiotics John age: 45 smoker: true Fever temp: >38°C Cough type: productive AKO AKO AKO AKO has_diagnosis has_symptom AKO / is-a (inheritance) instance relation property/symptom link
Figure 4.1 — Semantic network for medical diagnosis. Green AKO arcs form the class hierarchy (Pneumonia is both a Lung Disease and an Infectious Disease). John inherits properties from classes via AKO links — e.g., treatment=antibiotics propagates down from Pneumonia.
Key Feature — Inheritance

Inheritance is the key power of semantic networks. John's diagnosis of Pneumonia automatically grants him all properties of Pneumonia (treatment: antibiotics), Lung Disease (organ: lung), and Infectious Disease (cause: pathogen) — without stating each property individually. This dramatically reduces redundancy. But inheritance can be problematic when exceptions exist: "Tweety is a Bird; Birds fly; Tweety is a Penguin; Penguins don't fly." Which rule wins? This is the famous multiple inheritance problem.

Frames

Frame (Minsky, 1975)

A frame is a data structure (like a record or class) that collects all knowledge about a concept or object into a single unit. Each frame has slots (attributes) and fillers (values). Slot values can be: specific values, pointers to other frames, default values (assumed unless overridden), or procedural attachments (code to run when the slot is accessed).

Frames introduced the ideas of inheritance, default values, and procedural attachment that later became core object-oriented programming (OOP) concepts.

Worked Example Frame Representation — Medical Diagnosis Domain

Disease Frame (superclass)

FRAME: Disease
  name:           [STRING]
  category:       [STRING]
  treatment:      [Frame: Drug]
  severity:       default: "moderate"
  is-a:           Medical-Condition

Pneumonia Frame (inherits from Disease)

FRAME: Pneumonia
  is-a:           Disease, LungDisease, InfectiousDisease
  name:           "Pneumonia"
  symptoms:       [fever, productive-cough, chest-pain, dyspnea]
  diagnostic-criteria:
      - HasSymptom(fever) ∧ HasSymptom(cough)
      - XRayResult(consolidation)
  treatment:      amoxicillin-500mg   -- overrides Disease default
  duration:       default: "7 days"
  severity:       "moderate-to-severe" -- overrides Disease default
  when-filled(diagnosis):
      -- procedural attachment: run when diagnosis slot is filledGeneratePrescription(treatment, duration)

Patient-Instance Frame: John

FRAME: John-Patient
  is-a:           Patient
  name:           "John Smith"
  age:            45
  smoker:         true
  symptoms:       [fever(38.5°C), productive-cough, chest-pain]
  test-results:   [xray: consolidation, WBC: 14000]
  diagnosis:      Pneumonia    -- filled by inference; triggers procedural attachment
  prescription:   amoxicillin-500mg × 7 days   -- generated automatically
Frame Mechanism — Inheritance + Default + Procedure

When diagnosis = Pneumonia is filled in John's frame: (1) John inherits all Pneumonia slot values. (2) Default values ("7 days", "moderate") are used unless explicitly overridden. (3) The procedural attachment when-filled(diagnosis) automatically triggers GeneratePrescription — producing the prescription without additional rules.

Production Rules (IF-THEN Systems)

Production Rule System

A production rule is an IF-THEN pair: IF <condition> THEN <action>. A production system has three components: a set of production rules (knowledge base), a working memory (current state), and an inference engine (selects and fires rules).

Production rules directly model human expert decision-making and are the basis of most clinical decision support systems, credit scoring systems, and early expert systems like MYCIN.

Classic Example MYCIN-Style Production Rules for Medical Diagnosis

MYCIN (1976) was the first successful medical expert system, diagnosing bacterial infections. It used production rules with certainty factors (CF) to handle uncertainty. CF ranges from −1 (definitely false) to +1 (definitely true).

-- Rule 1: Suspect bacterial pneumonia --
IF   the patient has fever (temp > 38°C)
AND  the patient has productive cough
AND  chest X-ray shows consolidation
THEN suspect bacterial pneumonia  [CF = 0.8]

-- Rule 2: Raise confidence with positive culture --
IF   suspect bacterial pneumonia
AND  sputum culture positive for Streptococcus pneumoniae
THEN diagnose community-acquired pneumonia  [CF = 0.95]

-- Rule 3: Select antibiotic --
IF   diagnose community-acquired pneumonia
AND  patient is NOT penicillin-allergic
THEN prescribe amoxicillin 500mg three times daily  [CF = 0.9]

-- Rule 4: Age-based risk flag --
IF   patient age > 65
AND  diagnose community-acquired pneumonia
THEN flag as HIGH RISK — consider hospitalisation  [CF = 0.85]

Forward Chaining Trace (Data → Conclusion)

StepWorking Memory ContainsRule FiredNew Fact Added
InitFever(38.5°C), ProductiveCough, XRay(+), Culture(S.pneumoniae), Age(45)
1Above facts match Rule 1 conditionsRule 1SuspectBacterialPneumonia [CF=0.8]
2SuspectPneumonia + Culture match Rule 2Rule 2DiagnoseCAP [CF=0.95]
3DiagnoseCAP + no allergy match Rule 3Rule 3PrescribeAmoxicillin [CF=0.9] ✓

Scripts

Script (Schank & Abelson, 1977)

A script is a structured representation of a stereotyped sequence of events — a template for typical situations. Scripts capture procedural knowledge about how common events typically unfold. They have four components:

  • Entry conditions: What must be true before the script begins.
  • Roles: The participants (doctor, patient, nurse).
  • Props: The objects involved (stethoscope, prescription pad).
  • Scenes: The sequence of actions, each with expected causal structure.
Worked Example Medical Consultation Script
ComponentContent
Script NameMEDICAL-CONSULTATION
Entry ConditionsPatient is unwell. Patient has appointment. Doctor is available.
RolesPatient (p), Doctor (d), Nurse (n), Receptionist (r)
PropsWaiting room, examination table, stethoscope, blood pressure cuff, prescription pad, medical records
Scene 1: Arrivalp arrives at clinic → r checks in p → n takes vitals (temp, BP, pulse) → p waits in waiting room
Scene 2: Consultationn calls p → p enters examination room → d greets p → d asks about symptoms → p describes symptoms → d examines p (auscultation, palpation)
Scene 3: Diagnosisd orders tests (X-ray, blood work) → d reviews results → d formulates diagnosis → d explains diagnosis to p
Scene 4: Treatmentd writes prescription → d gives follow-up instructions → p leaves clinic → p fills prescription at pharmacy
Exit ConditionsPatient has prescription. Patient understands treatment plan.
Expected OutcomesPatient recovers. Condition is monitored. Follow-up scheduled if needed.
Why Scripts Matter

Scripts allow an AI system to fill in missing information. If a story says "John went to the doctor and got amoxicillin," a script-based system knows John probably had to check in, wait, be examined, and receive a diagnosis — even though none of this is stated. Scripts power natural language understanding of stories and are the basis of modern frame-based NLU systems.

Comparing All KR Approaches

ApproachStructureStrengthsWeaknessesBest For
Propositional LogicTruth-valued propositionsDecidable; fast; sound & completeNo variables; no quantifiers; exponential growthSimple boolean reasoning, hardware verification
First-Order Logic (FOL)Objects + predicates + quantifiersHighly expressive; sound; generalSemi-decidable; slow; verboseExpert systems, ontologies, theorem proving
Horn Clauses / PrologDefinite clauses — body → headEfficient SLD resolution; PrologNo disjunctive heads; limited negationLogic programming, Datalog databases
Semantic NetworksNodes + labelled arcs + inheritanceNatural; visual; inheritanceAmbiguous semantics; multiple inheritance issuesTaxonomies, NLU, knowledge graphs
FramesSlots + fillers + inheritance + proceduresDefault values; procedural attachment; OOP-likeComplex interaction of defaults; not formalExpert systems, object modelling, planning
Production RulesIF condition THEN actionNatural expert knowledge; modular; explainableConflict resolution needed; no structure between rulesExpert systems (MYCIN), decision support
ScriptsStereotyped event sequencesCaptures procedural knowledge; enables inferenceRigid; hard to handle deviations; difficult to buildNLU story understanding, dialogue systems
🎯 Quick Check: A hospital wants to build a system that automatically generates a default treatment plan the moment a diagnosis is entered — without writing a separate rule for every disease. Which KR mechanism is BEST suited for this?
✅ Correct! Frames with procedural attachments (specifically "when-filled demons") are designed exactly for this: when a slot value is assigned, attached code fires automatically. No separate rules are needed per disease — the procedure is part of the frame definition itself. This is superior to production rules (which require one rule per disease-treatment pair) and propositional logic (which cannot express this pattern compactly). This is why frames became the basis of object-oriented programming — methods fire when attributes are set.
Section 05

Issues in Knowledge Representation

Building a working knowledge representation system is hard — much harder than picking a formalism and writing down facts. Fundamental problems arise that no current KR approach fully solves. These issues are not bugs in specific systems; they are deep conceptual challenges inherent to representing a complex, changing, and incompletely known world in a finite, static formal language.

This section covers the six most important issues: the expressiveness–tractability trade-off, completeness and consistency, uncertainty and vagueness, the Frame Problem, the Qualification and Ramification Problems, and the knowledge acquisition bottleneck.

Issue 1: Expressiveness vs. Computational Tractability

The most fundamental issue in KR is a tension between two desirable but conflicting goals. This trade-off is the most frequently examined issue in KR courses.

The Expressiveness–Tractability Trade-off in KR Languages ← Less Expressive ·················· More Expressive → Tractability / Speed Prop. Logic Decidable Horn Clauses PTIME Description Logic Decidable FOL (∀, ∃) Semi-decidable Higher-Order Logic Undecidable Full NL Intractable ★ Sweet Spot Description Logics (OWL) Decidable + highly expressive Powers modern ontologies (used in SNOMED CT, Gene Ontology)
Figure 5.1 — The expressiveness–tractability trade-off. Moving right increases what can be expressed but reduces reasoning speed. Description Logics occupy the current "sweet spot" — expressive enough for most ontological knowledge, decidable, and implemented in OWL for the Semantic Web.
Key Insight — No Free Lunch

There is no KR language that is simultaneously fully expressive (can represent all human knowledge), computationally efficient (answers queries in polynomial time), and complete (derives all valid conclusions). Every practical KR system makes a deliberate trade-off. Description Logics (the basis of OWL — Web Ontology Language) are the current best balance for ontology engineering.

Issue 2: Completeness and Consistency

Completeness and Consistency in Knowledge Bases

Completeness: A KB is complete if it contains all relevant facts about the domain — no true fact is missing. Real-world KBs are almost never complete (we don't know everything).

Consistency: A KB is consistent if no contradiction can be derived — no statement and its negation are both entailed. Inconsistent KBs are dangerous: from a contradiction, everything is provable (ex falso quodlibet).

Closed World Assumption (CWA): Anything not in the KB is assumed false. Databases use CWA. Simple but dangerous — absence of evidence treated as evidence of absence.

Open World Assumption (OWA): Anything not in the KB is simply unknown. Web ontologies (OWL) use OWA. More faithful to reality but requires explicit negation to say something is false.

Worked Example CWA vs. OWA — Medical Records

The KB contains: Allergy(John, penicillin) but does NOT contain Allergy(John, amoxicillin).

AssumptionQuery: Is John allergic to amoxicillin?Consequence
CWA (Database)"NO — not in the KB, therefore false"System confidently prescribes amoxicillin — possibly dangerous!
OWA (Ontology)"UNKNOWN — not stated either way"System asks doctor to verify before prescribing — safer!

Medical KBs should use OWA: a missing allergy record does not mean no allergy — it may mean the allergy was never tested or recorded.

Issue 3: Uncertainty and Vagueness

Real-world knowledge is rarely certain. A doctor doesn't know that a patient has pneumonia — they have a degree of belief based on incomplete evidence. Classic logic is bivalent (true or false). Two main approaches handle uncertainty in KR:

ApproachRepresentationExampleUsed In
Certainty Factors (CF)Weight from −1 to +1 attached to rulesIF fever AND cough THEN pneumonia [CF=0.8]MYCIN, early expert systems
Bayesian NetworksConditional probability distributionsP(Pneumonia | Fever=T, Cough=T) = 0.72Medical diagnosis, spam filters, NLP
Fuzzy LogicTruth values in [0,1]; linguistic variablesTemperature is "HIGH" with degree 0.85Control systems, washing machines
Dempster-Shafer TheoryBelief functions over sets of hypothesesBelief({pneumonia, bronchitis}) = 0.6Decision support under ignorance
Certainty Factor Combination (MYCIN) CF(H, E₁ ∧ E₂) = CF(H|E₁) + CF(H|E₂) × (1 − CF(H|E₁)) if both positive Example: Fever gives CF=0.6; Positive X-ray gives CF=0.7 Combined CF = 0.6 + 0.7 × (1 − 0.6) = 0.6 + 0.28 = 0.88 → Strong belief in pneumonia

Issue 4: The Frame Problem

The Frame Problem (McCarthy & Hayes, 1969)

The Frame Problem asks: when an agent takes an action, which facts about the world remain true (the "frame") and which change? In formal terms: how do we efficiently represent non-change without explicitly listing all unchanged facts after every action?

Naïve solution: add an axiom of persistence for every fact and every action. With F facts and A actions, this requires F×A frame axioms — exponentially expensive and impossible to maintain.

Classic Example The Frame Problem — Medical Treatment

State before action: John has Fever, Cough, Chest-Pain, Diagnosis=Pneumonia.

Action: Prescribe(John, amoxicillin)

Question: What is true after the action?

FactAfter Prescribing?How do we know?
HasFever(John)Still true (immediately)Frame axiom: Prescribe doesn't change fever
HasCough(John)Still true (immediately)Frame axiom: Prescribe doesn't change cough
Diagnosis(John, Pneumonia)Still trueFrame axiom: Prescribe doesn't change diagnosis
Prescription(John, amoxicillin)Now true (NEW)Effect axiom: Prescribe creates this fact
Age(John, 45)Still trueFrame axiom: Prescribe doesn't change age
Smoker(John)Still trueFrame axiom: Prescribe doesn't change smoking

For one action and six facts, we need five explicit frame axioms. With 1,000 facts and 100 actions, we need 100,000 frame axioms. This is the Frame Problem.

Solutions to the Frame Problem

Successor-State Axioms (Reiter, 1991): Instead of frame axioms, write one axiom per fluent: "Fact F is true after action A if: A causes F, OR F was already true and A doesn't change F." This collapses exponentially many axioms into one per fact.
Default Persistence: Assume all facts persist unless explicitly changed — "what was true remains true unless otherwise stated" (the STRIPS assumption used in planning).

Issue 5: The Qualification and Ramification Problems

The Qualification Problem

The Qualification Problem asks: how many conditions must be listed before an action is guaranteed to achieve its effect? Practically — how complete must the precondition list of an action be?

Example: "Prescribing amoxicillin cures bacterial pneumonia." Qualifications needed: the patient is not allergic, the bacteria are not resistant, the patient actually takes the medication, the dosage is correct, the patient doesn't have an interfering condition… The list is potentially infinite. We can never fully qualify an action.

The Ramification Problem

The Ramification Problem asks: how do we represent all the indirect consequences of an action? When an action changes something, it may trigger cascading changes that are hard to enumerate.

Example: Prescribing amoxicillin → patient buys medicine → patient spends money → patient's bank balance changes → patient has less money for food → … The chain of indirect consequences can be infinite and unpredictable.

ProblemCore QuestionChallengePartial Solution
Frame ProblemWhat stays the same after an action?Exponential frame axiomsSuccessor-state axioms; STRIPS default
Qualification ProblemWhat must be true for an action to work?Infinite preconditionsDefault logic; closed world for preconditions
Ramification ProblemWhat changes indirectly?Infinite ripple effectsCausal theories; ontological modularisation

Issue 6: The Knowledge Acquisition Bottleneck

Even if we choose the perfect KR formalism, we still need to fill the knowledge base with knowledge. This turns out to be the single hardest practical challenge in AI: the knowledge acquisition bottleneck.

The Knowledge Acquisition Bottleneck

The process of extracting knowledge from human experts and encoding it into a formal KB is: slow (experts communicate poorly in formal terms), expensive (expert time costs money), incomplete (experts cannot articulate all their knowledge), and inconsistent (different experts contradict each other).

Studies show that building a medical expert system requires years of collaboration between knowledge engineers and domain experts. Experts know things they cannot articulate — this tacit knowledge is the hardest to capture.

THE KNOWLEDGE ACQUISITION PROCESS — Stages and Challenges
1

Knowledge Elicitation: Interview domain experts. Use protocol analysis (think-aloud), structured interviews, cases and repertory grids. Challenge: experts cannot fully articulate tacit knowledge.

2

Knowledge Analysis: Organise raw information into concepts, relations, and rules. Identify inconsistencies. Challenge: different experts disagree; elicited knowledge is ambiguous.

3

Knowledge Encoding: Translate analysed knowledge into the chosen KR formalism. Challenge: knowledge does not fit cleanly into any single formalism; lossy translation.

4

Knowledge Validation: Test the KB against known cases. Identify missing rules and incorrect encodings. Challenge: errors may not surface until rare edge cases; validation requires more expert time.

5

Knowledge Maintenance: Update the KB as the domain changes (new drugs, new diseases, changed protocols). Challenge: changes may invalidate many existing rules; no version control for knowledge.

Modern Approach — Machine Learning as a Solution

The knowledge acquisition bottleneck drove the AI community toward machine learning: rather than manually encoding knowledge, learn it automatically from data. Large language models (GPT-4, Claude) learn vast amounts of implicit world knowledge from text corpora — effectively automating much of the knowledge acquisition process. However, learned knowledge is less transparent, harder to verify, and may contain errors — trading the encoding problem for a verification problem.

Summary — All Issues at a Glance

IssueDefinitionImpactKey Solution Strategies
Expressiveness vs. TractabilityMore expressive → slower reasoningCannot represent all knowledge efficientlyDescription Logics, Horn clauses for efficiency
CompletenessKB may be missing factsSystem gives wrong answers on unknown factsCWA vs. OWA; explicit negation
ConsistencyKB may contain contradictionsAny conclusion derivable — system uselessTruth maintenance systems; paraconsistent logic
UncertaintyKnowledge is often probabilisticBinary T/F fails on real evidenceCertainty factors, Bayesian networks, fuzzy logic
Frame ProblemWhat stays same after action?Exponential axiom countSuccessor-state axioms; STRIPS
Qualification ProblemPreconditions may be infiniteActions may fail unexpectedlyDefault logic; assume normal conditions
Ramification ProblemIndirect effects may be infiniteCannot predict all consequencesCausal models; modular ontologies
Knowledge AcquisitionEncoding expert knowledge is hardKBs are incomplete, inconsistent, expensiveMachine learning; crowdsourcing; ontology reuse
🎯 Quick Check: A robotic surgery system plans to cut a tendon. After the cut, the system must determine what has changed. It needs to verify that the patient's blood pressure, heart rate, oxygen saturation, age, and medical history are all still the same. This is an instance of which KR problem?
✅ Correct! The Frame Problem: the system must determine what persists (blood pressure, heart rate, age, etc.) and what changes (tendon is cut, bleeding may start) after the action. Without frame axioms or a default persistence assumption, the system cannot assume anything is unchanged — it must check every fact explicitly, which is computationally infeasible. The Ramification Problem would arise if we asked about all the indirect effects of cutting (pain → increased heart rate → changed blood pressure). Those are different aspects of the same challenge.
Section 06

Exam Preparation Summary

This section consolidates every definition, comparison, and issue from Unit III into a single revision reference. Work through all tables carefully — the most commonly tested items are marked with a ★.

★ All Key Definitions at a Glance

TermDefinitionExam Tip
Knowledge RepresentationA formal language + inference procedure for encoding and reasoning about domain knowledgeAlways mention: syntax, semantics, reasoning procedure
KR HypothesisIntelligent behaviour requires internal structures that represent propositional knowledge and causally drive behaviour (B.C. Smith, 1985)Quote the key phrase: "structural ingredients that represent…"
Ontological CommitmentThe assumptions a KR language makes about what kinds of things exist in the worldEvery language makes different commitments — give examples
Representational MappingA structure-preserving correspondence from the real world to formal symbolsMust be faithful: conclusions in formal world = true in real world
CWA vs. OWACWA: what's not stated is false. OWA: what's not stated is unknownDatabases use CWA; OWL ontologies use OWA
Frame ProblemHow to represent what does NOT change after an action without listing all unchanged factsMcCarthy & Hayes 1969; solution = successor-state axioms
Qualification ProblemHow many preconditions must be listed for an action to guarantee its effect?List is potentially infinite; use default logic as solution
Ramification ProblemHow to represent all indirect consequences of an actionDifferent from Frame Problem — it's about what DOES change indirectly
KA BottleneckThe practical difficulty of extracting, encoding, and maintaining expert knowledge in a KBTacit knowledge = hardest to capture; ML is the modern partial solution

★ Types of Knowledge — Summary

Declarative
What IS
"Fever is a symptom of infection." Facts about the world. Represented by logic, frames, semantic networks.
Procedural
How TO
"To diagnose, first take temperature…" Step-by-step knowledge. Represented by scripts, production rules, algorithms.
Heuristic
Rules of Thumb
"In elderly patients, suspect pneumonia first." Expert shortcuts. Represented by IF-THEN rules with certainty factors.
Meta-knowledge
About Knowledge
"Culture results are more reliable than symptoms." Knowledge about the reliability of other knowledge.
Structural
Relationships
"Pneumonia is a subtype of lung disease." Class hierarchies. Represented by ontologies, semantic networks.
Common-Sense
Implicit
"Dead patients cannot be treated." Hardest to represent — humans never state it because it's too obvious.

★ Master KR Approaches Comparison

ApproachYear / AuthorCore StructureKey StrengthKey WeaknessExample System
Propositional LogicBoole 1847Truth-valued propositions + connectivesDecidable; fast; sound & completeNo variables, quantifiers, or objectsSAT solvers, hardware verification
First-Order Logic (FOL)Frege 1879Objects + predicates + ∀/∃ + functionsHighly expressive; general-purposeSemi-decidable; slow on large KBsCyc, theorem provers, Prolog
Horn ClausesHorn 1951 / Kowalski 1974Definite clauses Body → HeadPolynomial inference (SLD)No disjunctive head; limited negationProlog, Datalog
Semantic NetworksQuillian 1966Nodes (concepts) + labelled arcsNatural; visual; inheritanceAmbiguous semantics; multiple inheritanceWordNet, ConceptNet, Knowledge Graphs
FramesMinsky 1975Slots + fillers + default + proceduresDefault values; procedural attachmentInformal; complex default interactionsFRL, KRL; basis of OOP
Production RulesNewell & Simon 1972IF condition THEN actionNatural expert encoding; modularRule interaction; conflict resolutionMYCIN, CLIPS, Drools
ScriptsSchank & Abelson 1977Stereotyped event sequences with rolesProcedural + causal structure; NLURigid; hard to handle novel situationsSAM, PAM (story understanding)

★ Issues in KR — Quick Reference

IssueOne-Line DefinitionClassic ExampleSolution Approach
Expressiveness–TractabilityMore expressive = slower reasoningFOL: expressive but semi-decidableDescription Logics (OWL)
CompletenessMissing facts cause wrong answersAbsent allergy record ≠ no allergyOpen World Assumption
ConsistencyContradictions make KB uselessDrug A cures and harms pneumoniaTruth Maintenance Systems
UncertaintyKnowledge is probabilistic, not binary"Possibly pneumonia" (CF=0.8)Certainty factors, Bayesian nets
Frame ProblemWhat persists after an action?After prescribing, age still sameSuccessor-state axioms; STRIPS
Qualification ProblemHow many preconditions does an action need?Drug works IF not allergic AND not resistant AND…Default normal conditions
Ramification ProblemWhat are all indirect effects?Prescription → purchase → bank balance changesCausal theories, modular ontology
KA BottleneckGetting expert knowledge in is very hardExpert cannot articulate tacit knowledgeMachine learning; ontology reuse

Common Exam Mistakes

Watch Out!

Mistake 1: Confusing the Frame Problem (what stays the same?) with the Ramification Problem (what changes indirectly?). They are different aspects of the action-effects problem.

Mistake 2: Saying propositional logic is "complete" without qualification — it is complete for propositional reasoning, but cannot express FOL statements at all (no variables, no quantifiers).

Mistake 3: Saying Horn clauses are the same as FOL — they are a proper SUBSET of FOL. The key restriction: at most ONE positive literal in the head. Disjunctive conclusions cannot be expressed.

Mistake 4: Confusing semantic networks and frames — semantic networks show relationships between concepts; frames package all slot-value knowledge about a single concept. Frames evolved from semantic networks.

Mistake 5: Saying the knowledge acquisition bottleneck is about encoding speed — it is fundamentally about tacit knowledge that experts cannot articulate, making it impossible to elicit, not merely slow to encode.

Mistake 6: Forgetting CWA vs. OWA — databases (SQL) use CWA; ontologies (OWL, SPARQL) use OWA. This difference is commonly tested and has real-world safety consequences.

Typical Exam Question Types

Question PatternRequired ApproachKey Terms to Use
"What is knowledge representation?"Define KR + give the 5 roles (surrogate, ontological commitment, etc.) + KR hypothesisFormal language, inference, surrogate, Brian Smith
"Compare approaches to KR"Use the master comparison table; highlight expressiveness, strengths, weaknesses, example systemsLogic, frames, semantic networks, production rules, scripts
"Explain the Frame Problem with an example"Define the problem → give action example → show exponential frame axioms → explain successor-state solutionNon-change, frame axioms, persistence, STRIPS
"Represent X in [formalism]"Give concrete syntax for the chosen formalism applied to the given domainUse correct notation; show both facts and rules
"What are issues in KR?"List and explain all 8 issues; give one example for eachExpressiveness, tractability, completeness, uncertainty, Frame, Qualification, Ramification, KA bottleneck
"CWA vs OWA — when to use each?"Define both; give database vs ontology example; explain safety implicationsClosed world, open world, absence of evidence

Challenge Quiz — Exam-Level Question

🎯 Challenge: A medical AI system uses First-Order Logic with the Closed World Assumption. A patient record does not contain the fact "AllergicToPenicillin(Mary)." The system concludes "NOT AllergicToPenicillin(Mary)" and prescribes penicillin. The patient has a severe allergic reaction. Identify (a) which KR issue caused the problem, (b) what representational assumption was wrong, and (c) what change would prevent this?
✅ Correct! This is a classic completeness + CWA failure. (a) The KR issue: the KB is incomplete — the allergy was never recorded, not because it doesn't exist but because it wasn't tested or entered. (b) The wrong assumption: the Closed World Assumption treats any fact absent from the KB as FALSE. "AllergicToPenicillin(Mary) is not in the KB → Mary is NOT allergic" is a dangerous inference. (c) The fix: switch to the Open World Assumption (OWA) — if "AllergicToPenicillin(Mary)" is absent, the system should conclude UNKNOWN, not FALSE. Under OWA, the prescribing rule requires an explicit "NOT allergic" fact before proceeding. This is exactly why medical ontologies use OWL (OWA) rather than SQL databases (CWA).