A-Level Revision Guides
All subjects covered
Amazon amazon.co.uk
Fastmail -- Private Email
Privacy-first email with no ads and no tracking
fastmail.com
Dynadot -- Domain Registration ->
Register or transfer domains with free SSL and affordable pricing
dynadot.com
Zen Internet -- UK Broadband ->
Award-winning UK broadband with no data caps and great customer service
zen.co.uk
A-Level Revision Aid: This resource is designed to support your revision. Content may contain errors. If you find a discrepancy with your class teaching, your teacher is correct β€” please let us know at alevelrevise@scott.scottrix.co.uk.

Theory of Computation

Year 1 / ASYear 2 / A-Level AQA, OCR, WJEC/Eduqas

Exam-focused AQA 7517, OCR H446 and WJEC/Eduqas revision for theory of computation: abstraction, finite state machines, regular languages, BNF, Turing machines, computability and the halting problem with worked traces.

Fastmail

🎯 Learning Objectives

πŸ“‹ Key Definitions and Core Concepts

Abstraction: The process of removing unnecessary detail from a problem while keeping the features essential to its solution (AQA 4.2.1).
Decomposition: Breaking a complex problem into smaller subproblems that can be solved separately and combined.
Finite state machine (FSM): A model of computation with a finite set of states, transitions between them, and (optionally) outputs; it has no auxiliary memory (AQA 4.2.2).
State transition diagram: A directed graph of an FSM: circles for states, labelled arrows for transitions; a double circle marks the accepting/halting state.
Regular language: A language that can be recognised by a finite state machine, equivalently described by a regular expression (AQA 4.2.3).
Backus-Naur Form (BNF): A meta-language of productions (e.g. <digit> ::= 0 | 1 | ... | 9) that describes context-free languages β€” strictly more powerful than regular expressions.
Turing machine: A model of computation: an infinite tape of symbols, a read/write head, a finite set of states and a transition function (AQA 4.2.3).
Universal Turing machine: A Turing machine that can simulate any other Turing machine by reading its description from tape β€” the theoretical ancestor of the stored-program computer.
Computable problem: A problem for which some Turing machine (equivalently, some algorithm) can produce the correct output in a finite number of steps for every valid input.
Halting problem: The (provably uncomputable) problem of deciding, for an arbitrary program and input, whether the program will eventually halt or run forever.

πŸ“Œ Key Points

Abstraction removes unnecessary detail, keeping only what is essential (AQA 4.2.1); decomposition splits the problem into solvable subproblems
FSM = finite states + transitions + optional output; no memory beyond the current state (AQA 4.2.2)
FSM without output = acceptor (double circle = accepting state); FSM with output (Mealy machine) emits output per transition
Regular languages = languages an FSM can recognise = languages a regular expression describes (AQA 4.2.3)
BNF describes context-free languages (e.g. nested brackets) which regular expressions cannot capture
Turing machine = infinite tape + read/write head + states + transition function; Church-Turing thesis: everything computable is TM-computable
The halting problem is undecidable: no algorithm can decide for every program/input whether it halts (AQA 4.2.3, WJEC 3.3)

Abstraction and decomposition

Abstraction (AQA 4.2.1, OCR 2.1.5) is the deliberate removal of unnecessary detail. The exam wants you to apply it, not recite it. AQA names four flavours worth quoting:

Decomposition is the companion technique: split a problem into subproblems, solve each (recursively if needed), and combine. The standard 4-marker is 'Explain the benefits of abstraction in solving this problem.' Full-credit structure: (1) state what detail is removed; (2) state why it is irrelevant to the goal; (3) state the consequence β€” smaller search space, faster to model, easier to reason about, reusable model. Example: modelling a queue at a supermarket β€” arrivals, service times and number of tills are relevant; customers' items, ages and payment methods are not; the abstracted simulation can be run thousands of times cheaply where the real experiment could not.

The A* link matters too: a heuristic function is abstraction in action β€” straight-line distance on a map abstracts away road curvature and traffic to give a cheap, admissible estimate. And the link to automation: once a problem is abstracted to a formal model (states, symbols, rules), it can be executed mechanically β€” which is exactly what a finite state machine or Turing machine is.

Finite state machines

A finite state machine (AQA 4.2.2, WJEC 3.3) has: a finite set of states; an initial state; a transition function moving from state to state on input symbols; optionally a set of accepting states (for an acceptor) or outputs (for a machine with output). Crucially, it has no memory beyond the current state β€” it cannot count arbitrarily high, which is the fact that limits it to regular languages.

FSM without output (acceptor): drawn as circles with labelled arrows; a double circle is the accepting state. Canonical worked example β€” accept binary strings containing an even number of 1s:

States: S0 (start, accepting), S1
Transitions:
S0 --0--> S0
S0 --1--> S1
S1 --0--> S1
S1 --1--> S0

State S0 means 'even number of 1s seen so far', S1 means 'odd'. Trace the input 1101: start S0; read 1 β†’ S1 (odd); read 1 β†’ S0 (even again); read 0 β†’ S0; read 1 β†’ S1. End in S1, which is not accepting, so 1101 is rejected (three 1s β€” odd). Trace 1010: S0β†’S1β†’S0β†’S0β†’S0, ends in S0, accepted. The idea to internalise: each state summarises everything relevant about the input so far; here a single bit of memory (parity) suffices, so an FSM can do it.

FSM with output (Mealy machine): every transition is labelled input/output, e.g. S0 --1/0--> S1 means 'on input 1, emit 0 and move to S1'. Classic example β€” a machine that outputs 1 whenever two consecutive identical bits arrive: states track the previous bit; on each input, output 1 if it equals the previous, else 0. Trace input 0110 with previous = none: read 0 β†’ output 0; read 1 β†’ 0 != prev(0), output 0; read 1 β†’ matches prev(1), output 1; read 0 β†’ output 0. Output string 0010. Exam questions also use FSMs for turnstiles, vending machines and locks β€” the marking points are always: correct number of states, correct initial state, complete transition set (every state has an arrow for every input symbol β€” a missing transition is a mark lost), and correct accepting/output behaviour.

State transition table is the same machine in tabular form, and exams ask you to convert between the two:

Current stateInput 0Input 1
S0 (accept)S0S1
S1S1S0

Know also that a transition function written formally as Ξ΄(S0, 1) = S1 is just the table in notation. And the significance link: FSMs model state-dependent behaviour β€” network protocols, lexical analysis in compilers, UI locks β€” precisely because real systems have finite relevant states.

Regular languages, regular expressions and BNF

A regular language (AQA 4.2.3, WJEC 3.3) is one that a finite state machine can recognise. Regular expressions are the notation for describing them, and the examinable fact is the equivalence: a language is regular if and only if some regular expression (equivalently, some FSM) describes it. OCR also uses regex for pattern matching, e.g. ^[a-z]+[0-9]*$.

Regex syntax to be fluent in:

Worked example: a UK-style vehicle year letter [A-Y] followed by 2–3 digits is [A-Y][0-9][0-9][0-9]?. An even-parity binary string is (0|10*1)* β€” pairs of 0s and pairs wrapping 0s with 1s keep the count of 1s even; an FSM can recognise it (above), so the language is regular.

What FSMs cannot do: count unboundedly. The language of matched brackets ( ) ( ) ... or a^n b^n needs to remember how many opens are outstanding β€” arbitrarily many β€” so no FSM recognises it, and no regular expression describes it. That is where Backus-Naur Form comes in (AQA 4.2.3): BNF is a meta-language of recursive productions describing context-free languages, which strictly contain the regular languages:

   ::= '' |  0 |  1 1 | 1 1 
  ::= '' | (  ) |  
       ::=  |  
     ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

The recursion in is what allows arbitrary nesting β€” the power FSMs lack. Exam question pattern: 'Explain why the following language cannot be described by a regular expression.' Answer structure: identify the unbounded counting requirement (e.g. equal numbers of opens and closes); state that an FSM has finitely many states and no memory beyond the current state, so it cannot count arbitrarily high; conclude the language is not regular and needs a context-free description (BNF) or a pushdown automaton. The hierarchy to quote: regular languages (FSM/regex) are a strict subset of context-free languages (BNF/pushdown), which are a strict subset of all computable (decidable) languages (Turing machine).

Turing machines

A Turing machine (AQA 4.2.3, WJEC 3.3) is the formal model of computation. Components: an infinite tape divided into cells holding symbols (with a blank symbol); a read/write head over one cell; a finite set of states with a start state and halting state(s); and a transition function of the form:

Ξ΄(state, symbol) = (new state, symbol to write, move L/R/N)

Unlike an FSM, a Turing machine can read and write the tape, using it as unlimited memory β€” that is precisely the extra power that makes it a general model of computation. Worked example β€” increment a binary number, head starting on the rightmost digit, q0 = 'adding 1 with carry', H = halt:

Ξ΄(q0, 1) = (q0, 0, L)     // 1+1 = 0, carry propagates left
Ξ΄(q0, 0) = (H, 1, N)      // no carry: write 1 and halt
Ξ΄(q0, _) = (H, 1, N)      // overflowed left end: append new 1

Trace on tape 1011 (head on last cell): read 1 → write 0, move left (tape now 1010, carry). Read 1 → write 0, move left (1000, carry). Read 0 → write 1, halt (tape 1100). Indeed 1011 + 1 = 1100. Trace on tape 111: 1→0 (L), 1→0 (L), 1→0 (L), blank→1 (H): tape 1000 — the overflow rule appended a digit. Exam marking points: write before moving, carry semantics in the state, and correct halting.

Why Turing machines matter β€” the two examinable facts:

Also know the phrase Turing-complete: a language or system in which every Turing-computable function can be expressed β€” all mainstream programming languages are. And be ready to compare FSM vs Turing machine in one line: an FSM has a fixed finite number of states and cannot remember unbounded information; a Turing machine's tape gives it unlimited memory, so it can compute anything computable (e.g. a^n b^n, arbitrary arithmetic), where an FSM cannot.

Computability and the halting problem

A problem is computable (decidable) if some algorithm β€” a Turing machine β€” solves it correctly for every input in finite time. Problems that are not computable exist, and the exam requires you to know the canonical example and its proof shape (AQA 4.2.3, WJEC 3.3).

The halting problem: given an arbitrary program P and input w, decide whether P eventually halts on w or runs forever. It cannot be solved by any algorithm. The proof is by contradiction:

  1. Assume a program H(P, w) exists that always halts and returns true if P halts on w, false otherwise.
  2. Construct a new program D(P): if H(P, P) returns true, loop forever; otherwise halt.
  3. Now ask what D(D) does. If H says D halts on D, then D(D) loops forever β€” contradicting H's answer. If H says D does not halt on D, then D(D) halts β€” again contradicting H.
  4. Either way H's answer about D(D) is wrong. So the assumption fails: no such H exists. The halting problem is undecidable.

Practical exam phrasing for a 6-marker: state the problem precisely; state the assumption (a universal decider H exists); describe the construction of D and the self-application D(D); show the contradiction both ways; conclude undecidability. Award points are almost always: correct statement of the problem (1), assumption of H (1), construction of D/D(D) (2), contradiction shown (1), conclusion (1).

Why this matters beyond the proof: the halting problem proves there are limits to computation β€” no programming language, however powerful, and no future hardware can decide it, because the limitation is mathematical, not technological. Related consequences worth one line each: no tool can perfectly detect all infinite loops or viruses in arbitrary programs (a virus detector that always halts would solve a halting-equivalent problem); some functions are computable but not practically computable because they take exponential time (e.g. brute-force TSP) β€” distinguish undecidable (no algorithm exists, ever) from intractable (an algorithm exists but is impractical, e.g. O(2^n)).

Exam question pattern: 'State what is meant by a computable problem and give one example of a problem that is not computable.' Answer: a computable problem is one for which there exists an algorithm/Turing machine that produces the correct result in finite time for every input; the halting problem is not computable β€” no algorithm can decide for every program/input whether it halts, proved by contradiction using a program D that does the opposite of the assumed decider when fed itself.

πŸ’‘ Worked Example

Exam-style: (a) Draw a finite state machine that accepts all binary strings containing an even number of 1s. [4 marks] (b) Trace your machine on the input 1010, stating whether the string is accepted. [3 marks] (c) Explain why a finite state machine cannot recognise the language of strings consisting of n opening brackets followed by n closing brackets. [3 marks]
Mark-scheme logic: (a) Two states: S0 (initial and accepting, double circle) meaning 'even 1s so far', S1 meaning 'odd'. Transitions: S0-0->S0, S0-1->S1, S1-0->S1, S1-1->S0. Award: correct states and start/accepting marked (1), transition on 0 keeps state (1), transition on 1 toggles state (1), all transitions complete and diagram valid (1). (b) S0 --1--> S1 --0--> S1 --1--> S0 --0--> S0 (2 marks for correct trace). Ends in S0, an accepting state, so 1010 is accepted β€” it contains two 1s, an even number (1). (c) Recognising the language requires counting how many opening brackets are outstanding, and n can be arbitrarily large (1). An FSM has only a finite number of states and no memory beyond the current state, so it cannot count unboundedly (1). Therefore the language is not regular; it is context-free and requires a description such as BNF (e.g. <brackets> ::= '' | ( <brackets> )) or a pushdown machine (1).

❓ Practice Questions & Mark Schemes

Define abstraction and decomposition, and explain how both are used when modelling a supermarket checkout system. [6 marks]
Answer: Abstraction removes unnecessary detail from a problem while keeping the features essential to a solution (1); decomposition breaks a complex problem into smaller, separately solvable subproblems (1). In the model, abstraction keeps arrival rates, service times and the number of tills, and discards irrelevant detail such as customers' identities, ages or the brands bought (1), because they do not affect queue behaviour β€” this makes the model cheap enough to simulate thousands of times (1). Decomposition splits the system into subproblems: generating arrivals, simulating service, measuring queue lengths and reporting statistics (1), each developed and tested independently before being combined (1).
A Mealy machine outputs 1 on any transition where the input bit equals the previous input bit, and 0 otherwise. Trace the output for the input string 00110. [4 marks]
Answer: State remembers the previous bit. Read 0: no previous bit, output 0 (1). Read 0: equals previous 0, output 1. Read 1: differs, output 0. Read 1: equals previous 1, output 1. Read 0: differs, output 0 (2 marks for the remaining trace). Output string: 01010 (1).
Write a Backus-Naur Form definition for a signed integer, i.e. an optional + or - sign followed by one or more digits. Use it to explain why BNF is more powerful than a regular expression for describing languages. [5 marks]
Answer: <signed-int> ::= <sign> <int> (1); <sign> ::= + | - (1); <int> ::= <digit> | <int> <digit> (1); <digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 (1). BNF productions are recursive and can nest, so they describe context-free languages such as matched brackets or a^n b^n, which no regular expression can describe because regular expressions/FSMs cannot count unboundedly (1).
A Turing machine has transition function Ξ΄(q0,1) = (q0,0,L), Ξ΄(q0,0) = (H,1,N), Ξ΄(q0,_) = (H,1,N), starting on the rightmost digit of the tape 1101. Show the final tape contents and explain what the machine computes. [5 marks]
Answer: Read 1 β†’ write 0, move left (tape 1100, carry) (1). Read 0 β†’ write 1, halt (1). Final tape: 1110 (1). The machine computes increment of the binary number by one (1): 1101 + 1 = 1110; state q0 represents a propagating carry, 1+1 writes 0 and carries left, and the first non-carry position absorbs the addition (1).
Explain what the halting problem is and outline why it is undecidable. [6 marks]
Answer: The halting problem is: given an arbitrary program P and input w, decide whether P will eventually halt on w or run forever (1). Suppose a decider H(P, w) exists that always halts with the correct answer (1). Construct D(P): if H(P, P) returns true then loop forever, else halt (2 marks: construction and self-application). Then D(D) leads to contradiction: if H says D halts on D, D(D) loops forever; if H says D does not halt, D(D) halts β€” H is wrong in both cases (1). Therefore the assumption fails: no such H exists, so the halting problem is undecidable (1).
State the Church-Turing thesis and explain the significance of the universal Turing machine for modern computing. [4 marks]
Answer: The Church-Turing thesis states that every function that is computable in any practical sense can be computed by a Turing machine β€” it is a thesis, not a provable theorem, supported by all equivalent formal models matching its power (2). The universal Turing machine can simulate any other Turing machine by reading its description from tape (1); this is the theoretical basis of the stored-program concept β€” programs stored as data and interpreted by one general-purpose machine β€” which underlies every modern computer (1).

🎬 Video Resources

πŸ“„ Past Papers & Exam Resources

πŸ”— Further Reading & Resources

🧠 Flashcards (Spaced Repetition)

πŸ“ Exam Questions by Topic

🎯 Target Tests (Auto-Graded)

πŸŽ“ Smart Lesson (Guided)