The Timpson Lyceum · Computation Theory
Lecture 12 (Computation Theory) Turing Machines
Turing Machines – Lecture 12
Overview
This lecture introduces the Turing machine, the most powerful model of computation we study and a faithful abstraction of a general-purpose computer with unbounded memory. After the limitations of pushdown automata, the Turing machine gains the ability to both read and write a two-way-movable head on an infinite tape, and it accepts or rejects the instant it enters a dedicated halt state rather than waiting to finish reading the input. We define the machine formally as a 7-tuple, build up the notion of a configuration and the yields relation that links one configuration to the next, and then state precisely what it means for a machine to accept, reject, or loop forever. Finally we distinguish the two central language classes of the rest of the course: Turing-recognizable and decidable.
Key Concepts
From PDA to Turing machine. A pushdown automaton has a state control, a read-only input, and a stack. A Turing machine keeps the state control but replaces the input + stack with a single tape:
- The tape is infinite (extends infinitely to the right; the input occupies the leftmost cells and every cell beyond it holds the blank symbol
⊔). - The head can both read and write the current cell, and can move left or right each step (not just rightward).
- Turing machines are deterministic: for each (state, tape symbol) there is exactly one action.
- There is no notion of "finishing" the input. The machine has a special accept state and reject state; entering either one halts the machine immediately (accept → accept, reject → reject), regardless of head position.
Transition notation. An edge labeled a, b → R means: if the head reads a, write b, then move right. If you read and write the same symbol you may abbreviate a → R (read a, leave it, move right). There is no "stay" action; you can only move left or right.
Formal definition. A Turing machine is a 7-tuple :
- — finite set of states.
- — input alphabet; the blank symbol (otherwise the input would be infinitely long).
- — tape alphabet; must contain , and (you must be able to write the input on the tape).
- — the transition function: given a state and the tape symbol under the head, it returns the next state, the symbol to write, and the direction to move.
- — start state; — accept state; — reject state (with ).
Implicit reject. Because the machine is deterministic, any (state, symbol) pair with no drawn transition is understood to go to . Diagrams omit these edges (there would be one from nearly every state) — they are implied.
Left-edge behavior. If the head is on the leftmost cell and is told to move left, it stays put. To avoid relying on this, mark the left end with a sentinel symbol (e.g. $) so the program never tries to run off the left edge.
Configuration. A configuration captures the entire instantaneous state of the machine — like a save file. For state and tape strings , write to mean: the tape contains (then blanks), the machine is in state , and the head is on the first symbol of . Example: with the head reading the 0 in 0 1 X | y 1 0 while in state , the configuration is .
The "yields" relation. Configuration yields if the machine can move legally from to in one step. Concretely, if then yields ; if then yields .
Acceptance / rejection / looping. accepts if there is a sequence of configurations where is the start configuration , each yields , and is an accepting configuration. Rejection is defined the same way ending in a rejecting configuration. Crucially, a Turing machine need not do either — it may loop forever. (Finite automata and PDAs couldn't loop because they consumed input each step; Turing machines have no such guarantee.)
Two language classes (the heart of the rest of the course):
- A language is Turing-recognizable (mathematicians: recursively enumerable) if some Turing machine accepts exactly the strings in it. On non-members the machine may reject or loop forever.
- A language is decidable (mathematicians: recursive) if some Turing machine accepts every string in the language and rejects every string not in it — it always halts. Every decidable language is Turing-recognizable, but not conversely; the gap is the undecidable-but-recognizable languages.
- Intuition (halting problem): the strings that cause a machine to halt are recognizable — just run and wait, a halting one eventually halts — but you can't recognize the non-halting ones, since a slow run is indistinguishable from one that never ends.
Describing machines at a high level. Drawing full diagrams is extremely tedious, so for anything nontrivial we instead give a step-by-step procedure (a verbose pseudocode), and assume a reader could build the actual machine from it. A common first line is "scan the input to confirm it has the form of some regular expression," which is trivially Turing-implementable since any regular language is.
Worked Example
Goal: build a Turing machine recognizing by pairing each 0 with a 1. Strategy: replace the leftmost 0 with X, scan right to the leftmost 1 and replace it with Y, return left, and repeat; accept iff every symbol is crossed off. Trace the input 0011 (then blanks) by listing configurations, where scans right over 0's and scans left over 0's:
After all 0's are X and all 1's are Y, the head scans right over the Y's; reading a blank with nothing left to match means the counts were equal, so the machine accepts. Any leftover 0/1, or a missing partner, falls through to the implicit reject.
Summary
- A Turing machine adds a read/write head, a two-way infinite tape, and left/right motion to the finite-state control — making it equivalent to a real computer with unbounded memory.
- It is deterministic and halts the instant it enters or ; missing transitions implicitly reject.
- Formally it is the 7-tuple with , , and .
- A configuration records the whole machine state; the yields relation chains configurations, and acceptance is a legal chain from the start configuration to an accepting one.
- Turing-recognizable: some machine accepts exactly the language (may loop on non-members). Decidable: some machine always halts, accepting members and rejecting non-members. Every decidable language is recognizable, but not vice versa.
- Beyond toy languages, machines are specified by a clear procedure rather than a full state diagram, since explicit diagrams grow unmanageably large.