This mini-lesson covers AQA 4.4 β Theory of computation: the deepest and most beautiful part of the course. It asks not how to solve a problem but whether it can be solved at all β and if so, in a usable time
Work through each screen, answer the questions as you go (some are recall, some are calculations you must actually work out) and collect β stars. Press Start when you're ready.
Abstraction is the removal of unnecessary detail so that the essence of a problem can be reasoned about. AQA distinguishes several kinds:
Automation is putting an abstraction to work: you build a model of a real system and then simulate it β a flight simulator, a climate model, a queueing model of a supermarket. The model is only ever as good as the abstraction it rests on.
A finite state machine (FSM) is a machine with a finite set of states, one start state, a set of accepting states, and transitions that fire on an input symbol.
An FSM can be drawn as a state transition diagram or written as a state transition table.
The limit of an FSM: it has finite memory β the current state is all it remembers. So it cannot count without bound. No FSM can recognise the language aβΏbβΏ (n a's followed by exactly n b's), because it would need unlimited memory to remember how many a's it has seen. That limit is precisely why we need Turing machines.
A regular expression is a compact way of describing a set of strings β a regular language. The key result: a language is regular if and only if some FSM accepts it. Regular expressions and finite state machines have exactly the same power.
| Symbol | Meaning | Example |
|---|---|---|
| | | either / or | a|b matches a or b |
| * | zero or more | ab* matches a, ab, abb, abbb⦠|
| + | one or more | ab+ matches ab, abb⦠but not a |
| ? | zero or one | ab? matches a and ab only |
| ( ) | grouping | (ab)* matches "", ab, abab⦠|
Useful set notation goes with this: β (member of), βͺ (union), β© (intersection), β (subset), β (empty set), and the Cartesian product A Γ B of all ordered pairs.
Real use: regular expressions drive the lexical analysis stage of every compiler β the tokeniser that recognises identifiers, numbers and keywords is, literally, a finite state machine built from regular expressions.
Backus-Naur Form (BNF) is a formal metalanguage for defining the syntax of a language. Compilers use it in the syntax analysis stage.
Read ::= as "is defined as" and | as "or". Symbols in <angle brackets> are non-terminals (defined elsewhere); everything else is a terminal.
The crucial feature is recursion: <number> is defined partly in terms of itself, which lets a finite set of rules describe an infinite set of valid numbers.
Why BNF beats regular expressions: BNF can express nested, balanced structure β matching brackets, nested IF statements β which no regular expression can. BNF describes context-free languages, a strictly larger class than the regular languages. A syntax diagram (railroad diagram) shows the same rules pictorially.
A Turing machine is the formal model of computation. It has:
That is all. Yet the Church-Turing thesis holds that anything that can be computed by any effective procedure can be computed by a Turing machine. A universal Turing machine takes the description of another Turing machine on its tape and simulates it β the theoretical ancestor of the stored-program computer.
Language hierarchy: FSM (regular) β pushdown automaton (context-free) β Turing machine (recursively enumerable). Each machine adds memory: none β a stack β an infinite tape.
Some problems are non-computable: no algorithm can exist for them, however clever the programmer and however fast the computer.
The halting problem asks: given any program and any input, decide whether that program will eventually halt or run forever. Turing proved in 1936 that no algorithm can do this for all cases.
The proof, in outline (by contradiction):
It is not a limit of technology. No future computer, no quantum machine, no amount of memory changes this. It is a limit of computation itself β and it is why no compiler can ever warn you about every infinite loop.
Even among computable problems, some are useless in practice. AQA divides them by the complexity of the best known algorithm:
| n | nΒ² | 2βΏ | n! |
|---|---|---|---|
| 10 | 100 | 1 024 | 3 628 800 |
| 20 | 400 | 1 048 576 | β 2.4 Γ 10ΒΉβΈ |
| 50 | 2 500 | β 1.1 Γ 10ΒΉβ΅ | β 3.0 Γ 10βΆβ΄ |
Because intractable problems must still be dealt with, we use a heuristic: a rule of thumb that finds a good enough answer quickly, with no guarantee of optimality. Nearest-neighbour for the travelling salesman, and the estimate function inside A*, are both heuristics.
Tap a problem, then tap the group it belongs to.
Tap an item on the left, then its partner on the right.
Abstraction: representational Β· generalisation Β· procedural Β· functional Β· data Β· information hiding
FSM: finite states + transitions; accepts regular languages only; cannot count without bound
Regex: | * + ? ( ) β regular expressions and FSMs have exactly the same power
BNF: ::= and | Β· non-terminals in angle brackets Β· recursion gives infinite languages Β· beats regex on nesting
Turing machine: infinite tape + head + finite states; Church-Turing thesis; universal TM = stored program
Halting problem: proved undecidable by contradiction β a limit of computation, not of hardware
Tractability: tractable = polynomial Β· intractable = exponential/factorial Β· use heuristics
That is the whole of AQA 4.4. Press Finish to see your score.
You've worked through Theory of computation for AQA A-level Computer Science (7517). π
Your stars: 0 / 0
Next: test yourself in the Evaluate stage Confidence Quiz, then lock it in with Verify.