Zero to hero · built from 12 past papers, 2018-2024

Artificial Intelligence, taught from nothing to full marks.

You have attended one class. That is fine. This book assumes you know nothing, teaches every topic in the COM 713.3 syllabus in plain language, shows you the exact words and diagrams that earn marks in a Pokhara University script, and then solves every numerical that has appeared in the last seven years.

Reading order: read a unit, then immediately do that unit's solved questions. Do not read all six units first, you will forget Unit 1 by the time you reach Unit 6.

Start

How to use this book

Four passes, roughly three weeks. It works even if you start ten days out.

PassWhat you doWhy
1Read Units 1-6 straight through, ignoring the boxes. Do not memorise.You need the shape of the subject before the detail. AI is one story: an agent that searches, reasons, handles uncertainty, and learns.
2Re-read one unit, then solve that unit's past questions with a pen, without looking at the solution.The exam is 70% numerical/procedural. Reading a solved A* does not teach you A*. Writing one does.
3Work through the must-do list and write full 10-mark answers to time (18 minutes each).Your bottleneck in the hall is writing speed and structure, not knowledge.
4Night before: the one-page revision sheet only.New material the night before displaces what you already know.
What the boxes mean

Blue = how to present this in the answer sheet. Yellow = write this exact thing or you lose marks. Red = the mistake students actually make here. Green = a model answer or worked solution.

Start

How to write a 10-mark answer

The single highest-return page in this book. Most students lose 20 marks on presentation, not on knowledge.

4 hrs · 100 marks

Your paper is 4 hours for 10 questions of 10 marks. That is 24 minutes per question, so budget 18 minutes writing and keep 60 minutes spare for the two numericals that will eat time (crypt-arithmetic and A*). Never leave a question blank: an examiner cannot give marks to a blank page, but a definition plus a diagram on a half-remembered topic reliably fetches 4.

The five-part skeleton

Every theory question in this paper fits this skeleton. Use it mechanically.

PartContentMarks
DefinitionOne or two sentences. Formal, textbook phrasing. Underline the term being defined.2
BodyTypes / components / steps as a numbered or bulleted list, each with one line of explanation. Never a wall of prose.4
DiagramLabelled, boxed, drawn with a scale, captioned "Fig: …". Even when not asked.2
ExampleA concrete one: a vacuum cleaner, a self-driving car, a spam filter. Named, not generic.1.5
CloseOne line of advantages/limitations/application.0.5
Rules that convert directly into marks
  • Answer the verb. "Compare" needs a table with a criteria column. "Justify" needs a stand and reasons. "Discuss with example" without an example is capped around 6.
  • Diagram in every answer. This syllabus is diagram-heavy: agents, search trees, belief networks, perceptrons, expert systems, NLP stages. A page of prose with no figure reads as memorised.
  • Show every step in numericals. In A*, write the OPEN and CLOSED list at each step. In crypt-arithmetic, state the carry equations. The steps carry the marks; the final answer is worth about 2.
  • Write the final answer in a box and repeat it as a sentence: "Hence the optimal path is S→4→5→6→7 with solution cost 13."
  • Start every question on a fresh page and write the question number in the margin. Examiners mark in bulk.
Where marks actually leak
  • Answering "Explain A*" by only writing the formula f(n)=g(n)+h(n). You must give admissibility, the algorithm, a worked example, and its drawback (memory).
  • Giving a truth table where a proof was asked (resolution), or a proof where a table was asked.
  • In FOPL questions, forgetting the quantifiers, writing buys(x,y) → smart(x) with no ∀. That is an automatic cut.
  • Rounding probability answers to "about 10%" without showing Bayes' rule substituted with numbers.
  • Running out of time because crypt-arithmetic was attempted first. Do it last: it is the one question that can silently consume 45 minutes.

Question-order strategy in the hall

  1. 0-5 min: read the whole paper, tick the four questions you can answer cold.
  2. 5-90 min: those four theory questions, fast, with diagrams.
  3. 90-150 min: the standard numericals: Bayes, A*, resolution, ID3. These are formulaic; you will have practised them.
  4. 150-210 min: crypt-arithmetic and anything requiring construction (Bayesian network, decision tree).
  5. 210-240 min: the weakest question, plus going back to add diagrams and headings to earlier answers.
↑ contents
Start

Syllabus map and where the marks live

Counted across twelve papers, 2018 Spring to 2024 Fall.

UnitSyllabus hoursTypical marks in paperWhat is always asked
1 · Introduction, agents310-20Turing test; agent types; PEAS; task environments
2 · Problem solving & search920-30A* on a graph; crypt-arithmetic (CSP); BFS/DFS comparison; heuristics
3 · Knowledge & logic820-30FOPL translation; resolution proof; CNF conversion; forward/backward chaining
4 · Uncertain knowledge910-20Bayes numerical; Bayesian belief network; fuzzy logic
5 · Learning1220-30Supervised/unsupervised/RL; backpropagation; decision tree & ID3; genetic algorithm; perceptron/XOR
6 · Expert systems & NLP410-20Expert system components + development steps; NLP stages/ambiguity
Read this before planning your revision

Six topics have appeared in every single paper in some form: crypt-arithmetic, A*, resolution/FOPL, a Bayes numerical, expert system components, and supervised vs unsupervised vs reinforcement learning. That is 60 marks. Pass marks are 60. Master those six and everything else is upside.

↑ contents
Unit 1

Introduction and Intelligent Agents

Foundations of AI, history, the Turing test, rational agents, agent structures, task environments.

3 hrs · 10-20 marks

What Artificial Intelligence actually means

Forget the movies. In this syllabus AI has a narrow, examinable meaning: the study and construction of agents that receive percepts from an environment and perform actions that are rational, that is, actions expected to maximise some performance measure. That one sentence is the definition to write in any "What is AI?" question.

Russell and Norvig, the prescribed book, organise every definition of AI ever proposed into four boxes along two axes: thinking versus acting, and human-like versus rational. Draw this table for a guaranteed 2 marks in any introductory question.

Human-like (measured against people)Rational (measured against an ideal)
ThinkingThinking humanly: cognitive modelling. Make machines whose internal reasoning matches human reasoning. Tools: introspection, psychological experiment, brain imaging.Thinking rationally: the "laws of thought". Formal logic: encode knowledge as sentences, derive conclusions by valid inference. Basis of Units 3 and 4.
ActingActing humanly: the Turing test approach. Requires NLP, knowledge representation, automated reasoning, machine learning.Acting rationally: the rational agent approach. This is the approach the whole course takes.
Write this line in any Unit 1 answer

"This course adopts the acting rationally / rational agent view, because rationality is mathematically well-defined and completely general, whereas human behaviour is neither."

Foundations of AI: the disciplines it borrowed from

A "foundations of AI" question wants six to eight lines. One line each:

DisciplineWhat AI took from it
PhilosophyLogic, methods of reasoning, mind as a physical system, foundations of learning and rationality (Aristotle's syllogisms, Descartes' dualism).
MathematicsFormal logic, computability, decidability, algorithms, probability, NP-completeness (Boole, Gödel, Turing).
EconomicsUtility theory, decision theory, game theory, the idea of maximising expected utility, which defines rational behaviour.
NeuroscienceThe physical substrate of thought; the neuron model that became the artificial neural network.
PsychologyCognitive science, perception, information processing view of the mind.
Computer engineeringFast, cheap hardware: without it none of this runs.
Control theoryHomeostatic systems, feedback loops, optimising an objective over time.
LinguisticsKnowledge representation, grammar and syntax: the base of NLP in Unit 6.

History of AI: the milestones worth naming

  • 1943 McCulloch & Pitts propose the first artificial neuron model.
  • 1950 Turing publishes Computing Machinery and Intelligence, proposing the Turing test.
  • 1956 Dartmouth Conference: John McCarthy coins the term "artificial intelligence". Birth year of the field.
  • 1956-1969 Early enthusiasm: Logic Theorist, General Problem Solver (GPS), LISP (McCarthy, 1958), perceptron (Rosenblatt, 1958).
  • 1969 Minsky & Papert show a single perceptron cannot learn XOR → funding collapses.
  • 1974-1980 First "AI winter": the reality of intractability and the knowledge bottleneck.
  • 1980s Expert systems become industry (DENDRAL, MYCIN, XCON); Japan's Fifth Generation project; then a second winter.
  • 1986 Backpropagation popularised: neural networks revive.
  • 1997 IBM's Deep Blue defeats world chess champion Garry Kasparov.
  • 1995 onwards The field turns to probability and statistics: Bayesian networks, HMMs, machine learning on data.
  • 2011 onwards IBM Watson wins Jeopardy!; deep learning wins ImageNet (2012); AlphaGo beats Lee Sedol (2016); large language models (2020s).

The Turing test

Definition: Proposed by Alan Turing in 1950 as an operational definition of intelligence. A human interrogator, in a separate room, converses through a text-only channel with a human and a machine. If the interrogator cannot reliably tell which is which, the machine is said to have passed the test and is deemed intelligent. Turing called it the "imitation game".

Interrogator (human judge) wall Machine (A) tries to appear human Human (B) answers honestly typed questions / typed answers only Verdict: which is the machine?
Fig 1.1: The Turing test. The channel is deliberately text-only so that physical appearance and voice play no part.

Capabilities a machine needs to pass it

  1. Natural language processing: to communicate in English.
  2. Knowledge representation: to store what it knows and hears.
  3. Automated reasoning: to answer questions and draw new conclusions.
  4. Machine learning: to adapt to new circumstances and detect patterns.

Total Turing test

The standard test avoids physical interaction. The total Turing test includes a video signal and a hatch through which objects are passed, so the machine must also have:

  1. Computer vision: to perceive objects.
  2. Robotics: to manipulate objects and move about.

These six capabilities together are essentially the whole of AI, which is why Turing's test still structures the field.

Reverse Turing test and CAPTCHA

In a reverse Turing test the roles are inverted: a machine is the interrogator and must decide whether the entity it is talking to is a human or another machine. CAPTCHA: Completely Automated Public Turing test to tell Computers and Humans Apart, is exactly this: a server poses a distorted-text or image-selection challenge that humans solve easily and programs solve poorly.

Answering "Do you agree CAPTCHA is a reverse Turing test? Justify."

Take a stand: yes, with a qualification: and give three reasons. (i) The judge is a machine, not a human, so the roles are reversed. (ii) The goal is to distinguish human from machine, which is the Turing test's goal. (iii) But it differs in two ways: it is administered automatically at scale, and it tests a narrow perceptual skill rather than open conversation, so passing a CAPTCHA does not imply general intelligence. Then close: "Modern OCR and CNNs now break most text CAPTCHAs, which shows the test measures a capability gap that is shrinking, not intelligence itself."

Limitations and criticisms of the Turing test

  • It tests imitation of humans, not intelligence. An aeroplane is not tested by whether it fools a birdwatcher.
  • It rewards deception: a machine must pretend to be bad at arithmetic to pass.
  • It is not reproducible or mathematically analysable; results depend on the interrogator's skill.
  • Trivial programs can fool naive judges (ELIZA, 1966), so passing is not sufficient.
  • Searle's Chinese Room argument: manipulating symbols correctly does not entail understanding.
  • It is anthropocentric: it cannot recognise a non-human form of intelligence.

Asked "If the Turing test is passed, does this show computers exhibit intelligence?": answer: it shows behavioural equivalence in conversation, which is evidence of intelligence under a behaviourist definition, but it is neither necessary (a superintelligent system might fail by being too fast and accurate) nor sufficient (ELIZA-style trickery). Conclude that AI moved on to the rational-agent definition for exactly this reason.

Agents, rationality and PEAS

An agent is anything that perceives its environment through sensors and acts upon that environment through actuators. The percept sequence is the complete history of everything the agent has perceived. An agent function maps every percept sequence to an action; the agent program is its concrete implementation running on the architecture.

Agent = Architecture + Program f: P* → A (agent function: percept sequences to actions)
AGENT Sensors Actuators Agent program ENVIRONMENT percepts actions
Fig 1.2: Agent-environment interaction. Draw this once at the top of any agent question.

Rational agent

Definition: For each possible percept sequence, a rational agent selects the action that is expected to maximise its performance measure, given the evidence provided by the percept sequence and whatever built-in knowledge the agent has.

Four things rationality depends on: examiners look for this list
  1. The performance measure that defines success.
  2. The agent's prior knowledge of the environment.
  3. The actions available to the agent.
  4. The agent's percept sequence to date.

Rational is not the same as omniscient (rationality maximises expected not actual performance), not the same as perfect, and not the same as clairvoyant. A rational agent must also explore, learn, and be autonomous: relying on its own percepts rather than only on the designer's prior knowledge.

PEAS: how to specify a task environment

Before designing an agent you specify Performance measure, Environment, Actuators, Sensors. Always answer PEAS questions as a table.

AgentPerformance measureEnvironmentActuatorsSensors
Part-picking robotPercentage of parts placed in the correct bin; parts per hour; damage rateConveyor belt with parts; bins; factory floorJointed arm, gripper/suction hand, wheels or rail motorCamera, joint-angle sensors, force/tactile sensors, proximity sensor
Automated carSafe, fast, legal, comfortable trip; fuel economy; passenger satisfactionRoads, traffic, pedestrians, weather, traffic signals, customersSteering, accelerator, brake, indicator, horn, display/voiceCameras, LIDAR, RADAR, GPS, speedometer, odometer, accelerometer, engine sensors
Medical diagnosis systemHealthy patient, minimised cost, avoidance of lawsuitsPatient, hospital, staffScreen display of questions, tests, diagnoses, treatmentsKeyboard entry of symptoms, findings, patient answers
Vacuum cleaner agentCleanliness, energy used, time taken, noiseRoom, dirt, obstacles, floor typeWheels, brushes, suction, vacuum extractorDirt sensor, bump/cliff sensor, camera, wall sensor

Types of intelligent agents

Five types, in increasing order of capability. Every one of them has appeared in a paper. Learn the one-line definition, the diagram, and a named example for each.

1. Simple reflex agent

Selects an action using only the current percept, ignoring the percept history, through condition-action rules of the form if condition then action. Works only if the environment is fully observable; otherwise it gets stuck in infinite loops. Example: a thermostat; a vacuum agent whose rule is "if dirty then suck else move".

Simple reflex agent Sensors What the world is like now Condition-action rulesif dirty then suck Actuators ENVIRONMENT
Fig 1.3: Simple reflex agent. No internal state, no memory of past percepts.

2. Model-based reflex agent

Maintains internal state: a model of the world, so it can handle a partially observable environment. The model answers two questions: how the world evolves independently of the agent, and how the agent's own actions affect the world. Example: a robot vacuum that remembers which rooms it has already cleaned; a car that remembers a vehicle it saw a moment ago and is now in its blind spot.

Model-based reflex agent Sensors What the world is like now State+ Model Condition-action rules Actuators state feeds back into decisions ENVIRONMENT
Fig 1.4: Model-based reflex agent. The extra block is the internal state updated by a model of the world.

3. Goal-based agent

Keeps internal state and explicit goal information describing desirable situations. It asks "what will happen if I do action A, and does that bring me closer to the goal?": this requires search and planning (all of Unit 2). Slower and less efficient than a reflex agent, but far more flexible: change the goal and the behaviour changes without rewriting rules. Example: a route-finding car agent told to reach Pokhara; a chess program aiming at checkmate.

4. Utility-based agent

Goals give only a binary distinction, happy or unhappy. A utility function maps a state (or a sequence) to a real number measuring degree of happiness, so the agent can choose between conflicting goals (speed versus safety) and weigh uncertain outcomes by expected utility. Example: a taxi choosing between a fast risky route and a slow safe one; an airline pricing engine.

"How does a goal-based agent differ from a utility-based agent?": the answer they want
CriterionGoal-basedUtility-based
Decision basisBinary: does this state satisfy the goal?Continuous: how good is this state, numerically?
Conflicting goalsCannot trade offTrades off via utility weights
UncertaintyPoorly handledMaximises expected utility over outcome probabilities
Multiple solutionsAny goal-satisfying path is acceptablePicks the best-quality path
ComplexitySimpler, needs only goal testNeeds a full utility function; harder to design
ExampleGPS that finds a route to the destinationGPS that balances time, tolls, fuel and traffic risk

5. Learning agent

Any of the above can be turned into a learning agent. Four components: this list is the answer to "explain learning agents":

  1. Performance element: selects external actions; this is the whole agent we described so far.
  2. Critic: observes the environment through a fixed performance standard and tells the learning element how well the agent is doing.
  3. Learning element: makes improvements to the performance element using the critic's feedback.
  4. Problem generator: suggests exploratory actions that are suboptimal now but lead to informative experiences (this is how the agent avoids getting stuck in a local habit).
Learning agent Critic Learning element Performance element Problemgenerator feedback changes suggestions performance standard fixes what "good" means ENVIRONMENT
Fig 1.5: Learning agent. Critic → learning element → performance element, with the problem generator forcing exploration.

Properties of task environments

Asked as "discuss rational agent with its various task environment". Give all seven pairs, each with a one-line definition and an example, then classify one environment (chess, taxi driving) against all seven as a closing table.

PropertyMeaningExample
Fully vs partially observableDo the sensors give access to the complete state of the environment at each point?Chess (fully) vs taxi driving / poker (partially)
Single-agent vs multi-agentIs another entity's behaviour maximising a performance measure that depends on our actions? Multi-agent splits into competitive and cooperative.Crossword (single) vs chess (competitive) vs taxi driving (partly cooperative)
Deterministic vs stochasticIs the next state completely determined by the current state and the action? (If it is deterministic except for other agents, we call it strategic.)Chess (deterministic) vs taxi driving, dice games (stochastic)
Episodic vs sequentialIs experience divided into independent episodes, or does the current action affect all future decisions?Defect-spotting on an assembly line (episodic) vs chess, driving (sequential)
Static vs dynamicCan the environment change while the agent is deliberating? (Semi-dynamic: environment fixed but score changes with time, chess with a clock.)Crossword (static) vs taxi driving (dynamic)
Discrete vs continuousAre states, time, percepts and actions finite and distinct, or continuously varying?Chess (discrete) vs taxi driving (continuous)
Known vs unknownDoes the agent know the "laws of physics" / outcomes of actions? This is about the agent's knowledge, not about observability.Solitaire with published rules (known) vs a new video game (unknown)
The closing line that earns the last mark

"The hardest case is a partially observable, multi-agent, stochastic, sequential, dynamic, continuous and unknown environment: automated taxi driving is exactly this, which is why it is still unsolved."

Human intelligence vs machine intelligence

BasisHuman intelligenceMachine intelligence
OriginBiological, evolved; carried by neuronsEngineered; programs on silicon
LearningFrom few examples, by experience, analogy and transferNeeds large labelled datasets; transfers poorly across domains
Speed & precisionSlow, error-prone in computationExtremely fast, exact, tireless
AdaptabilityGeneral; adapts to entirely new situationsNarrow; degrades outside its training distribution
Creativity & common sensePresentLimited; no genuine common-sense understanding
Emotion & ethicsIntrinsic; social and moral judgementSimulated at best; ethics must be imposed externally
MemoryAssociative, lossy, reconstructiveExact, unlimited, retrievable
FatigueTires, needs restContinuous operation

Applications of AI to list in that same question: healthcare diagnosis and imaging, autonomous vehicles, natural language assistants and machine translation, fraud detection and credit scoring, recommendation systems, robotics and manufacturing, agriculture (crop and pest detection), weather and disaster prediction, expert systems, computer vision and biometrics, game playing.

↑ contents
Unit 2

Problem Solving and Searching

State space, uninformed and informed search, heuristics, A*, local search, adversarial search, constraint satisfaction, optimisation.

9 hrs · 20-30 marks

Problem solving as search

A goal-based agent solves a problem by deciding on a goal, formulating the problem, searching for a sequence of actions that reaches the goal, and then executing it. Formulating the problem means writing down five things, memorise this list, it is the standard opener for the whole unit:

  1. Initial state: where the agent starts. In(Kathmandu).
  2. Actions: ACTIONS(s) returns the set of actions applicable in state s.
  3. Transition model: RESULT(s, a) returns the state reached. Together, the initial state, actions and transition model define the state space, drawn as a graph whose nodes are states and edges are actions.
  4. Goal test: decides whether a state is a goal state.
  5. Path cost: a numeric cost for each path; step cost c(s, a, s′) is the cost of one action. The solution is a path from initial to goal; the optimal solution is the one with the lowest path cost.
Standard example to use in any state-space answer

8-puzzle: States = the 9! /2 = 181,440 reachable arrangements of eight tiles and a blank. Initial state = any given configuration. Actions = move blank Up, Down, Left, Right. Goal test = tiles in order. Path cost = 1 per move. Water-jug and the vacuum world (2 locations × dirt states = 8 states) are equally acceptable and quicker to draw.

How every search algorithm is judged

CriterionQuestion it answers
CompletenessIf a solution exists, is the algorithm guaranteed to find it?
OptimalityDoes it find the least-cost solution?
Time complexityHow many nodes are generated? Expressed with b = branching factor, d = depth of shallowest solution, m = maximum depth of the tree.
Space complexityHow many nodes must be kept in memory at once?

Uninformed (blind) search

No information beyond the problem definition, the algorithm cannot tell a promising state from a hopeless one. It only knows whether a state is a goal.

1 2 3 4 5 6 7 8 9 1 2 7 3 4 8 9 5 6 Breadth-first: level by level Depth-first: branch to the bottom first
Fig 2.1: Numbers show the order in which nodes are expanded. Draw exactly this to answer "compare BFS and DFS".

Breadth-first search (BFS)

Expands the shallowest unexpanded node first. Implemented with a FIFO queue. Complete; optimal only when every step cost is equal; time and space O(bd). Its fatal flaw is memory: it keeps every node of the frontier.

Uniform cost search (UCS)

Expands the node with the lowest path cost g(n), using a priority queue. It is BFS generalised to unequal step costs. Complete and optimal for any non-negative step costs. Complexity O(b1+⌊C*/ε⌋) where C* is the optimal cost and ε the smallest step cost. UCS = A* with h(n) = 0: say this and you get the comparison mark free.

Depth-first search (DFS)

Expands the deepest node first, using a LIFO stack (or recursion). Space is only O(bm), which is its one great virtue. Not complete (infinite loops on cycles or infinite depth) and not optimal. Time O(bm) which can be far worse than BFS when m ≫ d.

Depth-limited search (DLS)

DFS with a cut-off depth ℓ. Fixes the infinite-path problem but becomes incomplete if ℓ < d, and is non-optimal. Time O(b), space O(bℓ).

Iterative deepening search (IDS)

Runs DLS with ℓ = 0, 1, 2, … until a goal is found. The best uninformed method: it combines DFS's O(bd) memory with BFS's completeness and optimality (for unit costs). Repeating the shallow levels costs little because the bottom level dominates the node count, for b = 10, d = 5, IDS generates about 123,456 nodes against BFS's 111,111, an overhead of only ~11%.

Bidirectional search

Runs two simultaneous searches, forward from the initial state and backward from the goal, stopping when the frontiers meet. Time and space fall from O(bd) to O(bd/2), an enormous saving. Requires the goal state to be explicitly known and the actions to be reversible, and the meeting check itself costs memory.

StrategyComplete?Optimal?TimeSpaceData structure
Breadth-firstYes (finite b)Yes, if equal step costsO(bd)O(bd)FIFO queue
Uniform costYesYesO(b1+⌊C*/ε⌋)samePriority queue on g(n)
Depth-firstNoNoO(bm)O(bm)LIFO stack
Depth-limitedNo (if ℓ < d)NoO(b)O(bℓ)Stack + limit
Iterative deepeningYesYes, if equal step costsO(bd)O(bd)Stack, repeated
BidirectionalYesYes (with BFS both ways)O(bd/2)O(bd/2)Two queues
Greedy best-firstNoNoO(bm)O(bm)Priority queue on h(n)
A*YesYes, if h admissibleExponentialExponential: the drawbackPriority queue on f(n)
Memorise this table

"Compare BFS/DFS/UCS/A*" is a recurring 10-mark question and this table plus Fig 2.1 plus one worked example is a complete answer. Note the two facts examiners check: DFS is the only one with linear memory, and BFS is optimal only for uniform step costs.

Informed (heuristic) search

Heuristic function h(n) = the estimated cost of the cheapest path from node n to a goal state, with h(goal) = 0. It injects problem-specific knowledge so the search can prefer promising branches. A heuristic is:

  • Admissible if it never overestimates: h(n) ≤ h*(n), the true remaining cost. Admissibility is what makes A* optimal in tree search.
  • Consistent (monotonic) if for every node n and successor n′, h(n) ≤ c(n, a, n′) + h(n′), the triangle inequality. Consistency implies admissibility and makes A* optimal for graph search.

Where heuristics come from: relax the problem. In the 8-puzzle, if a tile could move anywhere you get h₁ = number of misplaced tiles; if it could move to any adjacent square you get h₂ = total Manhattan distance. Both are admissible, and h₂ dominates h₁ (h₂ ≥ h₁ everywhere), so h₂ expands fewer nodes. Other sources: pattern databases, subproblem costs, and learning from experience.

"Define heuristics: significance, types, challenges": a full-marks structure

Significance: reduces the effective branching factor, turns intractable exponential search into feasible search, guides towards the goal.
Types: admissible vs non-admissible; consistent vs inconsistent; dominating heuristics; exact vs relaxed-problem-derived; domain-specific (Manhattan distance, straight-line distance, misplaced tiles, number of attacking pairs in 8-queens).
Challenges: designing one is domain expertise, not algorithmic; a good heuristic costs time to compute (there is a trade-off between accuracy and cost); inadmissible heuristics break optimality; heuristics can mislead into local optima (greedy search); memory still grows exponentially in A*.

Greedy best-first search

Evaluation function f(n) = h(n). Expands the node that looks closest to the goal. Fast and memory-light in practice, but incomplete (can loop) and not optimal, the classic failure is Arad→Sibiu→Fagaras→Bucharest, which greedy finds but which is 32 km longer than the route through Rimnicu Vilcea and Pitesti.

A* search: the most examined algorithm in this syllabus

f(n) = g(n) + h(n) g(n) = actual cost of the path from the start node to n h(n) = estimated (heuristic) cost from n to the goal f(n) = estimated cost of the cheapest solution through n

Algorithm: write these steps, then trace the table:

  1. Put the start node in OPEN with f = g + h; CLOSED is empty.
  2. If OPEN is empty, stop and report failure.
  3. Remove from OPEN the node n with the smallest f(n) and move it to CLOSED.
  4. If n is the goal, stop; trace parent pointers back to give the solution path and cost.
  5. Otherwise generate the successors of n. For each successor n′, compute g(n′) = g(n) + c(n, n′) and f(n′) = g(n′) + h(n′).
  6. If n′ is new, add it to OPEN. If it is already in OPEN or CLOSED with a larger g, update its g and parent (re-open it if necessary); otherwise discard it.
  7. Go to step 2.
Properties to state after the algorithm
  • Complete (if b is finite and step costs exceed some ε > 0).
  • Optimal if h is admissible (tree search) or consistent (graph search).
  • Optimally efficient: no other optimal algorithm using the same heuristic is guaranteed to expand fewer nodes than A*. Proof sketch: any algorithm that does not expand all nodes with f(n) < C* risks missing an optimal solution, because such a node might lie on an optimal path; A* expands exactly those nodes.
  • Drawback: it keeps every generated node in memory, so space is exponential, A* runs out of memory long before it runs out of time. Remedies: IDA*, RBFS, SMA*, memory-bounded and weighted A*.
S 1 2 3 4 5 6 7 341 455 243 GOAL h: S=15, 1=14, 2=10, 3=8, 4=12, 5=10, 6=10, 7=0 · shaded path = solution found by A*
Fig 2.2: The 2018 Fall A* graph. Fully solved, with the OPEN/CLOSED table, in the solved questions.

Local search and optimisation

When the path to the goal is irrelevant and only the final state matters (8-queens, timetabling, VLSI layout), keep a single current state and move to a better neighbour. Memory is constant, and the state space may be infinite.

Hill climbing

A loop that continually moves in the direction of increasing value and terminates when no neighbour is higher. It is "greedy local search": it never looks beyond the immediate neighbours, keeps no search tree, and is sometimes described as trying to climb Everest in thick fog while suffering from amnesia.

Variants: Simple hill climbing (take the first better neighbour), steepest-ascent (evaluate all neighbours, take the best), stochastic (choose randomly among uphill moves), first-choice (generate successors randomly until a better one appears, good for many successors), random-restart (run hill climbing from random initial states until a goal is found; this one is complete with probability approaching 1).

local maximum global maximum plateau / shoulder ridge state space → objective value
Fig 2.3: The three failure modes of hill climbing. This single figure answers "explain hill climbing with its problems".
ProblemWhat happensSolution
Local maximumA peak higher than its neighbours but lower than the global maximum; the algorithm halts there.Random-restart hill climbing; simulated annealing; backtracking to an earlier promising node.
Plateau / shoulderA flat region where all neighbours have the same value, so search has no direction and wanders.Allow a limited number of sideways moves; take a big jump; random restart.
RidgeA sequence of local maxima along a slope that is not directly climbable by single moves, every single move goes downhill.Move in several directions at once (compound moves); use a different operator set; stochastic hill climbing.

Simulated annealing fixes all three by occasionally accepting a worse move with probability eΔE/T, where T (temperature) is lowered over time. At high T it explores almost randomly; as T → 0 it becomes ordinary hill climbing. If the schedule lowers T slowly enough it finds the global optimum with probability approaching 1. Local beam search keeps k states instead of one; genetic algorithms are beam search with sexual recombination.

Adversarial search: min-max and alpha-beta

In a two-player, zero-sum, perfect-information game (chess, tic-tac-toe), one player MAX tries to maximise the score and the opponent MIN tries to minimise it. The min-max algorithm computes the value of each node by a depth-first exploration to a terminal (or cut-off) depth, then backs values up: MAX nodes take the maximum of their children, MIN nodes the minimum. It assumes the opponent plays optimally, which is why it is suitable for chess: the resulting move is the best achievable against a perfect opponent. Complete and optimal on finite trees; time O(bm), space O(bm).

MAX 3 MIN 3 MIN 2 3 6 2 X 3 12 6 8 2 ✕ = pruned by alpha-beta, never evaluated
Fig 2.4: Min-max with alpha-beta pruning. Root value 3; once MIN on the right is known to be ≤ 2, the rest of that subtree cannot affect the root.

Alpha-beta pruning keeps two bounds along the current path: α = the best (highest) value MAX can guarantee so far, β = the best (lowest) value MIN can guarantee. Prune a branch when α ≥ β, because that branch can never influence the final decision.

Advantages of alpha-beta over plain min-max
  • It returns exactly the same move as min-max: pruning loses nothing.
  • With perfect move ordering, time drops from O(bm) to O(bm/2), so the program can search roughly twice as deep in the same time. Random ordering gives about O(b3m/4).
  • It saves memory and evaluation-function calls, enabling real-time play.

Why the AI still struggles against aggressive human players (a 2024 question): the evaluation function is imperfect at the cut-off depth, unexpected sacrifices push the real consequence beyond the horizon (the horizon effect), and min-max assumes an optimal opponent so it plays conservatively. Fixes: quiescence search, iterative deepening with move ordering, transposition tables, opponent modelling, and learned evaluation functions.

Constraint Satisfaction Problems (CSP)

Definition: A CSP is defined by three components:

  1. X: a set of variables {X₁ … Xₙ}.
  2. D: a set of domains {D₁ … Dₙ}, one per variable, listing its allowed values.
  3. C: a set of constraints specifying allowed combinations of values.

A state is an assignment of values to some variables; it is consistent if it violates no constraint, complete if every variable is assigned, and a solution if it is both. The key idea is that the goal test is decomposed into constraints, so the solver can prune whole regions of the space at once instead of treating states as black boxes.

Types of constraints: unary (one variable: SA ≠ green), binary (two variables, SA ≠ WA), higher-order/global (Alldiff, the cryptarithmetic column sums), and preference/soft constraints (turned into an optimisation problem). Examples: map colouring, N-queens, Sudoku, timetable scheduling, job-shop scheduling, crypt-arithmetic.

Solving techniques to name: backtracking search (depth-first, one variable at a time); forward checking (delete inconsistent values from neighbours' domains immediately); constraint propagation / arc consistency (AC-3); and the ordering heuristics: MRV (minimum remaining values: pick the most constrained variable), degree heuristic (tie-break on the variable involved in most constraints), LCV (least constraining value: pick the value that rules out fewest choices for neighbours). Local search with the min-conflicts heuristic solves million-queens problems in seconds.

Crypt-arithmetic: the guaranteed 10 marks

Every paper since 2018 contains one. It is a CSP: variables are the letters, domains are {0…9}, constraints are all letters have different digits, no leading letter is zero, and one column-sum equation with carries per column.

The seven "necessary conditions" to write before solving, worth 3 marks on their own
  1. Each letter stands for exactly one digit, 0-9.
  2. Each digit is used by at most one letter (Alldiff).
  3. No leading letter of any word may be 0.
  4. The arithmetic must hold column by column, from the units column leftwards.
  5. Each column carry cᵢ ∈ {0, 1} for addition of two numbers (0, 1 or 2 for three addends).
  6. If the sum has one more digit than the longest addend, that extra leading digit must be the final carry, so it is 1.
  7. The solution must be verified by substituting back into the original sum.

The method, in the order you should write it

  1. Write the sum in column form, label columns from the right as c₁, c₂, … and mark the carries.
  2. Fix the forced digits first: the leading digit of a longer answer is 1; letters that repeat across columns give the strongest equations.
  3. Write one algebraic equation per column, of the form (digit + digit + carry-in) = result digit + 10 × carry-out.
  4. Substitute known values and reason about parity and ranges to narrow the domains, this is constraint propagation.
  5. Only when the domains are small, try candidates (backtracking); reject any that repeat a digit.
  6. Verify by full addition and state the mapping in a table.

All seven crypt-arithmetic problems set at PU, EAT+THAT, ODD+ODD, GO+TO, NINA+SING, LOGIC+LOGIC, WRONG+WRONG and BASE+BALL, are solved step by step in the solved questions section.

Genetic algorithms

Definition: A genetic algorithm is a randomised, population-based search and optimisation technique inspired by Darwinian natural selection, in which candidate solutions encoded as chromosomes are evaluated by a fitness function and evolved through selection, crossover and mutation over successive generations.

Why "the study of genes is an important part of AI", the justification asked in 2018

Because evolution is an existence proof of a search algorithm that produced intelligence itself, and because it gives AI a general-purpose optimiser for problems where the search space is huge, discontinuous, noisy or has no usable gradient: neural network weight and architecture optimisation, feature selection, timetabling, TSP and routing, VLSI layout, game strategy evolution, robot controllers. Unlike hill climbing, a GA maintains a population, so it escapes local optima; unlike exhaustive search, it samples the space intelligently.

Steps of a genetic algorithm

  1. Encoding / representation. Represent a candidate solution as a chromosome, usually a binary string, but permutations or real vectors are also used.
  2. Initialise population. Generate N random chromosomes.
  3. Fitness evaluation. Score each chromosome with a fitness function f(x) that measures how good that solution is.
  4. Selection. Choose parents with probability related to fitness, roulette-wheel, tournament, rank or elitist selection.
  5. Crossover (recombination). With probability pc (typically 0.6-0.9) pick a crossover point and swap the tails of two parents to make two offspring. Variants: single-point, two-point, uniform.
  6. Mutation. With a small probability pm (typically 0.001-0.01) flip a bit, to maintain diversity and reintroduce lost alleles.
  7. Replacement. Form the new generation, usually keeping the best individuals (elitism).
  8. Termination. Stop when the fitness converges, an optimal solution is found, or a generation limit is reached. Return the fittest chromosome.
Initialpopulation Fitnessevaluation Selection Crossover Mutation Best solution new generation, repeat until termination criterion is met if converged / max generations
Fig 2.5: The genetic algorithm cycle. Draw this, then work the numerical example below.
Worked example to reproduce in the exam, maximise f(x) = x² for x ∈ [0, 31]

Encoding: 5-bit binary, so 01101 = 13. Population (N = 4): 01101 (13), 11000 (24), 01000 (8), 10011 (19).

Chromosome x f(x)=x² share of total 01101 13 169 14.4% 11000 24 576 49.2% 01000 8 64 5.5% 10011 19 361 30.9% ------- total 1170 100%

Selection (roulette wheel): 11000 and 10011 are most likely to be picked; 01000 is likely to die out. Suppose we pick 01101, 11000, 11000, 10011.

Crossover after bit 4 on pair (0110|1, 1100|0) → offspring 01100 (12) and 11001 (25). Crossover after bit 2 on (11|000, 10|011) → 11011 (27) and 10000 (16).

Mutation: flip one bit of 11011 → 11111 (31).

New generation fitness: 144, 625, 729, 961: total 2459, average risen from 293 to 615, and the optimum x = 31 has appeared. Conclude: "the average fitness improves each generation, which demonstrates the hill-climbing effect of selection combined with the exploration provided by crossover and mutation."

Swarm intelligence, ant colony and particle swarm optimisation

Swarm / collective intelligence is the emergence of global intelligent behaviour from the local interactions of many simple agents with no central control, ants, bees, bird flocks, fish schools. It is used when the search space is large, dynamic and distributed, and when robustness matters more than a guaranteed optimum: routing, scheduling, clustering, robot swarms, feature selection.

Ant Colony Optimisation (ACO)

Real ants deposit pheromone on their path; shorter paths are traversed more often per unit time, so they accumulate pheromone faster, so more ants follow them, a positive feedback loop that converges on the shortest route. Evaporation prevents premature convergence on a bad path.

Algorithm:

  1. Initialise pheromone τij on every edge to a small constant; place m ants on random nodes.
  2. Each ant builds a complete tour, choosing the next node j from i with probability pij = [τij]αij]β ⁄ Σ [τik]αik]β, where ηij = 1/dij is the visibility (heuristic desirability), α weights pheromone and β weights distance.
  3. Evaporate: τij ← (1 − ρ)·τij, with evaporation rate ρ ∈ (0,1).
  4. Deposit: each ant adds Δτ = Q / Lk to the edges of its tour, where Lk is its tour length: shorter tours deposit more.
  5. Record the best tour; repeat from step 2 until the iteration limit or convergence.

Answer to "can search optimisation be performed with swarm intelligence?": yes: ACO solves TSP, vehicle routing, network routing and job scheduling; it is adaptive to changing graphs, inherently parallel and robust to failure of individual agents, at the cost of no optimality guarantee, several parameters to tune (α, β, ρ, Q, m) and slow theoretical convergence.

Particle Swarm Optimisation (PSO)

A population of particles flies through the search space; each remembers its own best position pbest and knows the swarm's best gbest. On each iteration:

vi(t+1) = w·vi(t) + c₁·r₁·(pbesti − xi) + c₂·r₂·(gbest − xi) xi(t+1) = xi(t) + vi(t+1) w = inertia weight c₁ = cognitive coefficient (self) r₁,r₂ ∈ [0,1] random c₂ = social coefficient (swarm)

Steps: initialise positions and velocities randomly → evaluate fitness → update pbest and gbest → update velocity and position by the equations above → repeat until convergence → return gbest. PSO is simpler than a GA (no crossover or mutation, few parameters) and works naturally on continuous problems such as neural network weight tuning.

↑ contents
Unit 3

Knowledge, Logic and Inferencing

Knowledge representation, propositional logic, rules of inference, first-order predicate logic, CNF, resolution, forward and backward chaining.

8 hrs · 20-30 marks

Knowledge and its representation

Knowledge is information about the world in a form that an agent can use to decide what to do: facts, relationships, rules, procedures and heuristics. A knowledge-based agent keeps a knowledge base (a set of sentences in a formal language), TELLs it new percepts, and ASKs it what action to take; the answer follows by inference.

Types of knowledge

  • Declarative: knowing that: facts and assertions. "Kathmandu is the capital of Nepal."
  • Procedural: knowing how: rules, procedures, strategies. "To start the car, turn the key."
  • Meta-knowledge: knowledge about knowledge: which rule to apply, how reliable a source is.
  • Heuristic: rules of thumb from an expert's experience.
  • Structural: knowledge of concepts, relationships and hierarchies between objects.

Knowledge representation schemes

SchemeIdeaStrength / weakness
Logical representationPropositional and first-order logic sentences with formal syntax and semantics.Precise, sound inference; but rigid and can be computationally expensive.
Semantic networkGraph of nodes (objects/concepts) and labelled arcs (relations such as is-a, has-a).Intuitive, inherits properties naturally; but no standard semantics and inefficient for large networks.
FramesA record-like structure of slots and fillers describing a stereotyped object or situation.Organised, supports defaults and inheritance; but inflexible for exceptions.
Production rulesif-then rules operating on working memory, driven by an inference engine.Modular, easy for experts to write, the basis of expert systems; but hard to keep consistent as rules multiply.
ScriptsFrame-like description of a stereotyped sequence of events (the restaurant script).Good for narrative understanding in NLP.

Properties of a good representation: representational adequacy (can express everything needed), inferential adequacy (can derive new knowledge), inferential efficiency (can do so quickly, with guidance), acquisitional efficiency (new knowledge can be added easily).

Animal Bird Sparrow Wings Skin Breathes is-ais-ahas canhas Sparrow inherits "breathes" and "skin" through the is-a links
Fig 3.1: A semantic network. The whole point is property inheritance down is-a links: say this explicitly.

Frames represent the same knowledge as a table of slots and values, which is easier to compute with:

Frame: Sparrow ├─ is-a: Bird ├─ size: small ├─ colour: brown (default) ├─ can-fly: true (inherited, overridable for penguin) └─ eats: seeds, insects

Semantic nets and frames are used in reasoning under uncertainty by attaching certainty factors or probabilities to links and slots, and they underpin ontologies and the knowledge base of an expert system.

Propositional logic

A proposition is a declarative sentence that is either true or false. Symbols P, Q, R combine with connectives ¬ (not), ∧ (and), ∨ (or), → (implies), ↔ (if and only if).

PQ¬PP ∧ QP ∨ QP → QP ↔ Q
TTFTTTT
TFFFTFF
FTTFTTF
FFTFFTT

A sentence is valid (a tautology) if true in every model, satisfiable if true in some model, unsatisfiable if true in none. KB ⊨ α ("KB entails α") means α is true in every model in which KB is true; the whole of logical inference is machinery for deciding entailment. The key identity used by resolution is: KB ⊨ α if and only if (KB ∧ ¬α) is unsatisfiable: this is proof by refutation / contradiction.

Rules of inference: list these in any "rules for inference" question

RuleFormExample
Modus PonensP → Q, P ⊢ Q"If it rains the ground is wet"; it rains ⟹ the ground is wet.
Modus TollensP → Q, ¬Q ⊢ ¬PGround is not wet ⟹ it did not rain.
And-eliminationP ∧ Q ⊢ P:
And-introductionP, Q ⊢ P ∧ Q:
Or-introductionP ⊢ P ∨ Q:
Disjunctive syllogismP ∨ Q, ¬P ⊢ Q:
Hypothetical syllogismP → Q, Q → R ⊢ P → RChaining implications.
ResolutionP ∨ Q, ¬P ∨ R ⊢ Q ∨ RThe single rule needed for a complete proof procedure.
Universal instantiation∀x P(x) ⊢ P(a)FOL only.
Existential instantiation∃x P(x) ⊢ P(k), k a new constantFOL only.

Useful equivalences for rewriting: P → Q ≡ ¬P ∨ Q; P ↔ Q ≡ (P → Q) ∧ (Q → P); De Morgan ¬(P ∧ Q) ≡ ¬P ∨ ¬Q and ¬(P ∨ Q) ≡ ¬P ∧ ¬Q; contraposition P → Q ≡ ¬Q → ¬P; distributivity P ∨ (Q ∧ R) ≡ (P ∨ Q) ∧ (P ∨ R).

Limitations of propositional logic: the reason FOPL exists

It has no way to talk about objects, their properties or relations. To say "all humans are mortal" you must write one proposition per human. It cannot express quantification, cannot generalise, and the knowledge base grows unmanageably. It is also purely declarative and cannot handle uncertainty.

First-order predicate logic (FOPL)

FOPL adds objects, relations and quantifiers to propositional logic.

  • Constants: Ram, Nepal, 3: specific objects.
  • Variables: x, y, z.
  • Predicates: likes(x, y), Student(x): relations returning true/false.
  • Functions: father(x), plus(x, y): return objects, not truth values.
  • Connectives: ¬ ∧ ∨ → ↔ as before.
  • Quantifiers: ∀ (universal, "for all") and ∃ (existential, "there exists").
The two translation rules that decide FOPL marks

∀ goes with →, ∃ goes with ∧.
"Every student is smart" = ∀x student(x) → smart(x). Writing ∀x student(x) ∧ smart(x) claims everything in the universe is a smart student: wrong.
"Some student is smart" = ∃x student(x) ∧ smart(x). Writing ∃x student(x) → smart(x) is trivially satisfied by any non-student, wrong.

Advantages of FOPL: asked directly in 2018

  • Expressive: represents objects, their properties, relations among them, and general rules over all objects, which propositional logic cannot.
  • Concise: one quantified sentence replaces thousands of propositions, so the knowledge base is compact and maintainable.
  • Well-defined syntax and semantics, so inference is sound and complete (resolution refutation).
  • Declarative and modular: knowledge is separate from the inference engine, so new facts can be added without rewriting procedures.
  • It is the basis of logic programming (Prolog) and of the rule bases of expert systems.
  • Supports variables, functions and equality, allowing complex real-world statements.

Propositional vs predicate logic: the comparison table

BasisPropositional logicPredicate logic (FOPL)
Basic unitA whole proposition (P, Q)Objects, predicates, functions, quantified variables
QuantifiersNone∀ and ∃
Expressive powerLow: cannot generalise over objectsHigh: can state general rules over all objects
Ontological commitmentFacts onlyFacts, objects and relations
Knowledge base sizeGrows with the number of objectsCompact and reusable
DecidabilityDecidable (truth tables always terminate)Semi-decidable: proofs of entailment terminate, disproofs may not
Example"Ram is a student" = P (an atom with no internal structure)student(Ram); ∀x student(x) → studies(x)

Unification and substitution

Unification finds a substitution θ that makes two logical expressions identical: UNIFY(p, q) = θ where SUBST(θ, p) = SUBST(θ, q). Example: UNIFY(knows(Ram, x), knows(y, Sita)) gives θ = {y/Ram, x/Sita}. Rules: a variable may bind to any term; two different constants never unify; the occur check forbids binding x to a term containing x. Unification is what lets Generalised Modus Ponens and resolution work on quantified sentences.

Conjunctive Normal Form (CNF)

Definition: A sentence is in CNF when it is a conjunction of clauses, where each clause is a disjunction of literals: (A ∨ ¬B) ∧ (C ∨ D ∨ ¬E).

"Why is CNF required?": the answer, every time
  • The resolution inference rule operates only on clauses, and resolution is the single rule that is sound and refutation-complete for first-order logic: so every proof procedure needs its input in CNF.
  • CNF is a uniform, standard form: quantifiers and implications are removed, so an automated theorem prover needs to handle only one syntactic shape.
  • Every propositional or first-order sentence has a logically equivalent CNF (equisatisfiable after Skolemisation), so nothing is lost.
  • It makes the search mechanical and machine-friendly: clause sets are just lists of literals, easy to index and match.

The eight steps of CNF conversion

  1. Eliminate ↔: α ↔ β becomes (α → β) ∧ (β → α).
  2. Eliminate →: α → β becomes ¬α ∨ β.
  3. Move ¬ inwards (De Morgan): ¬(α ∧ β) → ¬α ∨ ¬β; ¬(α ∨ β) → ¬α ∧ ¬β; ¬¬α → α; ¬∀x P → ∃x ¬P; ¬∃x P → ∀x ¬P. The result is negation normal form.
  4. Standardise variables apart: rename so that each quantifier uses a unique variable.
  5. Skolemise: remove ∃. An ∃ not inside any ∀ becomes a new constant (a Skolem constant); an ∃ inside ∀x becomes a function of x (a Skolem function), e.g. ∀x ∃y loves(x, y) → ∀x loves(x, F(x)).
  6. Drop universal quantifiers: all remaining variables are implicitly universally quantified.
  7. Distribute ∨ over ∧: (α ∧ β) ∨ γ → (α ∨ γ) ∧ (β ∨ γ).
  8. Flatten and separate clauses, writing each conjunct on its own line.

Both CNF problems that PU has ever set, P → ((Q ∧ ¬R) ↔ S) and "Everyone who loves all animals is loved by someone", are worked out line by line in the solved section.

Resolution and refutation

Resolution rule: from (A ∨ B) and (¬B ∨ C) infer (A ∨ C). The complementary literals B and ¬B cancel. In FOL the literals must first be made identical by unification, and the resulting substitution is applied to the resolvent.

The resolution-refutation procedure: write these five steps every time
  1. Convert all sentences of the knowledge base into FOPL.
  2. Convert each into CNF and list the clauses, numbered.
  3. Negate the goal and convert it to CNF; add it to the clause set.
  4. Repeatedly resolve pairs of clauses containing complementary literals, unifying as needed, adding each resolvent to the set.
  5. If the empty clause □ (NIL) is derived, a contradiction exists, so the negated goal is false and hence the goal is proved. Draw the derivation as a tree.
¬S ∨ ¬G G (¬goal) ¬S S ∨ M M ¬M ∨ C C … then ¬C ⟹ □
Fig 3.2: Resolution refutation tree (the butler-and-maid problem). Always draw the derivation as a tree, it is worth 2-3 marks by itself.

Forward and backward chaining

Both work on Horn clauses (clauses with at most one positive literal, i.e. rules of the form P₁ ∧ P₂ ∧ … → Q), which is why they are efficient enough for real expert systems.

Forward chaining (data-driven) starts from the known facts, finds all rules whose premises are satisfied, adds their conclusions to working memory, and repeats until the goal appears or no new fact can be derived. Backward chaining (goal-driven) starts from the goal, finds rules that conclude it, and recursively tries to prove those rules' premises as sub-goals.

Forward chaining: data driven Backward chaining: goal driven Facts Rules fire New facts Goal reached Goal Sub-goals Facts? Proved / failed
Fig 3.3: Direction of reasoning. Forward chaining pushes from facts to conclusions; backward chaining pulls from the goal back to the facts.
BasisForward chainingBackward chaining
DirectionFacts → conclusions (bottom-up)Goal → facts (top-down)
Also calledData-driven, forward deductionGoal-driven, backward deduction
Starts fromAvailable data in working memoryThe hypothesis to be proved
Search strategyBreadth-first in effect; derives everything derivableDepth-first; explores only relevant rules
EfficiencyMay derive many irrelevant facts; slower when only one query mattersFar fewer rules touched; efficient for a specific query
Good forMonitoring, planning, control, design: where new data arrives continuouslyDiagnosis, classification, debugging: where you test a hypothesis
Example systemsCLIPS, Rete-based production systems, DENDRALProlog, MYCIN
Example"It is raining" ⟹ derive "ground wet" ⟹ derive "match cancelled""Is the match cancelled?" ⟹ need "ground wet" ⟹ need "raining" ⟹ check fact
↑ contents
Unit 4

Uncertain Knowledge and Reasoning

Probability, Bayes' rule, belief networks, knowledge engineering for uncertainty, fuzzy logic.

9 hrs · 10-20 marks

Why uncertainty exists, and why logic is not enough

A logical agent must believe a sentence, disbelieve it, or have no opinion. The real world does not cooperate. Consider the medical rule ∀p Toothache(p) → Cavity(p). It is wrong: toothache can be caused by gum disease, an abscess or many other things. Repairing it into Toothache(p) → Cavity(p) ∨ GumProblem(p) ∨ Abscess(p) ∨ … requires an almost unlimited list, which is the qualification problem.

Sources of uncertainty: partial observability (sensors see only part of the world), noisy or faulty sensors, non-deterministic action outcomes, incomplete or contradictory knowledge, theoretical ignorance (no complete theory of the domain exists), practical ignorance (the theory exists but the data is not available for this patient), and vague or imprecise linguistic terms ("tall", "hot").

Approaches to handling uncertainty: name all five

  • Probability theory (Bayesian): degrees of belief in [0, 1], updated by Bayes' rule. The dominant approach; combined with utility it gives decision theory.
  • Fuzzy logic: degrees of truth for vague predicates, not degrees of belief.
  • Certainty factors: the ad-hoc [−1, 1] confidence scores used by MYCIN.
  • Dempster-Shafer theory: belief functions over sets of hypotheses; distinguishes "unknown" from "equally likely".
  • Non-monotonic / default reasoning: conclusions can be retracted when new facts arrive (birds fly, but Tweety the penguin does not).

Basic probability

Axioms (Kolmogorov) 0 ≤ P(A) ≤ 1 P(true) = 1, P(false) = 0 P(A ∨ B) = P(A) + P(B) − P(A ∧ B) P(¬A) = 1 − P(A) Prior (unconditional) P(A) belief before any evidence Posterior (conditional) P(A|B) belief in A given that B is observed Product rule P(A ∧ B) = P(A|B)·P(B) = P(B|A)·P(A) Independence P(A ∧ B) = P(A)·P(B) ⟺ P(A|B) = P(A) Marginalisation P(A) = Σ_b P(A ∧ B=b) Conditioning P(A) = Σ_b P(A|B=b)·P(B=b) Chain rule P(X₁…Xₙ) = Π P(Xᵢ | X₁…Xᵢ₋₁)

Bayes' rule: derive it, then use it

From the product rule: P(A ∧ B) = P(A|B)·P(B) and P(A ∧ B) = P(B|A)·P(A) Equating the two: P(A|B)·P(B) = P(B|A)·P(A) P(B|A) · P(A) likelihood × prior P(A|B) = ───────────────── posterior = ──────────────────── P(B) evidence with the denominator expanded by conditioning (total probability): P(B) = P(B|A)·P(A) + P(B|¬A)·P(¬A)
The five-line template for every Bayes numerical in this paper
  1. Name the events and write the given probabilities as symbols: "Let C = has cancer, + = positive test. Given P(C) = 0.01, P(+|C) = 0.90, P(+|¬C) = 0.08."
  2. State what is asked in symbols: "Required: P(C|+)."
  3. Write Bayes' rule in full with the expanded denominator.
  4. Substitute numbers: do not skip to the answer; the substitution line carries the marks.
  5. Interpret: "Only about 10% of women with a positive mammogram actually have cancer, because the disease is rare and the 8% false-positive rate applies to a much larger population. This is the base-rate fallacy."

That last interpretation sentence is what separates a 7 from a 10.

Bayesian belief networks

Definition: A Bayesian (belief) network is a directed acyclic graph in which each node is a random variable, each directed edge X → Y means "X is a direct cause of / directly influences Y", and each node carries a conditional probability table (CPT) giving P(node | its parents). It is a compact representation of the full joint distribution.

P(x₁, x₂, …, xₙ) = Π P(xᵢ | Parents(Xᵢ)) A full joint table over n boolean variables needs 2ⁿ − 1 numbers. The Burglary network below needs only 10. That compression is the whole point.
Burglary Earthquake Alarm JohnCalls MaryCalls P(B)0.001 P(E)0.002 B E P(A|B,E) T T 0.95 T F 0.94 F T 0.29 F F 0.001 A P(J|A) T 0.90 F 0.05 A P(M|A) T 0.70 F 0.01
Fig 4.1: The burglar-alarm belief network with all conditional probability tables. Reproduce this exactly: it is the 2018 Fall question and the standard textbook example.
Reading the network aloud (write this under the diagram)

Burglary and Earthquake are root nodes with prior probabilities and are independent of each other. Both directly cause the Alarm, so Alarm has a CPT with 2² = 4 rows. John and Mary each hear only the alarm, so they are conditionally independent of Burglary and Earthquake given Alarm. John's 0.05 false-call rate models his confusing the telephone with the alarm; Mary's 0.70 detection rate models her missing the alarm when her music is loud.

Example computation: the probability that the alarm sounds, both call, and there is neither a burglary nor an earthquake:

P(j ∧ m ∧ a ∧ ¬b ∧ ¬e) = P(j|a)·P(m|a)·P(a|¬b,¬e)·P(¬b)·P(¬e) = 0.90 × 0.70 × 0.001 × 0.999 × 0.998 = 0.00062 (about 1 in 1600 nights)

Steps to construct a Bayesian network

  1. Identify the relevant random variables and their domains.
  2. Order the variables so that causes come before effects: a causal order gives the sparsest network.
  3. For each variable in order, choose the minimal set of already-placed variables that directly influence it; draw arrows from those parents.
  4. Write the CPT for each node, 2k rows for k boolean parents. Root nodes get priors.
  5. Check acyclicity, and check that the conditional independence assumptions the graph asserts are actually reasonable.

Inference in belief networks means computing P(query | evidence). Exact methods: inference by enumeration of the joint, and variable elimination (which reuses repeated sub-expressions). Because exact inference is NP-hard in general networks, approximate methods are used: direct sampling, rejection sampling, likelihood weighting and Markov chain Monte Carlo (Gibbs sampling).

Applications: medical diagnosis (Pathfinder), spam filtering, fault and network diagnosis, speech recognition, gene regulatory networks, risk analysis and insurance, image segmentation, troubleshooting wizards, information retrieval. Advantages: compact, encodes causal structure readably, handles missing data, combines expert knowledge with data, supports both diagnostic (effect → cause) and causal (cause → effect) reasoning. Limitations: exact inference is NP-hard; the network structure and CPTs are hard to elicit; it assumes a fixed, acyclic causal structure; poor at continuous variables without discretisation.

Knowledge engineering for uncertain reasoning

The process of building the probabilistic model: (1) decide what to talk about, (2) decide on the vocabulary of random variables, (3) encode general knowledge about dependences, the network topology, (4) encode a description of the specific problem instance as evidence, (5) pose queries and check the answers against expert intuition, (6) debug and refine the model. This mirrors ordinary knowledge engineering but with probabilities rather than hard rules.

Fuzzy logic

Definition: Fuzzy logic, introduced by Lotfi Zadeh in 1965, is a many-valued logic in which the truth value of a proposition is a real number in [0, 1] rather than just 0 or 1. It models vagueness: the fact that predicates like "tall", "hot" or "fast" have no sharp boundary, as opposed to probability, which models likelihood.

The distinction examiners reward

"There is a 0.7 probability that the bottle contains drinkable water" means it is either drinkable or not, and we are 70% sure. "The membership of this water in the fuzzy set drinkable is 0.7" means it is definitely somewhat drinkable, a matter of degree, not of chance.

A fuzzy set A over a universe X is defined by a membership function μA(x) → [0, 1]. Operations: union μA∪B = max(μA, μB); intersection μA∩B = min(μA, μB); complement μ¬A = 1 − μA. Common membership shapes: triangular, trapezoidal, Gaussian, sigmoid.

1.00 temperature (°C) μ(x) Cold Warm Hot x = 22°C is Cold to degree 0.5 and Warm to degree 0.32: both at once 02245
Fig 4.2: Overlapping fuzzy sets. A crisp set would force 22°C into exactly one box; fuzzy membership lets it belong partially to two.

The fuzzy inference system: four blocks

  1. Fuzzification. Convert crisp inputs into degrees of membership in the linguistic sets (22°C → Cold 0.5, Warm 0.32).
  2. Knowledge base / rule base. IF-THEN rules written by an expert in linguistic terms: IF temperature is Hot AND humidity is High THEN fan speed is Fast.
  3. Inference engine. Evaluate each rule: take the min (AND) or max (OR) of the antecedent memberships to get the firing strength, clip or scale the consequent set accordingly, then aggregate all rule outputs by max. (Mamdani method; Sugeno uses a functional consequent.)
  4. Defuzzification. Convert the aggregated fuzzy output back to a crisp number. Methods: centroid / centre of gravity (most common), mean of maxima, weighted average, bisector.
Crispinput Fuzzifier Inferenceengine Rule base Defuzzifier Crispoutput e.g. 22°C → {Cold 0.5, Warm 0.32} → rules fire → aggregated fuzzy set → 47% fan speed
Fig 4.3: Fuzzy inference system. Answering "how can uncertainty be represented using fuzzy logic" = this diagram + the four blocks + the washing-machine example.
The example to write: air conditioner controller

Rules: R1 IF temp is Cold THEN fan is Slow. R2 IF temp is Warm THEN fan is Medium. R3 IF temp is Hot THEN fan is Fast.
Input 22°C fuzzifies to Cold 0.5, Warm 0.32, Hot 0.
R1 fires at 0.5 clipping the Slow set; R2 fires at 0.32 clipping Medium; R3 does not fire.
Aggregate by max, then defuzzify by centroid: fan speed ≈ 47%.
A crisp controller would have jumped from Slow to Medium at a threshold; the fuzzy controller moves smoothly, which is why fuzzy control is used in washing machines, rice cookers, camera autofocus, anti-lock brakes and the Sendai subway.

Advantages: handles vague, linguistic and imprecise knowledge; rules are readable by domain experts; robust to noisy or missing inputs; no exact mathematical model of the plant is needed; smooth, continuous control; simple and cheap to implement in hardware. Limitations: membership functions and rules are chosen by hand with no formal method; not based on probability so it cannot learn from data by itself; validation is difficult; performance degrades as the number of variables (and hence rules) grows.

↑ contents
Unit 5

Learning

Learning models, inductive learning, decision trees, neural networks, backpropagation, reinforcement learning, knowledge in learning.

12 hrs · 20-30 marks

What learning means for an agent

Definition (Mitchell): A computer program is said to learn from experience E with respect to a class of tasks T and performance measure P, if its performance at tasks in T, as measured by P, improves with experience E. In agent terms: learning is any modification of the agent's components that improves its future performance, driven by feedback from the critic.

Three things determine the design of any learning element: which component is being improved, what prior knowledge the agent already has, and what feedback is available. The third determines the type of learning.

Supervised, unsupervised and reinforcement learning

This comparison has appeared in nine of the twelve papers. Learn the table, the three examples, and the diagram.

BasisSupervised learningUnsupervised learningReinforcement learning
FeedbackLabelled data: every input comes with the correct outputNo labels at allDelayed scalar reward or punishment after actions
GoalLearn a mapping f: X → Y that generalises to unseen inputsDiscover hidden structure, groups or associations in the dataLearn a policy π: state → action that maximises cumulative reward
Data(x, y) pairsx onlySequence of (state, action, reward, next state)
Sub-typesClassification (discrete label), Regression (continuous value)Clustering, association rule mining, dimensionality reductionModel-free (Q-learning, SARSA), model-based, policy gradient
AlgorithmsDecision tree, naïve Bayes, KNN, SVM, linear/logistic regression, neural networks, random forestK-means, hierarchical clustering, DBSCAN, PCA, AprioriQ-learning, Deep Q-Network, actor-critic, temporal difference
ExampleSpam / not-spam email filter trained on labelled mail; predicting house price from areaSegmenting bank customers into groups; market-basket analysis "bread ⟹ butter"A robot learning to walk; AlphaGo; a game agent scoring points
DrawbackLabelling is expensive; needs lots of labelled dataNo ground truth, so results are hard to validateNeeds many trials; reward design is difficult; slow convergence

Classification vs regression vs clustering vs association

TaskOutputExample
ClassificationA discrete class labelIs this tumour malignant or benign? Which digit is this image?
RegressionA continuous numberPredict tomorrow's temperature, or a flat's rent from its area.
ClusteringGroups discovered without labelsGroup 10,000 news articles into topics with K-means.
Associationif-then co-occurrence rules with support and confidenceCustomers who buy nappies also buy beer (Apriori on transactions).

Classification vs clustering in one line: classification is supervised and assigns data to predefined classes learned from labelled examples; clustering is unsupervised and discovers the groups itself from similarity, with no labels and no predefined classes.

Inductive learning and learning from observations

Inductive learning is the task of finding a hypothesis h that approximates an unknown target function f, given a training set of examples (x, f(x)). It is induction: reasoning from specific examples to a general rule, so the conclusion is never guaranteed, only supported.

  • Hypothesis space H: the set of functions the learner is allowed to consider. If the true f ∈ H the problem is realisable.
  • Ockham's razor: prefer the simplest hypothesis consistent with the data.
  • Overfitting: the model memorises noise in the training data; training error is tiny but test error is large. Cured by more data, pruning, regularisation, early stopping, dropout, simpler models.
  • Underfitting: the model is too simple to capture the pattern; both errors are high. Cured by a richer model or better features.
  • Validation: split into training / validation / test sets (typically 60/20/20), or use k-fold cross-validation: divide into k folds, train on k−1 and test on the remaining one, rotate, and average. Model selection uses the validation set; the test set is touched only once, at the end.

Decision trees

Definition: A decision tree is a supervised learning model shaped like a flowchart, in which each internal node tests one attribute, each branch is an outcome of that test, and each leaf gives a class label (classification tree) or a value (regression tree). Classification is done by walking from the root to a leaf following the tests, which is exactly how the tree performs inference.

Outlook? Humidity? Wind? No Yes Yes SunnyRain HighNormalWeak Path Sunny → High ⟹ "Don't play tennis". Each root-to-leaf path is one if-then rule.
Fig 5.1: Decision tree for the play-tennis problem. Every root-to-leaf path converts directly to a production rule, which is why trees are called self-explanatory models.

ID3 and information gain: the formulas you must write

ID3 (Iterative Dichotomiser 3, Quinlan 1986) builds the tree top-down, greedily choosing at each node the attribute with the highest information gain, and recursing on each branch until the examples at a node are pure or no attributes remain.

Entropy: impurity of a set S with classes i: H(S) = − Σᵢ pᵢ · log₂ pᵢ Two classes: H(S) = − p₊log₂p₊ − p₋log₂p₋ H = 0 when the set is pure; H = 1 for a 50/50 boolean split. Information gain of attribute A on set S: Gain(S, A) = H(S) − Σ_{v ∈ Values(A)} (|S_v| / |S|) · H(S_v) ↑ entropy before ↑ weighted entropy after the split Split Information / Gain Ratio (C4.5, corrects ID3's bias toward many-valued attributes): SplitInfo(S,A) = − Σ (|S_v|/|S|)·log₂(|S_v|/|S|) GainRatio = Gain / SplitInfo Gini index (CART): Gini(S) = 1 − Σ pᵢ²

Handy logs for the exam: log₂(1/2) = −1, log₂(1/3) = −1.585, log₂(2/3) = −0.585, log₂(1/4) = −2, log₂(3/4) = −0.415, log₂(1/5) = −2.322, log₂(2/5) = −1.322, log₂(3/5) = −0.737, log₂(3/8) = −1.415, log₂(5/8) = −0.678.

ID3 algorithm: write these six steps before any calculation
  1. Compute the entropy H(S) of the current example set with respect to the target attribute.
  2. For every remaining attribute A, split S by A and compute the weighted entropy of the subsets.
  3. Compute Gain(S, A) = H(S) − weighted entropy, for each A.
  4. Choose the attribute with the maximum gain as the decision node.
  5. Recurse on each branch with the remaining attributes and the corresponding subset.
  6. Stop when a subset is pure (make a leaf with that class), or attributes run out (leaf = majority class), or the subset is empty (leaf = majority class of the parent).

Types of decision tree: classification trees (discrete label) and regression trees (continuous value); by algorithm: ID3 (information gain, categorical only), C4.5 (gain ratio, handles continuous attributes and missing values, prunes), CART (Gini index, binary splits, does both classification and regression), CHAID (chi-square).

Significance: easy to understand and to explain to a non-expert (white-box model); needs little data preparation: no normalisation or scaling; handles both numeric and categorical data; fast at prediction time; performs implicit feature selection; converts directly into rules. Limitations: unstable: a small change in data can change the whole tree (high variance); greedy so it does not guarantee the globally optimal tree; strongly prone to overfitting without pruning; biased towards attributes with many values; poor at capturing smooth or linear relations; can be biased if classes are imbalanced.

Pruning combats overfitting: pre-pruning (stop early on a depth, minimum-samples or significance criterion) and post-pruning (grow the full tree, then remove subtrees that do not improve validation accuracy, reduced-error pruning, cost-complexity pruning).

Decision tree vs random forest

BasisDecision treeRandom forest
StructureOne treeAn ensemble of many trees; prediction by majority vote (classification) or average (regression)
Training dataThe whole datasetBagging: each tree is trained on a bootstrap sample, and at each split only a random subset of features is considered
OverfittingHigh riskMuch lower: averaging independent trees cancels their individual variance
AccuracyLower, unstableHigher and far more stable
InterpretabilityFully interpretable: you can read the rulesBlack box; only feature-importance scores are readable
Speed / costFast to train and predictSlower, memory-heavy, but parallelisable
Use whenYou must explain the decision (loan rejection, medical triage)You need accuracy on noisy, high-dimensional data

Example to close with: for credit approval a single tree gives the bank a reason it can quote to the customer; a random forest of 500 trees gives a few percent more accuracy but cannot be explained in a rejection letter.

Evaluating a classifier

Validation approaches: hold-out split, k-fold cross-validation, leave-one-out, stratified sampling (preserves class proportions), and bootstrap. The results go into a confusion matrix.

Actual Positive Actual Negative Predicted Positive TP (true pos) FP (false pos, Type I) Predicted Negative FN (false neg, TN (true neg) Type II) Accuracy = (TP + TN) / (TP + TN + FP + FN) overall correctness Precision = TP / (TP + FP) of those flagged positive, how many really are Recall = TP / (TP + FN) of the real positives, how many we caught Specificity = TN / (TN + FP) F1-score = 2 · Precision · Recall / (Precision + Recall) harmonic mean
The sentence that earns the "analyse the result" mark

"Accuracy alone is misleading on imbalanced data, a model that calls every patient benign scores 95% accuracy on a dataset with 5% cancer. In cancer screening a false negative is far more costly than a false positive, so recall is the metric to optimise, even at the cost of precision."

Neural networks

An artificial neural network is a computing system of simple interconnected processing units (neurons) modelled on the brain, in which knowledge is stored in the weights of the connections and learned by adjusting those weights from data.

The perceptron

Definition: A perceptron (Rosenblatt, 1958) is the simplest neural unit, a single neuron that computes a weighted sum of its inputs plus a bias and passes it through an activation function to produce an output.

net = Σᵢ wᵢxᵢ + b y = f(net) Step activation: y = 1 if net ≥ 0, else 0 Perceptron learning rule: wᵢ ← wᵢ + η(t − y)xᵢ, b ← b + η(t − y) t = target, y = output, η = learning rate
x₁ x₂ x₃ Σ wᵢxᵢ+bthen f( ) y w₁w₂w₃ bias b output Decision boundary: w₁x₁ + w₂x₂ + b = 0, a straight line, hence a linear classifier
Fig 5.2: A perceptron. Label the weights, the summation, the bias and the activation function, unlabelled diagrams do not score.

Activation functions

FunctionFormulaRange / use
Step (threshold)1 if x ≥ θ else 0{0,1}. Original perceptron; not differentiable so it cannot be used with backpropagation.
Linear / identityf(x) = x(−∞,∞). Output layer of a regression network. Stacking linear layers collapses to one linear layer.
Sigmoid (logistic)1 / (1 + e−x)(0,1). Smooth, differentiable: f′ = f(1−f). Used for binary output; suffers from vanishing gradients.
Tanh(ex−e−x)/(ex+e−x)(−1,1). Zero-centred, so it converges faster than sigmoid.
ReLUmax(0, x)[0,∞). Default in deep networks: cheap and avoids vanishing gradients; can "die" for negative inputs (fixed by Leaky ReLU).
Softmaxexᵢ / Σ exⱼProbabilities summing to 1. Output layer for multi-class classification.
Significance of the activation function: the exam answer

It introduces non-linearity. Without it, a network of any depth is just a composition of linear maps, which is itself linear, so the whole network collapses to a single-layer perceptron and can never learn a non-linear boundary such as XOR. It also bounds the output to a usable range and, being differentiable, makes gradient-based learning possible.

Why a perceptron is a linear classifier, and why XOR breaks it

The perceptron fires when w₁x₁ + w₂x₂ + b ≥ 0. That equation defines a straight line (a hyperplane in higher dimensions) that divides the input space into two half-planes. So a perceptron can only represent linearly separable functions. AND, OR and NOT are linearly separable and one perceptron learns each of them. XOR is not: its true points (0,1) and (1,0) lie on one diagonal and its false points (0,0) and (1,1) on the other, so no single straight line separates them.

(0,0)(1,0)(0,1)(1,1) (0,0)(1,0)(0,1)(1,1) OR: one line separates them XOR: no line can
Fig 5.3: Filled circles = output 1, hollow = output 0. Draw both squares side by side, this figure is the answer to the XOR question.

The fix: a multilayer perceptron. XOR = (x₁ OR x₂) AND NOT(x₁ AND x₂), so two hidden neurons, one computing OR, one computing NAND, feeding an AND output neuron solve it. One concrete set of weights: hidden h₁ = step(x₁ + x₂ − 0.5) (OR), h₂ = step(−x₁ − x₂ + 1.5) (NAND), output y = step(h₁ + h₂ − 1.5) (AND). The hidden layer transforms the input space into one in which the classes are linearly separable: that is the whole purpose of hidden layers.

Multilayer perceptron (MLP)

Definition: A feed-forward network with an input layer, one or more hidden layers of non-linear units, and an output layer, fully connected between adjacent layers, with information flowing in one direction and no cycles. With one sufficiently large hidden layer and a non-linear activation, an MLP is a universal approximator: it can approximate any continuous function to arbitrary accuracy.

x₁ x₂ h₁ h₂ h₃ y Input layer Hidden layer Output layer forward pass: compute activations backward pass: propagate error, update weights
Fig 5.4: A 2-3-1 multilayer perceptron with the two phases of backpropagation marked.

Backpropagation

Definition: Backpropagation is the supervised learning algorithm for multilayer networks. It repeatedly (i) propagates an input forward to produce an output, (ii) computes the error against the target, and (iii) propagates that error backwards, using the chain rule of calculus to find the gradient of the error with respect to every weight, then updates each weight by gradient descent.

Error E = ½ Σ (tₖ − oₖ)² Output-layer delta δₖ = oₖ(1 − oₖ)(tₖ − oₖ) [sigmoid] Hidden-layer delta δⱼ = oⱼ(1 − oⱼ) · Σₖ δₖ·wⱼₖ Weight update wᵢⱼ ← wᵢⱼ + η·δⱼ·oᵢ (+ momentum α·Δw_prev) η = learning rate. Too small ⟹ slow; too large ⟹ oscillation.
The seven steps: write these, then do the numerical
  1. Initialise all weights and biases to small random values.
  2. Forward pass: for each layer compute net = Σwx + b and output = f(net), up to the output layer.
  3. Compute the error E = ½Σ(t − o)² at the output.
  4. Compute δ for each output unit.
  5. Backward pass: propagate δ to each hidden unit using the weights above it.
  6. Update every weight by w ← w + η·δ·input.
  7. Repeat for all training patterns (an epoch) until the error falls below a threshold or the epoch limit is reached.
Worked numerical: one full iteration on a 2-2-1 network (η = 1)
Inputs x₁=0.35, x₂=0.9 Target t=0.5 Sigmoid activation Weights: w₁₃=0.1 w₁₄=0.8 w₂₃=0.4 w₂₄=0.6 w₃₅=0.3 w₄₅=0.9 Forward pass net₃ = 0.35(0.1) + 0.9(0.4) = 0.395 o₃ = σ(0.395) = 0.5975 net₄ = 0.35(0.8) + 0.9(0.6) = 0.820 o₄ = σ(0.820) = 0.6943 net₅ = 0.5975(0.3) + 0.6943(0.9) = 0.8041 o₅ = σ(0.8041) = 0.6908 Error = 0.5 − 0.6908 = −0.1908 Backward pass δ₅ = o₅(1−o₅)(t−o₅) = 0.6908 × 0.3092 × (−0.1908) = −0.0408 δ₃ = o₃(1−o₃)·δ₅w₃₅ = 0.5975 × 0.4025 × (−0.0408 × 0.3) = −0.0029 δ₄ = o₄(1−o₄)·δ₅w₄₅ = 0.6943 × 0.3057 × (−0.0408 × 0.9) = −0.0078 Weight update w ← w + η·δ·input w₃₅ = 0.3 + (−0.0408)(0.5975) = 0.2757 w₄₅ = 0.9 + (−0.0408)(0.6943) = 0.8717 w₁₃ = 0.1 + (−0.0029)(0.35) = 0.0990 w₂₃ = 0.4 + (−0.0029)(0.90) = 0.3974 w₁₄ = 0.8 + (−0.0078)(0.35) = 0.7973 w₂₄ = 0.6 + (−0.0078)(0.90) = 0.5930 Repeating the forward pass with the new weights gives o₅ = 0.682, closer to the target 0.5: the error has decreased, as required.

Learning and validation in backpropagation: the dataset is split into training and validation sets. Weights are updated only on the training set; after each epoch the error on the validation set is measured. Training error falls monotonically, but validation error falls and then starts to rise, that turning point is the onset of overfitting, and training is stopped there (early stopping). Cross-validation, regularisation, dropout and momentum are the other standard controls.

When do we need backpropagation? Whenever a network has hidden layers: the perceptron rule only works when the target output of a unit is known, and for hidden units it is not. Backpropagation supplies that missing error signal by the chain rule. Limitations: slow convergence, local minima, vanishing gradients in deep sigmoid networks, sensitivity to the learning rate and initial weights, and the need for large labelled datasets.

Hebbian learning

The oldest learning rule (Donald Hebb, 1949), often summarised as "neurons that fire together, wire together": if two connected neurons are active simultaneously, the strength of the connection between them increases. It is unsupervised: no target output is used.

Δwᵢⱼ = η · xᵢ · yⱼ wᵢⱼ(new) = wᵢⱼ(old) + η·xᵢ·yⱼ

Example. Train a Hebbian unit on the AND function in bipolar form (inputs and targets in {−1, +1}), starting from w₁ = w₂ = b = 0 with η = 1:

x₁ x₂ b t Δw₁=t·x₁ Δw₂=t·x₂ Δb=t w₁ w₂ b 1 1 1 1 1 1 1 1 1 1 1 −1 1 −1 −1 1 −1 0 2 0 −1 1 1 −1 1 −1 −1 1 1 −1 −1 −1 1 −1 1 1 −1 2 2 −2 Final: y = sign(2x₁ + 2x₂ − 2), the correct AND boundary.

Hebbian learning explains associative memory and conditioning (the bell and the food in Pavlov's experiment) and underlies Hopfield networks, but unmodified it grows weights without bound, so practical versions normalise (Oja's rule).

Reinforcement learning in a little more depth

The agent occupies a state s, takes an action a, receives a scalar reward r and moves to s′. It learns a policy π that maximises expected discounted return. The central trade-off is exploration versus exploitation: trying new actions to gather information versus taking the best-known action now (handled by ε-greedy or softmax action selection).

Q-learning update Q(s,a) ← Q(s,a) + α [ r + γ·max_{a′} Q(s′,a′) − Q(s,a) ] α = learning rate, γ = discount factor (how far ahead the agent cares)

Example: a robot in a grid gets +10 for reaching the goal, −10 for a pit and −1 per step; after many episodes the Q-table encodes the shortest safe route. Applications: game playing (AlphaGo, Atari), robot control, self-driving, dynamic pricing, recommendation, traffic-signal control.

Other learning methods worth two marks each

MethodOne-line definition and use
Linear regressionFits y = mx + c by minimising squared error; predicts a continuous value such as house price. Output range (−∞, ∞).
Logistic regressionApplies the sigmoid to a linear combination to output a probability in (0,1) and hence a class. Used for spam detection, disease prediction, credit default. Trained with cross-entropy loss, not squared error.
Naïve BayesApplies Bayes' rule assuming all features are conditionally independent given the class. Fast, works well for text and spam.
K-nearest neighboursLazy learner: classify a point by the majority vote of its k closest training points. No training phase; slow at prediction.
K-means clusteringUnsupervised: pick k centroids, assign each point to the nearest, recompute centroids, repeat until stable.
Support Vector MachineFinds the hyperplane that maximises the margin between two classes; the closest points are the support vectors. The kernel trick (polynomial, RBF) maps data into a higher-dimensional space where it becomes linearly separable. Strong for high-dimensional data such as text and images; slow on very large datasets.
Deep learningNeural networks with many hidden layers that learn a hierarchy of features automatically, removing the need for hand-crafted feature engineering. CNNs for images, RNN/LSTM for sequences, Transformers for language. Needs large data and GPUs, and is a black box.
Ensemble methodsBagging (random forest), boosting (AdaBoost, XGBoost) and stacking combine weak learners into a strong one.

Knowledge in learning

Pure inductive learning starts from a blank slate; in practice an agent already knows a great deal, and prior knowledge makes learning far faster and from far fewer examples. Explanation-based learning (EBL) generalises from a single example by explaining why it worked using background knowledge. Relevance-based learning (RBL) uses knowledge about which attributes matter to cut the hypothesis space. Knowledge-based inductive learning (KBIL) and inductive logic programming (ILP) find hypotheses that, together with background knowledge, explain the observations, allowing the learner to invent new predicates.

↑ contents
Unit 6

Expert Systems and Natural Language Processing

Architecture, components and development of expert systems; the stages of NLP, parse trees and ambiguity.

4 hrs · 10-20 marks

Expert systems

Definition: An expert system is a computer program that uses a knowledge base of human expertise and an inference engine to solve problems within a narrow domain at a level comparable to a human expert, and can explain its reasoning.

Characteristics: high performance in a narrow domain; use of heuristic and judgemental knowledge; separation of knowledge from the inference mechanism; ability to explain why a question is asked and how a conclusion was reached; ability to reason under uncertainty; symbolic rather than numerical reasoning.

EXPERT SYSTEM Knowledge basefacts + IF-THEN rules(domain knowledge) Inference engineforward / backwardchaining + conflict resolution Working memoryfacts about this case Explanation facilitywhy? how? Knowledgeacquisition User interface(dialogue) User Domain expert Knowledge engineer
Fig 6.1: Expert system architecture. The knowledge base and inference engine are the two core components; everything else supports them.

Components: explain each with one line and an example

  1. Knowledge base. The domain knowledge: facts and heuristic IF-THEN production rules acquired from human experts. IF the patient has a fever AND a stiff neck THEN suspect meningitis (CF 0.7). This is what makes the system expert.
  2. Inference engine. The reasoning mechanism that matches rules against the working memory, resolves conflicts when several rules fire (by priority, specificity or recency), and applies forward or backward chaining to reach a conclusion.
  3. Working memory (database of facts). Holds the facts of the current case: this patient's symptoms and test results, and the intermediate conclusions derived so far.
  4. User interface. Lets a non-expert consult the system in near-natural language, asking questions and displaying conclusions.
  5. Explanation facility. Answers "why are you asking this?" and "how did you reach that diagnosis?" by replaying the chain of fired rules. This is essential for user trust and for medical or legal accountability.
  6. Knowledge acquisition subsystem. The tools by which the knowledge engineer adds, edits and validates rules obtained from the domain expert, the main bottleneck in building the system.

People involved: the domain expert (supplies knowledge), the knowledge engineer (elicits and encodes it), the end user (consults the system), and the system builder / tool vendor. Classic systems to name: DENDRAL (chemical structures, the first), MYCIN (bacterial infections, certainty factors, Stanford), XCON/R1 (configuring DEC computers), PROSPECTOR (mineral exploration), CADUCEUS (internal medicine).

Stages in developing an expert system

  1. Problem identification and feasibility. Is the domain narrow, is a human expert available, is the knowledge heuristic rather than algorithmic, is the payoff worth it?
  2. Knowledge acquisition. Interview the expert, observe cases, study manuals; the hardest and slowest stage.
  3. Knowledge representation. Choose rules, frames or logic and formalise the knowledge into that structure.
  4. Design and tool selection. Select a shell (CLIPS, JESS, Prolog) or build from scratch; design the inference strategy and the user interface.
  5. Prototype development. Build a small system covering a core subset of cases.
  6. Testing, verification and validation. Run historical cases; compare conclusions against the expert's; measure accuracy, sensitivity and specificity.
  7. Deployment and user training.
  8. Maintenance and refinement. Update rules as domain knowledge changes; the knowledge base is never finished.
The 2024 case-study question: hospital diagnosis expert system

(i) How components contribute to medical diagnosis: knowledge base holds diagnostic rules from senior doctors; working memory holds this patient's symptoms, history and test results; the inference engine chains rules (backward chaining to test a suspected disease, forward chaining as new test results arrive); the explanation facility justifies the diagnosis so the doctor can accept or override it; knowledge acquisition lets the hospital add new protocols.

(ii) How to evaluate accuracy and reliability: run the system on a large set of retrospective cases with confirmed diagnoses; build a confusion matrix and report accuracy, sensitivity (recall) and specificity; compare against a panel of doctors on the same blinded cases; measure inter-rater agreement (Cohen's kappa); run prospective trials; monitor error and near-miss rates after deployment; check that performance holds across age, sex and disease-prevalence subgroups.

(iii) Ethical and legal concerns: who is liable when the system is wrong, the hospital, the vendor or the doctor; patient data privacy and consent; algorithmic bias against groups under-represented in the training data; the need for explainability and informed consent; automation bias, where doctors defer to the machine; the requirement to keep a human in the loop for final decisions; regulatory approval as a medical device; and clear rules on data ownership and audit trails.

Advantages: preserves scarce expertise and makes it available anywhere, any time; consistent, unbiased and tireless; fast; useful for training juniors; explains its reasoning; can combine the knowledge of several experts. Disadvantages: no common sense or creativity; brittle at the edges of its domain, it fails badly rather than gracefully; expensive and slow to build because of the knowledge-acquisition bottleneck; cannot learn from experience by itself; needs constant maintenance; cannot handle novel situations its rules do not cover. Applications: medical diagnosis, geological prospecting, financial credit and fraud assessment, equipment fault diagnosis, process control, agricultural advice, legal reasoning, configuration and scheduling, helpdesks.

Natural Language Processing

Definition: NLP is the branch of AI concerned with enabling computers to read, understand, interpret and generate human language. It has two halves: natural language understanding (text or speech → meaning) and natural language generation (meaning → text or speech).

Why NLP is difficult: the problems of natural language understanding

  • Ambiguity at every level (below): the central problem.
  • Context dependence: the meaning of "it" or "there" depends on earlier sentences and on the physical situation.
  • Need for world knowledge and common sense: "The trophy did not fit in the suitcase because it was too big", resolving "it" requires knowing about sizes and containers.
  • Idioms, sarcasm, metaphor and humour that cannot be composed from word meanings.
  • Ellipsis and anaphora: omitted words and pronoun references.
  • Language variation: dialect, code-mixing (Nepali-English), spelling errors, new coinages, informal social-media text.
  • Speech-specific problems: homophones, no clear word boundaries in continuous speech, accents, background noise.
  • Resource scarcity for low-resource languages such as Nepali, few annotated corpora, no reliable parsers.

The stages of NLP

Lexical /morphological Syntactic(parsing) Semantic Discourse Pragmatic words → structure → meaning → across sentences → intention in context Preprocessing before stage 1: tokenisation, stop-word removal, stemming and lemmatisation, POS tagging
Fig 6.2: The five levels of NLP. Name all five in order; most students stop at three.
  1. Lexical / morphological analysis. Break the text into tokens, identify word structure, roots, prefixes, suffixes, and assign parts of speech. "unhappiness" → un + happy + ness.
  2. Syntactic analysis (parsing). Check the sentence against the grammar and build a parse tree showing how words group into phrases. "Colourless green ideas sleep furiously" is syntactically valid but semantically nonsense; "the boy the apple ate" is rejected here.
  3. Semantic analysis. Attach meaning to the structure, checking that it is meaningful in the domain. "Hot ice-cream" is rejected at this stage.
  4. Discourse integration. Interpret each sentence in the light of those around it, resolving pronouns and references. "Ram went home. He was tired."
  5. Pragmatic analysis. Interpret intended meaning in the real-world context. "Can you pass the salt?" is a request, not a question about ability.

How a parse tree helps

A parse tree makes the grammatical structure of a sentence explicit, showing which words modify which. This lets the system (i) verify grammaticality, (ii) identify subject, verb and object for meaning extraction, (iii) resolve structural ambiguity by generating one tree per reading, and (iv) feed a systematic, compositional semantic interpretation.

S NP VP Det N V NP Det N Theboyate anapple S → NP VP · NP → Det N · VP → V NP
Fig 6.3: Parse tree for "The boy ate an apple", with the context-free grammar rules used.

Ambiguity in NLP: one example each, and do not mix them up

TypeWhat is ambiguousExample
Lexical / morphologicalA single word has more than one meaning or part of speech, or more than one morphological decomposition"I saw a bat": animal or cricket bat? "Book the ticket": verb or noun? "unlockable": able to be unlocked, or unable to be locked?
Syntactic (structural)The sentence has more than one valid parse tree"I saw the man with a telescope", did I use the telescope, or does he have it? "Old men and women": are the women old?
SemanticThe structure is clear but the meaning still has multiple readings"The car hit the pole while it was moving", which was moving? "Every man loves a woman": the same woman, or one each?
Pragmatic / discourseThe literal meaning is clear but the intended meaning or the reference depends on context"Can you open the window?": request, not a question. "Ram told Shyam that he had passed": who passed?

Applications of NLP: machine translation, chatbots and virtual assistants, sentiment analysis, spam filtering, speech recognition and synthesis, information retrieval and search, text summarisation, question answering, optical character recognition, grammar checking.

↑ contents
Solved

Crypt-arithmetic: all seven PU problems

One of these appears in every paper. Learn the reasoning pattern, not the answers, but knowing the answers lets you check your work in 30 seconds.

Open every crypt-arithmetic answer with this

"This is a Constraint Satisfaction Problem. Variables = the distinct letters; Domain = {0,1,…,9} for each; Constraints = (i) Alldiff on the letters, (ii) no leading letter is zero, (iii) one column equation per column of the form digit + digit + carry-in = result digit + 10 × carry-out, with every carry in {0,1}." Then solve by constraint propagation and backtracking.

Fall 2018 Q4 · Fall 2019 Q3 · Spring 2021 Q4 · Spring 2023 Q3, the most-repeated question in the syllabus
Solve: EAT + THAT = APPLE
Worked solution
E A T + T H A T ------------ A P P L E

1. Fix A and P. The largest possible sum is 999 + 9999 = 10998, and the smallest 5-digit result is 10000. So APPLE lies between 10000 and 10998, which forces A = 1 and P = 0.

2. Rewrite algebraically with A = 1, P = 0:

EAT = 100E + 10(1) + T = 100E + T + 10 THAT = 1000T + 100H + 10(1) + T = 1001T + 100H + 10 APPLE = 10000(1) + 0 + 0 + 10L + E = 10000 + 10L + E Sum: 1002T + 100H + 100E + 20 = 10000 + 10L + E

3. Bound T. The left side is at most 1002T + 900 + 900 + 20. For it to reach 10000 we need 1002T ≥ 8180, so T ≥ 8.17, i.e. T ∈ {8, 9}. If T = 8: 100H + 99E = 1964 + 10L, but the maximum of 100H + 99E is 900 + 891 = 1791 < 1964. So T = 9.

4. Substitute T = 9: 9018 + 100H + 100E + 20 = 10000 + 10L + E, giving

100H + 99E = 962 + 10L with H, E, L ∈ {2,…,8} and all distinct

5. Propagate. Test H from 8 downwards. The right-hand side lies between 962 and 1052, so 100H + 99E must fall in that band:

HRequired 99EEResulting LValid?
8162 + 10LE = 2 → 19810L = 36No, L not an integer
7262 + 10LE = 3 → 29710L = 35No
6362 + 10LE = 4 → 39610L = 34No
5462 + 10LE = 5 → 49510L = 33No
4562 + 10LE = 6 → 59410L = 32No
3662 + 10LE = 7 → 69310L = 31No
2762 + 10LE = 8 → 79210L = 30 → L = 3Yes
Answer: unique

A = 1, P = 0, T = 9, H = 2, E = 8, L = 3

8 1 9 EAT = 819 + 9 2 1 9 THAT = 9219 --------------- 1 0 0 3 8 APPLE = 10038 ✓ verified
Fall 2021 Q4 · Fall 2023 Q2 · 10 marks
Solve: ODD + ODD = EVEN
Worked solution

Note first that ODD + ODD = 2 × ODD, so EVEN is even, the puzzle is self-describing.

O D D + O D D ----------- E V E N columns: units, tens, hundreds, thousands

1. A 3-digit number doubled is at most 1998, and EVEN has 4 digits, so E = 1.

2. Units: 2D = N + 10c₁. Tens: 2D + c₁ = E + 10c₂ = 1 + 10c₂. The left side must end in 1, which is odd, so c₁ must be odd, hence c₁ = 1 and 2D ≥ 10. Then 2D + 1 ≡ 1 (mod 10) ⟹ 2D ≡ 0 (mod 10) ⟹ D = 0 or 5; since 2D ≥ 10, D = 5.

3. With D = 5: units gives N = 10 − 10 = 0; tens gives 2(5) + 1 = 11, so the digit is 1 = E ✓ and c₂ = 1.

4. Hundreds: 2O + c₂ = V + 10c₃, and thousands: c₃ = E = 1. So 2O + 1 = V + 10, i.e. V = 2O − 9, requiring O ≥ 5.

OV = 2O − 9Check against E=1, D=5, N=0
51clashes with E = 1 ✗
63all distinct ✓
75clashes with D = 5 ✗
87all distinct ✓
99clashes with O ✗
Answer: two valid solutions, present both
O=6, D=5, E=1, V=3, N=0 655 + 655 = 1310 ✓ O=8, D=5, E=1, V=7, N=0 855 + 855 = 1710 ✓

Stating that the constraints do not force a unique solution, and giving both, scores higher than giving one and stopping.

Fall 2022, Q4 · 10 marks
Solve: GO + TO = OUT
Worked solution
G O + T O -------- O U T

1. Two 2-digit numbers sum to at most 198, and OUT has 3 digits, so the leading digit O = 1.

2. Units column: O + O = T + 10c₁ ⟹ 1 + 1 = 2, which is less than 10, so c₁ = 0 and T = 2.

3. Tens column: G + T + c₁ = U + 10c₂ ⟹ G + 2 = U + 10c₂. Since the hundreds digit of the answer is O = 1, we need c₂ = 1, so G + 2 = U + 10, i.e. G = U + 8.

4. U = 0 → G = 8 ✓. U = 1 → G = 9, but U would clash with O = 1 ✗. So U = 0, G = 8.

Answer: unique
G=8, O=1, T=2, U=0 8 1 GO = 81 + 2 1 TO = 21 -------- 1 0 2 OUT = 102 ✓ verified
Fall 2022 mid-term Q2 · Fall 2024 mid-term Q3 · 10 marks
Solve: NINA + SING = AGAIN
Worked solution
N I N A + S I N G -------------- A G A I N

1. Two 4-digit numbers sum to at most 19998, so the leading digit A = 1.

2. Write the five column equations (c₁…c₄ are the carries out of each column, right to left):

units: A + G = N + 10c₁ → 1 + G = N + 10c₁ tens: N + N + c₁ = I + 10c₂ hundreds: I + I + c₂ = A + 10c₃ → 2I + c₂ = 1 + 10c₃ thousands: N + S + c₃ = G + 10c₄ ten-thou.: c₄ = A = 1

3. Hundreds column: 2I + c₂ = 1 + 10c₃. The left side is even + c₂ and the right is odd, so c₂ = 1. Then 2I + 1 = 1 + 10c₃ ⟹ 2I = 10c₃. If c₃ = 1 then I = 5; if c₃ = 0 then I = 0.

4. Case c₃ = 1, I = 5: tens gives 2N + c₁ = 5 + 10 = 15, so c₁ = 1 and N = 7. Units then gives 1 + G = 7 + 10 = 17 ⟹ G = 16, impossible. Case rejected.

5. Case c₃ = 0, I = 0: tens gives 2N + c₁ = 0 + 10 = 10, so c₁ = 0 and N = 5. Units: 1 + G = 5 + 0 ⟹ G = 4. Thousands: N + S + c₃ = G + 10c₄ ⟹ 5 + S + 0 = 4 + 10 ⟹ S = 9.

Answer: unique
A=1, I=0, N=5, G=4, S=9 5 0 5 1 NINA = 5051 + 9 0 5 4 SING = 9054 -------------- 1 4 1 0 5 AGAIN = 14105 ✓ verified
Spring 2018, Q3 · 10 marks
Solve: LOGIC + LOGIC = PROLOG
Worked solution

The sum is 2 × LOGIC, so every column is a doubling with carry.

L O G I C + L O G I C ------------------ P R O L O G units: 2C = G + 10a₁ thousands: 2O + a₃ = O + 10a₄ tens: 2I + a₁ = O + 10a₂ ten-thous.: 2L + a₄ = R + 10a₅ hund.: 2G + a₂ = L + 10a₃ hund-thous.: a₅ = P = 1

1. A 5-digit number doubled has at most 6 digits, so P = 1 and a₅ = 1.

2. The thousands column is the key: 2O + a₃ = O + 10a₄ ⟹ O + a₃ = 10a₄. Either a₄ = 1 with O = 10 − a₃ (so a₃ = 1, O = 9), or a₄ = 0 with O = 0 and a₃ = 0.

3. Branch A (O = 9, a₃ = 1, a₄ = 1): the tens column gives 2I + a₁ = 9 + 10a₂; a₂ = 0 forces I = 4, a₁ = 1; then units 2C = G + 10 and hundreds 2G = L + 10 give G = 2C − 10 and L = 4C − 30, so L ≥ 5 needs C ≥ 8.75, i.e. C = 9: but O = 9 already. Contradiction, branch rejected.

4. Branch B (O = 0, a₃ = 0, a₄ = 0):

tens: 2I + a₁ = 0 + 10a₂ ⟹ a₂ = 1, a₁ = 0, I = 5 units: 2C = G + 10a₁ = G ⟹ G = 2C, and C ≤ 4 hund.: 2G + a₂ = L + 0 ⟹ L = 2G + 1 = 4C + 1 ten-th: 2L + a₄ = R + 10 ⟹ R = 2L − 10 = 8C − 8 C = 1 → G=2, L=5 (clashes with I=5) ✗ … also R=0 clashes with O C = 2 → G=4, L=9, R=8 all distinct ✓ C = 3 → G=6, L=13 impossible ✗
Answer: unique
L=9, O=0, G=4, I=5, C=2, P=1, R=8 9 0 4 5 2 LOGIC = 90452 + 9 0 4 5 2 LOGIC = 90452 ------------------ 1 8 0 9 0 4 PROLOG = 180904 ✓ verified
Spring 2019, Q4 · 10 marks
Solve: WRONG + WRONG = RIGHT
Worked solution
W R O N G + W R O N G ------------------ R I G H T units: 2G = T + 10a₁ thousands: 2R + a₃ = I + 10a₄ tens: 2N + a₁ = H + 10a₂ ten-thous.: 2W + a₄ = R (no 6th digit ⟹ no final carry) hund.: 2O + a₂ = G + 10a₃

1. Both numbers have 5 digits and so does the sum, so there is no carry out of the leftmost column: 2W + a₄ = R with R ≤ 9, hence W ≤ 4.

2. Try W = 1. Then R = 2 + a₄. Take a₄ = 0 so R = 2. The thousands column gives 2R + a₃ = I, i.e. I = 4 + a₃. Take a₃ = 1, so I = 5.

3. The hundreds column with a₃ = 1: 2O + a₂ = G + 10. Try a₂ = 0, O = 7 → G = 4. Check the units: 2G = 8 = T + 10a₁ ⟹ a₁ = 0, T = 8. Check the tens: 2N + a₁ = H + 10a₂ = H ⟹ H = 2N, and with N = 3 we get H = 6. All carries are consistent (a₁ = 0, a₂ = 0, a₃ = 1, a₄ = 0).

Answer
W=1, R=2, O=7, N=3, G=4, I=5, H=6, T=8 1 2 7 3 4 WRONG = 12734 + 1 2 7 3 4 WRONG = 12734 ------------------ 2 5 4 6 8 RIGHT = 25468 ✓ verified

Say this in the exam: "This puzzle is under-constrained: eight letters, ten digits and only five column equations, so it has many valid solutions (21 in total). Any assignment satisfying all constraints is acceptable; the one above is verified by direct addition." Examiners accept a different valid answer, but only if you verified it.

Spring/Fall 2022-23, Q3 · 10 marks
Solve: BASE + BALL = GAMES
Worked solution
B A S E + B A L L -------------- G A M E S units: E + L = S + 10c₁ thousands: B + B + c₃ = A + 10c₄ tens: S + L + c₁ = E + 10c₂ ten-thous.: c₄ = G hundreds: A + A + c₂ = M + 10c₃

1. The sum has one more digit than the addends, so G = 1 and c₄ = 1.

2. Add the units and tens equations to eliminate E and S:

(E + L) + (S + L + c₁) = (S + 10c₁) + (E + 10c₂) 2L + c₁ = 10c₁ + 10c₂ 2L = 9c₁ + 10c₂ 2L is even, so 9c₁ must be even ⟹ c₁ = 0, giving 2L = 10c₂. c₂ = 1 ⟹ L = 5 (c₂ = 0 ⟹ L = 0, which then forces E = S, rejected)

3. With c₁ = 0 the units column gives E + 5 = S. The thousands column gives 2B + c₃ = A + 10, and the hundreds column 2A + 1 = M + 10c₃.

4. Try c₃ = 0: then M = 2A + 1 (so A ≤ 4) and 2B = A + 10. A = 4 → B = 7, M = 9. Remaining digits for E and S with S = E + 5 and E, S ∉ {1,4,5,7,9}: E = 3 → S = 8 ✓ (both free).

Answer: unique
B=7, A=4, S=8, E=3, L=5, G=1, M=9 7 4 8 3 BASE = 7483 + 7 4 5 5 BALL = 7455 -------------- 1 4 9 3 8 GAMES = 14938 ✓ verified
↑ contents
Solved

FOPL translation and resolution proofs

Eight knowledge bases, eight refutation proofs. The pattern never changes, so drill it once and it is 10 free marks.

Fall 2018, Q3 · 10 marks
What are the advantages of FOPL? Represent in first-order logic: (a) Every person who buys a policy is smart. (b) No person buys an expensive policy. (c) There is an agent who sells policies only to people who are not insured. (d) Some agents are not loyal. (e) Everyone is loyal to someone.
Worked solution

Advantages of FOPL: see the Unit 3 list: expressiveness, conciseness, sound and complete inference, declarative and modular, basis of Prolog and expert systems.

(a) ∀x [ person(x) ∧ ∃y (policy(y) ∧ buys(x, y)) → smart(x) ] (b) ¬∃x ∃y [ person(x) ∧ policy(y) ∧ expensive(y) ∧ buys(x, y) ] equivalently ∀x ∀y [ person(x) ∧ policy(y) ∧ expensive(y) → ¬buys(x, y) ] (c) ∃x [ agent(x) ∧ ∀y ∀z ( policy(y) ∧ sells(x, y, z) → person(z) ∧ ¬insured(z) ) ] (d) ∃x [ agent(x) ∧ ¬loyal(x) ] (e) ∀x ∃y loyalTo(x, y)
The three traps in this question
  • (a) must use → after ∀, never ∧.
  • (c) the word only reverses the implication: selling implies the buyer is uninsured, not the other way round.
  • (e) the order of quantifiers matters. ∀x ∃y loyalTo(x,y) = everyone is loyal to someone (possibly different people). ∃y ∀x loyalTo(x,y) = there is one person everyone is loyal to. Write the first, and say why.
Fall 2019 Q4 · Fall 2024 mid-term Q5 · 10 marks
Write first-order logic statements: (a) If a perfect square is divisible by a prime p then it is also divisible by the square of p. (b) Every perfect square is divisible by some prime. (c) Anil does not like Chemistry and History. (d) If it is Saturday and warm, then Santosh is in the park. (e) Anything anyone eats and is not killed by is food.
Worked solution
(a) ∀x ∀p [ perfectSquare(x) ∧ prime(p) ∧ divides(p, x) → divides(square(p), x) ] (b) ∀x [ perfectSquare(x) → ∃p ( prime(p) ∧ divides(p, x) ) ] (c) ¬likes(Anil, Chemistry) ∧ ¬likes(Anil, History) (d) saturday ∧ warm → inPark(Santosh) or with a time argument: ∀d [ saturday(d) ∧ warm(d) → inPark(Santosh, d) ] (e) ∀x ∀y [ eats(y, x) ∧ ¬killedBy(y, x) → food(x) ]

The related 2024 knowledge base ("John likes all kinds of food …") in FOPL:

1. ∀x [ food(x) → likes(John, x) ] 2. food(Apple) 3. food(Chicken) 4. ∀x ∀y [ eats(y, x) ∧ ¬killedBy(y, x) → food(x) ] 5. eats(Bill, Peanuts) ∧ alive(Bill) 6. ∀x [ eats(Bill, x) → eats(Sue, x) ] (useful extra rule: ∀x [ alive(x) → ¬killedBy(x, anything) ] )
Spring 2018, Q4 · 10 marks
(a) If the maid stole the jewellery, then the butler wasn't guilty. (b) Either the maid stole the jewellery or she milked the cows. (c) If the maid milked the cows, then the butler got his cream. (d) Therefore, if the butler was guilty, then he got his cream. Prove (d) using resolution.
Worked solution

Step 1: symbols. S = the maid stole the jewellery; G = the butler was guilty; M = the maid milked the cows; C = the butler got his cream.

Premises S → ¬G, S ∨ M, M → C Goal G → C

Step 2: convert to CNF.

1. S → ¬G ≡ ¬S ∨ ¬G 2. S ∨ M (already a clause) 3. M → C ≡ ¬M ∨ C

Step 3: negate the goal and convert.

¬(G → C) ≡ ¬(¬G ∨ C) ≡ G ∧ ¬C 4. G 5. ¬C

Step 4: resolve.

6. from 1 and 4 (¬S ∨ ¬G), G ⟹ ¬S 7. from 2 and 6 (S ∨ M), ¬S ⟹ M 8. from 3 and 7 (¬M ∨ C), M ⟹ C 9. from 5 and 8 ¬C, C ⟹ □ (empty clause)
Conclusion

The empty clause is derived, so KB ∧ ¬goal is unsatisfiable. Hence KB ⊨ (G → C): if the butler was guilty then he got his cream. Draw the derivation as the tree in Fig 3.2.

Spring 2019 Q3 · Fall 2023 Q5 · 10 marks
Represent in FOPL and use resolution: Geeta likes almond. Gita likes all kinds of food. Mango and chapati are food. Gita eats almond and is still alive. Anything eaten by anyone and is still alive is food. Goal: prove that Gita likes almond.
Worked solution

Step 1: FOPL.

1. ∀x [ food(x) → likes(Gita, x) ] 2. food(Mango) 3. food(Chapati) 4. eats(Gita, Almond) 5. alive(Gita) 6. ∀x ∀y [ eats(y, x) ∧ alive(y) → food(x) ] Goal: likes(Gita, Almond)

Step 2: CNF (clause form).

C1. ¬food(x) ∨ likes(Gita, x) C2. food(Mango) C3. food(Chapati) C4. eats(Gita, Almond) C5. alive(Gita) C6. ¬eats(y, x) ∨ ¬alive(y) ∨ food(x) C7. ¬likes(Gita, Almond) ← negated goal

Step 3: resolution with unification.

C8. C7 + C1 with θ = {x/Almond} ⟹ ¬food(Almond) C9. C8 + C6 with θ = {x/Almond} ⟹ ¬eats(y, Almond) ∨ ¬alive(y) C10. C9 + C4 with θ = {y/Gita} ⟹ ¬alive(Gita) C11. C10 + C5 ⟹
Conclusion

Contradiction reached, so the negation of the goal is false and likes(Gita, Almond) is proved. Clauses C2 and C3 (mango, chapati) are never used, say so; recognising irrelevant premises is itself a mark.

Spring 2021, Q3 · 10 marks
Represent in FOPL and use resolution: (i) Ram owns a dog. (ii) Cat is an animal. (iii) Every dog owner is an animal lover. (iv) No animal lover can kill animals. (v) Either Ram or Sita killed a cat. Goal: Who killed the cat?
Worked solution

Step 1: FOPL.

1. ∃x [ dog(x) ∧ owns(Ram, x) ] 2. animal(Cat) 3. ∀x [ ∃y ( dog(y) ∧ owns(x, y) ) → animalLover(x) ] 4. ∀x ∀y [ animalLover(x) ∧ animal(y) → ¬kills(x, y) ] 5. kills(Ram, Cat) ∨ kills(Sita, Cat) Goal: kills(Sita, Cat)

Step 2: CNF. Skolemise the ∃ in (1) with a new constant D (Ram's dog):

C1a. dog(D) C1b. owns(Ram, D) C2. animal(Cat) C3. ¬dog(y) ∨ ¬owns(x, y) ∨ animalLover(x) C4. ¬animalLover(x) ∨ ¬animal(y) ∨ ¬kills(x, y) C5. kills(Ram, Cat) ∨ kills(Sita, Cat) C6. ¬kills(Sita, Cat) ← negated goal

Step 3: resolution.

C7. C3 + C1a θ = {y/D} ⟹ ¬owns(x, D) ∨ animalLover(x) C8. C7 + C1b θ = {x/Ram} ⟹ animalLover(Ram) C9. C4 + C8 θ = {x/Ram} ⟹ ¬animal(y) ∨ ¬kills(Ram, y) C10. C9 + C2 θ = {y/Cat} ⟹ ¬kills(Ram, Cat) C11. C5 + C10 ⟹ kills(Sita, Cat) C12. C11 + C6 ⟹
Conclusion

Sita killed the cat. The reasoning chain in words: Ram owns a dog, therefore Ram is an animal lover; animal lovers do not kill animals, and a cat is an animal, so Ram did not kill the cat; since one of the two did, it must be Sita.

Fall 2022 Q3 · Fall 2024 Q3a · 8-10 marks
Represent in FOPL and use resolution refutation: (i) Shyam only likes easy courses. (ii) Science courses are hard. (iii) All the courses in the Computer Science department are easy. (iv) CS301 is a computer science course. Goal: What course would Shyam like?
Worked solution

Step 1: FOPL. Read "hard" as ¬easy. To be able to derive a liked course we use the reading "Shyam likes exactly the easy courses":

1. ∀x [ easy(x) → likes(Shyam, x) ] (and its converse ∀x[likes(Shyam,x) → easy(x)]) 2. ∀x [ science(x) → ¬easy(x) ] 3. ∀x [ cs(x) → easy(x) ] 4. cs(CS301) Goal: ∃x likes(Shyam, x): answer to be extracted, expected x = CS301

Step 2: CNF.

C1. ¬easy(x) ∨ likes(Shyam, x) C2. ¬science(x) ∨ ¬easy(x) C3. ¬cs(x) ∨ easy(x) C4. cs(CS301) C5. ¬likes(Shyam, CS301) ← negated goal

Step 3: resolution.

C6. C4 + C3 θ = {x/CS301} ⟹ easy(CS301) C7. C6 + C1 θ = {x/CS301} ⟹ likes(Shyam, CS301) C8. C7 + C5 ⟹
Conclusion

Shyam would like CS301. Add the note: "the sentence Shyam only likes easy courses strictly translates as likes(Shyam,x) → easy(x), which alone cannot derive a liked course; the intended knowledge base is the biconditional, so I use easy(x) → likes(Shyam,x) for the proof." That single sentence shows the examiner you understood the logic rather than copying a pattern.

Spring 2023, Q4 · 10 marks
Prove "Krishna is angry" using resolution: (i) Fuchhe is a dog. (ii) Krishna has a dog. (iii) Every dog barks when they are hungry. (iv) Man gets angry when the dog barks. (v) Fuchhe is hungry. (vi) Krishna is a man.
Worked solution
FOPL 1. dog(Fuchhe) 2. owns(Krishna, Fuchhe) 3. ∀x [ dog(x) ∧ hungry(x) → barks(x) ] 4. ∀x ∀y [ man(x) ∧ owns(x, y) ∧ dog(y) ∧ barks(y) → angry(x) ] 5. hungry(Fuchhe) 6. man(Krishna) CNF C1. dog(Fuchhe) C4. ¬man(x) ∨ ¬owns(x,y) ∨ ¬dog(y) ∨ ¬barks(y) ∨ angry(x) C2. owns(Krishna,Fuchhe) C5. hungry(Fuchhe) C3. ¬dog(x) ∨ ¬hungry(x) ∨ barks(x) C6. man(Krishna) C7. ¬angry(Krishna) ← negated goal Resolution C8. C3 + C1 θ={x/Fuchhe} ⟹ ¬hungry(Fuchhe) ∨ barks(Fuchhe) C9. C8 + C5 ⟹ barks(Fuchhe) C10. C4 + C7 θ={x/Krishna} ⟹ ¬man(Krishna) ∨ ¬owns(Krishna,y) ∨ ¬dog(y) ∨ ¬barks(y) C11. C10 + C6 ⟹ ¬owns(Krishna,y) ∨ ¬dog(y) ∨ ¬barks(y) C12. C11 + C2 θ={y/Fuchhe} ⟹ ¬dog(Fuchhe) ∨ ¬barks(Fuchhe) C13. C12 + C1 ⟹ ¬barks(Fuchhe) C14. C13 + C9 ⟹
Conclusion

Contradiction, therefore Krishna is angry is proved.

Spring/Fall 2022-23, Q4 · 10 marks
Prove ¬C using the resolution rule, given: 1. (¬A → ¬B) → ¬B · 2. ¬A → ¬C · 3. C → B
Worked solution

Step 1: convert each premise to CNF. Premise 1 needs care:

¬A → ¬B ≡ A ∨ ¬B (A ∨ ¬B) → ¬B ≡ ¬(A ∨ ¬B) ∨ ¬B ≡ (¬A ∧ B) ∨ ¬B ≡ (¬A ∨ ¬B) ∧ (B ∨ ¬B) distributing ≡ ¬A ∨ ¬B since (B ∨ ¬B) is a tautology 2. ¬A → ¬C ≡ A ∨ ¬C 3. C → B ≡ ¬C ∨ B

Step 2: negate the goal. ¬(¬C) = C.

Step 3: resolve.

C1. ¬A ∨ ¬B C2. A ∨ ¬C C3. ¬C ∨ B C4. C (negated goal) C5. C2 + C4 ⟹ A C6. C3 + C4 ⟹ B C7. C1 + C5 ⟹ ¬B C8. C6 + C7 ⟹
Conclusion

The empty clause is derived, so ¬C is proved.

Fall 2021, Q5 · 10 marks
Show that the hypotheses "It is not sunny this afternoon and it is colder than yesterday", "We will go swimming only if it is sunny", "If we do not go swimming, we will take a cycle trip", "If we take a cycle trip we will be home by sunset" lead to the conclusion "We will be home by sunset", using propositional logic and rules of inference.
Worked solution
Let P = it is sunny this afternoon Q = it is colder than yesterday R = we will go swimming S = we will take a cycle trip T = we will be home by sunset Premises 1. ¬P ∧ Q 2. R → P ("only if" gives this direction) 3. ¬R → S 4. S → T Conclusion T

Proof by rules of inference (write the rule name beside every line):

5. ¬P from 1, Simplification / And-elimination 6. ¬R from 2 and 5, Modus Tollens 7. S from 3 and 6, Modus Ponens 8. T from 4 and 7, Modus Ponens

Alternative by resolution (if the question says "using resolution"): clauses ¬P, Q, ¬R ∨ P, R ∨ S, ¬S ∨ T, plus the negated goal ¬T. Resolve ¬T with (¬S ∨ T) → ¬S; ¬S with (R ∨ S) → R; R with (¬R ∨ P) → P; P with ¬P → □.

Spring/Fall 2022-23, Q5 · 10 marks
Flood prediction system. Rule I: IF continuous rains for the last 3 weeks THEN water level is above danger level. Rule II: IF prediction of rain for next 4 weeks AND water level above danger level THEN chances of over-flooding in rivers. Rule III: IF prediction of heavy clouds for the coming four weeks AND prediction of coming air with heavy concentration of water THEN prediction of rain for next 4 weeks. Facts: there have been continuous rains for the last 3 weeks; in the coming four weeks there are chances of coming air with heavy concentration of water along with heavy clouds. Prove there are chances of over-flooding using forward and backward chaining.
Worked solution
Symbols A = continuous rains for the last 3 weeks (fact) B = water level above danger level C = prediction of rain for the next 4 weeks D = chances of over-flooding in rivers (goal) E = prediction of heavy clouds for coming 4 weeks (fact) F = prediction of air with heavy water concentration (fact) Rules R1: A → B R2: C ∧ B → D R3: E ∧ F → C Facts A, E, F

Forward chaining (data-driven). Start from the facts and fire whatever matches:

Working memory: {A, E, F} Iteration 1: R1 matches (A present) ⟹ add B WM = {A,E,F,B} Iteration 2: R3 matches (E and F present) ⟹ add C WM = {A,E,F,B,C} Iteration 3: R2 matches (C and B present) ⟹ add D WM = {A,E,F,B,C,D} D is the goal ⟹ proved. (R1 could also fire before R3; either order works.)

Backward chaining (goal-driven). Start from the goal and work back:

Goal D? → only R2 concludes D, so prove sub-goals C and B. Sub-goal C? → only R3 concludes C, so prove E and F. E?: a given fact ✓ F?: a given fact ✓ ⟹ C established Sub-goal B? → only R1 concludes B, so prove A. A?: a given fact ✓ ⟹ B established Both sub-goals of R2 hold ⟹ D is proved.
The comparison sentence to close with

"Forward chaining derived every intermediate fact whether or not it was needed; backward chaining touched only the rules relevant to D. On a small rule base the difference is invisible, but in a real flood-warning system with thousands of rules, backward chaining is far cheaper for answering a specific query, while forward chaining is the right choice when new sensor readings stream in continuously and all consequences must be updated."

↑ contents
Solved

CNF conversions, solved

PU has set the same two conversions in 2018, 2019, 2019 Spring and 2023. They are free marks.

Fall 2018 Q5 · Fall 2019 Q5 · Spring 2019 Q5 · Internal 2023 Q4 · 10 marks
Why is conjunctive normal form required? Explain the steps and convert: P → ((Q ∧ ¬R) ↔ S)
Worked solution

Begin with the "why CNF" paragraph from Unit 3 and the eight steps, then:

Step 1: eliminate ↔. α ↔ β ≡ (α → β) ∧ (β → α) P → [ ((Q ∧ ¬R) → S) ∧ (S → (Q ∧ ¬R)) ] Step 2: eliminate → inside the brackets. α → β ≡ ¬α ∨ β P → [ (¬(Q ∧ ¬R) ∨ S) ∧ (¬S ∨ (Q ∧ ¬R)) ] Step 3: move ¬ inwards (De Morgan). ¬(Q ∧ ¬R) ≡ ¬Q ∨ R P → [ (¬Q ∨ R ∨ S) ∧ (¬S ∨ (Q ∧ ¬R)) ] Step 4: distribute ∨ over ∧ in the second conjunct: ¬S ∨ (Q ∧ ¬R) ≡ (¬S ∨ Q) ∧ (¬S ∨ ¬R) P → [ (¬Q ∨ R ∨ S) ∧ (¬S ∨ Q) ∧ (¬S ∨ ¬R) ] Step 5: eliminate the outer →. ¬P ∨ [ (¬Q ∨ R ∨ S) ∧ (¬S ∨ Q) ∧ (¬S ∨ ¬R) ] Step 6: distribute ¬P over the conjunction.
Answer: CNF
(¬P ∨ ¬Q ∨ R ∨ S) ∧ (¬P ∨ ¬S ∨ Q) ∧ (¬P ∨ ¬S ∨ ¬R) Three clauses: C1: ¬P ∨ ¬Q ∨ R ∨ S C2: ¬P ∨ ¬S ∨ Q C3: ¬P ∨ ¬S ∨ ¬R
Fall 2018 Q5(ii) · Fall 2019 Q5(ii) · 5 marks
Transform into CNF: "Everyone who loves all animals is loved by someone."
Worked solution
Step 0: FOPL. ∀x [ ( ∀y animal(y) → loves(x, y) ) → ( ∃y loves(y, x) ) ] Step 1: eliminate → (both of them). ∀x [ ¬( ∀y ¬animal(y) ∨ loves(x, y) ) ∨ ( ∃y loves(y, x) ) ] Step 2: move ¬ inwards. ¬∀y α ≡ ∃y ¬α, then De Morgan: ∀x [ ( ∃y ¬(¬animal(y) ∨ loves(x, y)) ) ∨ ( ∃y loves(y, x) ) ] ∀x [ ( ∃y animal(y) ∧ ¬loves(x, y) ) ∨ ( ∃y loves(y, x) ) ] Step 3: standardise variables apart (the two ∃y are different): ∀x [ ( ∃y animal(y) ∧ ¬loves(x, y) ) ∨ ( ∃z loves(z, x) ) ] Step 4: Skolemise. Both ∃ lie inside ∀x, so each becomes a function of x: y → F(x) and z → G(x) ∀x [ ( animal(F(x)) ∧ ¬loves(x, F(x)) ) ∨ loves(G(x), x) ] Step 5: drop ∀x. ( animal(F(x)) ∧ ¬loves(x, F(x)) ) ∨ loves(G(x), x) Step 6: distribute ∨ over ∧.
Answer: CNF, two clauses
[ animal(F(x)) ∨ loves(G(x), x) ] ∧ [ ¬loves(x, F(x)) ∨ loves(G(x), x) ] Reading of the Skolem functions: F(x) = "the animal that x fails to love", if such an animal exists G(x) = "someone who loves x"
Internal assessment Spring 2023, Q4(a) · 5 marks
Transform into CNF: ¬(P ∧ Q) ∨ (P ∨ S) → R
Worked solution
Step 1: name the antecedent. Antecedent X = ¬(P ∧ Q) ∨ (P ∨ S) ≡ (¬P ∨ ¬Q) ∨ P ∨ S Step 2: eliminate →. X → R ≡ ¬X ∨ R ¬[(¬P ∨ ¬Q) ∨ P ∨ S] ∨ R Step 3: De Morgan on the negated antecedent. (P ∧ Q ∧ ¬P ∧ ¬S) ∨ R Step 4: distribute ∨ over ∧. (P ∨ R) ∧ (Q ∨ R) ∧ (¬P ∨ R) ∧ (¬S ∨ R)
Answer, and the observation that earns the last mark

CNF = (P ∨ R) ∧ (Q ∨ R) ∧ (¬P ∨ R) ∧ (¬S ∨ R).

This simplifies further. The antecedent contains both ¬P and P, so it is a tautology; an implication with a tautologous antecedent is equivalent to its consequent. Resolving (P ∨ R) with (¬P ∨ R) gives R directly, so the whole sentence reduces to R. Writing both the mechanical CNF and this simplification demonstrates real understanding.

↑ contents
Solved

Probability and Bayes numericals, solved

Five variants of the same question. Learn one method and all five fall.

Fall 2021 Q7 · Spring 2021 Q5 · Fall 2023 Q7 · Fall 2024 mid Q6, asked four times · 10 marks
What is the probability that a woman has cancer if she has a positive mammogram result? One percent of women over 50 have breast cancer. Ninety percent of women who have breast cancer test positive on mammograms. Eight percent of women will have false positives.
Worked solution
Step 1: define events and list the givens. C = the woman has breast cancer P(C) = 0.01 ¬C = she does not P(¬C) = 0.99 + = the mammogram is positive P(+|C) = 0.90 (true positive / sensitivity) P(+|¬C) = 0.08 (false positive rate) Step 2: what is required. P(C | +) Step 3: Bayes' rule with the denominator expanded. P(+|C) · P(C) P(C|+) = ───────────────────────────────── P(+|C)·P(C) + P(+|¬C)·P(¬C) Step 4: substitute. 0.90 × 0.01 0.009 P(C|+) = ──────────────────────── = ───────── = 0.1020 0.90×0.01 + 0.08×0.99 0.0882
Answer and interpretation

P(cancer | positive mammogram) ≈ 0.102, about 10.2%.

Interpretation to write: out of 1000 women, 10 have cancer and 9 of them test positive; of the 990 without cancer, 79 still test positive. So 9 out of 88 positives are true, roughly 10%. Despite a 90% accurate test, a positive result means the woman probably does not have cancer, because the disease is rare. This is the base-rate fallacy, and it is why screening tests are followed by confirmatory biopsy.

Spring 2018, Q6 · 10 marks
A disease affects 1 in 10,000 people. P(test positive | no disease) = 2%. P(test negative | disease) = 1%. A random person tests positive. What is the probability they have the disease?
Worked solution
Givens P(D) = 1/10000 = 0.0001 P(¬D) = 0.9999 P(+|¬D) = 0.02 P(−|D) = 0.01 ⟹ P(+|D) = 0.99 Required P(D|+) P(+|D)·P(D) P(D|+) = ────────────────────────── P(+|D)·P(D) + P(+|¬D)·P(¬D) 0.99 × 0.0001 0.000099 = ─────────────────────── = ────────── = 0.004926 0.000099 + 0.019998 0.020097
Answer

P ≈ 0.0049, i.e. about 0.49%: roughly 1 in 203.

In a population of one million: 100 have the disease and 99 test positive; 999,900 are healthy and 19,998 of them test positive anyway. Almost every positive is a false alarm. Note also that the test's apparent accuracy (99% sensitivity, 98% specificity) is irrelevant next to the tiny prior, the lesson of the base-rate fallacy again.

Fall 2022, Q5 · 10 marks
50% of emails are spam; 1% of spam emails contain the word "refinance"; 0.001% of non-spam emails contain "refinance". An email contains "refinance". What is the probability that it is spam?
Worked solution
Givens P(S) = 0.5 P(¬S) = 0.5 P(R|S) = 0.01 (1%) P(R|¬S) = 0.00001 (0.001%) P(R|S)·P(S) P(S|R) = ──────────────────────── P(R|S)·P(S) + P(R|¬S)·P(¬S) 0.01 × 0.5 0.005 = ────────────────────── = ────────── = 0.9990 0.005 + 0.000005 0.005005
Answer

P(spam | "refinance") ≈ 0.999, about 99.9%.

Contrast this with the cancer question and say so: here the prior is 50/50 and the likelihood ratio is 1000:1, so a single word is nearly conclusive. This is exactly how a naïve Bayes spam filter works: it multiplies such likelihood ratios over all the words in the email, assuming the words are conditionally independent given the class.

Fall 2024, Q4b · 7 marks
A cab was involved in a hit-and-run at night. 70% of the city's cabs are Green and 30% Blue. A witness identified the cab as Blue. The witness correctly identifies each colour 85% of the time and false positives are 25% of the time. What is the probability the cab was Blue?
Worked solution
Givens P(Blue) = 0.30 P(Green) = 0.70 P(says Blue | Blue) = 0.85 (correct identification) P(says Blue | Green) = 0.25 (false positive) Required P(Blue | says Blue) P(sB|B)·P(B) P(B|sB) = ──────────────────────────────── P(sB|B)·P(B) + P(sB|G)·P(G) 0.85 × 0.30 0.255 = ────────────────────── = ────────── = 0.593 0.255 + (0.25 × 0.70) 0.430
Answer

P(Blue | witness says Blue) ≈ 0.593, about 59.3%, so the cab was more likely Blue than Green, but far less certain than the witness's 85% reliability suggests, because Green cabs are more than twice as common. Note that the two figures given (85% correct, 25% false positive) do not sum to 100%, so they describe two separate conditional probabilities and must be used as given.

Fall 2018 Q6 · Fall 2019 Q6 · Spring 2019 Q6 · 10 marks
You have a new burglar alarm. It reliably detects burglary but also responds to minor earthquakes. Two neighbours, John and Mary, promise to call when they hear it. John almost always calls but sometimes confuses the alarm with the phone; Mary likes loud music and sometimes misses it. Draw a Bayesian network for this domain with suitable probability tables.
Worked solution

Reproduce Fig 4.1 exactly: the five nodes, the four arrows, and all four CPTs, then write the following four paragraphs beneath it.

  1. Variables. Five boolean variables: Burglary, Earthquake, Alarm, JohnCalls, MaryCalls.
  2. Topology and why. Burglary and Earthquake are root causes and are independent of one another, so they have no parents and carry prior probabilities. Both directly affect the Alarm, so both are parents of Alarm. John and Mary hear only the alarm itself, not the burglary, so Alarm is the sole parent of each, and JohnCalls and MaryCalls are conditionally independent given Alarm.
  3. CPTs. P(B) = 0.001, P(E) = 0.002; Alarm has four rows because it has two boolean parents; John's 0.05 false-alarm rate models the telephone confusion and Mary's 0.70 detection rate models her loud music.
  4. Use. The network answers diagnostic queries such as P(Burglary | JohnCalls ∧ MaryCalls) by summing the joint distribution P(b,e,a,j,m) = P(b)P(e)P(a|b,e)P(j|a)P(m|a) over the unobserved variables. It needs only 10 numbers instead of the 2⁵ − 1 = 31 of a full joint table.
Add one numerical to prove you can use the network
P(j ∧ m ∧ a ∧ ¬b ∧ ¬e) = P(j|a) · P(m|a) · P(a|¬b,¬e) · P(¬b) · P(¬e) = 0.90 × 0.70 × 0.001 × 0.999 × 0.998 = 0.00062
↑ contents
Solved

ID3, evaluation metrics and the learning numericals

The two calculation-type learning questions PU has set, worked to the last decimal.

Spring 2019, Q7 · 10 marks
Dogs are described by four binary features, Heavy, Smelly, Big, Growling, with the target attribute Bites. (a) What is the entropy of Bites? (b) Which attribute would ID3 choose as the root? (c) What is its information gain? (d) Draw the full decision tree learned by ID3 without pruning.
Worked solution
#HeavySmellyBigGrowlingBites
1NoNoNoNoNo
2NoNoYesNoNo
3YesYesNoYesNo
4YesNoNoYesYes
5NoYesYesNoYes
6NoNoYesYesYes
7NoNoNoYesYes
8YesYesNoNoYes

(a) Entropy of the target. 5 examples Bite, 3 do not, out of 8.

H(S) = −(5/8)·log₂(5/8) − (3/8)·log₂(3/8) = −0.625(−0.678) − 0.375(−1.415) = 0.4238 + 0.5306 = 0.9544 bits

(b) and (c) Information gain of each attribute. Split, compute each subset's entropy, take the weighted average, subtract from 0.9544.

AttributeValue = YesValue = NoWeighted entropyGain
Heavy{3,4,8} → 2 bite, 1 not, H = 0.918{1,2,5,6,7} → 3 bite, 2 not, H = 0.971(3/8)(0.918) + (5/8)(0.971) = 0.9510.003
Smelly{3,5,8} → 2 bite, 1 not, H = 0.918{1,2,4,6,7} → 3 bite, 2 not, H = 0.9710.9510.003
Big{2,5,6} → 2 bite, 1 not, H = 0.918{1,3,4,7,8} → 3 bite, 2 not, H = 0.9710.9510.003
Growling{3,4,6,7} → 3 bite, 1 not, H = 0.811{1,2,5,8} → 2 bite, 2 not, H = 1.000(4/8)(0.811) + (4/8)(1.000) = 0.9060.049
Answers (b) and (c)

ID3 chooses Growling as the root, because its information gain of 0.0488 bits is the largest (the other three tie at 0.0031).

(d) Build the rest of the tree.

Branch Growling = Yes, examples {3, 4, 6, 7} with H = 0.811:

Smelly = Yes → {3} → all "No bite" H = 0 Smelly = No → {4,6,7} → all "Bite" H = 0 Weighted entropy = 0 ⟹ Gain(Smelly) = 0.811: a perfect split (Heavy gives 0.311, Big gives 0.123, so Smelly wins)

Branch Growling = No, examples {1, 2, 5, 8} with H = 1.0:

Smelly = Yes → {5,8} → both "Bite" H = 0 Smelly = No → {1,2} → both "No bite" H = 0 Weighted entropy = 0 ⟹ Gain(Smelly) = 1.0: again perfect (Heavy gives 0.311, Big gives 0)
Growling? Smelly? Smelly? No bite Bites Bites No bite YesNo YesNo YesNo Every leaf is pure: the tree classifies all 8 training examples correctly.
Fig S.1: The full ID3 tree for the dog-bite data.
The insight that lifts this answer above everyone else's

Read the four leaves: the dog bites exactly when Growling and Smelly differ. The target function is Bites = Growling XOR Smelly. That is why every single attribute has a near-zero information gain at the root, an XOR target is invisible to a one-attribute-at-a-time greedy test, and ID3 only picks Growling because of a tiny accidental asymmetry in the sample. Write this: "the example demonstrates ID3's main weakness, the myopia of greedy attribute selection on interacting attributes."

Note: the Bites column for rows 1-3 is faint in the scanned paper; the reading above (No, No, No) is the one that makes the data consistent and produces the clean XOR structure.

Fall 2024, Q6b · 7 marks
Discuss validation approaches for classification. A neural network predicts whether a skin lesion is Malignant or Benign. Predicted Malignant: 50 actually malignant, 10 actually benign. Predicted Benign: 5 actually malignant, 35 actually benign. Find the accuracy, precision and recall, and analyse the result.
Worked solution

Step 1: validation approaches (2 marks): hold-out split, k-fold cross-validation, stratified k-fold, leave-one-out, bootstrap; and the metrics derived from the confusion matrix.

Step 2: label the confusion matrix with Malignant as the positive class.

Actual Malignant Actual Benign Total Predicted Malignant TP = 50 FP = 10 60 Predicted Benign FN = 5 TN = 35 40 Total 55 45 100
Accuracy = (TP + TN)/Total = (50 + 35)/100 = 0.85 → 85% Precision = TP/(TP + FP) = 50/60 = 0.833 → 83.3% Recall = TP/(TP + FN) = 50/55 = 0.909 → 90.9% (sensitivity) Specificity = TN/(TN + FP) = 35/45 = 0.778 → 77.8% F1-score = 2·P·R/(P + R) = 2(0.833)(0.909)/(1.742) = 0.870
Analysis: this paragraph is worth as much as the arithmetic

The model is right 85% of the time overall. Recall (90.9%) exceeds precision (83.3%), which is the right trade-off for a cancer screening tool: only 5 of 55 true malignancies are missed. Those 5 false negatives are still the most dangerous errors, since a missed melanoma goes untreated, whereas the 10 false positives merely trigger an unnecessary biopsy. If the system were to be deployed, the decision threshold should be lowered further to raise recall towards 100%, accepting lower precision, and the model should never be the final decision-maker, a dermatologist reviews every flagged case. Note also that accuracy alone would be a poor metric on a realistic dataset where malignant lesions are only 2-5% of cases.

↑ contents
Predict

What actually gets asked

Every question from fourteen PU and NCIT papers (2018 Spring to 2024 Fall), sorted by how often the topic appeared.

TopicPapersForm the question takes
Crypt-arithmetic / CSP12 / 14"Solve stating all necessary conditions": EAT+THAT, ODD+ODD, GO+TO, NINA+SING, LOGIC+LOGIC, WRONG+WRONG, BASE+BALL
Search (A*, BFS/DFS, heuristics)12 / 14A* trace on a given graph; compare BFS/DFS/UCS/A*; define heuristics; informed vs uninformed
Neural networks & backpropagation11 / 14Define perceptron; XOR with a single neuron; MLP; explain backprop with example; activation functions
FOPL & resolution10 / 14Represent 5 sentences in FOPL; prove a goal by resolution on a small knowledge base
Agents / Turing test10 / 14Types of agent with diagrams; rational agent + task environments; Turing test, total and reverse; PEAS
Expert systems9 / 14Components + architecture diagram; development stages; advantages and applications
Supervised / unsupervised / RL8 / 14"Explain with examples"; classification vs clustering
Bayes numerical7 / 14Mammogram (×4), rare disease, spam filter, blue cab
Decision tree / ID37 / 14Entropy and information gain calculation; tree vs random forest; ID3 significance and limitations
Fuzzy logic7 / 14"How can uncertainty be represented using fuzzy logic? Explain with example"
Genetic algorithm6 / 14Steps with an example; use for optimisation
NLP5 / 14Steps of NLP; why it is difficult; ambiguity types; parse trees
Forward / backward chaining5 / 14Compare with examples; prove a goal both ways (flood system)
CNF conversion4 / 14Why CNF + steps + the same two formulas every time
Bayesian belief network4 / 14Burglar alarm network with CPTs; working principle; applications
Swarm intelligence (ACO / PSO)3 / 14Can search optimisation use swarm intelligence? describe the algorithm
Min-max & alpha-beta2 / 14Explain and give the advantage of pruning; chess case study
Semantic nets / frames2 / 14Discuss with examples; application in uncertain reasoning
Linear vs logistic regression2 / 14Compare with examples
Hill climbing · Hebbian learning · PEAS · SVM · deep learning1 eachUsually as a short note or one part of a two-part question
Read the pattern

The paper is not randomly sampled from the syllabus. It is a rotating set of about twenty question templates. Nine of the ten questions in your exam will come from the top twelve rows of this table. If you can do those twelve topics cold, you are looking at 85+, not 60.

↑ contents
Predict

The 24 questions to have ready

Write a full answer to each, to time. If you finish these you have covered roughly 95% of what can be asked.

Certain Do these first: one of each will be on the paper

  1. Solve a crypt-arithmetic problem stating all necessary conditions. Practise EAT+THAT and NINA+SING by hand until you can do either in 15 minutes. → solutions
  2. Trace A* on a given graph and report the solution cost. With the OPEN/CLOSED table and an admissibility comment. → solutions
  3. Represent a knowledge base in FOPL and prove a goal by resolution.solutions
  4. A Bayes' rule numerical with interpretation.solutions
  5. Components of an expert system + architecture diagram + development stages.Unit 6
  6. Supervised vs unsupervised vs reinforcement learning with examples.Unit 5

Very likely Second priority

  1. Explain backpropagation with an example; how learning and validation are done. → worked numerical
  2. What is a perceptron? Can a single perceptron design an XOR gate? Justify. → Fig 5.3
  3. Types of intelligent agent with diagrams and examples. → Unit 1
  4. How can uncertainty be represented using fuzzy logic? Explain with an example. → Unit 4
  5. Decision tree: types, significance, limitations; compare with random forest; ID3 with an example. → Unit 5, worked ID3
  6. Genetic algorithm: steps with an example; use for optimisation. → Unit 2
  7. Compare forward and backward chaining with examples. → Unit 3
  8. Why is CNF required? Steps, then convert P → ((Q ∧ ¬R) ↔ S). → solutions
  9. Compare BFS, DFS, UCS and A* with examples; informed vs uninformed search. → Unit 2 table
  10. Turing test, total Turing test, reverse Turing test / CAPTCHA, with a justified stand. → Unit 1
  11. Bayesian belief network: draw the burglar alarm network with CPTs; working principle; applications. → Fig 4.1
  12. Steps of NLP; why NLP is difficult; types of ambiguity with examples. → Unit 6

Worth an hour each The rest of the surface area

  1. Rational agent and the seven task-environment properties; PEAS for a part-picking robot and an automated car.
  2. Heuristics: definition, significance, types and challenges in informed search.
  3. Min-max search and the advantages of alpha-beta pruning.
  4. Hill climbing: algorithm, its three problems and their solutions.
  5. Semantic nets and frames with examples; propositional vs predicate logic.
  6. Swarm intelligence: ant colony optimisation and particle swarm optimisation algorithms; short notes on SVM, deep learning, machine learning, reinforcement learning.
↑ contents
Predict

A predicted paper for your exam

Built by taking the rotation pattern of the last seven years and picking what is due. Sit this under timed conditions one week before the exam.

Attempt all · 100 marks · 4 hrs
How this was constructed

Topics that appeared in 2023 and 2024 but not in consecutive years are due to rotate back; the six "certain" topics appear regardless. Two questions below (5 and 9) are variants that have not been set before but sit squarely inside the syllabus, those are the ones to think about rather than memorise.

Predicted Q1 · 10 marks · Unit 1
Define a rational agent. Explain the different types of intelligent agent with diagrams and suitable examples, and state which type is most appropriate for an automated taxi and why.
Answer plan

Rational agent definition + the four things rationality depends on → the five agent types, one diagram each (Figs 1.3-1.5) → PEAS table for the taxi → conclude that the taxi needs a utility-based learning agent because the environment is partially observable, stochastic and multi-agent, and goals conflict (speed vs safety vs comfort).

Predicted Q2 · 10 marks · Unit 2
Explain the A* algorithm with its evaluation function. Trace A* on the graph provided and report the path and the solution cost. Comment on whether the given heuristic is admissible, and state the main drawback of A* with its remedies.
Answer plan

f = g + h, the seven algorithm steps, the OPEN/CLOSED table, the path in a box, the admissibility check (compare h(start) with the actual cost), then the memory drawback and IDA*/SMA*/RBFS. → worked examples

Predicted Q3 · 10 marks · Unit 2
What is a Constraint Satisfaction Problem? Solve the following crypt-arithmetic problem stating all necessary conditions: SEND + MORE = MONEY (or one of EAT+THAT, ODD+ODD, BASE+BALL).
Answer plan and the SEND+MORE solution

CSP definition (X, D, C) → the seven necessary conditions → column equations → propagate.

M = 1 (carry). S + M ≥ 10 ⟹ S = 8 or 9; O = 0. Working through the carries gives: S=9, E=5, N=6, D=7, M=1, O=0, R=8, Y=2 9 5 6 7 SEND = 9567 + 1 0 8 5 MORE = 1085 -------------- 1 0 6 5 2 MONEY = 10652 ✓

Note that SEND+MORE has not yet been set at PU but is the single most famous instance, so it is a live candidate. The method is identical to the seven solved problems.

Predicted Q4 · 10 marks · Unit 3
Consider the knowledge base: "John likes all kinds of food. Apples are food. Chicken is food. Anything anyone eats and isn't killed by is food. Bill eats peanuts and is still alive. Sue eats everything Bill eats." Represent in FOPL and use resolution to prove that John likes peanuts.
Answer plan
C1. ¬food(x) ∨ likes(John, x) C2. food(Apple) C3. food(Chicken) C4. ¬eats(y,x) ∨ killedBy(y,x) ∨ food(x) C5. eats(Bill, Peanuts) C6. alive(Bill) C7. ¬alive(y) ∨ ¬killedBy(y, x) (alive ⟹ not killed by anything) C8. ¬eats(Bill, x) ∨ eats(Sue, x) C9. ¬likes(John, Peanuts) ← negated goal C9+C1 {x/Peanuts} ⟹ ¬food(Peanuts) +C4 ⟹ ¬eats(y,Peanuts) ∨ killedBy(y,Peanuts) +C5 {y/Bill} ⟹ killedBy(Bill, Peanuts) +C7 ⟹ ¬alive(Bill) +C6 ⟹ □ ∴ John likes peanuts
Predicted Q5 · 10 marks · Unit 3, a variant not set before
What is knowledge representation? Compare semantic networks and frames with examples, and explain how a semantic network supports inheritance-based inference.
Answer plan

Types of knowledge → the five representation schemes table → semantic net diagram (Fig 3.1) with is-a and has-a links → the same knowledge as a frame → inheritance walk ("Sparrow is-a Bird is-a Animal, therefore Sparrow breathes") → properties of a good representation → strengths and weaknesses of each.

Predicted Q6 · 10 marks · Unit 4
A factory has two machines, A and B, producing 60% and 40% of the output; 3% of A's output and 5% of B's output is defective. An item is found defective. What is the probability it came from machine B? Also state Bayes' theorem and explain prior and posterior probability.
Worked answer
P(A)=0.6, P(B)=0.4, P(D|A)=0.03, P(D|B)=0.05 P(D) = 0.6(0.03) + 0.4(0.05) = 0.018 + 0.020 = 0.038 P(D|B)·P(B) 0.020 P(B|D) = ───────────── = ─────── = 0.5263 ≈ 52.6% P(D) 0.038

Prior P(B) = 0.40 rises to posterior P(B|D) = 0.53 once the defect is observed, evidence shifts belief towards the less reliable machine. Any Bayes variant is this same five-line template.

Predicted Q7 · 10 marks · Unit 4
What are Bayesian belief networks? Draw one for the burglar-alarm domain with suitable probability tables and explain its working principle. List its applications.
Answer plan

Definition + the product formula → Fig 4.1 reproduced with all four CPTs → the four explanatory paragraphs → one joint-probability calculation → applications and limitations. → worked version

Predicted Q8 · 10 marks · Unit 5
What is a multilayer perceptron? Explain the backpropagation algorithm in detail with an example, and describe how learning and validation are carried out.
Answer plan

MLP definition + Fig 5.4 → the seven backprop steps → the delta formulas → the full 2-2-1 numerical from Unit 5 → training vs validation curves and early stopping → limitations (local minima, vanishing gradients, learning-rate sensitivity).

Predicted Q9 · 10 marks · Unit 5, a variant not set before
Given a small training table, compute the entropy and information gain of each attribute, choose the root by ID3, and draw the resulting decision tree. Compare the tree with a random forest.
Answer plan

Entropy and gain formulas → a table of gains → the tree diagram → decision tree vs random forest comparison table → pruning as the answer to overfitting. Practise the arithmetic on the dog-bite dataset and on the classic play-tennis table.

Predicted Q10 · 5 + 5 marks · Unit 6
Draw and describe the architecture of an expert system and discuss the stages of its development. How does a parse tree help in NLP? Explain with a suitable example.
Answer plan

Fig 6.1 + the six components → the eight development stages → then the five NLP levels, the parse tree of Fig 6.3 with the grammar rules, and how the tree resolves the "I saw the man with a telescope" ambiguity by producing two trees.

↑ contents
Revise

The night-before sheet

Everything that must be in your head when you walk in. Read only this on the last night, nothing else.

Formulas

A* f(n) = g(n) + h(n) · admissible: h(n) ≤ h*(n) consistent: h(n) ≤ c(n,a,n′) + h(n′) UCS A* with h = 0 Greedy f(n) = h(n) Alpha-beta prune when α ≥ β; best case O(b^(m/2)) Bayes P(A|B) = P(B|A)P(A) / [P(B|A)P(A) + P(B|¬A)P(¬A)] Belief net P(x₁…xₙ) = Π P(xᵢ | Parents(Xᵢ)) Entropy H(S) = − Σ pᵢ log₂ pᵢ Info gain Gain(S,A) = H(S) − Σ (|Sᵥ|/|S|) H(Sᵥ) Gini 1 − Σ pᵢ² Perceptron y = f(Σwᵢxᵢ + b); wᵢ ← wᵢ + η(t − y)xᵢ Backprop δ_out = o(1−o)(t−o) δ_hid = o(1−o) Σ δₖwⱼₖ w ← w + η·δ·input Sigmoid σ(x) = 1/(1+e⁻ˣ), σ′ = σ(1−σ) Q-learning Q(s,a) ← Q(s,a) + α[r + γ max Q(s′,a′) − Q(s,a)] Accuracy (TP+TN)/N Precision TP/(TP+FP) Recall TP/(TP+FN) F1 2PR/(P+R) Fuzzy μ_A∪B = max(μA,μB) · μ_A∩B = min(μA,μB) · μ¬A = 1 − μA PSO v ← wv + c₁r₁(pbest − x) + c₂r₂(gbest − x)

Numbers to remember

  • log₂: 1/2 = −1 · 1/3 = −1.585 · 2/3 = −0.585 · 1/4 = −2 · 3/4 = −0.415 · 3/8 = −1.415 · 5/8 = −0.678 · 1/5 = −2.322 · 2/5 = −1.322 · 3/5 = −0.737
  • Burglary CPT: P(B) = 0.001, P(E) = 0.002, P(A|b,e) = 0.95 / 0.94 / 0.29 / 0.001, P(J|a) = 0.90 / 0.05, P(M|a) = 0.70 / 0.01
  • Crypt answers: EAT+THAT = 819 + 9219 = 10038 · ODD+ODD = 655 + 655 = 1310 · GO+TO = 81 + 21 = 102 · NINA+SING = 5051 + 9054 = 14105 · LOGIC×2 = 90452 → 180904 · WRONG×2 = 12734 → 25468 · BASE+BALL = 7483 + 7455 = 14938 · SEND+MORE = 9567 + 1085 = 10652
  • Mammogram answer 10.2% · rare disease 0.49% · spam 99.9% · blue cab 59.3%

Lists you will be asked to produce

Agent types (5)

Simple reflex · model-based reflex · goal-based · utility-based · learning

Learning agent parts (4)

Performance element · critic · learning element · problem generator

Task environments (7)

Observable · agents · deterministic · episodic · static · discrete · known

Problem formulation (5)

Initial state · actions · transition model · goal test · path cost

CNF steps (8)

↔ out · → out · ¬ inwards · standardise · Skolemise · drop ∀ · distribute · flatten

Resolution steps (5)

FOPL · CNF · negate goal · resolve · derive □

GA steps (8)

Encode · initialise · fitness · select · crossover · mutate · replace · terminate

Backprop steps (7)

Init · forward · error · output δ · hidden δ · update · repeat

Expert system parts (6)

Knowledge base · inference engine · working memory · user interface · explanation · knowledge acquisition

NLP levels (5)

Lexical · syntactic · semantic · discourse · pragmatic

Fuzzy system blocks (4)

Fuzzifier · rule base · inference engine · defuzzifier

Hill climbing problems (3)

Local maximum · plateau · ridge

Ten one-line answers that carry marks

  1. Rationality maximises expected performance, not actual; it is not omniscience.
  2. BFS is optimal only when all step costs are equal; UCS fixes that.
  3. DFS is the only classical strategy with linear O(bm) memory.
  4. A*'s drawback is memory, not time, it keeps every generated node.
  5. ∀ pairs with →, ∃ pairs with ∧.
  6. KB ⊨ α iff (KB ∧ ¬α) is unsatisfiable, the basis of refutation.
  7. Fuzzy logic models degree of truth; probability models degree of belief.
  8. Without a non-linear activation, any depth of network collapses to a single linear layer.
  9. A single perceptron can only separate linearly separable classes, so XOR needs a hidden layer.
  10. Accuracy is a misleading metric on imbalanced data; quote recall for screening problems.
In the hall

Draw a diagram in every answer. Number your steps. Box every final answer. Never leave a question blank: a definition plus a labelled figure is worth four marks on a topic you barely know. Keep the crypt-arithmetic for last.

Built from the COM 713.3 syllabus and fourteen past papers, 2018-2024. Where a scanned figure was unreadable, the method is given so you can apply it to your own printed copy. Good luck: the six certain topics are worth 60 marks, and you have time to own all of them.

↑ contents