You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
A Turing machine is the most powerful model of computation in the whole of theoretical Computer Science — and, remarkably, one of the simplest to describe. Devised by Alan Turing in 1936, years before any electronic computer existed, it was not a blueprint for a machine to build but a mathematical idealisation designed to answer a profound question: what does it mean for something to be computable at all? Turing's answer — a tireless clerk following fixed rules, with an endless supply of paper, reading and rewriting symbols one at a time — turned out to capture every form of mechanical computation we have ever devised. Anything a modern supercomputer can compute, a Turing machine can compute too (given enough tape and time); and, more startlingly, there are precisely-stated problems that no Turing machine — and therefore no computer ever — can solve.
This is the model that sits at the top of the automata story you have been building. A finite-state machine has only its states as memory; a pushdown automaton adds a stack; a Turing machine adds an unbounded tape it can move along and rewrite freely — and that single addition is enough to make it as powerful as computation gets. This lesson develops the H446 view: the Turing-machine model (tape, head, states, transition function), the formal definition written in proper notation, two fully worked machines that you can trace by hand, the idea of the Universal Turing Machine (one machine that runs any other — the theoretical root of the stored-program computer), the Church–Turing thesis, and the halting problem — the landmark proof that some things are simply non-computable. The halting problem links straight to the optimisation & tractability material in the Algorithms course, where the practical cousin of "impossible" — "possible but infeasible" — is explored.
This lesson addresses the Turing-machine content of H446 section 2.1 (computational methods / theory of computation). The specification expects you to be able to:
It is the apex of the automata sequence (FSMs → pushdown automata → Turing machines) developed across this course, and it connects to optimisation & tractability (Algorithms course) and stored-program architecture (Processors topic).
A Turing machine has just four parts, but each is chosen with care:
| Component | Description |
|---|---|
| Tape | an infinite strip of cells, each holding one symbol (or a blank); it can be read and written, and is unbounded in (at least) one direction |
| Read/write head | points at one cell at a time; it can read that cell's symbol, overwrite it, and move one cell left or right |
| State register | holds the machine's current state, one of a finite set |
| Transition function | the fixed rulebook: given (current state, symbol read) it dictates (symbol to write, direction to move, next state) |
The contrast with the earlier automata is the whole story. A finite-state machine reads its input once, left to right, and cannot write; its only memory is which of finitely many states it is in. A Turing machine can move both ways along its tape and rewrite any cell, and its tape is unbounded — so it has effectively limitless, re-usable memory it can revisit as often as it likes. That is exactly the capability the lesser machines lacked, and it is why the Turing machine can do things (genuine arithmetic, simulating other machines, recognising the hardest languages) that they cannot.
At each step the machine:
That final clause is not a flaw to be engineered away — the possibility of running forever is intrinsic to the model, and it is precisely what makes the halting problem meaningful later.
A Turing machine is formally a 7-tuple:
M=(Q, Σ, Γ, δ, q0, qaccept, qreject)
with each component defined as follows:
| Symbol | Meaning |
|---|---|
| Q | a finite set of states |
| Σ | the input alphabet — symbols that may appear on the tape initially (the blank is not in Σ) |
| Γ | the tape alphabet — everything that may appear on the tape; it includes Σ and the blank symbol |
| δ | the transition function (the rulebook) |
| q0 | the start state (an element of Q) |
| qaccept | the accepting halting state |
| qreject | the rejecting halting state |
The transition function has the signature
δ:Q×Γ → Q×Γ×{L,R}
which reads: given a state and the symbol under the head, produce a next state, a symbol to write, and a move direction (Left or Right). The relationship Σ⊆Γ — the input alphabet is part of the larger tape alphabet — matters because a machine often needs extra working symbols (markers, a blank) that were never in the input but are useful as scratch notation on the tape.
A single rule of δ is conventionally written
δ(qi, a)=(qj, b, D)
meaning: in state qi, reading symbol a, write b, move in direction D, and switch to state qj. The same information is usually laid out as a table. Here, for instance, is a machine that flips every bit and then returns the head to the left (using _ for the blank):
| Current state | Read | Write | Move | Next state |
|---|---|---|---|---|
| q0 | 0 | 1 | R | q0 |
| q0 | 1 | 0 | R | q0 |
| q0 | _ | _ | L | q1 |
| q1 | 0 | 0 | L | q1 |
| q1 | 1 | 1 | L | q1 |
| q1 | _ | _ | R | qhalt |
Reading row 1 in formal notation: δ(q0,0)=(q0,1,R). The table is the machine — together with the start state and the alphabets, it fully determines the behaviour, exactly as a state-transition table fully determines an FSM.
A useful idea when tracing is the configuration (sometimes called an instantaneous description): a complete snapshot of the machine at one moment, consisting of the current state, the entire tape contents, and the head position. Because the transition function is fixed, each configuration determines exactly one next configuration — so a Turing-machine computation is nothing more than a chain of configurations, each following from the last by one rule, starting from the initial configuration (start state, head on the leftmost input symbol) and ending — if it ends at all — in a halting configuration. The trace tables below are simply that chain of configurations written out row by row, which is why showing the state, full tape and head position on every line is the correct way to present a trace.
Task. Build a Turing machine that replaces every bit of a binary string with its complement (every 0→1, every 1→0).
Idea. Sweep right across the string, flipping each bit as the head passes over it, and stop at the first blank. Only one working state is needed:
| Current state | Read | Write | Move | Next state |
|---|---|---|---|---|
| q0 | 0 | 1 | R | q0 |
| q0 | 1 | 0 | R | q0 |
| q0 | _ | _ | L | qhalt |
Formally the flipping rules are δ(q0,0)=(q0,1,R) and δ(q0,1)=(q0,0,R), with δ(q0,_)=(qhalt,_,L) to stop at the blank. Trace on input 10110 (head starts on the leftmost symbol; brackets mark the head):
| Step | State | Tape (head in brackets) | Action |
|---|---|---|---|
| 0 | q0 | _ [1] 0 1 1 0 _ | read 1 → write 0, move R |
| 1 | q0 | _ 0 [0] 1 1 0 _ | read 0 → write 1, move R |
| 2 | q0 | _ 0 1 [1] 1 0 _ | read 1 → write 0, move R |
| 3 | q0 | _ 0 1 0 [1] 0 _ | read 1 → write 0, move R |
| 4 | q0 | _ 0 1 0 0 [0] _ | read 0 → write 1, move R |
| 5 | q0 | _ 0 1 0 0 1 [_] | read _ → halt (move L into qhalt) |
Output tape: _ 0 1 0 0 1 _. The complement of 10110 is 01001 — correct. Notice how the machine rewrites the tape in place, something no FSM can do — the tape is both the input and the workspace.
Task. Add 1 to a number written in unary (the number n is written as n ones). So 111 (three) must become 1111 (four).
Idea. Walk right over the existing ones to the first blank, write a 1 there, and stop:
| Current state | Read | Write | Move | Next state |
|---|---|---|---|---|
| q0 | 1 | 1 | R | q0 |
| q0 | _ | 1 | L | qhalt |
In notation: δ(q0,1)=(q0,1,R) to skip over existing ones, and δ(q0,_)=(qhalt,1,L) to append the new one. Trace on 111:
| Step | State | Tape (head in brackets) | Action |
|---|---|---|---|
| 0 | q0 | _ [1] 1 1 _ | read 1 → keep, move R |
| 1 | q0 | _ 1 [1] 1 _ | read 1 → keep, move R |
| 2 | q0 | _ 1 1 [1] _ | read 1 → keep, move R |
| 3 | q0 | _ 1 1 1 [_] | read _ → write 1, halt |
Output: 1111 — four in unary. The machine extended its own data by writing into a previously blank cell, using the unbounded tape as growable memory. These two examples — complement and increment — show the model doing genuine symbol manipulation that a finite-state or pushdown machine could not.
So far each machine does one job, hard-wired into its rules. Turing's masterstroke was to show that a single machine can do every job. A Universal Turing Machine (UTM) is a Turing machine that takes, as its input, an encoded description of any other Turing machine T together with T's input, and then simulates T on that input — producing whatever T would have produced.
| Aspect | Detail |
|---|---|
| Input | a description of a machine T (its rules), plus the input intended for T |
| Operation | the UTM reads T's description and faithfully imitates T step by step |
| Significance | one fixed machine can perform the computation of any machine — generality from a single device |
The implications are enormous, and they are why the UTM, not the special-purpose machines, is the truly profound idea. The UTM is the theoretical ancestor of the stored-program (von Neumann) computer:
In other words, the reason a single physical computer can run a word processor, a game, and a compiler — rather than needing a different machine soldered for each — is precisely the universality Turing identified in 1936. Programs are data that another program (the machine) interprets.
Key Term: The Universal Turing Machine is why general-purpose computing exists. Because one machine can simulate any other from a stored description, we write software — programs treated as data — instead of building bespoke hardware for every task. This is the conceptual seed of the stored-program architecture.
The Church–Turing thesis asserts:
Any function that can be computed by any effective (mechanical, step-by-step) method can be computed by a Turing machine.
It is one of the most important claims in the subject, and its status is worth getting exactly right:
| Aspect | Detail |
|---|---|
| It is a thesis, not a theorem | It cannot be proved, because "any effective method" is an informal, intuitive notion — there is nothing precise to prove it against |
| Overwhelming evidence | Every model of computation ever proposed (lambda calculus, recursive functions, register machines, real computers) has turned out no more powerful than a Turing machine |
| No counterexample | In nearly a century, nothing computable by any means has been found that a Turing machine cannot compute |
| Implication | the Turing machine defines the limit of what is computable — "computable" effectively means "computable by a Turing machine" |
The practical upshot is stark: if no Turing machine can solve a problem, then no computer can solve it — ever — regardless of speed or memory. Computability is not about engineering; it is an absolute mathematical boundary.
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.