Semester 5
MAKAUT · B.Tech CSE
SEMESTER 5 · ARTIFICIAL INTELLIGENCE

Artificial Intelligence Study Notes

Exam-focused coverage of all 5 units — agents, search strategies, knowledge representation, and machine learning.

5 Units 1M + 5M + 15M PYQs Marked MAKAUT Pattern
1-Mark Qs
30+
Quick definitions
5-Mark Qs
18+
Explanations
15-Mark Qs
10+
Detailed answers
PYQs
2021–24
Previous years
01

Introduction to AI & Problem Solving

Agents · PEAS · State Space · Problem Formulation

Definition

Artificial Intelligence is the design and study of systems that perceive their environment and take actions that maximise the probability of achieving their goals. [Rich & Knight]

Definition

An AI agent is anything that perceives its environment through sensors and acts upon that environment through actuators. [Russell & Norvig]

1-mark Questions 1M
1M U1 / Q1
Define Artificial Intelligence.

AI is the branch of computer science concerned with making computers behave like humans — reasoning, learning, and problem-solving. [2023]

1M U1 / Q2
What is an agent in AI?

An agent is anything that can perceive its environment through sensors and act through actuators. [2021]

1M U1 / Q3
What does PEAS stand for?

Performance measure, Environment, Actuators, Sensors.

1M U1 / Q4
What is the Turing Test?

A test proposed by Alan Turing (1950) where a human interrogator chats with both a human and a machine. If the interrogator cannot reliably tell the machine apart, the machine is said to exhibit intelligent behaviour.

1M U1 / Q5
What is the Dartmouth Conference?

The 1956 summer workshop at Dartmouth College, co-organised by John McCarthy, Marvin Minsky, Claude Shannon and Nathaniel Rochester. It coined the term "Artificial Intelligence" and marked the birth of AI as a field.

1M U1 / Q6
Differentiate rational vs omniscient agent.

A rational agent does the right thing given its percept sequence. An omniscient agent would know the actual outcome of every action — an unrealistic ideal. Rationality ≠ omniscience.

1M U1 / Q7
What is a state space?

The set of all possible states reachable from the initial state by any sequence of actions. Represented as a graph where nodes are states and edges are actions.

1M U1 / Q8
What is problem formulation?

The process of defining precisely: (1) initial state, (2) actions/ successor function, (3) goal test, and (4) path cost. This converts a real-world problem into a formal search problem.

1M U1 / Q9
Name the four types of agents based on degree of perception.

(1) Simple reflex agent, (2) Model-based reflex agent, (3) Goal-based agent, (4) Utility-based agent.

5-mark Questions 5M
5M U1 / Q1
Describe the PEAS framework for (a) Vacuum Cleaner Robot, (b) Chess-Playing Program, (c) Self-Driving Car.
AgentPerformanceEnvironmentActuatorsSensors
Vacuum RobotCleanliness, time, energyRoom, furniture, dirtBrush, wheels, vacuumCamera, dirt sensor, bumper
Chess PlayerWin rate, game lengthBoard, opponent, clockScreen/move notationBoard state, clock display
Self-Driving CarSafety, speed, comfortRoad, traffic, weatherSteering, throttle, brakeCamera, LIDAR, GPS, radar
5M U1 / Q2
Explain the four types of AI agents with examples.

(1) Simple Reflex Agent: Acts only on current percept, ignoring history. Uses condition-action rules. Example: a thermostat that turns heat ON when T < 20°C.

(2) Model-Based Reflex Agent: Maintains an internal model of the world (current state). Updates the model using percept history. Example: a robot with a map of the room.

(3) Goal-Based Agent: Has explicit goals and chooses actions to achieve them. Needs search/planning. Example: a navigation app choosing route to destination.

(4) Utility-Based Agent: Uses a utility function to rank outcomes. Chooses actions that maximise expected utility. Example: stock trading bot balancing profit vs risk.

5M U1 / Q3
What are the properties of environment? Classify a typical environment.

Environments are classified along several dimensions:

  • Fully vs Partially Observable: Does the agent have access to the complete state?
  • Single vs Multi-agent: One agent or multiple competing agents?
  • Deterministic vs Stochastic: Is the next state fully determined by current state + action?
  • Episodic vs Sequential: Are decisions independent episodes or does each affect the future?
  • Static vs Dynamic: Does the environment change while the agent deliberates?
  • Discrete vs Continuous: Are states/time/actions countable?
  • Known vs Unknown: Are the rules/outcomes known to the designer?

Chess is: fully observable, multi-agent, deterministic, sequential, static, discrete, known.

5M U1 / Q4
Discuss the history of AI with major milestones.
  • 1943: McCulloch & Pitts — first computational model of neurons.
  • 1950: Turing publishes "Computing Machinery and Intelligence" and proposes the Turing Test.
  • 1956: Dartmouth Conference — "Artificial Intelligence" term coined. Birth of AI.
  • 1959: Arthur Samuel's checkers program — first self-learning program.
  • 1966: ELIZA — first chatbot by Joseph Weizenbaum.
  • 1969: Shakey the Robot — first general-purpose mobile robot at SRI.
  • 1974–80 (First AI Winter): Funding cut, limitations exposed.
  • 1997: Deep Blue defeats Garry Kasparov at chess.
  • 2011: Watson wins Jeopardy!
  • 2016: AlphaGo defeats Lee Sedol at Go.
  • 2022–present: Large Language Models (GPT, Claude, etc.) — generative AI revolution.
5M U1 / Q5
What is problem solving in AI? Explain with the 8-queen problem.

Problem solving in AI means finding a sequence of actions that transforms the world from an initial state to a goal state.

8-Queen Problem formulation:

  • Initial state: Empty board.
  • Actions: Place a queen in any unattacked square of the first non-empty row.
  • Goal test: 8 queens placed, none attacking each other.
  • Path cost: Number of queens placed (each costs 1).

State space size is 64! / (56! · 8!) ≈ 4.4 × 109 — a constraint satisfaction approach is preferred over general search.

15-mark Questions 15M
15M U1 / Q1 PYQ [2023]
Explain the Turing Test. Discuss its strengths and limitations as a test for machine intelligence.

The Turing Test (1950): Alan Turing proposed an "Imitation Game." A human interrogator communicates via text with two hidden entities — one human, one machine. If the interrogator cannot reliably distinguish the machine from the human (more than 30% of the time over 5 minutes), the machine is said to have passed.

Strength:

  • Practical, behaviour-based — focuses on what a system does, not how it thinks.
  • Subjective bias avoided — the interrogator does not know which is which.
  • Applicable to any behaviour (text, speech, image).

Limitations:

  • Does not measure understanding or consciousness — only behavioural mimicry.
  • Anthropocentric — designed around human-level interaction.
  • Can be "gamed" by ELIZA-style tricks (evasion, keyword matching).
  • Does not distinguish between simulating intelligence and actually being intelligent.
  • Chinese Room argument (Searle, 1980): syntax is not semantics.

Modern view: The Turing Test is a useful benchmark for conversational AI, but not a definitive test of general intelligence.

15M U1 / Q2 PYQ [2022]
Describe in detail the types of AI agents (simple reflex, model-based, goal-based, utility-based) with suitable examples and diagrams.

(1) Simple Reflex Agent — acts only on the current percept.

function SIMPLE-REFLEX-AGENT(percept) returns action
  static: rules, a set of condition-action rules
  rule ← RULE-MATCH(percept, rules)
  action ← rule.ACTION
  return action

Example: A vacuum cleaner that turns RIGHT when it bumps into a wall.

(2) Model-Based Reflex Agent — maintains internal state.

function MODEL-BASED-AGENT(percept) returns action
  static: model, rules
  model ← UPDATE-MODEL(model, action, percept)
  state ← MODEL-STATE(model, action, percept)
  rule ← RULE-MATCH(state, rules)
  action ← rule.ACTION
  return action

Example: A robot that remembers which rooms it has cleaned using a map.

(3) Goal-Based Agent — has explicit goals and reasons about future.

function GOAL-BASED-AGENT(percept) returns action
  goals ← INFER-GOALS(percept)
  state ← UPDATE-STATE(percept)
  action ← FIND-ACTION(goals, state)
  return action

Example: A taxi driver navigating to a destination — the goal is the destination address.

(4) Utility-Based Agent — maximises expected utility.

function UTILITY-BASED-AGENT(percept) returns action
  state ← UPDATE-STATE(percept)
  action ← argmaxa in ACTIONS(state) EXPECTED-UTILITY(a, state)
  return action

Example: A medical diagnosis system choosing treatments ranked by expected patient quality-of-life.

Exam Tip: Always draw the agent function diagram showing percept → agent function → action for each type. The Turing Test and Dartmouth Conference are very frequently asked in 1-mark and 5-mark questions.
02

Uninformed Search Strategies

BFS · DFS · UCS · DLS · IDDFS · Bidirectional

Definition

Uninformed (Blind) Search strategies have no additional information about the problem beyond the problem definition. They explore the state space systematically without any heuristic guidance.

1-mark Questions 1M
1M U2 / Q1
What is Breadth-First Search (BFS)?

A search strategy that expands the shallowest node first. Uses a FIFO queue. It is complete and optimal for uniform step cost.

1M U2 / Q2
What is Depth-First Search (DFS)?

A search strategy that expands the deepest node first. Uses a LIFO stack. Not complete for infinite spaces and not optimal.

1M U2 / Q3
What is Uniform Cost Search (UCS)?

UCS expands the node with the smallest path cost g(n). It generalises BFS to non-uniform step costs and is always optimal.

1M U2 / Q4
What is Depth-Limited Search (DLS)?

DFS with a predefined depth limit l. If the goal is deeper than l, DLS fails. Problem: choosing the right limit l.

1M U2 / Q5
What is Iterative Deepening DFS (IDDFS)?

It performs DFS with increasing depth limits: 0, 1, 2, ... until the goal is found. Combines BFS's completeness with DFS's low memory.

1M U2 / Q6
What is Bidirectional Search?

Search that simultaneously runs forward from the initial state and backward from the goal state, meeting in the middle. Effective branching factor becomes √b.

1M U2 / Q7
What is the time and space complexity of BFS?

Time: O(bd), Space: O(bd), where b = branching factor and d = depth of shallowest goal.

1M U2 / Q8
What is the main disadvantage of DFS?

DFS is not complete (can loop in infinite paths) and not optimal. It can get stuck in deep, irrelevant branches.

5-mark Questions 5M
5M U2 / Q1
Compare all uninformed search strategies in a comparison table.
AlgorithmData StructureComplete?Optimal?Time ComplexitySpace Complexity
BFSQueue (FIFO)Yes (finite b)Yes (unit cost)O(bd)O(bd)
DFSStack (LIFO)No (infinite paths)NoO(bm)O(bm)
UCSPriority QueueYesYesO(b1+C*/ε)O(b1+C*/ε)
DLSStackNo (if l < d)NoO(bl)O(bl)
IDDFSStackYesYes (unit cost)O(bd)O(bd)
BidirectionalTwo queuesYesYesO(bd/2)O(bd/2)

Here b = branching factor, d = depth of shallowest goal, m = max depth of tree, C* = optimal cost, ε = minimum non-zero step cost.

5M U2 / Q2
Explain Iterative Deepening DFS (IDDFS). Why is it preferred over BFS?

IDDFS performs repeated depth-limited DFS with increasing limits: depth 0, 1, 2, ..., d.

Algorithm:

function IDDFS(problem) returns solution
  for depth = 0 to ∞:
    result ← DLS(problem, depth)
    if result ≠ cutoff: return result

Why preferred over BFS:

  • Space complexity: O(bd) vs O(bd) for BFS — a huge saving for large b, d.
  • Complete for finite branching factor.
  • Optimal for unit step costs.
  • The overhead of revisiting nodes is small (< 11% for b=10).
  • Time complexity is asymptotically the same as BFS: O(bd).
5M U2 / Q3
Explain BFS and DFS with their algorithm and properties. [2021]

BFS Algorithm:

function BFS(problem) returns solution
  node ← NODE(problem.INITIAL)
  if problem.IS-GOAL(node.STATE): return node
  frontier ← FIFOQueue([node])
  reached ← {problem.INITIAL}
  while not frontier.EMPTY?:
    node ← POP(frontier)
    for child in EXPAND(node, problem):
      s ← child.STATE
      if problem.IS-GOAL(s): return child
      if s not in reached:
        reached.ADD(s)
        PUSH(frontier, child)
  return failure

DFS Algorithm (recursive):

function DFS(problem, limit) returns solution/failure/cutoff
  node ← NODE(problem.INITIAL)
  return RECURSIVE-DLS(node, problem, limit)

function RECURSIVE-DLS(node, problem, limit) returns solution/failure/cutoff
  if problem.IS-GOAL(node.STATE): return node
  else if limit = 0: return cutoff
  else:
    cutoff_occurred? ← false
    for child in EXPAND(node, problem):
      result ← RECURSIVE-DLS(child, problem, limit-1)
      if result = cutoff: cutoff_occurred? ← true
      else if result ≠ failure: return result
    if cutoff_occurred?: return cutoff else return failure

Properties:

  • BFS: Complete, Optimal (unit cost), Time O(bd), Space O(bd).
  • DFS: Not complete, Not optimal, Time O(bm), Space O(bm).
15-mark Questions 15M
15M U2 / Q1 PYQ [2022]
Solve the given search problem using BFS and DFS. Start at A, goal is G. Show the node expansion order with tree diagrams.

Problem graph:

A B C D E G 24 31 52 Figure 2.1 — Problem Graph

BFS (Queue-based, level by level):

Frontier evolution:
  [A]
  [B, C]          ← expand A
  [C, D, E]       ← expand B
  [D, E, G, G]    ← expand C → D, E added; D expands → G
  [G, G]          ← goal reached: path A-B-D-G cost=10

DFS (Stack-based, deepest first):

Stack evolution:
  [A]
  [B, C]          ← expand A
  [D, E, C]       ← expand B
  [G, E, C]       ← expand D
  [E, C]          ← expand G → GOAL! path A-B-D-G cost=10

Both BFS and DFS find the same path here: A → B → D → G with cost 2+3+5 = 10. However, BFS explores all nodes at depth 2 before depth 3, while DFS dives deep immediately. In a different graph, DFS could find a different (possibly non-optimal) path first.

15M U2 / Q2 PYQ [2023]
Apply Uniform Cost Search (UCS) to find the optimal path from Arad to Bucharest using the Romanian map. Show all node expansions. [2023]

Romania Road Map (selected cities & distances in km):

FromToDistance
AradSibiu140
AradTimisoara118
AradZerind75
SibiuFagaras99
SibiuRimnicu Vilcea80
FagarasBucharest211
Rimnicu VilceaPitesti97
PitestiBucharest101
TimisoaraLugoj111
LugojMehadia70
MehadiaDrobeta75
DrobetaCraiova120
CraiovaPitesti138

UCS Expansion Order (lowest path cost first):

Step 1: Expand Arad        path cost = 0
  Frontier: Zerind(75), Sibiu(140), Timisoara(118)

Step 2: Expand Zerind      path cost = 75
  Frontier: Timisoara(118), Sibiu(140), Oradea(71+152=223)

Step 3: Expand Timisoara   path cost = 118
  Frontier: Sibiu(140), Lugoj(118+111=229), ...

Step 4: Expand Sibiu       path cost = 140
  Frontier: Rimnicu Vilcea(140+80=220), Fagaras(140+99=239), ...

Step 5: Expand Rimnicu Vilcea  path cost = 220
  Frontier: Pitesti(220+97=317), ...

Step 6: Expand Pitesti     path cost = 317
  Frontier: Bucharest(317+101=418), Craiova(317+138=455)

Step 7: Expand Bucharest   path cost = 418  ← GOAL!

Optimal Path: Arad → Sibiu → Rimnicu Vilcea → Pitesti → Bucharest
Optimal Cost: 140 + 80 + 97 + 101 = 418 km

Exam Tip: BFS vs DFS comparison, IDDFS explanation, and BFS/DFS tree diagram questions are frequently asked. Remember: BFS = Queue (FIFO), DFS = Stack (LIFO). IDDFS combines the best of both.
03

Informed (Heuristic) Search

Heuristics · A* · AO* · Hill Climbing · CSP · Genetic Algorithms

Definition

Informed Search uses problem-specific knowledge (a heuristic function h(n)) to find solutions more efficiently than uninformed search.

Definition

A heuristic function h(n) estimates the cheapest cost from node n to a goal. It is admissible if it never overestimates the true cost: h(n) ≤ h*(n) for all n.

1-mark Questions 1M
1M U3 / Q1
What is a heuristic function h(n)?

A function that estimates the cost from node n to the goal. It guides search towards promising regions of the state space.

1M U3 / Q2
What is an admissible heuristic?

A heuristic that never overestimates the true cost to reach the goal: h(n) ≤ h*(n). Admissibility guarantees optimality of A*.

1M U3 / Q3
What is the A* evaluation function?

f(n) = g(n) + h(n), where g(n) is the actual cost from start to n, and h(n) is the estimated cost from n to the goal.

1M U3 / Q4
What is simulated annealing?

A metaheuristic that sometimes accepts worse moves with probability e^(-ΔE/T), where T is temperature that slowly cools. Helps escape local optima.

1M U3 / Q5
What is a Constraint Satisfaction Problem (CSP)?

A problem defined by variables X with domains D and constraints C. The goal is to find an assignment where all constraints are satisfied.

1M U3 / Q6
What is crossover in Genetic Algorithms?

An operator that combines two parent chromosomes to produce offspring. Common types: single-point, two-point, and uniform crossover.

1M U3 / Q7
What is the AO* algorithm used for?

AO* finds optimal solutions in AND-OR graphs by propagating cost values from goal nodes backward, choosing the minimum-cost subgraph.

1M U3 / Q8
Define fitness function in Genetic Algorithms.

A function that evaluates how good a solution (chromosome) is. Higher fitness → higher chance of being selected for reproduction.

5-mark Questions 5M
5M U3 / Q1
Explain the A* search algorithm. Prove that it is optimal when h is admissible.

Algorithm:

function A*(problem, h) returns solution
  node ← NODE(problem.INITIAL)
  frontier ← PriorityQueue ordered by f = g+h, containing node
  reached ← {problem.INITIAL: node}
  while not frontier.EMPTY?:
    node ← POP(frontier)
    if problem.GOAL?(node.STATE): return node
    for child in EXPAND(node, problem):
      s ← child.STATE
      if s not in reached or child.PATH-COST < reached[s].PATH-COST:
        reached[s] ← child
        ADD(frontier, child)
  return failure

Proof of Optimality:

  1. Let G be an optimal goal node with cost C*.
  2. A* expands nodes in order of increasing f.
  3. Since h is admissible, for every node n on the optimal path, f(n) = g(n) + h(n) ≤ g(n) + h*(n) = g(n) + (C* - g(n)) = C*.
  4. Thus no node on the optimal path has f > C*.
  5. When A* selects a goal node G for expansion, its f(G) = g(G) ≤ C* (since h(G)=0 and h is admissible).
  6. Therefore g(G) = C*, i.e., the solution is optimal.
5M U3 / Q2
Describe the variants of hill climbing (simple, steepest-ascent, first-choice, random-restart, simulated annealing).

(1) Simple Hill Climbing: Pick any neighbour better than current. Move to it. Stop when no neighbour is better. Fast but very basic.

(2) Steepest-Ascent Hill Climbing: Examine ALL neighbours and move to the best one. More thorough than simple HC.

(3) First-Choice Hill Climbing: Randomly generate successors until one is better than current. Efficient when many neighbours exist.

(4) Random-Restart Hill Climbing: Run hill climbing from many random initial states; keep the best result. Probabilistically complete.

(5) Simulated Annealing: Occasionally accept worse moves with probability P = e^(-ΔE/T), where T starts high and decreases. Escapes local optima.

Limitations of all variants:

  • Local maxima — stuck at a peak lower than the global maximum.
  • Ridges — sequence of local maxima makes progress zigzag and slow.
  • Plateaux — flat area where no neighbour is better.
5M U3 / Q3
Explain Genetic Algorithms with the main operators: selection, crossover, mutation.

Genetic Algorithms (GAs) are population-based search algorithms inspired by natural evolution. They work on a population of candidate solutions (chromosomes).

1. Selection: Choose fitter individuals for reproduction. Common methods:

  • Roulette Wheel Selection: probability proportional to fitness.
  • Tournament Selection: pick k individuals at random; the best wins.
  • Rank Selection: rank individuals by fitness; probability based on rank.

2. Crossover: Combine two parents to produce offspring. Single-point crossover: pick a crossover point and swap tails.

Parent 1:  11001 | 101    →   11001 011
Parent 2:  10110 | 011    →   10110 101
                  ↑ crossover point (after position 5)

3. Mutation: Randomly flip a bit in a chromosome with low probability (e.g., 0.01). Maintains genetic diversity and prevents premature convergence.

4. Fitness Function: Evaluates each chromosome. Problem-specific. Higher fitness → higher survival probability.

5M U3 / Q4
What is a CSP? Explain backtracking search and forward checking with an example.

A CSP has: variables X = {X1, ..., Xn}, domains D = {D1, ..., Dn}, and constraints C specifying allowed value combinations.

Backtracking Search: Assign variables one at a time. If a constraint is violated, backtrack to the last decision point and try a different value.

Example — Map Colouring (Australia): Variables: WA, NT, Q, NSW, V, SA, T. Domain: {Red, Green, Blue}. Constraint: adjacent regions must have different colours.

Forward Checking: When a variable Xi is assigned value vi, prune the domain of each unassigned neighbour Xj by removing values inconsistent with vi. If any domain becomes empty, backtrack immediately.

15-mark Questions 15M
15M U3 / Q1
Explain the A* algorithm. Apply it to find the shortest path from node S to node G in the graph below. Show f(n), g(n), h(n) for each node at every step.

Graph:

S A B C D G g=1g=4 g=3g=5 g=8g=6 h=6h=4 h=3h=2 h=1h=0 Figure 3.1 — A* Example Graph (g = edge cost, h = heuristic)

A* Step-by-Step:

Step 1: Expand S
  g(S)=0,  h(S)=6,  f(S)=0+6=6
  Children: A(g=1, f=1+4=5),  B(g=4, f=4+3=7)
  Frontier sorted: A(5), B(7)

Step 2: Expand A (lowest f=5)
  Children: C(g=1+3=4, f=4+2=6), D(g=1+7=8, f=8+1=9)
  Frontier sorted: C(6), B(7), D(9)

Step 3: Expand C (lowest f=6)
  Children: G(g=4+8=12, f=12+0=12)
  Frontier sorted: B(7), D(9), G(12)

Step 4: Expand B (lowest f=7)
  Children: D(g=4+5=9 → worse than existing 8, skip), G(g=4+6=10, f=10+0=10)
  Frontier sorted: D(9), G(10), G(12)

Step 5: Expand D (lowest f=9)
  Children: G(g=8+2=10 → same as existing, skip)
  Frontier sorted: G(10), G(12)

Step 6: Expand G (lowest f=10) ← GOAL!
  Path: S → A → B → G, total cost = 10

A* explores 5 nodes (S, A, C, B, D) before reaching the goal. The optimal path cost is 10 via S → A → B → G.

15M U3 / Q2 PYQ [2023]
Explain Genetic Algorithms in detail. Apply a GA to maximise f(x) = x² for x ∈ [0, 31], with population size 4, crossover rate 0.7, mutation rate 0.01. Show 3 generations.

GA Framework:

  1. Initialise: Create random population of chromosomes.
  2. Evaluate: Compute fitness of each chromosome.
  3. Select: Choose parents proportionally to fitness.
  4. Crossover: With probability Pc, recombine pairs.
  5. Mutate: With probability Pm, flip random bits.
  6. Replace: Form new population; repeat from step 2.
  7. Terminate: After fixed generations or convergence.

Application to maximise f(x) = x² (x ∈ [0, 31]):

Represent x as 5-bit binary: 0 = 00000, 31 = 11111. f(x) = x² is the fitness.

Generation 0 (random):

Chromosomex (decimal)Fitness = x²
0110113169
1100024576
0101111121
1001018324

Total fitness = 169+576+121+324 = 1190. Selection probabilities: 14.2%, 48.4%, 10.2%, 27.2%.

Selection (roulette wheel): Select 11000 (f=576) and 10010 (f=324) as parents.

Crossover (Pc=0.7, crossover at bit 2):

P1: 11 | 000  →  11000 (x=24)
P2: 10 | 010  →  10010 (x=18)
Offspring:  11 | 010  = 11010 (x=26, f=676)
             10 | 000  = 10000 (x=16, f=256)

Mutation (Pm=0.01, flip bit 4 of offspring2): 10000 → 10001 (x=17, f=289)

Generation 1: {11010(x=26,f=676), 10001(x=17,f=289), 01101(x=13,f=169), 11000(x=24,f=576)}

Repeating this process, the population converges toward x=31 (11111, f=961).

Exam Tip: A* with a numerical example and proof of optimality is a guaranteed 15-mark question. GA with 2-3 generations is also very common. Always show f(n)=g(n)+h(n) table at each step.
04

Knowledge Representation & Reasoning

Logic · FOL · Unification · Resolution · Expert Systems · Frames

Definition

Knowledge Representation (KR) is the study of how knowledge about the world can be expressed and stored in a form that a computer system can use to solve complex tasks.

Definition

Propositional Logic (PL) is the simplest logic where statements are either true or false. It uses atomic propositions combined with connectives: ∧ (AND), ∨ (OR), ¬ (NOT), → (IMPLIES), ↔ (IFF).

1-mark Questions 1M
1M U4 / Q1
What are the methods of knowledge representation?

Logical representation (propositional, predicate), Semantic networks, Frames/Scripts, Production rules, Conceptual dependencies.

1M U4 / Q2
What is a production rule?

A rule of the form IF (condition) THEN (action). Used in expert systems and rule-based systems. Also called IF-THEN rules.

1M U4 / Q3
What is a semantic network?

A graph where nodes represent objects/concepts and labelled edges represent relationships between them. Example: IS-A, HAS-A links.

1M U4 / Q4
What is a frame in AI?

A data structure for representing stereotypical situations. Contains slots with default values and procedural attachments (if-needed, if-added).

1M U4 / Q5
Define First-Order Logic (FOL).

FOL (predicate logic) extends propositional logic with quantifiers (∀, ∃), variables, predicates, and functions. It can express statements about objects and their relationships.

1M U4 / Q6
What is unification?

The process of finding a substitution that makes two logical expressions identical. It is the basic matching mechanism for resolution and logical inference.

1M U4 / Q7
What is the resolution principle?

A complete inference rule for FOL. Given two clauses containing complementary literals, derive a new clause (resolvent) by removing the complementary pair and merging the rest.

1M U4 / Q8
What is an expert system?

A program that encodes the knowledge of a human expert in a specific domain and uses inference rules to solve problems like the expert would.

5-mark Questions 5M
5M U4 / Q1
Explain forward chaining and backward chaining in rule-based systems. [2022]

Forward Chaining (Data-driven): Starts from known facts and applies rules forward until a goal is reached. Bottom-up reasoning. Used in OPS5, CLIPS.

R1: IF rainy THEN wet
R2: IF wet AND cold THEN slippery
Facts: rainy, cold
→ Apply R1: wet (inferred)
→ Apply R2: slippery (GOAL reached)

Backward Chaining (Goal-driven): Starts from the goal and works backward, finding rules that could prove the goal, then proving their antecedents. Top-down reasoning. Used in Prolog, MYCIN.

Goal: slippery
→ Need: wet AND cold
→ Prove wet: use R1 → need rainy (TRUE)
→ Prove cold: (TRUE)
→ Goal proved ✓
5M U4 / Q2
Describe the architecture and components of an expert system.

Components:

  • Knowledge Base: Stores domain knowledge as facts and rules. The most critical component.
  • Inference Engine: Applies reasoning (forward/backward chaining) to derive conclusions from the knowledge base.
  • Explanation Facility: Answers "why" and "how" questions from the user, making the reasoning transparent.
  • User Interface: Allows users to input queries and view results in natural language or structured form.
  • Knowledge Acquisition Module: Helps experts add or modify rules in the knowledge base.

Types:

  • Rule-based: MYCIN (medical diagnosis), DENDRAL (chemical analysis).
  • Frame-based: Uses frames/schemas with slots and default values.
5M U4 / Q3
Explain unification with an example. What is the most general unifier (MGU)?

Unification finds the most general substitution that makes two expressions identical.

Algorithm:

function UNIFY(x, y, θ) returns substitution
  if θ = failure: return failure
  else if x = y: return θ
  else if VARIABLE?(x): return UNIFY-VAR(x, y, θ)
  else if VARIABLE?(y): return UNIFY-VAR(y, x, θ)
  else if COMPOUND?(x) and COMPOUND?(y):
    return UNIFY(x.ARGS, y.ARGS, UNIFY(x.OP, y.OP, θ))
  else if LIST?(x) and LIST?(y):
    return UNIFY(x.REST, y.REST, UNIFY(x.FIRST, y.FIRST, θ))
  else: return failure

Example: Unify P(x, f(y)) and P(A, f(B))

Step 1: unify P with P → θ = {}
Step 2: unify x with A → θ = {x/A}
Step 3: unify f(y) with f(B) → unify y with B → θ = {x/A, y/B}
MGU = {x/A, y/B}
5M U4 / Q4
Compare propositional logic and predicate logic (FOL).
FeaturePropositional LogicPredicate Logic (FOL)
Basic unitAtomic proposition (P, Q, R)Predicate with arguments (P(x), Loves(John, Mary))
VariablesNo variablesSupports variables (x, y)
QuantifiersNone∀ (for all), ∃ (exists)
ExpressivenessLimited — only true/false statementsHigh — objects, relations, functions
ComplexitySAT is NP-completeEntailment is semi-decidable
ExampleP → Q∀x (Student(x) → ∃y Studies(x, y))
15-mark Questions 15M
15M U4 / Q1 PYQ [2023]
Perform inference using propositional logic. Given the knowledge base below, prove "C" using resolution.

Knowledge Base:

  1. A → B
  2. B → C
  3. A

Goal: Prove C

Method 1: Forward Chaining

1. A is TRUE (given).
2. A → B, A is TRUE → B is TRUE (Modus Ponens).
3. B → C, B is TRUE → C is TRUE (Modus Ponens).
∴ C is proved. ✓

Method 2: Resolution

Step 1: Convert KB to CNF:
  (A → B)       ≡  (¬A ∨ B)           ... Clauses: {¬A, B}
  (B → C)       ≡  (¬B ∨ C)           ... Clauses: {¬B, C}
  A                              ... Clause:  {A}

Step 2: Negate the goal: ¬C

Step 3: Add to clause set: {¬C}

Step 4: Resolve:
  Resolve {A} and {¬A, B} → {B}
  Resolve {B} and {¬B, C} → {C}
  Resolve {C} and {¬C} → {} (empty clause)

Step 5: Empty clause derived → contradiction → Goal C is TRUE. ✓
15M U4 / Q2 PYQ [2022]
Explain resolution with unification in FOL. Prove: "Socrates is mortal" from: All men are mortal; Socrates is a man.

Step 1: Encode in FOL

(1) ∀x (Man(x) → Mortal(x))
(2) Man(Socrates)
Goal: Mortal(Socrates)

Step 2: Convert to CNF (Skolemisation)

(1) ∀x (¬Man(x) ∨ Mortal(x))    → Clause: {¬Man(x), Mortal(x)}
(2) Man(Socrates)               → Clause: {Man(Socrates)}

Step 3: Negate the goal

¬Mortal(Socrates)               → Clause: {¬Mortal(Socrates)}

Step 4: Apply Resolution with Unification

Clause set:  {¬Man(x), Mortal(x)}
              {Man(Socrates)}
              {¬Mortal(Socrates)}

Resolve {Man(Socrates)} and {¬Man(x), Mortal(x)}:
  Unify: x = Socrates (MGU = {x/Socrates})
  Resolvent: {Mortal(Socrates)}

Resolve {Mortal(Socrates)} and {¬Mortal(Socrates)}:
  Unify: Mortal(Socrates) with Mortal(Socrates) (MGU = {})
  Resolvent: {}  (EMPTY CLAUSE) → Contradiction!

∴ ¬Mortal(Socrates) is FALSE → Mortal(Socrates) is TRUE. ✓
Exam Tip: Resolution proof (convert to CNF, negate goal, resolve until empty clause) is a very common 15-mark question. Practice with at least 3 examples. Always show the MGU explicitly.
05

Uncertainty & Machine Learning Basics

Probability · Bayes' Theorem · Fuzzy Logic · Decision Trees · Backpropagation

Definition

Uncertainty in AI arises because an agent's knowledge of the world is incomplete, the environment is stochastic, or outcomes are unpredictable. Probability theory and fuzzy logic are two major frameworks for handling uncertainty.

Definition

Bayes' Theorem: P(H|E) = [P(E|H) × P(H)] / P(E), where P(H) = prior probability, P(E|H) = likelihood, P(H|E) = posterior probability.

1-mark Questions 1M
1M U5 / Q1
State Bayes' Theorem.

P(H|E) = P(E|H) × P(H) / P(E), where H = hypothesis, E = evidence.

1M U5 / Q2
What is a Bayesian Network?

A directed acyclic graph where nodes represent random variables and edges represent conditional dependencies. Used for probabilistic reasoning.

1M U5 / Q3
What is fuzzy logic?

A form of many-valued logic where truth values range from 0 (false) to 1 (true) rather than just 0 or 1. Handles partial membership and reasoning with uncertainty.

1M U5 / Q4
What is a membership function in fuzzy logic?

A function μ(x) ∈ [0,1] that defines the degree of membership of element x in a fuzzy set. Example: μtall(180) = 0.8 means 180cm is 80% tall.

1M U5 / Q5
What is a decision tree?

A tree structure where internal nodes test attributes, branches represent outcomes, and leaf nodes represent class labels. Used for classification in ML.

1M U5 / Q6
What is entropy in ID3 algorithm?

Entropy(S) = -Σ pi log­₂(pi), where pi is the proportion of samples in class i. It measures impurity/uncertainty in a dataset.

1M U5 / Q7
What is information gain?

Gain(S, A) = Entropy(S) - Σ (|Sv|/|S|) × Entropy(Sv). It measures the reduction in entropy when splitting on attribute A. ID3 selects the attribute with highest gain.

1M U5 / Q8
What is backpropagation?

An algorithm for training neural networks. It computes the gradient of the loss function with respect to each weight using the chain rule, then updates weights via gradient descent.

5-mark Questions 5M
5M U5 / Q1
Explain Bayes' Theorem with a worked numerical example. [2021]

Bayes' Theorem: P(H|E) = P(E|H) × P(H) / P(E)

Where P(E) = P(E|H)×P(H) + P(E|¬H)×P(¬H)

Example — Medical Diagnosis:

Disease D occurs in 1% of population: P(D) = 0.01, P(¬D) = 0.99.
Test T is 95% accurate: P(T+|D) = 0.95, P(T+|¬D) = 0.05.
A person tests positive. What is P(D|T+)?

P(D|T+) = P(T+|D) × P(D) / P(T+)
P(T+) = P(T+|D)×P(D) + P(T+|¬D)×P(¬D)
      = 0.95×0.01 + 0.05×0.99
      = 0.0095 + 0.0495 = 0.059

P(D|T+) = 0.95 × 0.01 / 0.059
         = 0.0095 / 0.059
         ≈ 0.161 (16.1%)

Despite a positive test, the probability of disease is only ~16% because the disease is rare (base rate fallacy).

5M U5 / Q2
Explain fuzzy logic. What are membership functions and fuzzy rules?

Fuzzy Logic extends Boolean logic to handle partial truth values between 0 (completely false) and 1 (completely true).

Membership Function: Maps an input value to a degree of membership in a fuzzy set.

Example: Temperature "Hot" with triangular membership:

        1.0 ──┐
             │\
             │ \
        0.5 ─┼──\────
             │    \
        0.0 ─┴─────\──
             25    30  35  (°C)

μ_hot(28°C) ≈ 0.6,  μ_hot(32°C) ≈ 0.4

Fuzzy Rules: IF-THEN rules with fuzzy conditions and fuzzy conclusions.

R1: IF temperature is HOT  THEN fan_speed is HIGH
R2: IF temperature is WARM THEN fan_speed is MEDIUM
R3: IF temperature is COOL  THEN fan_speed is LOW

Fuzzy Inference Steps: Fuzzification → Rule evaluation → Aggregation → Defuzzification.

5M U5 / Q3
Explain Decision Tree learning. What is entropy and information gain?

Decision Tree is a flowchart-like structure for classification. Each internal node tests an attribute, each branch represents an outcome, and each leaf assigns a class.

ID3 Algorithm (Iterative Dichotomiser 3):

  1. Compute entropy of the target variable for the current dataset.
  2. For each attribute A, compute information gain.
  3. Select the attribute with the highest gain as the splitting node.
  4. Recursively repeat for each branch until all instances are classified or no attributes remain.

Entropy: Entropy(S) = -Σ pi × log­₂(pi) — measures impurity.

Information Gain: Gain(S, A) = Entropy(S) - Σ (|Sv|/|S|) × Entropy(Sv)

5M U5 / Q4
Compare supervised, unsupervised, and reinforcement learning.
FeatureSupervisedUnsupervisedReinforcement
Training dataLabeled (input + output)Unlabeled (input only)No explicit data; agent learns from rewards
GoalPredict output for new inputsFind hidden patterns/clustersMaximise cumulative reward
FeedbackDirect (correct answer given)NoneDelayed (reward signal)
ExamplesClassification, RegressionClustering, Dimensionality reductionGame playing, Robotics
AlgorithmsDecision Tree, SVM, Neural NetsK-Means, PCA, AutoencodersQ-Learning, SARSA, Policy Gradients
15-mark Questions 15M
15M U5 / Q1 PYQ [2023]
Apply the ID3 algorithm to construct a decision tree for the following dataset. Show entropy and information gain calculations at each step.

Dataset — Play Tennis:

DayOutlookTempHumidityWindPlay
1SunnyHotHighWeakNo
2SunnyHotHighStrongNo
3OvercastHotHighWeakYes
4RainMildHighWeakYes
5RainCoolNormalWeakYes
6RainCoolNormalStrongNo
7OvercastCoolNormalStrongYes
8SunnyMildHighWeakNo
9SunnyCoolNormalWeakYes
10RainMildNormalWeakYes
11SunnyMildNormalStrongYes
12OvercastMildHighStrongYes
13OvercastHotNormalWeakYes
14RainMildHighStrongNo

Step 1: Compute Entropy of entire dataset (S):

Total = 14,  Yes = 9,  No = 5
Entropy(S) = -(9/14)log₂(9/14) - (5/14)log₂(5/14)
           = -(0.643 × -0.637) - (0.357 × -1.485)
           = 0.409 + 0.530 = 0.940

Step 2: Compute Gain for each attribute:

Gain(S, Outlook):

Sunny(5): Yes=2, No=3 → Entropy = -(2/5)log₂(2/5) - (3/5)log₂(3/5) = 0.971
Overcast(4): Yes=4, No=0 → Entropy = 0.0
Rain(5): Yes=3, No=2 → Entropy = -(3/5)log₂(3/5) - (2/5)log₂(2/5) = 0.971

Gain(Outlook) = 0.940 - [(5/14)×0.971 + (4/14)×0 + (5/14)×0.971]
             = 0.940 - [0.347 + 0 + 0.347]
             = 0.940 - 0.694 = 0.246

Gain(S, Humidity):

High(7): Yes=3, No=4 → Entropy = 0.985
Normal(7): Yes=6, No=1 → Entropy = 0.592

Gain(Humidity) = 0.940 - [(7/14)×0.985 + (7/14)×0.592]
               = 0.940 - [0.492 + 0.296]
               = 0.940 - 0.788 = 0.152

Gain(S, Wind):

Weak(8): Yes=6, No=2 → Entropy = 0.811
Strong(6): Yes=3, No=3 → Entropy = 1.000

Gain(Wind) = 0.940 - [(8/14)×0.811 + (6/14)×1.000]
            = 0.940 - [0.464 + 0.429]
            = 0.940 - 0.893 = 0.047

Step 3: Root node = Outlook (highest gain = 0.246)

Step 4: For Outlook=Overcast (pure node): Leaf → Play = Yes

Step 5: For Outlook=Sunny (5 samples): Gain(Humidity) = 0.971 - [(3/5)×0 + (2/5)×0] = 0.971, Gain(Wind) = 0.971 - [(2/5)×0 + (3/5)×0] = 0.971

Pick Humidity (or Wind): Humidity → Leaf Normal=Yes, Leaf High=No

Step 6: For Outlook=Rain (5 samples): Gain(Wind) = 0.971 - [(2/5)×0 + (3/5)×0] = 0.971

Pick Wind: Weak → Yes, Strong → No

Final Decision Tree:

         [Outlook]
         /    |    \
    Sunny  Overcast  Rain
      |       |       |
   [Humidity] Yes   [Wind]
   /      \          /   \
 High    Normal  Weak   Strong
  |        |       |       |
  No      Yes     Yes     No
15M U5 / Q2 PYQ [2022]
Explain backpropagation in a neural network. Derive the weight update rule for a 2-layer network.

Backpropagation is an algorithm for computing gradients in a feedforward neural network. It applies the chain rule of calculus layer by layer, from the output back to the input.

Network: 2 inputs, 1 hidden layer (2 neurons), 1 output

  x1 ──→ h1 ──→ y
    ↘  ↗     ↘  ↗
  x2 ──→ h2 ──→

Forward Pass:

z_h = w1·x1 + w2·x2 + b_h     (hidden pre-activation)
h   = σ(z_h)                       (hidden activation)

z_o = w3·h + b_o                 (output pre-activation)
ŷ   = σ(z_o)                       (predicted output)

Loss: L = (1/2) × (y - ŷ)² (MSE)

Backward Pass (gradient computation):

δ_o = (ŷ - y) × σ'(z_o)           (output error signal)

∂L/∂w3 = δ_o × h                  (gradient for output weights)
∂L/∂b_o = δ_o                     (gradient for output bias)

δ_h = (δ_o × w3) × σ'(z_h)        (hidden error signal)

∂L/∂w1 = δ_h × x1                 (gradient for hidden weights)
∂L/∂w2 = δ_h × x2
∂L/∂b_h = δ_h

Weight Update Rule (gradient descent):

w_new = w_old - η × ∂L/∂w

Where η (eta) is the learning rate (typically 0.01 to 0.1).

Complete Algorithm:

1. Initialise all weights and biases randomly.
2. For each epoch:
   a. Forward pass: compute predictions ŷ for all training samples.
   b. Compute loss L.
   c. Backward pass: compute ∂L/∂w for each weight using chain rule.
   d. Update: w ← w - η × ∂L/∂w
3. Repeat until loss converges.

Key insight: The chain rule allows gradients to propagate backward through the network: ∂L/∂w = (∂L/∂ŷ) × (∂ŷ/∂z) × (∂z/∂w).

Exam Tip: Decision tree with entropy/gain calculations is almost always a 15-mark question. Backpropagation derivation and Bayes' theorem numerical problems are also very common. Always show the step-by-step math.
AI · Semester 5 · MAKAUT B.Tech CSE
Covers Units 1–5 · Exam-Focused