Turing Machines
4.1 Definition
A Turing machine (TM) is a 7-tuple where:
- is a finite set of states.
- is the input alphabet (does not contain the blank symbol ).
- is the tape alphabet, , .
- is the transition function.
- is the start state.
- q_{\mathrm{accept} \in Q is the accept state.
- q_{\mathrm{reject} \in Q is the reject state (q_{\mathrm{accept} \neq q_{\mathrm{reject}).
The TM has an infinite tape (initially containing the input followed by blanks), a read/write head That moves left or right, and a finite control. At each step, based on the current state and symbol Under the head, it writes a symbol, moves the head, and changes state.
accepts input if the computation halts in q_{\mathrm{accept}. rejects if It halts in q_{\mathrm{reject}. loops if it never halts.
The language recognised by is L(M) = \{w : M \mathrm{ accepts w\}.
A language is Turing-recognisable (recursively enumerable) if some TM recognises it. A language Is decidable if some TM decides it (halts on all inputs, accepting or rejecting).
4.2 TM Variants
Multitape TMs. Multiple tapes, each with its own head. The transition function maps to .
Theorem 4.1. Every multitape TM has an equivalent single-tape TM.
Proof. Simulate tapes on a single tape using tracks (or interleaving symbols with Delimiters). Simulating one step of the multitape TM requires scanning the single tape to read all heads and update them, costing steps per simulated step.
Nondeterministic TMs. . The TM accepts if some computation path accepts.
Theorem 4.2. Every nondeterministic TM has an equivalent deterministic TM.
Proof. Simulate the NTM using breadth-first search on the computation tree. Each level of the tree Has at most branches (where is the maximum number of choices). After steps, the tree has At most nodes. The simulation visits nodes in order, using a 3-tape DTM: tape 1 stores the Input, tape 2 simulates the current branch, tape 3 tracks the address of the current node in the Tree. The simulation runs in times the NTM’s time, which is exponential overhead.
Enumerators. A TM with a printer that outputs a list of strings. A language is Turing-recognisable If and only if some enumerator enumerates it.
Theorem 4.2a. A language is Turing-recognisable if and only if some enumerator enumerates it.
Proof. () Given TM recognising Construct an enumerator that dovetails: Runs on for 1 step, then on and on for 2 steps, then on for 3 steps, and so on. Whenever accepts, prints that String. Every string in is eventually printed.
() Given enumerator for Construct TM that on input runs and checks Each printed string against . If is printed, accept. If It will eventually be Printed, so recognises .
4.3 Church-Turing Thesis
Theorem 4.3 (Church-Turing Thesis). A function is computable (can be computed by any reasonable Model of computation) if and only if it is computable by a Turing machine.
This is a thesis, not a theorem — it cannot be formally proved because “reasonable model” is not Formally defined. However, all proposed models of computation (lambda calculus, recursive functions, Post systems, cellular automata, modern programming languages) have been shown equivalent to Turing Machines.
Implication: To show a problem is uncomputable, it suffices to show no TM can solve it.
Evidence supporting the thesis:
- Robustness. Every “reasonable” model of computation proposed since the 1930s has been shown to compute exactly the Turing-computable functions.
- Invariance. Adding resources (more tapes, nondeterminism, random access) does not increase the class of computable functions.
- Empirical adequacy. No physically realisable process has been shown to compute a non-Turing-computable function.
- Universality. The existence of universal Turing machines (Section 4.5) shows that a single fixed machine can simulate any other, reinforcing the notion of a canonical model.
Limitations. The Church-Turing thesis concerns computability in principle (unlimited time and Space). It does not address feasibility, which is the domain of complexity theory (Section 6). Quantum computers do not compute non-Turing-computable functions; they may offer speedups for Specific problems but remain within the Turing-computable class.
4.4 TM Construction Examples
Worked Example: TM for $L = \{0^n 1^n : n \geq 0\}$
Design a single-tape TM that decides .
Idea: Repeatedly cross off one 0 and one 1. If all symbols are crossed off, accept.
M = (Q, \{0, 1\}, \{0, 1, \mathrm{x, \sqcup\}, \delta, q_0, q_{\mathrm{accept}, q_{\mathrm{reject}).
Key transitions:
- In Read
0: writexMove right, go to . (Cross off a0.) - In Read
1: reject. (A1before any0.) - In Read : accept. (Nothing left.)
- In Read
0: move right, stay in . (Skip remaining0S.) - In Read
1: writexMove left, go to . (Cross off a1.) - In Read : reject. (No
1to match.) - In Read
0orx: move left, stay in . (Scan back.) - In Read : move right, go to . (Return to start.)
Correctness. Each iteration crosses off exactly one 0 and one 1. If the input is The machine performs iterations and accepts. If counts differ or the pattern is violated, The machine rejects.
Worked Example: TM that decides $A_{\mathrm{DFA}$
Design a TM that decides A_{\mathrm{DFA} = \{\langle B, w \rangle : B \mathrm{ accepts w\}.
Construction. On input where :
- Simulate on . Maintain the current state and position in .
- At each step, look up in ‘s transition table (encoded on the tape).
- Update and . If when Accept.
- If and Reject.
The simulation takes steps and always halts.
4.5 The Universal Turing Machine
A universal Turing machine (UTM) is a Turing machine that can simulate any other Turing Machine on any input . The input to is an encoding .
Theorem 4.4. A universal Turing machine exists.
Proof (construction sketch). Fix an encoding scheme for TMs and their inputs as strings over a Finite alphabet. The UTM uses multiple tapes:
- Tape 1: Stores the description of the simulated TM (the “program”).
- Tape 2: Stores the current contents of ‘s tape (the “memory”).
- Tape 3: Stores the current state of and the position of ‘s head.
At each step, reads the current state and tape symbol from tapes 3 and 2, scans tape 1 to Find the matching transition in ‘s description, updates tape 2 (write symbol), tape 3 (state And head position), and repeats. Since ‘s description is finite and each step requires a finite Scan, correctly simulates .
Significance. The UTM is the theoretical foundation for the stored-program computer: hardware (the UTM) is fixed, and software (the encoded TM) provides the specific computation.
Simulation overhead. If runs in time Then simulates in time Where is the size of ‘s description.
Worked Example: TM for $L = \{w\#w^R : w \in \{0,1\}^*\}$
Design a TM that decides .
Idea: Repeatedly check the first and last non- symbols, then cross them off. When only remains, accept.
Algorithm:
- Scan right to find the rightmost non-Non-\mathrm{x symbol (call it ). If we cross on the way, note its position.
- Return to the leftmost non-Non-\mathrm{x symbol (call it ).
- If Reject.
- Cross off both and (write \mathrm{x).
- Repeat until only (and \mathrm{xS) remain, then accept.
Correctness. If the input is The first symbol of equals the last symbol of (which is the first symbol of ), the second equals the second-to-last, etc. Each Iteration verifies one pair. If any pair mismatches, the string is not of the form .