FAI Study Hub
← Back to Study Hub
Module 04 · Bayes Nets & KR
← Hub
Intuition Bayes Net Math Frames Chaining Traps Past Papers Calculator Quiz Checklist
Module 04 · Uncertain Reasoning & Symbolic Knowledge

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.

May 2025 (Q5 20M, Q6 20M) Nov 2025 (Q6 20M) Alarm Net (55.78%) Forward vs Backward Frames & Demons

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.

Uncertainty Handling

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

Inference Direction

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

The Master Bayesian Network Chain Rule
$$P(X_1, X_2, \dots, X_n) = \prod_{i=1}^n P(X_i \mid \operatorname{Parents}(X_i))$$ Collapses exponential joint distributions from $O(2^n)$ down to linear local parent tables.

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:

  1. Slots: Named attributes or properties characterizing the entity (e.g., `Color`, `Fuel`, `Owner`).
  2. Facets: Constraints, default values, or data type metadata for a slot (e.g., `Default: 4`, `Range: [1, 10]`).
  3. 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.
Frame: AUTOMOBILE SuperClass: Vehicle Wheels: 4 (Default Facet) Fuel: Petrol / Diesel (Range Constraint) Frame: CAR (Inherits from AUTOMOBILE) Body_Type: Sedan Passenger_Capacity: 5 Mileage: if-needed Compute_Mileage() <-- Procedural Demon Frame: MY_SEDAN (Instance of CAR) Color: Silver Registration_No: "TN-09-AB-1234"

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

Step 1: Write Down the Joint Factorization Equation $$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)}$$
Step 2: Cancel Out Common Prior Factors

Both numerator and denominator share the prior term $P(\neg B)P(\neg E)$. Cancel them out immediately to save computation!

Step 3: Compute Numerator for $A = \text{True}$ $$\text{Term}_1 = P(A \mid \neg B, \neg E) \times P(J \mid A) \times P(M \mid A) = 0.001 \times 0.90 \times 0.70 = \mathbf{0.000630}$$
Step 4: Compute Numerator for $A = \text{False}$ $$\text{Term}_2 = P(\neg A \mid \neg B, \neg E) \times P(J \mid \neg A) \times P(M \mid \neg A) = 0.999 \times 0.05 \times 0.01 = \mathbf{0.0004995}$$
Step 5: Compute Total Evidence & Final Posterior Fraction $$\text{Evidence} = 0.000630 + 0.0004995 = 0.0011295$$ $$P(A \mid J, M, \neg E, \neg B) = \frac{0.000630}{0.0011295} = \frac{630}{1129.5} = \frac{140}{251} \approx \mathbf{55.78\%}$$

07. 6 Deadly Exam Traps & Common Student Mistakes

Trap 01: Multiplying Unnecessary Priors

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!

Trap 02: Inverting $P(\neg A \mid \neg B, \neg E)$

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.

Trap 03: Forgetting Normalization

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$).

Trap 04: Omitting Procedural Demons in Frames

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.

Trap 05: Swapping Forward and Backward Roles

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.

Trap 06: Diagnostic vs Causal Reasoning

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)
Question Statement:
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)
Question Statement:
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**.

Frame_Name: Slot_1: Value_1 Slot_2: Value_2 (Default_Facet) Slot_3: if-needed Procedural_Attachment
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:
  1. Inheritance: Automatic property inheritance along `is-a` taxonomies.
  2. Default Reasoning: Uses inherited defaults when instance data is omitted.
  3. Active Demon Execution: Computes missing values dynamically via `if-needed` code.
Nov 2025 · Question 6 Forward vs. Backward Reasoning in AI (20 Marks)
Question Statement:
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.

Click button to compute posterior probability.

10. Active Recall Self-Test Quiz

Answer the questions below to evaluate progress (0/4 answered).
1. In the May 2025 exam Alarm Bayesian network, what is the calculated posterior probability $P(A \mid J, M, \neg E, \neg B)$?
Correct: (b) $\frac{0.000630}{0.000630 + 0.0004995} = \frac{0.000630}{0.0011295} \approx \mathbf{55.78\%}$.
2. Which procedural attachment in Minsky's Frames is executed when a slot value is queried but missing?
Correct: (c) An `if-needed` demon is an active procedure triggered on demand to compute missing attribute values dynamically.
3. What search direction is fundamentally used by Forward Chaining in expert systems?
Correct: (a) Forward chaining moves forward from known evidence to derive conclusions (data-driven).
4. Why can the prior terms $P(\neg B)P(\neg E)$ be canceled in the Alarm Network calculation?
Correct: (c) Factoring out $P(\neg B)P(\neg E)$ from both numerator and denominator cancels them completely, simplifying arithmetic.

11. Exam Hall Answer Sheet Presentation Checklist

1. Write the Conditional Independence Chain Expansion

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)$.

2. Show the Prior Factor Cancellation Explicitly

Strike out $P(\neg B)P(\neg E)$ from numerator and denominator so the examiner sees clean algebra.

3. Show Both Numerator Terms ($A = \text{True}$ and $A = \text{False}$)

Write $\text{Term}_1 = 0.000630$ and $\text{Term}_2 = 0.0004995$ clearly labeled.

4. Provide Both Fraction and Percentage for Final Posterior

Box: $P(A \mid J, M, \neg E, \neg B) = \frac{140}{251} \approx \mathbf{55.78\%}$.

5. For Frames, List All 3 Demons Explicitly

Never omit `if-needed`, `if-added`, and `if-removed` with definitions.