CS Atlas GATE 2027
TOC course
0 / 91 complete

TOC/Phase 4 · Turing Machines

Lesson 4.4 · Item 74 of 91

Encoding TMs, the universal TM, and the Church–Turing thesis

Read at your own pace. Try the questions before opening the answers.

On this page

Recall warm-up

  1. If L and L̅ are RE, what is L?
    Stuck? Peek at 4.3.3 Closure of REC and RE; L and L̅ both RE ⇒ L recursive
    • REC closed: ∪ ∩ complement − concat * reversal h⁻¹; not h.
    • RE closed: ∪ ∩ concat * reversal h h⁻¹; not complement, not difference.
    • L, L̅ ∈ RE ⇒ L ∈ REC. L ∈ RE − REC ⇒ L̅ ∉ RE.

    Read lesson 4.3.3

  2. What is the difference between a decider and a recognizer?
    Stuck? Peek at 4.3.1 Recursive vs recursively enumerable; deciders and recognizers
    • Recognizer: accepts L, may loop outside. RE = recognizable = semi-decidable = enumerable.
    • Decider: halts always. Recursive = decidable.
    • REC ⊆ RE. Enumerator ⇔ recognizer (dovetailing). Shortlex enumeration ⇔ recursive.

    Read lesson 4.3.1

  3. What is ⟨X⟩?
    Stuck? Peek at 0.3.4 Problems as languages
    • Problem P ↔ language L_P = {⟨x⟩ : answer yes}. ⟨X⟩ = string encoding of X.
    • Solving P = machine M with: M says yes on w ⇔ w ∈ L_P (membership).
    • Always test ε against count conditions.

    Read lesson 0.3.4

The Hook

Your laptop runs a web browser, a game, a compiler — one machine, any program. Turing saw this in 1936: a single universal TM can read the description of any TM M plus an input w, and do whatever M would do on w. This makes programs into data — and that is exactly what lets us ask machines questions about other machines, the gateway to Phase 5.

Predict First

A TM is a finite object: finitely many states, symbols and transitions. Can every TM be written as a finite binary string?

Core Concept

Prediction check

Yes. Number the states q₁, q₂, …, the tape symbols X₁, X₂, …, directions D₁ = L, D₂ = R; write each transition δ(qᵢ, Xⱼ) = (qₖ, Xₗ, Dₘ) as 0ⁱ1 0ʲ1 0ᵏ1 0ˡ1 0ᵐ and separate transitions with 11. The whole machine is one binary string ⟨M⟩.

0100100010100q₁X₂q₃X₁R
δ(q₁, X₂) = (q₃, X₁, R) encoded as 0 1 00 1 000 1 0 1 00.

TMs are countable

Every TM has a finite binary code, so TMs can be listed M₁, M₂, M₃, … in shortlex order of their codes (strings that are not valid codes can stand for a fixed trivial machine). There are only as many TMs as there are natural numbers. Phase 5 compares this with how many languages exist.

TM M
code ⟨M⟩ ∈ {0,1}*
position in shortlex order
M₁, M₂, M₃, …
Every machine gets a number.

The universal Turing machine

A universal TM U takes input ⟨M, w⟩ and simulates M on w: U accepts iff M accepts w, rejects iff M rejects, loops iff M loops.

Implementation: tape 1 holds ⟨M⟩, tape 2 simulates M’s tape, tape 3 holds M’s current state; each step looks up the matching transition in the code. (Multi-tape is fine — 4.2.)

So L(U) = { ⟨M, w⟩ : M accepts w } is RE. Whether it is recursive is the first question of Phase 5.

tape 1
⟨M⟩ — the program
tape 2
M’s tape contents
tape 3
M’s current state
U = an interpreter.

The Church–Turing thesis

Church–Turing thesis: every function that can be computed by an effective, step-by-step procedure (an algorithm) can be computed by a Turing machine.

It is a thesis, not a theorem: “effective procedure” is an informal idea. The evidence: every proposed model — λ-calculus, recursive functions, register machines, every programming language — computes exactly the same functions.

Consequence: “there is no algorithm for X” and “no TM decides X” mean the same thing.

λ-calculus
=
recursive functions
=
register machines
=
Python / C / Java
=
Turing machines
all compute the same functions
Every reasonable model lands on the same class.

Putting it together

  • Every TM is a finite string; TMs can be listed M₁, M₂, …
  • A universal TM runs any encoded TM on any input.
  • Church–Turing: TM = algorithm, so “no TM” means “no algorithm”.

Visual

⟨M, w⟩ ──► [ U ] ──►  accept   if M accepts w
                     reject   if M rejects w
                     loop     if M loops on w
L(U) = { ⟨M,w⟩ : M accepts w }   — RE (U recognizes it)

Worked Examples

Easy

Is the set of all TMs finite, countably infinite, or larger?

Show the full solution

Countably infinite: each TM has a finite binary code.

Medium

Is the Church–Turing thesis a theorem?

Show the full solution

No — it relates a mathematical notion (TMs) to an informal one (algorithms); it cannot be proved, only supported by evidence.

GATE-level

Which are true? (i) A universal TM exists. (ii) The universal TM halts on every input. (iii) { ⟨M, w⟩ : M accepts w } is RE. (iv) The Church–Turing thesis implies a quantum computer can solve problems no TM can.

Show the full solution

(i) true. (ii) false — it loops when the simulated M loops. (iii) true. (iv) false — the thesis says the opposite about computability (speed is another matter). Answer: (i) and (iii).

GATE Traps

  • The universal TM is a recognizer for { ⟨M, w⟩ : M accepts w }, not a decider.
  • Church–Turing is a thesis (a hypothesis about the informal notion of algorithm).
  • Programs are data: questions “about TMs” are questions about strings ⟨M⟩.

Memory Hook

The universal TM is the clerk who is handed another clerk’s rulebook and follows it to the letter — including getting stuck forever when that clerk would.

Connect the Dots

Phase 4 complete. We have the most powerful machine model and a machine that runs every other machine. Phase 5 asks the question Turing asked: are there problems no TM can decide? You will prove there are — starting from a counting argument and a diagonal trick.

Self-Test

  1. MCQ

    The universal TM U on ⟨M, w⟩:

    1. always halts
    2. accepts iff M accepts w
    3. decides whether M halts
    4. rejects if M loops
  2. MSQ

    Which are true?

    1. Every TM can be encoded as a binary string
    2. The set of TMs is countable
    3. Church–Turing thesis is a proven theorem
    4. { ⟨M,w⟩ : M accepts w } is RE
  3. MCQ

    Church–Turing thesis states:

    1. TMs are faster than any computer
    2. every effectively computable function is TM-computable
    3. every language is decidable
    4. P = NP

Rule Card

  • ⟨M⟩: binary code of transitions (0ⁱ1 0ʲ1 0ᵏ1 0ˡ1 0ᵐ, separated by 11). TMs are countable.
  • Universal TM U: simulates M on w; L(U) = {⟨M,w⟩ : M accepts w} is RE.
  • Church–Turing thesis: algorithm ⇔ TM (thesis, not theorem).

Concept Ledger

  • encoding of a TM ⟨M⟩
  • countably many TMs
  • universal Turing machine U
  • Church–Turing thesis

Answer Vault

Reveal answers when you’re ready

Warm-up answers

  1. Recursive.
  2. A decider halts on every input; a recognizer may loop on non-members.
  3. A string encoding of the object X.

Self-test answers

  1. B — It simulates M.
    • A: It loops if M loops.
    • C: That is impossible (Phase 5).
    • D: It cannot detect looping.
  2. ABD — Encoding and UTM facts.
    • C: It is a thesis.
  3. B — Definition.
    • A: About speed — no.
    • C: False.
    • D: Unrelated.

Flashcards

  1. What does the universal TM do?
    Reveal answerGiven ⟨M, w⟩ it simulates M on w.
  2. Is the set of TMs countable?
    Reveal answerYes — each has a finite binary code.
  3. Is the Church–Turing thesis a theorem?
    Reveal answerNo, a thesis.

Ready for the next idea?

Mark this item complete when you’ve finished reading and working through it.