Knowledge Representation & Bayesian Networks
Probabilistic graphical models and symbolic reasoning under uncertainty. Complete verified solutions for the classic Alarm Bayesian Network ($P(A \mid J, M, \neg E, \neg B) = 55.78\%$), Knowledge-Based Agent architectures, Forward vs Backward Chaining, and Minsky's Frames schema.
01. Intuition & Concept Contrast
Classical logic handles exact deterministic truths ($\text{True} / \text{False}$). Real-world AI systems must reason under noise, incomplete evidence, and uncertainty using probabilistic graph factorizations and symbolic schemas.
Propositional Logic vs Bayesian Networks
Propositional Logic: Strict boolean assertions ($P \implies Q$). Cannot express partial belief, noisy sensor readings, or conflicting evidence.
Bayesian Belief Networks (BBN): Directed Acyclic Graphs (DAGs) capturing conditional independence. Factorizes massive joint distributions into manageable local conditional probability tables (CPTs).
Forward Chaining vs Backward Chaining
Forward Chaining (Data-Driven / Bottom-Up): Starts from observed facts; fires matching rules ($\text{IF} \to \text{THEN}$) to deduce new assertions. Used in monitoring and real-time control (CLIPS, Rete).
Backward Chaining (Goal-Driven / Top-Down): Starts from a target hypothesis; works backward to find supporting facts. Used in diagnosis and automated theorem proving (Prolog, MYCIN).
02. Bayesian Network Mathematical Factorization
Conditional Independence & D-Separation:
In a Bayesian network, each variable $X$ is conditionally independent of its non-descendants given its parents:
$$P(X \mid \operatorname{Parents}(X), \operatorname{NonDescendants}(X)) = P(X \mid \operatorname{Parents}(X))$$In the classic Alarm network: $Burglary (B) \to Alarm (A) \leftarrow Earthquake (E)$, and $A \to JohnCalls (J)$, $A \to MaryCalls (M)$.
- Given $A$, $J$ and $M$ are conditionally independent: $P(J, M \mid A) = P(J \mid A)P(M \mid A)$.
- $B$ and $E$ are marginally independent priors: $P(B, E) = P(B)P(E)$.
03. Minsky's Frames in Knowledge Representation
May 2025 (Q6.ii) Guaranteed 10-Mark Question. Object-oriented structured knowledge representation.
Core Components of a Frame:
- Slots: Named attributes or properties characterizing the entity (e.g., `Color`, `Fuel`, `Owner`).
- Facets: Constraints, default values, or data type metadata for a slot (e.g., `Default: 4`, `Range: [1, 10]`).
- Procedural Attachments (Demons): Active subroutines invoked automatically by slot modifications:
- `if-needed`: Triggered when a slot value is requested but empty; computes the value dynamically on the fly.
- `if-added`: Triggered when a new value is placed into a slot; verifies integrity constraints.
- `if-removed`: Triggered when a slot value is deleted.
04. Forward vs Backward Reasoning Comparison
Nov 2025 (Q6) 20-Mark Long Answer Question.
| Dimension | Forward Reasoning (Data-Driven) | Backward Reasoning (Goal-Driven) |
|---|---|---|
| Starting Point | Initial known facts and sensor observations | Target hypothesis or query to prove |
| Direction of Search | Bottom-Up: Antecedent (IF) $\to$ Consequent (THEN) | Top-Down: Consequent (THEN) $\to$ Antecedent (IF) |
| Branching Factor | High (may derive many irrelevant facts) | Low (focused strictly on goal sub-branches) |
| Question Answered | "What follows from these known facts?" | "Why is this conclusion valid?" |
| Industrial Examples | CLIPS, Rete algorithm, trading bots | Prolog, MYCIN medical diagnosis |
05. Notation Decoding Matrix
| Symbol | Formal Name | Plain-English Meaning | Alarm Network Value |
|---|---|---|---|
| $B, \neg B$ | Burglary Variable | Burglary occurred ($B$) vs did not occur ($\neg B$) | $P(B) = 0.001, \ P(\neg B) = 0.999$ |
| $E, \neg E$ | Earthquake Variable | Earthquake occurred ($E$) vs did not occur ($\neg E$) | $P(E) = 0.002, \ P(\neg E) = 0.998$ |
| $A \mid \neg B, \neg E$ | Alarm Likelihood | Alarm rings given no burglary and no earthquake | $P(A \mid \neg B, \neg E) = \mathbf{0.001}$ |
| $J \mid A, M \mid A$ | Sensor Likelihoods | Probability John/Mary calls given Alarm occurred | $P(J \mid A) = 0.90, \ P(M \mid A) = 0.70$ |
| $\text{Evidence}$ | Normalizing Constant | Marginal probability denominator across all states of $A$ | $\alpha = 0.000630 + 0.0004995 = \mathbf{0.0011295}$ |
06. Repeatable Step-by-Step Solving Protocol
Both numerator and denominator share the prior term $P(\neg B)P(\neg E)$. Cancel them out immediately to save computation!
07. 6 Deadly Exam Traps & Common Student Mistakes
Multiplying $P(\neg B)P(\neg E)$ into Every Term
Multiplying $0.999 \times 0.998$ adds tiny decimal factors that invite arithmetic errors. Cancel $P(\neg B)P(\neg E)$ from numerator and denominator before multiplying!
Writing $P(\neg A) = 0.001$
If $P(A \mid \neg B, \neg E) = 0.001$, then $P(\neg A \mid \neg B, \neg E) = 1 - 0.001 = \mathbf{0.999}$. Using $0.001$ for $\neg A$ destroys the calculation.
Reporting $0.000630$ as Final Probability
$0.000630$ is an unnormalized joint term. A probability cannot be complete without dividing by the total evidence sum ($0.0011295$).
Defining Only Slots and Values
Frames are distinguished from simple records by their **procedural attachment demons** (`if-needed`, `if-added`, `if-removed`). Omitting demons loses 4 marks.
Claiming Backward Chaining is Data-Driven
Forward Chaining is data-driven (starts with facts). Backward Chaining is **goal-driven** (starts with hypothesis). Confusing them loses 5 marks.
Confusing $P(\text{Cause} \mid \text{Symptom})$ with $P(\text{Symptom} \mid \text{Cause})$
Causal reasoning moves from disease to symptoms. Diagnostic reasoning uses Bayes' rule to invert the direction from symptoms to cause.
08. Complete University Question Bank (All Past PYQs Solved)
May 2025 · Question 6.i The Alarm Bayesian Network Probability Calculation (10 Marks)
Calculate the probability that the Alarm rings (A) given that:
John Calls (J), Mary Calls (M), Earthquake doesn't happen (~E), Burglary doesn't happen (~B). (10 Marks)
Solution:
1. Formula Setup via Bayes' Rule & Factorization:
$$P(A \mid J, M, \neg E, \neg B) = \frac{P(A, J, M, \neg E, \neg B)}{P(J, M, \neg E, \neg B)}$$Canceling the common prior term $P(\neg B)P(\neg E)$ from both sides:
$$P(A \mid J, M, \neg E, \neg B) = \frac{P(A \mid \neg B, \neg E) P(J \mid A) P(M \mid A)}{P(A \mid \neg B, \neg E)P(J \mid A)P(M \mid A) + P(\neg A \mid \neg B, \neg E)P(J \mid \neg A)P(M \mid \neg A)}$$2. CPT Value Substitutions:
- $P(A \mid \neg B, \neg E) = \mathbf{0.001} \implies P(\neg A \mid \neg B, \neg E) = 1 - 0.001 = \mathbf{0.999}$
- $P(J \mid A) = \mathbf{0.90} \implies P(J \mid \neg A) = \mathbf{0.05}$
- $P(M \mid A) = \mathbf{0.70} \implies P(M \mid \neg A) = \mathbf{0.01}$
3. Numerical Evaluation:
$$\begin{aligned} \text{Numerator (Alarm = True):} & \quad 0.001 \times 0.90 \times 0.70 = \mathbf{0.000630} \\[4pt] \text{Term (Alarm = False):} & \quad 0.999 \times 0.05 \times 0.01 = \mathbf{0.0004995} \\[4pt] \text{Denominator (Evidence):} & \quad 0.000630 + 0.0004995 = \mathbf{0.0011295} \end{aligned}$$4. Final Posterior Probability:
$$P(A \mid J, M, \neg E, \neg B) = \frac{0.000630}{0.0011295} = \frac{630}{1129.5} = \frac{1260}{2259} = \frac{140}{251} \approx \mathbf{0.5578}$$Final Answer: $\mathbf{55.78\%}$
May 2025 · Question 6.ii Frames Syntax, Semantics & Inference Mechanisms (10 Marks)
Give the syntax, semantic and inference mechanisms in Frames with example. (10 Marks)
Solution:
1. Syntax & Structural Schema:
Introduced by Marvin Minsky (1974), a **Frame** is an object-oriented knowledge schema consisting of **Slots**, **Facets**, and **Procedural Attachments**.
2. Semantics & Components:
- Slots: Attributes describing the entity (e.g. `Passenger_Capacity`, `Fuel`).
- Facets: Metadata describing constraints or defaults (e.g. `Default: 4`).
- Procedural Demons:
- `if-needed`: Executed when a slot value is requested but missing.
- `if-added`: Executed when a new value is inserted into a slot.
- `if-removed`: Executed when a value is removed from a slot.
3. Inference Mechanisms:
- Inheritance: Automatic property inheritance along `is-a` taxonomies.
- Default Reasoning: Uses inherited defaults when instance data is omitted.
- Active Demon Execution: Computes missing values dynamically via `if-needed` code.
Nov 2025 · Question 6 Forward vs. Backward Reasoning in AI (20 Marks)
Explain the concepts of Forward and Backward Reasoning in AI with suitable examples, highlighting working principles, differences, and applications. (20 Marks)
Solution:
1. Forward Reasoning (Data-Driven / Bottom-Up) (7 Marks):
Starts with initial observed facts in working memory and applies rules ($\text{IF} \to \text{THEN}$) iteratively to deduce new assertions until reaching a goal.
Example: Facts: "Fritz croaks" and "Fritz eats flies". Rule: $\text{Croaks} \land \text{Eats Flies} \implies \text{Frog}$. Infers: "Fritz is a frog". Rule: $\text{Frog} \implies \text{Green}$. Conclusion: "Fritz is green".
2. Backward Reasoning (Goal-Driven / Top-Down) (7 Marks):
Starts with a target hypothesis and works backward through rules to locate supporting facts. Antecedents become intermediate sub-goals.
Example: Query: "Is Fritz green?" Checks rule: $\text{Frog} \implies \text{Green}$. Sets sub-goal: "Is Fritz a frog?" Checks rule: $\text{Croaks} \land \text{Eats Flies} \implies \text{Frog}$. Verifies stored database confirming Fritz croaks and eats flies. Hypothesis confirmed!
3. Applications (6 Marks):
- Forward: Real-time monitoring, trading bots, robotics sensor interpretation (CLIPS, Rete algorithm).
- Backward: Medical diagnostic expert systems (MYCIN), automated theorem proving, logic programming (Prolog).
09. Interactive Offline Alarm Bayesian Network Calculator
Change sensor probabilities to observe how posterior alarm belief updates live.
10. Active Recall Self-Test Quiz
11. Exam Hall Answer Sheet Presentation Checklist
Write $P(A, J, M, \neg E, \neg B) = P(\neg B)P(\neg E)P(A \mid \neg B, \neg E)P(J \mid A)P(M \mid A)$.
Strike out $P(\neg B)P(\neg E)$ from numerator and denominator so the examiner sees clean algebra.
Write $\text{Term}_1 = 0.000630$ and $\text{Term}_2 = 0.0004995$ clearly labeled.
Box: $P(A \mid J, M, \neg E, \neg B) = \frac{140}{251} \approx \mathbf{55.78\%}$.
Never omit `if-needed`, `if-added`, and `if-removed` with definitions.