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 estimates the cost of the cheapest path from the current node 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: where represents the true optimal cost from node to the goal. Admissible heuristics are always optimistic about the remaining distance.
-
Typical Examples:
- Manhattan Distance (in grid-world / 8-puzzle navigation): The sum of horizontal and vertical distances of tiles from their target positions.
- Straight-line Distance (in routing problems): The Euclidean distance from node to the coordinates of the goal node.
-
Proof: Consistency Admissibility Let be the step cost of transitioning from node to child node via action . A heuristic is consistent (or monotonic) if: and for any goal state .
We prove admissibility by induction on the number of steps on the optimal path from node to a goal .
- Base Case (): If , then . Admissibility holds.
- Inductive Step: Assume admissibility holds for all nodes with an optimal path of steps to the goal. Let be a node with an optimal path of steps, and let be its immediate successor on that optimal path. By consistency: By our inductive hypothesis, since is steps away from the goal: Since lies on the optimal path from to , the optimal cost satisfies: Substituting the induction hypothesis back into the consistency inequality yields: Thus, for all nodes, proving that any consistent heuristic is admissible.
1 (b) A* Search
- A Search:* An informed search algorithm that selects the next node for expansion by minimizing the total evaluation function: where is the exact cost incurred to reach node from the start state, and is the estimated cost from 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 ().
- Optimality: A* is guaranteed to find the optimal path if 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: in the worst case (where is the branching factor and 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: in the worst case, though it can be much lower with an extremely accurate heuristic.
Theory: A* Search and Extensions
1 (c) 8-Puzzle State-Space Search
- Heuristic (): Number of misplaced tiles (excluding the blank tile
-). - Path Cost (): 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.
- Start State:
[2, 8, 3 / 1, 6, 4 / 7, -, 5], , misplaced tiles , so . . - Step 1: Slide
6down into-(Move Up).- Successor State:
[2, 8, 3 / 1, -, 4 / 7, 6, 5], , misplaced tiles , so . .
- Successor State:
- Step 2: Slide
8down into-(Move Up).- Successor State:
[2, -, 3 / 1, 8, 4 / 7, 6, 5], , misplaced tiles , so . .
- Successor State:
- Step 3: Slide
2right into-(Move Left).- Successor State:
[-, 2, 3 / 1, 8, 4 / 7, 6, 5], , misplaced tiles , so . .
- Successor State:
- Step 4: Slide
1up into-(Move Down).- Successor State:
[1, 2, 3 / -, 8, 4 / 7, 6, 5], , misplaced tiles , so . .
- Successor State:
- Step 5: Slide
8left into-(Move Right).- Goal State reached:
[1, 2, 3 / 8, -, 4 / 7, 6, 5], , misplaced tiles , so . .
- Goal State reached:
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:
- Eliminate implication:
- Standardize variables:
- Skolemize (existential quantifiers inside universal quantifier ): Let Skolem functions be for , and for .
- Distribute over :
- Resulting Clauses:
- Clause A1:
- Clause A2:
-
Formula B:
- Eliminate implication:
- Move quantifiers and drop:
- Resulting Clause:
- Clause B1:
-
Formula C:
- Clause C1: (using standardized variable )
-
Formula D:
- Clause D1:
-
Formula E:
- Clause E1:
-
Formula F:
- Clause F1: (using standardized variable )
-
Negated Goal (): We assume the goal is to prove "Jack did not kill the cat" (i.e. ). The negation of the goal is:
- Clause G1:
2. Resolution Proof (Deriving Contradiction)
We resolve clauses to arrive at the empty clause ():
- Resolve E1 () with F1 () under substitution :
- R1:
- Resolve B1 () with R1 () and G1 () under substitution :
- R2: (i.e., No one loves Jack)
- Resolve A2 () with R2 () under substitution :
- R3:
- Resolve A1 () with R2 () under substitution :
- R4:
- Resolve C1 () with R4 () under substitution :
- R5:
- Resolve R3 () with R5 ():
- Empty Clause ()
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 () = 0.25 and Number of Servers () = 0.65.
1. Fuzzification (Calculate Degrees of Membership)
Using the membership function equations:
-
Mean Delay ():
- Very Small (VS): Vertices at and .
- Small (S): Vertices at , , and .
- Medium (M): Range starts at , so does not overlap.
-
Number of Servers ():
- Small (S): Range ends at , so .
- Medium (M): Vertices at , , and .
- Large (L): Vertices at , and .
2. Rule Evaluation (Applying Mamdani Min-inference)
We calculate the activation strength () of each rule using for the conjunction "AND":
- Rule 1: If Mean Delay is VS and Number of Servers is L, then Utilization is Low.
- Rule 2: If Mean Delay is S and Number of Servers is M, then Utilization is Medium.
- Rule 3: If Mean Delay is M and Number of Servers is S, then Utilization is High.
- Rule 4: If Mean Delay is S and Number of Servers is S, then Utilization is High.
- Rule 5: If Mean Delay is M and Number of Servers is M, then Utilization is Medium.
3. Aggregation
Using to combine multiple rules mapping to the same output:
4. Defuzzification (Weighted Average Method / Singleton Approximation)
Assuming standard center values for output membership functions (Low = 0.2, Medium = 0.6, High = 0.8):
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: (representing rows of queens in columns 1, 2, 3, 4).
- Domains: .
Step-by-Step Execution Trace:
- Assign .
- Forward Checking (reduce domains of unassigned variables):
- cannot be in row 1 (same row) or row 2 (diagonal). .
- cannot be in row 1 or row 3 (diagonal). .
- cannot be in row 1 or row 4 (diagonal). .
- Forward Checking (reduce domains of unassigned variables):
- Assign (first available value in ).
- Forward Checking:
- cannot be in row 3 (same row), row 2 (diagonal: ), or row 4 (diagonal: ).
- Since was , removing 2 and 4 makes .
- Result: Forward checking triggers immediate backtracking because the domain of became empty.
- Forward Checking:
- Backtrack and Try (next value in ).
- Forward Checking:
- cannot be in row 4 (same row) or row 3 (diagonal: ). .
- cannot be in row 4 (same row) or row 2 (diagonal: ). .
- Forward Checking:
- Assign (only available value in ).
- Forward Checking:
- cannot be in row 2 (same row) or row 3 (diagonal: ).
- Since was , removing 3 makes .
- Result: Backtrack! No more values for , so we backtrack to .
- Forward Checking:
- Assign (next value in ).
- Forward Checking:
- cannot be 2, 1 (diagonal: ), or 3 (diagonal: ). .
- cannot be 2 or 4 (diagonal: ). .
- cannot be 2. .
- Forward Checking:
- Assign (only value in ).
- Forward Checking:
- cannot be 4, or 3 (diagonal: ). .
- cannot be 4, or 2 (diagonal: ). .
- Forward Checking:
- Assign (only value in ).
- Forward Checking:
- cannot be 1, or 2 (diagonal: ). .
- Forward Checking:
- Assign .
- Result: Search succeeds. Solution found: .
- Condition to Trigger Backtracking: Forward checking triggers backtracking when the domain of any unassigned variable is reduced to an empty set () during domain propagation.
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 instead of exponential time.
Theory: Constraint Satisfaction Problems
Question 4 Solutions
4 (a) MDP Value Iteration
Value Iteration Equation: Given: , , . Let .
Iteration 1 ()
Iteration 2 ()
- State :
- : Expected utility
- : Expected utility
- State :
- : Expected utility
- : Expected utility
Iteration 3 ()
- State :
- : Expected utility
- : Expected utility
- Optimal Action at :
- State :
- : Expected utility
- : Expected utility
- Optimal Action at :
4 (b) Q-learning vs. Value Iteration
- Equation Modification: Q-learning removes the transition probability and the reward function by learning directly from environmental samples (experience tuples ). The update rule is:
- Key Differences:
- Transition Model: Value Iteration is model-based (requires knowing transition probabilities and rewards ). Q-learning is model-free (learns directly from interactions without a model of the environment).
- Type of Value Learned: Value Iteration learns state utilities . Q-learning learns action-values (the value of taking action in state ).
- 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:
- Max (Root) Evaluation:
The minimax value of the root node is 3. Max should choose the branch leading to the first Min node ().
5 (b) Alpha-Beta Pruning Tracing
Using (Max's guaranteed minimum) and (Min's guaranteed maximum), initialized to .
- Evaluate :
- Leaves: 8, 9, 3, 4, 5. value .
- Update root: .
- Evaluate (with bounds ):
- Leaf 7: .
- Leaf 1: .
- Pruning Condition: Since (), we prune the remaining leaves of this node.
- Pruned: 3, 8, 2.
- Evaluate (with bounds ):
- Leaf 4: .
- Leaf 3: .
- Pruning Condition: Since (), we prune.
- Pruned: 9, 2, 2.
- Evaluate (with bounds ):
- Leaf 9: .
- Leaf 1: .
- Pruning Condition: Since (), we prune.
- Pruned: 5, 6, 4.
- Evaluate (with bounds ):
- Leaf 2: .
- Pruning Condition: Since (), 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:
- (Probability of disease)
- (Probability of no disease)
- (True positive rate)
- (True negative rate)
- (False positive rate)
1. Probability of disease given a positive test :
Using Bayes Theorem:
2. Probability of no disease given a negative test :
Theory: Decision Theory and Utility
6 (b) Hidden Markov Models (HMM)
i. HMM Graphical Formulation and Tuples
An HMM is formulated using the tuple :
- : Set of hidden states.
- : Set of observable symbols.
- : State transition probability matrix (defines probability of transitioning from state to ).
- : Emission probability matrix (probability of emitting observation from state ).
- : Initial state probability distribution.
ii. Initial State Distribution ()
- Representation: The probability that the system starts in state is , state is , and state is .
- Role of : It anchors the probability calculations at step . 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
- Evaluation Problem: Given model and observation sequence , compute . Resolved using the Forward or Backward Algorithm.
- Decoding Problem: Given model and observation sequence , find the most likely hidden state sequence . Resolved using the Viterbi Algorithm.
- Learning Problem: Given observation sequence , adjust model parameters to maximize . 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:
- Stage 1 (Sigmoid):
- Issue: Vanishing Gradient Problem. The Sigmoid function squeezes outputs to . Its derivative has a maximum value of . As gradients are backpropagated through multiple layers, multiplying these small numbers causes the gradient to decay exponentially, slowing learning in early layers.
- Stage 2 (ReLU):
- Issue: Dying ReLU Problem. ReLU has derivative for and for . If a large gradient updates weights such that a neuron receives negative inputs across the entire dataset, its output and derivative become . The neuron becomes inactive and ceases to update.
- Stage 3 (Leaky ReLU / ELU):
- Solution: Leaky ReLU (where ) guarantees a small, non-zero gradient () 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: . True Class = Car (Class 0).
1. Softmax Calculation
-
-
-
-
Denominator sum
-
-
-
2. One-hot encoded true label
3. Cross-Entropy Loss
4. Interpretation
The loss value is high () because the model predicted the incorrect class (Bike) with high confidence () while allocating only a probability to the correct class (Car). This penalty reflects the model being "confident and wrong."