Skip to content

Turing Machines

The Turing machine (TM) is the most powerful model of computation. It captures everything that can be computed algorithmically. Unlike finite automata and PDAs, a TM has unlimited memory in the form of an infinite tape.


Formal Definition

A Turing machine is a 7-tuple M=(Q,Σ,Γ,δ,q0,B,F):

  • Q: finite set of states
  • Σ: input alphabet (does not contain the blank symbol)
  • Γ: tape alphabet (ΣΓ)
  • δ: transition function Q×ΓQ×Γ×{L,R}
  • q0Q: start state
  • BΓΣ: blank symbol
  • FQ: halting/final states

Transition Interpretation

δ(q,X)=(p,Y,D) means:

In state q, reading symbol X on the tape, write Y, move the head in direction D (Left or Right), and go to state p.

Computation Model

  • Infinite tape divided into cells, each holding one symbol from Γ
  • Initially, the input string w is written at the left end of the tape, preceded and followed by blanks (B)
  • The tape head starts at the leftmost symbol of the input
  • The TM can read, write, and move the head at each step
  • The TM halts when it enters a state qF (accept) or when δ(q,X) is undefined (reject)

Instantaneous Description (ID)

An ID is a string X1X2Xi1qXiXi+1Xn where:

  • q is the current state
  • The tape head is scanning Xi
  • Everything to the left and right (up to first infinite blank) is shown

Moves

X1Xi1qXiXnX1Xi1YpXi+1Xn if δ(q,Xi)=(p,Y,R)

= zero or more moves.


Acceptance and Language

A TM M accepts input w if:

q0wαpβ for some pF

L(M) = set of strings accepted by M.

Recursive vs. Recursively Enumerable (RE)

  • L is recursively enumerable (RE): There exists a TM that accepts L. If wL, the TM may run forever (not halt).
  • L is recursive (decidable): There exists a TM that accepts L AND halts on all inputs (both wL and wL).
RecursiveREAll languages

Variations of Turing Machines (All Equivalent)

Multi-Tape TM

Has k tapes, each with its own head. Transition: δ(q,X1,,Xk)=(p,Y1,D1,,Yk,Dk).

Equivalence: Can be simulated by a single-tape TM using tracks or interleaving. k tapes → k tracks on one tape, with markers for head positions. Simulation overhead: O(n2).

Nondeterministic TM (NTM)

δ returns a SET of choices: δ(q,X)={(p1,Y1,D1),(p2,Y2,D2),}.

w is accepted if SOME sequence of choices leads to acceptance.

Equivalence: Simulated by a deterministic TM using breadth-first search (dovetailing) of the nondeterministic computation tree — exponential time in worst case.

Semi-Infinite Tape

Tape infinite only to the right. Simulated by two-track tape: one track for the right half, another for the left half (with reversed addressing).

Multi-Track Tape

Each cell holds a tuple of symbols. Equivalent to expanding the tape alphabet (Γk).

Enumerator

A TM with a printer that outputs strings. A language is RE iff some enumerator enumerates it.


The Church-Turing Thesis

Every effectively computable function can be computed by a Turing machine.

This is a thesis, not a theorem — it connects the intuitive notion of "algorithm" to the formal TM model. All other formal models of computation (lambda calculus, recursive functions, register machines, Post systems, etc.) have been proven equivalent to TMs.

No one has found a computational model more powerful than the TM (that is physically realizable).


Universal Turing Machine

A universal TM U takes an encoding M,w of a TM M and input w, and simulates M on w.

L(U)={M,wM accepts w}

The existence of U is fundamental — it's the theoretical basis for stored-program computers: one machine can simulate any other.

Encoding

  • States: q0,q1,q2, represented as q followed by binary
  • Symbols: X0,X1,X2, (binary)
  • Transitions: Encoded as qiXjqkXlDm (binary)
  • Separator: Use special delimiter

Decoding the Language ATM

ATM={M,wM accepts w}

ATM is recursively enumerable (recognizable by U) but NOT recursive (not decidable).


Decidable Problems About Turing Machines

Some problems about TMs are decidable:

  • Does a TM have exactly k states? (just count)
  • Given a TM and k, does the TM use more than k tape cells on a particular input of length n? (simulate for up to k steps)

Most interesting questions, however, are undecidable.


The Halting Problem

HALTTM={M,wM halts on input w}

Theorem: HALTTM is undecidable.

If a decider for HALTTM existed, we could decide ATM: run the halting decider on M,w; if it says "does not halt", reject; if "halts", simulate M on w to see if it accepts.