Skip to content

Turing Machines

4.1 Definition

A Turing machine (TM) is a 7-tuple M=(Q,Σ,Γ,δ,q0,qaccept,Qreject)M = (Q, \Sigma, \Gamma, \delta, q_0, q_{\mathrm{accept}, Q_{\mathrm{reject})}} where:

  • QQ is a finite set of states.
  • Σ\Sigma is the input alphabet (does not contain the blank symbol \sqcup).
  • Γ\Gamma is the tape alphabet, Γ\sqcup \in \Gamma, ΣΓ\Sigma \subseteq \Gamma.
  • δ:Q×ΓQ×Γ×{L,R}\delta : Q \times \Gamma \to Q \times \Gamma \times \{L, R\} is the transition function.
  • q0Qq_0 \in Q 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.

MM accepts input ww if the computation halts in q_{\mathrm{accept}. MM rejects ww if It halts in q_{\mathrm{reject}. MM loops if it never halts.

The language recognised by MM 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 (q,a1,,ak)(q, a_1, \ldots, a_k) to (q",b1,,bk,d1,,dk)(q", b_1, \ldots, b_k, d_1, \ldots, d_k).

Theorem 4.1. Every multitape TM has an equivalent single-tape TM.

Proof. Simulate kk tapes on a single tape using kk tracks (or interleaving symbols with Delimiters). Simulating one step of the multitape TM requires scanning the single tape to read all kk heads and update them, costing O(kn)O(k \cdot n) steps per simulated step. \blacksquare

Nondeterministic TMs. δ:Q×ΓP(Q×Γ×{L,R})\delta : Q \times \Gamma \to \mathcal{P}(Q \times \Gamma \times \{L, R\}). 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 bb branches (where bb is the maximum number of choices). After nn steps, the tree has At most bnb^n 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 O(bn)O(b^n) times the NTM’s time, which is exponential overhead. \blacksquare

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. (\Rightarrow) Given TM MM recognising LLConstruct an enumerator EE that dovetails: Runs MM on ε\varepsilon for 1 step, then MM on ε\varepsilon and MM on 00 for 2 steps, then on ε,0,1,00,01,10,11\varepsilon, 0, 1, 00, 01, 10, 11 for 3 steps, and so on. Whenever MM accepts, EE prints that String. Every string in LL is eventually printed.

(\Leftarrow) Given enumerator EE for LLConstruct TM MM that on input ww runs EE and checks Each printed string against ww. If ww is printed, accept. If wLw \in LIt will eventually be Printed, so MM recognises LL. \blacksquare

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:

  1. Robustness. Every “reasonable” model of computation proposed since the 1930s has been shown to compute exactly the Turing-computable functions.
  2. Invariance. Adding resources (more tapes, nondeterminism, random access) does not increase the class of computable functions.
  3. Empirical adequacy. No physically realisable process has been shown to compute a non-Turing-computable function.
  4. 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 L={0n1n:n0}L = \{0^n 1^n : n \geq 0\}.

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:

  1. In q0q_0Read 0: write xMove right, go to q1q_1. (Cross off a 0.)
  2. In q0q_0Read 1: reject. (A 1 before any 0.)
  3. In q0q_0Read \sqcup: accept. (Nothing left.)
  4. In q1q_1Read 0: move right, stay in q1q_1. (Skip remaining 0S.)
  5. In q1q_1Read 1: write xMove left, go to q2q_2. (Cross off a 1.)
  6. In q1q_1Read \sqcup: reject. (No 1 to match.)
  7. In q2q_2Read 0 or x: move left, stay in q2q_2. (Scan back.)
  8. In q2q_2Read \sqcup: move right, go to q0q_0. (Return to start.)

Correctness. Each iteration crosses off exactly one 0 and one 1. If the input is 0n1n0^n 1^n The machine performs nn iterations and accepts. If counts differ or the pattern is violated, The machine rejects. \blacksquare

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 B,w\langle B, w \rangle where B=(Q,Σ,δ,q0,F)B = (Q, \Sigma, \delta, q_0, F):

  1. Simulate BB on ww. Maintain the current state qq and position ii in ww.
  2. At each step, look up δ(q,wi)\delta(q, w_i) in BB‘s transition table (encoded on the tape).
  3. Update qq and ii. If qFq \in F when i=w+1i = |w| + 1Accept.
  4. If i=w+1i = |w| + 1 and qFq \notin FReject.

The simulation takes O(w)O(|w|) steps and always halts. \blacksquare

4.5 The Universal Turing Machine

A universal Turing machine (UTM) UU is a Turing machine that can simulate any other Turing Machine MM on any input ww. The input to UU is an encoding M,w\langle M, w \rangle.

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 UU uses multiple tapes:

  1. Tape 1: Stores the description M\langle M \rangle of the simulated TM (the “program”).
  2. Tape 2: Stores the current contents of MM‘s tape (the “memory”).
  3. Tape 3: Stores the current state of MM and the position of MM‘s head.

At each step, UU reads the current state and tape symbol from tapes 3 and 2, scans tape 1 to Find the matching transition in MM‘s description, updates tape 2 (write symbol), tape 3 (state And head position), and repeats. Since MM‘s description is finite and each step requires a finite Scan, UU correctly simulates MM. \blacksquare

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 MM runs in time t(n)t(n)Then UU simulates MM in time O(t(n)M)O(t(n) \cdot |M|)Where M|M| is the size of MM‘s description.

Worked Example: TM for $L = \{w\#w^R : w \in \{0,1\}^*\}$

Design a TM that decides L={w#wR:w{0,1}}L = \{w\#w^R : w \in \{0,1\}^*\}.

Idea: Repeatedly check the first and last non-#\# symbols, then cross them off. When only #\# remains, accept.

Algorithm:

  1. Scan right to find the rightmost non-\sqcupNon-\mathrm{x symbol (call it aa). If we cross #\# on the way, note its position.
  2. Return to the leftmost non-\sqcupNon-\mathrm{x symbol (call it bb).
  3. If aba \neq bReject.
  4. Cross off both aa and bb (write \mathrm{x).
  5. Repeat until only #\# (and \mathrm{xS) remain, then accept.

Correctness. If the input is w#wRw\#w^RThe first symbol of ww equals the last symbol of wRw^R (which is the first symbol of ww), the second equals the second-to-last, etc. Each Iteration verifies one pair. If any pair mismatches, the string is not of the form w#wRw\#w^R. \blacksquare