Turing Machine

6 min read Updated Wed May 06 2026 17:34:33 GMT+0000 (Coordinated Universal Time)

Most powerful abstract model of computation. Can simulate any real computer (ignoring efficiency). Modelled by Alan Turing.

A 5-tuple T=(Q,Σ,Γ,q0,δ)T = (Q, \Sigma, \Gamma, q_0, \delta).

Where:

  • QQ = finite set of states
  • Σ{ha,hr}\Sigma \supset \set{ h_a, h_r } = input alphabet
  • Γ{Λ}\Gamma \supset \set{ \Lambda } = tape alphabet
  • q0q_0 = start state
  • δ:Q×ΣQ×Γ×{L,R,S}δ: Q \times \Sigma \rightarrow Q \times \Gamma \times \set{L,R,S} = transition function

Components

Tape

Consists of infinite cells. One dimensional. Works as memory.

Cell

A component inside the tape. Can be read from or written to.

Symbol

Element that can be written on a cell. Λ\Lambda means empty.

Tape Head

Points to a cell. Reads from or writes to a cell. Can move left or right or stay at the current cell.

CPU

Has internal state (from an finite set of states). Decides whether to move the tape head, in which direction to move, whether to write on the cell, what to write on the cell. Decisions based on current symbol and current state.

State

State of the machine (or the CPU). Includes 2 halting states:

  • hah_a: Accept
  • hrh_r → Reject

Transition Function

δ(q,X)=(r,Y,D)\delta(q, X) = (r, Y, D)

It means, from state qq, reading XX:

  • Write YY
  • Move to state rr
  • Move head DL,R,SD \in {L, R, S}

Configuration

Represents the current status. (q,xay)Q×Γ(q, x\underline{a}y) \in Q \times \Gamma^*. Current symbol under tape head is underlined.

For input string xx, the machine starts at (q0,Δx)(q_0, \Delta x).

Configuration Changes

Turing machine changes from 1 configuration to another in each step. Can either move in:

  • Single step
    (q,xay)T(r,zbw)(q, x\underline{a}y) \vdash_T (r, z\underline{b}w)
  • Multiple steps
    (q,xay)T(r,zbw)(q, x\underline{a}y) \vdash_T^* (r, z\underline{b}w)

Halting

Turing machine halts when it reaches either of the halting states. May run forever without halting.

Acceptance

A string xx is accepted iff the machine reaches accepting state i.e. (q0,Δx)T(ha,yaz)(q_0, \Delta x) \vdash_T^* (h_a, yaz).

Examples

Regular Language

L=(ab)aba(ab)L = (a|b)^*aba(a|b)^*

TM behaves like FA. Moves right only. Does not modify the tape.

Ends with “aba”

L=xx ends with abaL = {x \mid x \text{ ends with } aba}

Must read entire input before accepting.

Palindromes

L=xx=xRL = {x \mid x = x^R}

Match first and last symbols. Replace them and repeat. Deterministic.

Functions

TM can compute functions of the form f:ΣΓf: \Sigma^* \rightarrow \Gamma^*.

TM computes f(x)f(x) iff (q0,Δx)T(ha,Δf(x))(q_0, \Delta x) \vdash_T^* (h_a, \Delta f(x)).

Partial Functions

When the function is undefined for certain inputs.

TM will produce output only for valid inputs. Loop indefinitely otherwise.

Characteristic Function

For a language LL:

f(x)={1if xL0otherwisef(x) = \begin{cases} 1 & \text{if } x \in L \\ 0 & \text{otherwise} \end{cases}

Combination

Suppose T1T_1 and T2T_2 are 2 Turing machines with disjoint non-halting states and transition functions.

T1T2T_1T_2 denotes a new Turing machine that is a combination of the 2. It starts with the initial state of T1T_1 and executes T1T_1 first. For any move that halts in an accepting state of T1T_1, the machine moves to the initial state of T2T_2 and execute T2T_2. Can also be denoted as T1T2T_1 \rightarrow T_2.

If either T1T_1 or T2T_2 rejects, T1T2T_1T_2 also rejects.

Variations

Many minor variations can be defined such as:

  • A Turing machine that must move either left or right
  • A Turing machine that can either write a symbol or move but not both
  • A Turing machine with multiple tapes and multiple tape heads However the ultimate computing power is unchanged.

n-tape Turing Machine

A Turing machine with multiple tapes. Each tape has its own tape head.

An nn-tape Turing machine is a 6-tuple M=(Q,Σ,Γ,δ,q0,F)M = (Q, \Sigma, \Gamma, \delta, q_0, F) where:

  • QQ: finite set of states
  • Σ\Sigma: input alphabet
  • Γ\Gamma: tape alphabet (ΣΓ\Sigma \subseteq \Gamma)
  • q0q_0: initial state
  • FF: set of accepting states
  • δQ×ΓnQ×Γn×L,R,Sn\delta Q \times \Gamma^n \rightarrow Q \times \Gamma^n \times {L, R, S}^n: transition function

The machine reads n symbols (one from each tape). Based on the current state and these symbols:

  • It moves to a new state
  • Writes n symbols (one on each tape)
  • Moves each tape head independently (Left, Right, or Stay)

Non-deterministic TM

Aka. NTM. Same as the deterministic TM except the transition function’s output is a set of configurations.

For any non-deterministic TM, there exists a deterministic TM that accept the same language.

Universal TM

Denoted by TuT_u A Turing machine that can run any arbitrary program with an arbitrary data set (input to the program).

  • The program is expressed as a string that specifies another special purpose TM, T1T_1
  • Data set is a string ww (input to T1T_1)

TuT_u simulates the processing of ww by T1T_1.

Church-Turing Thesis

Formerly known as Church’s thesis. Says that a TM is a general model of computation, i.e. any real-world computation can be translated into an equivalent computation involving a Turing machine.

First formulated by Alonzo Church. Considered as a conjecture as well.

It’s generally accepted because:

  • no one has proposed a counterexample for 90+ years
  • other theoretical computation models have been proven to be equivalent to a Turing machine
  • enhanced Turing machines do not enhance the computing power
  • nature of Turing machine indicate all steps crucial to human computation

Characteristic Function

For any language LL in Σ\Sigma^*, its characteristic function χL:Σ{0,1}\chi_L: \Sigma^* \rightarrow \set{0,1} is defined as:

χL(x)={1 if xL0otherwise\chi_L(x) = \begin{cases} 1 \quad \text{ if } x \in L &\\ 0 \quad \text{otherwise} \end{cases}

Computing χL\chi_L is the same as accepting a language.

A Turing machine may distinguish between strings that are in LL and not in LL by either:

  • accepting or rejecting the string OR
  • accepting and ending up in either (ha,Δ0)(h_a,\Delta 0) or (ha,Δ1)(h_a, \Delta 1) configurations

Accept vs Decide

A Turing machine TT accepts LL iff TT accepts all strings of LL. For all strings of LL, the Turing machine TT halts in an accepting state. But for other strings, it may:

  • Halt at a rejecting state OR
  • Loop forever

A Turing machine TT decides LL iff:

  • TT halts in state hah_a and
  • calculates its characteristic function, for every string xΣx \in \Sigma^*.
T decides L    T accepts LT\text{ decides }L \implies T\text{ accepts }L

Turing Completeness

A system is said to Turing complete if it can simulate any Turing machines.