CSE-41XX
Previous Year Questions

27-2024 Solutions

Detailed step-by-step solutions with textbook theory links for the 4th Year 1st Semester Final Examination (2024).

This document provides complete, step-by-step solutions to the CSE-4101: Artificial Intelligence Final Examination questions.


Question 1 Solutions

1 (a) Heuristics & Admissibility

  • Heuristic Definition: A heuristic function h(n)h(n) estimates the cost of the cheapest path from the current node nn to a goal state. It incorporates domain-specific knowledge to guide the search algorithm toward the goal more efficiently than uninformed search.

  • Admissibility: A heuristic is admissible if it never overestimates the actual cost to reach a goal. That is: h(n)h(n)nh(n) \le h^*(n) \quad \forall n where h(n)h^*(n) represents the true optimal cost from node nn to the goal. Admissible heuristics are always optimistic about the remaining distance.

  • Typical Examples:

    1. Manhattan Distance (in grid-world / 8-puzzle navigation): The sum of horizontal and vertical distances of tiles from their target positions.
    2. Straight-line Distance (in routing problems): The Euclidean distance from node nn to the coordinates of the goal node.
  • Proof: Consistency     \implies Admissibility Let c(n,a,n)c(n, a, n') be the step cost of transitioning from node nn to child node nn' via action aa. A heuristic hh is consistent (or monotonic) if: h(n)c(n,a,n)+h(n)n,nh(n) \le c(n, a, n') + h(n') \quad \forall n, n' and h(G)=0h(G) = 0 for any goal state GG.

    We prove admissibility by induction on the number of steps kk on the optimal path from node nn to a goal GG.

    • Base Case (k=0k=0): If n=Gn = G, then h(G)=0h(G)=0h(G) = 0 \le h^*(G) = 0. Admissibility holds.
    • Inductive Step: Assume admissibility holds for all nodes with an optimal path of kk steps to the goal. Let nn be a node with an optimal path of k+1k+1 steps, and let nn' be its immediate successor on that optimal path. By consistency: h(n)c(n,a,n)+h(n)h(n) \le c(n, a, n') + h(n') By our inductive hypothesis, since nn' is kk steps away from the goal: h(n)h(n)h(n') \le h^*(n') Since nn' lies on the optimal path from nn to GG, the optimal cost h(n)h^*(n) satisfies: h(n)=c(n,a,n)+h(n)h^*(n) = c(n, a, n') + h^*(n') Substituting the induction hypothesis back into the consistency inequality yields: h(n)c(n,a,n)+h(n)=h(n)h(n) \le c(n, a, n') + h^*(n') = h^*(n) Thus, h(n)h(n)h(n) \le h^*(n) for all nodes, proving that any consistent heuristic is admissible.

Theory: Heuristic Functions and Optimality


  • A Search:* An informed search algorithm that selects the next node for expansion by minimizing the total evaluation function: f(n)=g(n)+h(n)f(n) = g(n) + h(n) where g(n)g(n) is the exact cost incurred to reach node nn from the start state, and h(n)h(n) is the estimated cost from nn to the goal.
  • Advantages:
    • Completeness: A* is guaranteed to find a solution if one exists, provided the branching factor is finite and the step costs are bounded away from zero (cϵ>0c \ge \epsilon > 0).
    • Optimality: A* is guaranteed to find the optimal path if h(n)h(n) is admissible (for tree search) or consistent (for graph search).
    • Optimal Efficiency: No other optimal search algorithm expanding nodes from the start is guaranteed to expand fewer nodes than A* using the same heuristic.
  • Disadvantages:
    • Space Complexity: O(bd)O(b^d) in the worst case (where bb is the branching factor and dd is the depth). Because it must keep all generated nodes in the Open List (priority queue) to maintain search paths, A* typically runs out of memory long before running out of time.
    • Time Complexity: O(bd)O(b^d) in the worst case, though it can be much lower with an extremely accurate heuristic.

Theory: A* Search and Extensions


  • Heuristic (hh): Number of misplaced tiles (excluding the blank tile -).
  • Path Cost (gg): +1+1 for each step/transition.
  • Goal State:
    1  2  3
    8  -  4
    7  6  5

Let's trace the optimal search path step-by-step, showing the candidates at each expansion.

  1. Start State: [2, 8, 3 / 1, 6, 4 / 7, -, 5], g=0g=0, misplaced tiles {2,8,1,6}\{2, 8, 1, 6\}, so h=4h=4. f=0+4=4f = 0 + 4 = 4.
  2. Step 1: Slide 6 down into - (Move Up).
    • Successor State: [2, 8, 3 / 1, -, 4 / 7, 6, 5], g=1g=1, misplaced tiles {2,8,1}\{2, 8, 1\}, so h=3h=3. f=1+3=4f = 1 + 3 = 4.
  3. Step 2: Slide 8 down into - (Move Up).
    • Successor State: [2, -, 3 / 1, 8, 4 / 7, 6, 5], g=2g=2, misplaced tiles {2,1,8}\{2, 1, 8\}, so h=3h=3. f=2+3=5f = 2 + 3 = 5.
  4. Step 3: Slide 2 right into - (Move Left).
    • Successor State: [-, 2, 3 / 1, 8, 4 / 7, 6, 5], g=3g=3, misplaced tiles {1,8}\{1, 8\}, so h=2h=2. f=3+2=5f = 3 + 2 = 5.
  5. Step 4: Slide 1 up into - (Move Down).
    • Successor State: [1, 2, 3 / -, 8, 4 / 7, 6, 5], g=4g=4, misplaced tiles {8}\{8\}, so h=1h=1. f=4+1=5f = 4 + 1 = 5.
  6. Step 5: Slide 8 left into - (Move Right).
    • Goal State reached: [1, 2, 3 / 8, -, 4 / 7, 6, 5], g=5g=5, misplaced tiles ==\emptyset, so h=0h=0. f=5+0=5f = 5 + 0 = 5.

Theory: Informed Search and Heuristics


Question 2 Solutions

2 (a) Resolution Inference in First Order Logic (FOPL)

We want to prove that the set of clauses along with the negated goal leads to a contradiction, verifying that "Jack did not kill the cat" is true (or refuting that "Jack killed the cat" is true).

1. Convert Formulas to Conjunctive Normal Form (CNF)
  • Formula A: x[y Animal(y)    Loves(x,y)]    [y Loves(y,x)]\forall x [\forall y \text{ Animal}(y) \implies \text{Loves}(x, y)] \implies [\exists y \text{ Loves}(y, x)]

    1. Eliminate implication: x[¬(y¬Animal(y)Loves(x,y))y Loves(y,x)]\forall x [ \neg(\forall y \neg\text{Animal}(y) \lor \text{Loves}(x, y)) \lor \exists y \text{ Loves}(y, x) ] x[(y Animal(y)¬Loves(x,y))y Loves(y,x)]\forall x [ (\exists y \text{ Animal}(y) \land \neg\text{Loves}(x, y)) \lor \exists y \text{ Loves}(y, x) ]
    2. Standardize variables: x[(y Animal(y)¬Loves(x,y))w Loves(w,x)]\forall x [ (\exists y \text{ Animal}(y) \land \neg\text{Loves}(x, y)) \lor \exists w \text{ Loves}(w, x) ]
    3. Skolemize (existential quantifiers inside universal quantifier x\forall x): Let Skolem functions be f(x)f(x) for yy, and g(x)g(x) for ww. x[(Animal(f(x))¬Loves(x,f(x)))Loves(g(x),x)]\forall x [ (\text{Animal}(f(x)) \land \neg\text{Loves}(x, f(x))) \lor \text{Loves}(g(x), x) ]
    4. Distribute \lor over \land: (Animal(f(x))Loves(g(x),x))(¬Loves(x,f(x))Loves(g(x),x))(\text{Animal}(f(x)) \lor \text{Loves}(g(x), x)) \land (\neg\text{Loves}(x, f(x)) \lor \text{Loves}(g(x), x))
    5. Resulting Clauses:
      • Clause A1: Animal(f(x))Loves(g(x),x)\text{Animal}(f(x)) \lor \text{Loves}(g(x), x)
      • Clause A2: ¬Loves(x,f(x))Loves(g(x),x)\neg\text{Loves}(x, f(x)) \lor \text{Loves}(g(x), x)
  • Formula B: x[z Animal(z)Kills(x,z)]    [y¬Loves(y,x)]\forall x [\exists z \text{ Animal}(z) \land \text{Kills}(x, z)] \implies [\forall y \neg\text{Loves}(y, x)]

    1. Eliminate implication: x[¬(z Animal(z)Kills(x,z))y¬Loves(y,x)]\forall x [ \neg(\exists z \text{ Animal}(z) \land \text{Kills}(x, z)) \lor \forall y \neg\text{Loves}(y, x) ] x[z(¬Animal(z)¬Kills(x,z))y¬Loves(y,x)]\forall x [ \forall z (\neg\text{Animal}(z) \lor \neg\text{Kills}(x, z)) \lor \forall y \neg\text{Loves}(y, x) ]
    2. Move quantifiers and drop: ¬Animal(z)¬Kills(x,z)¬Loves(y,x)\neg\text{Animal}(z) \lor \neg\text{Kills}(x, z) \lor \neg\text{Loves}(y, x)
    3. Resulting Clause:
      • Clause B1: ¬Animal(z)¬Kills(x,z)¬Loves(y,x)\neg\text{Animal}(z) \lor \neg\text{Kills}(x, z) \lor \neg\text{Loves}(y, x)
  • Formula C: x Animal(x)    Loves(Jack,x)\forall x \text{ Animal}(x) \implies \text{Loves}(\text{Jack}, x)

    • Clause C1: ¬Animal(w)Loves(Jack,w)\neg\text{Animal}(w) \lor \text{Loves}(\text{Jack}, w) (using standardized variable ww)
  • Formula D: Kills(Jack,Tuna)Kills(Curiosity,Tuna)\text{Kills}(\text{Jack}, \text{Tuna}) \lor \text{Kills}(\text{Curiosity}, \text{Tuna})

    • Clause D1: Kills(Jack,Tuna)Kills(Curiosity,Tuna)\text{Kills}(\text{Jack}, \text{Tuna}) \lor \text{Kills}(\text{Curiosity}, \text{Tuna})
  • Formula E: Cat(Tuna)\text{Cat}(\text{Tuna})

    • Clause E1: Cat(Tuna)\text{Cat}(\text{Tuna})
  • Formula F: x Cat(x)    Animal(x)\forall x \text{ Cat}(x) \implies \text{Animal}(x)

    • Clause F1: ¬Cat(v)Animal(v)\neg\text{Cat}(v) \lor \text{Animal}(v) (using standardized variable vv)
  • Negated Goal (¬G\neg G): We assume the goal is to prove "Jack did not kill the cat" (i.e. ¬Kills(Jack,Tuna)\neg \text{Kills}(\text{Jack}, \text{Tuna})). The negation of the goal is:

    • Clause G1: Kills(Jack,Tuna)\text{Kills}(\text{Jack}, \text{Tuna})
2. Resolution Proof (Deriving Contradiction)

We resolve clauses to arrive at the empty clause (\square):

  1. Resolve E1 (Cat(Tuna)\text{Cat}(\text{Tuna})) with F1 (¬Cat(v)Animal(v)\neg\text{Cat}(v) \lor \text{Animal}(v)) under substitution {v/Tuna}\{v / \text{Tuna}\}:
    • R1: Animal(Tuna)\text{Animal}(\text{Tuna})
  2. Resolve B1 (¬Animal(z)¬Kills(x,z)¬Loves(y,x)\neg\text{Animal}(z) \lor \neg\text{Kills}(x, z) \lor \neg\text{Loves}(y, x)) with R1 (Animal(Tuna)\text{Animal}(\text{Tuna})) and G1 (Kills(Jack,Tuna)\text{Kills}(\text{Jack}, \text{Tuna})) under substitution {x/Jack,z/Tuna}\{x / \text{Jack}, z / \text{Tuna}\}:
    • R2: ¬Loves(y,Jack)\neg\text{Loves}(y, \text{Jack}) (i.e., No one loves Jack)
  3. Resolve A2 (¬Loves(x,f(x))Loves(g(x),x)\neg\text{Loves}(x, f(x)) \lor \text{Loves}(g(x), x)) with R2 (¬Loves(y,Jack)\neg\text{Loves}(y, \text{Jack})) under substitution {x/Jack,y/g(Jack)}\{x / \text{Jack}, y / g(\text{Jack})\}:
    • R3: ¬Loves(Jack,f(Jack))\neg\text{Loves}(\text{Jack}, f(\text{Jack}))
  4. Resolve A1 (Animal(f(x))Loves(g(x),x)\text{Animal}(f(x)) \lor \text{Loves}(g(x), x)) with R2 (¬Loves(y,Jack)\neg\text{Loves}(y, \text{Jack})) under substitution {x/Jack,y/g(Jack)}\{x / \text{Jack}, y / g(\text{Jack})\}:
    • R4: Animal(f(Jack))\text{Animal}(f(\text{Jack}))
  5. Resolve C1 (¬Animal(w)Loves(Jack,w)\neg\text{Animal}(w) \lor \text{Loves}(\text{Jack}, w)) with R4 (Animal(f(Jack))\text{Animal}(f(\text{Jack}))) under substitution {w/f(Jack)}\{w / f(\text{Jack})\}:
    • R5: Loves(Jack,f(Jack))\text{Loves}(\text{Jack}, f(\text{Jack}))
  6. Resolve R3 (¬Loves(Jack,f(Jack))\neg\text{Loves}(\text{Jack}, f(\text{Jack}))) with R5 (Loves(Jack,f(Jack))\text{Loves}(\text{Jack}, f(\text{Jack}))):
    • Empty Clause (\square)

Because we derived a contradiction from the negated goal (which assumed Jack did kill the cat), we have successfully proved that "Jack did not kill the cat" is True (and thus "Jack killed the cat" is False).

Theory: CNF Conversion and Resolution


2 (b) Fuzzy Expert Systems & Inference

Given inputs: Mean Delay (xx) = 0.25 and Number of Servers (yy) = 0.65.

1. Fuzzification (Calculate Degrees of Membership)

Using the membership function equations:

  • Mean Delay (x=0.25x = 0.25):

    • Very Small (VS): Vertices at (0,1.0)(0, 1.0) and (0.3,0.0)(0.3, 0.0). μVS(0.25)=0.30.250.30=0.050.3=160.167\mu_{\text{VS}}(0.25) = \frac{0.3 - 0.25}{0.3 - 0} = \frac{0.05}{0.3} = \frac{1}{6} \approx 0.167
    • Small (S): Vertices at (0.1,0.0)(0.1, 0.0), (0.3,1.0)(0.3, 1.0), and (0.5,0.0)(0.5, 0.0). μS(0.25)=0.250.10.30.1=0.150.2=0.75\mu_{\text{S}}(0.25) = \frac{0.25 - 0.1}{0.3 - 0.1} = \frac{0.15}{0.2} = 0.75
    • Medium (M): Range starts at 0.40.4, so x=0.25x = 0.25 does not overlap. μM(0.25)=0\mu_{\text{M}}(0.25) = 0
  • Number of Servers (y=0.65y = 0.65):

    • Small (S): Range ends at 0.30.3, so μS(0.65)=0\mu_{\text{S}}(0.65) = 0.
    • Medium (M): Vertices at (0.3,0.0)(0.3, 0.0), (0.5,1.0)(0.5, 1.0), and (0.7,0.0)(0.7, 0.0). μM(0.65)=0.70.650.70.5=0.050.2=0.25\mu_{\text{M}}(0.65) = \frac{0.7 - 0.65}{0.7 - 0.5} = \frac{0.05}{0.2} = 0.25
    • Large (L): Vertices at (0.6,0.0)(0.6, 0.0), (0.8,1.0)(0.8, 1.0) and (1.0,1.0)(1.0, 1.0). μL(0.65)=0.650.60.80.6=0.050.2=0.25\mu_{\text{L}}(0.65) = \frac{0.65 - 0.6}{0.8 - 0.6} = \frac{0.05}{0.2} = 0.25
2. Rule Evaluation (Applying Mamdani Min-inference)

We calculate the activation strength (α\alpha) of each rule using min\min for the conjunction "AND":

  • Rule 1: If Mean Delay is VS and Number of Servers is L, then Utilization is Low. α1=min(μVS(0.25),μL(0.65))=min(0.167,0.25)=0.167    Low\alpha_1 = \min(\mu_{\text{VS}}(0.25), \mu_{\text{L}}(0.65)) = \min(0.167, 0.25) = 0.167 \implies \text{Low}
  • Rule 2: If Mean Delay is S and Number of Servers is M, then Utilization is Medium. α2=min(μS(0.25),μM(0.65))=min(0.75,0.25)=0.25    Medium\alpha_2 = \min(\mu_{\text{S}}(0.25), \mu_{\text{M}}(0.65)) = \min(0.75, 0.25) = 0.25 \implies \text{Medium}
  • Rule 3: If Mean Delay is M and Number of Servers is S, then Utilization is High. α3=min(μM(0.25),μS(0.65))=min(0,0)=0    High\alpha_3 = \min(\mu_{\text{M}}(0.25), \mu_{\text{S}}(0.65)) = \min(0, 0) = 0 \implies \text{High}
  • Rule 4: If Mean Delay is S and Number of Servers is S, then Utilization is High. α4=min(μS(0.25),μS(0.65))=min(0.75,0)=0    High\alpha_4 = \min(\mu_{\text{S}}(0.25), \mu_{\text{S}}(0.65)) = \min(0.75, 0) = 0 \implies \text{High}
  • Rule 5: If Mean Delay is M and Number of Servers is M, then Utilization is Medium. α5=min(μM(0.25),μM(0.65))=min(0,0.25)=0    Medium\alpha_5 = \min(\mu_{\text{M}}(0.25), \mu_{\text{M}}(0.65)) = \min(0, 0.25) = 0 \implies \text{Medium}
3. Aggregation

Using max\max to combine multiple rules mapping to the same output:

  • Low=α1=0.167\text{Low} = \alpha_1 = 0.167
  • Medium=max(α2,α5)=max(0.25,0)=0.25\text{Medium} = \max(\alpha_2, \alpha_5) = \max(0.25, 0) = 0.25
  • High=max(α3,α4)=0\text{High} = \max(\alpha_3, \alpha_4) = 0
4. Defuzzification (Weighted Average Method / Singleton Approximation)

Assuming standard center values for output membership functions (Low = 0.2, Medium = 0.6, High = 0.8): z=μiziμi=(0.167×0.2)+(0.25×0.6)+(0×0.8)0.167+0.25z^* = \frac{\sum \mu_i \cdot z_i}{\sum \mu_i} = \frac{(0.167 \times 0.2) + (0.25 \times 0.6) + (0 \times 0.8)}{0.167 + 0.25} z=0.0334+0.1500.417=0.18340.4170.44z^* = \frac{0.0334 + 0.150}{0.417} = \frac{0.1834}{0.417} \approx 0.44

The precise value of the repair utilization factor is 0.44.

Theory: Fuzzy Expert Systems


Question 3 Solutions

3 (a) 4-Queens with Backtracking and Forward Checking

  • Variables: Q1,Q2,Q3,Q4Q_1, Q_2, Q_3, Q_4 (representing rows of queens in columns 1, 2, 3, 4).
  • Domains: D1=D2=D3=D4={1,2,3,4}D_1 = D_2 = D_3 = D_4 = \{1, 2, 3, 4\}.
Step-by-Step Execution Trace:
  1. Assign Q1=1Q_1 = 1.
    • Forward Checking (reduce domains of unassigned variables):
      • Q2Q_2 cannot be in row 1 (same row) or row 2 (diagonal). D2{3,4}D_2 \leftarrow \{3, 4\}.
      • Q3Q_3 cannot be in row 1 or row 3 (diagonal). D3{2,4}D_3 \leftarrow \{2, 4\}.
      • Q4Q_4 cannot be in row 1 or row 4 (diagonal). D4{2,3}D_4 \leftarrow \{2, 3\}.
  2. Assign Q2=3Q_2 = 3 (first available value in D2D_2).
    • Forward Checking:
      • Q3Q_3 cannot be in row 3 (same row), row 2 (diagonal: 313 - 1), or row 4 (diagonal: 3+13 + 1).
      • Since D3D_3 was {2,4}\{2, 4\}, removing 2 and 4 makes D3D_3 \leftarrow \emptyset.
    • Result: Forward checking triggers immediate backtracking because the domain of Q3Q_3 became empty.
  3. Backtrack and Try Q2=4Q_2 = 4 (next value in D2D_2).
    • Forward Checking:
      • Q3Q_3 cannot be in row 4 (same row) or row 3 (diagonal: 414 - 1). D3={2,4}{3,4}{2}D_3 = \{2, 4\} \setminus \{3, 4\} \leftarrow \{2\}.
      • Q4Q_4 cannot be in row 4 (same row) or row 2 (diagonal: 424 - 2). D4={2,3}{2,4}{3}D_4 = \{2, 3\} \setminus \{2, 4\} \leftarrow \{3\}.
  4. Assign Q3=2Q_3 = 2 (only available value in D3D_3).
    • Forward Checking:
      • Q4Q_4 cannot be in row 2 (same row) or row 3 (diagonal: 2+12 + 1).
      • Since D4D_4 was {3}\{3\}, removing 3 makes D4D_4 \leftarrow \emptyset.
    • Result: Backtrack! No more values for Q2Q_2, so we backtrack to Q1Q_1.
  5. Assign Q1=2Q_1 = 2 (next value in D1D_1).
    • Forward Checking:
      • Q2Q_2 cannot be 2, 1 (diagonal: 212 - 1), or 3 (diagonal: 2+12 + 1). D2{4}D_2 \leftarrow \{4\}.
      • Q3Q_3 cannot be 2 or 4 (diagonal: 2+22 + 2). D3{1,3}D_3 \leftarrow \{1, 3\}.
      • Q4Q_4 cannot be 2. D4{1,3,4}D_4 \leftarrow \{1, 3, 4\}.
  6. Assign Q2=4Q_2 = 4 (only value in D2D_2).
    • Forward Checking:
      • Q3Q_3 cannot be 4, or 3 (diagonal: 414 - 1). D3={1,3}{3,4}{1}D_3 = \{1, 3\} \setminus \{3, 4\} \leftarrow \{1\}.
      • Q4Q_4 cannot be 4, or 2 (diagonal: 424 - 2). D4={1,3,4}{2,4}{1,3}D_4 = \{1, 3, 4\} \setminus \{2, 4\} \leftarrow \{1, 3\}.
  7. Assign Q3=1Q_3 = 1 (only value in D3D_3).
    • Forward Checking:
      • Q4Q_4 cannot be 1, or 2 (diagonal: 1+11 + 1). D4={1,3}{1,2}{3}D_4 = \{1, 3\} \setminus \{1, 2\} \leftarrow \{3\}.
  8. Assign Q4=3Q_4 = 3.
    • Result: Search succeeds. Solution found: [2,4,1,3][2, 4, 1, 3].
  • Condition to Trigger Backtracking: Forward checking triggers backtracking when the domain of any unassigned variable is reduced to an empty set (\emptyset) during domain propagation.

Theory: Backtracking and Local Search for CSPs


3 (b) Heuristics & Scalability in CSPs

  • i. Variable & Value Selection Heuristics:
    • Most Constrained Variable (Minimum Remaining Values - MRV): Choose the variable with the fewest remaining valid choices. This is a fail-first heuristic: it forces a failure as early as possible in the search tree if a branch is unviable, pruning large subtrees.
    • Least Constraining Value (LCV): Choose the value that rules out the fewest choices for neighboring variables in the constraint graph. This is a succeed-first heuristic: it maximizes flexibility for remaining variables to find a solution without backtracking.
  • ii. Scalability and Efficiency:
    • Heuristic strategies (such as MRV, LCV, and degree heuristics) improve backtracking scalability by dynamically pruning dead-ends early, reducing the effective branching factor from exponential down to a manageable search depth.
    • For extreme scalability, exactness can be sacrificed using approximate / local search algorithms (e.g., Min-Conflicts, Simulated Annealing). These algorithms do not guarantee finding a solution or proving unsatisfiability but find high-quality approximate solutions in linear time O(N)O(N) instead of exponential time.

Theory: Constraint Satisfaction Problems


Question 4 Solutions

4 (a) MDP Value Iteration

Value Iteration Equation: Ut+1(s)=R(s)+γmaxasT(s,a,s)Ut(s)U_{t+1}(s) = R(s) + \gamma \max_{a} \sum_{s'} T(s, a, s') U_t(s') Given: γ=0.9\gamma = 0.9, R(s1)=1.2R(s_1) = 1.2, R(s2)=2.5R(s_2) = 2.5. Let U0(s1)=U0(s2)=0U_0(s_1) = U_0(s_2) = 0.

Iteration 1 (t=1t=1)

U1(s1)=1.2+0.9(0)=1.20U_1(s_1) = 1.2 + 0.9(0) = 1.20 U1(s2)=2.5+0.9(0)=2.50U_1(s_2) = 2.5 + 0.9(0) = 2.50

Iteration 2 (t=2t=2)
  • State s1s_1:
    • a1a_1: Expected utility =0.6U1(s1)+0.4U1(s2)=0.6(1.20)+0.4(2.50)=0.72+1.00=1.72= 0.6 \cdot U_1(s_1) + 0.4 \cdot U_1(s_2) = 0.6(1.20) + 0.4(2.50) = 0.72 + 1.00 = 1.72
    • a2a_2: Expected utility =0.2U1(s1)+0.8U1(s2)=0.2(1.20)+0.8(2.50)=0.24+2.00=2.24= 0.2 \cdot U_1(s_1) + 0.8 \cdot U_1(s_2) = 0.2(1.20) + 0.8(2.50) = 0.24 + 2.00 = 2.24
    • U2(s1)=1.2+0.9max(1.72,2.24)=1.2+0.9(2.24)=1.2+2.0163.22U_2(s_1) = 1.2 + 0.9 \cdot \max(1.72, 2.24) = 1.2 + 0.9(2.24) = 1.2 + 2.016 \approx 3.22
  • State s2s_2:
    • a1a_1: Expected utility =0.3U1(s1)+0.7U1(s2)=0.3(1.20)+0.7(2.50)=0.36+1.75=2.11= 0.3 \cdot U_1(s_1) + 0.7 \cdot U_1(s_2) = 0.3(1.20) + 0.7(2.50) = 0.36 + 1.75 = 2.11
    • a2a_2: Expected utility =0.1U1(s1)+0.9U1(s2)=0.1(1.20)+0.9(2.50)=0.12+2.25=2.37= 0.1 \cdot U_1(s_1) + 0.9 \cdot U_1(s_2) = 0.1(1.20) + 0.9(2.50) = 0.12 + 2.25 = 2.37
    • U2(s2)=2.5+0.9max(2.11,2.37)=2.5+0.9(2.37)=2.5+2.1334.63U_2(s_2) = 2.5 + 0.9 \cdot \max(2.11, 2.37) = 2.5 + 0.9(2.37) = 2.5 + 2.133 \approx 4.63
Iteration 3 (t=3t=3)
  • State s1s_1:
    • a1a_1: Expected utility =0.6(3.22)+0.4(4.63)=1.932+1.852=3.784= 0.6(3.22) + 0.4(4.63) = 1.932 + 1.852 = 3.784
    • a2a_2: Expected utility =0.2(3.22)+0.8(4.63)=0.644+3.704=4.348= 0.2(3.22) + 0.8(4.63) = 0.644 + 3.704 = 4.348
    • U3(s1)=1.2+0.9max(3.784,4.348)=1.2+0.9(4.348)=1.2+3.91325.11U_3(s_1) = 1.2 + 0.9 \cdot \max(3.784, 4.348) = 1.2 + 0.9(4.348) = 1.2 + 3.9132 \approx 5.11
    • Optimal Action at s1s_1: a2a_2
  • State s2s_2:
    • a1a_1: Expected utility =0.3(3.22)+0.7(4.63)=0.966+3.241=4.207= 0.3(3.22) + 0.7(4.63) = 0.966 + 3.241 = 4.207
    • a2a_2: Expected utility =0.1(3.22)+0.9(4.63)=0.322+4.167=4.489= 0.1(3.22) + 0.9(4.63) = 0.322 + 4.167 = 4.489
    • U3(s2)=2.5+0.9max(4.207,4.489)=2.5+0.9(4.489)=2.5+4.04016.54U_3(s_2) = 2.5 + 0.9 \cdot \max(4.207, 4.489) = 2.5 + 0.9(4.489) = 2.5 + 4.0401 \approx 6.54
    • Optimal Action at s2s_2: a2a_2

4 (b) Q-learning vs. Value Iteration

  • Equation Modification: Q-learning removes the transition probability T(s,a,s)T(s, a, s') and the reward function R(s)R(s) by learning directly from environmental samples (experience tuples s,a,r,s\langle s, a, r, s' \rangle). The update rule is: Q(s,a)Q(s,a)+α[r+γmaxaQ(s,a)Q(s,a)]Q(s, a) \leftarrow Q(s, a) + \alpha \left[ r + \gamma \max_{a'} Q(s', a') - Q(s, a) \right]
  • Key Differences:
    1. Transition Model: Value Iteration is model-based (requires knowing transition probabilities T(s,a,s)T(s, a, s') and rewards R(s)R(s)). Q-learning is model-free (learns directly from interactions without a model of the environment).
    2. Type of Value Learned: Value Iteration learns state utilities U(s)U(s). Q-learning learns action-values Q(s,a)Q(s, a) (the value of taking action aa in state ss).
  • Applications:
    • Value Iteration (Model-based): Used where full environmental dynamics are known (e.g., path planning on an exact map).
    • Q-learning (Model-free): Used in complex, unknown environments (e.g., training an agent to play video games from raw screen pixels).

Theory: MDPs and Reinforcement Learning


Question 5 Solutions

5 (a) Minimax Game Tree Evaluation

The Minimax algorithm evaluates game states in a two-player, zero-sum game. The Max player tries to maximize the score, while the Min player tries to minimize it.

  • Min Level Evaluations:
    • Min1=min(8,9,3,4,5)=3\text{Min}_1 = \min(8, 9, 3, 4, 5) = 3
    • Min2=min(7,1,3,8,2)=1\text{Min}_2 = \min(7, 1, 3, 8, 2) = 1
    • Min3=min(4,3,9,2,2)=2\text{Min}_3 = \min(4, 3, 9, 2, 2) = 2
    • Min4=min(9,1,5,6,4)=1\text{Min}_4 = \min(9, 1, 5, 6, 4) = 1
    • Min5=min(2,3,7,3,8)=2\text{Min}_5 = \min(2, 3, 7, 3, 8) = 2
  • Max (Root) Evaluation:
    • Root=max(Min1,Min2,Min3,Min4,Min5)=max(3,1,2,1,2)=3\text{Root} = \max(\text{Min}_1, \text{Min}_2, \text{Min}_3, \text{Min}_4, \text{Min}_5) = \max(3, 1, 2, 1, 2) = 3

The minimax value of the root node is 3. Max should choose the branch leading to the first Min node (Min1\text{Min}_1).


5 (b) Alpha-Beta Pruning Tracing

Using α\alpha (Max's guaranteed minimum) and β\beta (Min's guaranteed maximum), initialized to α=,β=+\alpha = -\infty, \beta = +\infty.

  1. Evaluate Min1\text{Min}_1:
    • Leaves: 8, 9, 3, 4, 5. Min1\text{Min}_1 value =3= 3.
    • Update root: αmax(,3)=3\alpha \leftarrow \max(-\infty, 3) = 3.
  2. Evaluate Min2\text{Min}_2 (with bounds α=3,β=+\alpha = 3, \beta = +\infty):
    • Leaf 7: βmin(,7)=7\beta \leftarrow \min(\infty, 7) = 7.
    • Leaf 1: βmin(7,1)=1\beta \leftarrow \min(7, 1) = 1.
    • Pruning Condition: Since βα\beta \le \alpha (131 \le 3), we prune the remaining leaves of this node.
    • Pruned: 3, 8, 2.
  3. Evaluate Min3\text{Min}_3 (with bounds α=3,β=+\alpha = 3, \beta = +\infty):
    • Leaf 4: βmin(,4)=4\beta \leftarrow \min(\infty, 4) = 4.
    • Leaf 3: βmin(4,3)=3\beta \leftarrow \min(4, 3) = 3.
    • Pruning Condition: Since βα\beta \le \alpha (333 \le 3), we prune.
    • Pruned: 9, 2, 2.
  4. Evaluate Min4\text{Min}_4 (with bounds α=3,β=+\alpha = 3, \beta = +\infty):
    • Leaf 9: βmin(,9)=9\beta \leftarrow \min(\infty, 9) = 9.
    • Leaf 1: βmin(9,1)=1\beta \leftarrow \min(9, 1) = 1.
    • Pruning Condition: Since βα\beta \le \alpha (131 \le 3), we prune.
    • Pruned: 5, 6, 4.
  5. Evaluate Min5\text{Min}_5 (with bounds α=3,β=+\alpha = 3, \beta = +\infty):
    • Leaf 2: βmin(,2)=2\beta \leftarrow \min(\infty, 2) = 2.
    • Pruning Condition: Since βα\beta \le \alpha (232 \le 3), we prune immediately after the first leaf.
    • Pruned: 3, 7, 3, 8.

Theory: Minimax and Alpha-Beta Pruning


Question 6 Solutions

6 (a) Bayes Theorem Application

Given:

  • P(D)=0.01P(D) = 0.01 (Probability of disease)
  • P(D)=0.99P(\sim D) = 0.99 (Probability of no disease)
  • P(TD)=0.99P(T|D) = 0.99 (True positive rate)
  • P(TD)=0.95P(\sim T| \sim D) = 0.95 (True negative rate)
  • P(TD)=1P(TD)=0.05P(T| \sim D) = 1 - P(\sim T| \sim D) = 0.05 (False positive rate)
1. Probability of disease given a positive test P(DT)P(D|T):

Using Bayes Theorem: P(DT)=P(TD)P(D)P(T)P(D|T) = \frac{P(T|D)P(D)}{P(T)} P(T)=P(TD)P(D)+P(TD)P(D)=(0.99×0.01)+(0.05×0.99)=0.0099+0.0495=0.0594P(T) = P(T|D)P(D) + P(T| \sim D)P(\sim D) = (0.99 \times 0.01) + (0.05 \times 0.99) = 0.0099 + 0.0495 = 0.0594 P(DT)=0.00990.0594=160.1667 (or 16.67%)P(D|T) = \frac{0.0099}{0.0594} = \frac{1}{6} \approx 0.1667 \text{ (or 16.67\%)}

2. Probability of no disease given a negative test P(DT)P(\sim D| \sim T):

P(DT)=P(TD)P(D)P(T)P(\sim D| \sim T) = \frac{P(\sim T| \sim D)P(\sim D)}{P(\sim T)} P(T)=1P(T)=10.0594=0.9406P(\sim T) = 1 - P(T) = 1 - 0.0594 = 0.9406 P(DT)=0.95×0.990.9406=0.94050.94060.9999 (or 99.99%)P(\sim D| \sim T) = \frac{0.95 \times 0.99}{0.9406} = \frac{0.9405}{0.9406} \approx 0.9999 \text{ (or 99.99\%)}

Theory: Decision Theory and Utility


6 (b) Hidden Markov Models (HMM)

i. HMM Graphical Formulation and Tuples

An HMM is formulated using the tuple λ=(S,V,A,B,π)\lambda = (S, V, A, B, \pi):

  • S={A,B,C}S = \{A, B, C\}: Set of hidden states.
  • V={X,Y}V = \{X, Y\}: Set of observable symbols.
  • AA: State transition probability matrix (defines probability of transitioning from state SiS_i to SjS_j).
  • BB: Emission probability matrix (probability of emitting observation VkV_k from state SiS_i).
  • π\pi: Initial state probability distribution.
ii. Initial State Distribution (π=[0.5,0.3,0.2]\pi = [0.5, 0.3, 0.2])
  • Representation: The probability that the system starts in state AA is 0.50.5, state BB is 0.30.3, and state CC is 0.20.2.
  • Role of π\pi: It anchors the probability calculations at step t=1t=1. A highly biased initial distribution can steer the HMM's early predictions towards the highly probable state, requiring stronger emission evidence to override it.
iii. Markov Chain vs. HMM
  • Difference: In a Markov Chain, the states are directly observable to the user. In a Hidden Markov Model, the states are "hidden" (latent), and we can only observe outputs (emissions) that are probabilistically generated by the hidden states.
  • Markov Property: The state transition probability depends only on the current state and not on the history of states. In HMMs, this simplifies the calculations of the joint probability of state sequences.
iv. Three Fundamental Problems in HMM
  1. Evaluation Problem: Given model λ\lambda and observation sequence OO, compute P(Oλ)P(O|\lambda). Resolved using the Forward or Backward Algorithm.
  2. Decoding Problem: Given model λ\lambda and observation sequence OO, find the most likely hidden state sequence SS. Resolved using the Viterbi Algorithm.
  3. Learning Problem: Given observation sequence OO, adjust model parameters (A,B,π)(A, B, \pi) to maximize P(Oλ)P(O|\lambda). Resolved using the Baum-Welch Algorithm (an Expectation-Maximization approach).

Question 7 Solutions

7 (a) Activation Functions & Gradient Behavior in Neural Networks

Analysis of Stages:
  1. Stage 1 (Sigmoid):
    • Issue: Vanishing Gradient Problem. The Sigmoid function σ(z)=11+ez\sigma(z) = \frac{1}{1 + e^{-z}} squeezes outputs to [0,1][0, 1]. Its derivative σ(z)=σ(z)(1σ(z))\sigma'(z) = \sigma(z)(1 - \sigma(z)) has a maximum value of 0.250.25. As gradients are backpropagated through multiple layers, multiplying these small numbers causes the gradient to decay exponentially, slowing learning in early layers.
  2. Stage 2 (ReLU):
    • Issue: Dying ReLU Problem. ReLU f(z)=max(0,z)f(z) = \max(0, z) has derivative 11 for z>0z > 0 and 00 for z<0z < 0. If a large gradient updates weights such that a neuron receives negative inputs across the entire dataset, its output and derivative become 00. The neuron becomes inactive and ceases to update.
  3. Stage 3 (Leaky ReLU / ELU):
    • Solution: Leaky ReLU f(z)=max(αz,z)f(z) = \max(\alpha z, z) (where α0.01\alpha \approx 0.01) guarantees a small, non-zero gradient (0.010.01) for negative inputs, preventing neurons from dying while maintaining fast convergence.
Graphs & Derivatives:
   Sigmoid & Derivative             ReLU & Derivative           Leaky ReLU & Derivative
        1.0 |   _.-               1.0 |    /                         1.0 |    /
            | .-'                     |   /                              |   /
   f(z) 0.5 |/            f(z)        |  /              f(z)             |  /
            |                         | /                                | /
        0.0 +------           0.0 ----+------               0.0 ---------+------
             z                         z                             /   z
                                                                    /
        0.25|   _                     |                              |  
   f'(z)    |  / \        f'(z)   1.0 +-------          f'(z)    1.0 +-------
            | /   \                   |                              |
        0.0 +-------                  +------                        +------- 
                                      0.0                            0.01 ===

7 (b) Softmax & Cross-Entropy Calculation

Given logits: z=[0.2,2.5,0.3]z = [0.2, 2.5, 0.3]. True Class = Car (Class 0).

1. Softmax Calculation

P(y=cz)=ezcjezjP(y = c | z) = \frac{e^{z_c}}{\sum_j e^{z_j}}

  • e0.21.221e^{0.2} \approx 1.221

  • e2.512.182e^{2.5} \approx 12.182

  • e0.31.350e^{0.3} \approx 1.350

  • Denominator sum =1.221+12.182+1.350=14.753= 1.221 + 12.182 + 1.350 = 14.753

  • P(Car)=1.221/14.7530.083P(\text{Car}) = 1.221 / 14.753 \approx \mathbf{0.083}

  • P(Bike)=12.182/14.7530.826P(\text{Bike}) = 12.182 / 14.753 \approx \mathbf{0.826}

  • P(Bus)=1.350/14.7530.091P(\text{Bus}) = 1.350 / 14.753 \approx \mathbf{0.091}

2. One-hot encoded true label

ytrue=[1,0,0]\mathbf{y}_{\text{true}} = [1, 0, 0]

3. Cross-Entropy Loss

L=cycln(Pc)=1ln(P(Car))=ln(0.0828)2.491L = - \sum_c y_c \ln(P_c) = -1 \cdot \ln(P(\text{Car})) = -\ln(0.0828) \approx \mathbf{2.491}

4. Interpretation

The loss value is high (2.4912.491) because the model predicted the incorrect class (Bike) with high confidence (82.6%82.6\%) while allocating only a 8.3%8.3\% probability to the correct class (Car). This penalty reflects the model being "confident and wrong."

On this page

Question 1 Solutions1 (a) Heuristics & Admissibility1 (b) A* Search1 (c) 8-Puzzle State-Space SearchQuestion 2 Solutions2 (a) Resolution Inference in First Order Logic (FOPL)1. Convert Formulas to Conjunctive Normal Form (CNF)2. Resolution Proof (Deriving Contradiction)2 (b) Fuzzy Expert Systems & Inference1. Fuzzification (Calculate Degrees of Membership)2. Rule Evaluation (Applying Mamdani Min-inference)3. Aggregation4. Defuzzification (Weighted Average Method / Singleton Approximation)Question 3 Solutions3 (a) 4-Queens with Backtracking and Forward CheckingStep-by-Step Execution Trace:3 (b) Heuristics & Scalability in CSPsQuestion 4 Solutions4 (a) MDP Value IterationIteration 1 (t=1t=1)Iteration 2 (t=2t=2)Iteration 3 (t=3t=3)4 (b) Q-learning vs. Value IterationQuestion 5 Solutions5 (a) Minimax Game Tree Evaluation5 (b) Alpha-Beta Pruning TracingQuestion 6 Solutions6 (a) Bayes Theorem Application1. Probability of disease given a positive test P(DT)P(D|T):2. Probability of no disease given a negative test P(DT)P(\sim D| \sim T):6 (b) Hidden Markov Models (HMM)i. HMM Graphical Formulation and Tuplesii. Initial State Distribution (π=[0.5,0.3,0.2]\pi = [0.5, 0.3, 0.2])iii. Markov Chain vs. HMMiv. Three Fundamental Problems in HMMQuestion 7 Solutions7 (a) Activation Functions & Gradient Behavior in Neural NetworksAnalysis of Stages:Graphs & Derivatives:7 (b) Softmax & Cross-Entropy Calculation1. Softmax Calculation2. One-hot encoded true label3. Cross-Entropy Loss4. Interpretation