4.6.16 · D4Theory of Computation

Exercises — Universal Turing machine

2,571 words12 min readBack to topic

Before we start, a one-screen refresher of every symbol we will use, so nothing is assumed:


Level 1 — Recognition

L1.1

True or false: A UTM can compute a function that no ordinary Turing machine can compute.

Recall Solution

False. is itself an ordinary Turing machine — it is drawn from the exact same class. Whatever computes, some machine computes; and cannot break the ceiling of Turing computability (e.g. it still cannot solve the Halting Problem). Its gift is universality (it covers all machines with one fixed controller), not extra raw power.

L1.2

Match each role to its counterpart in a normal computer: , , .

Recall Solution
  • = the program / source code.
  • = the input data.
  • = the interpreter / CPU that runs the program on the data. This "code is just data fed to an interpreter" idea is the seed of the Stored-Program Computer and von Neumann Architecture.

L1.3

How many states does have: finite, or does it grow with ?

Recall Solution

Finite and fixed. 's state count does not depend on which you feed it. All the unbounded complexity of lives on the tape (inside ), never inside 's control. That separation — fixed controller, variable program on the tape — is the whole point.


Level 2 — Application

L2.1

Machine has one relevant rule: , and . Trace on with . State the final tape symbol under the head-start cell and whether accepts.

Recall Solution

Follow the parent's 3-tape layout: Tape 1 holds , Tape 2 holds 's tape, Tape 3 holds the current state.

  1. Initialize: Tape 3 , Tape 2 head reads 0. (set up 's start config)
  2. Scan Tape 1 for the rule matching : found . (fetch)
  3. Write 1 on Tape 2, move R, set Tape 3 . (execute)
  4. Tape 3 is accepts, and the flipped cell reads 1.

Result: accept, cell . This is exactly : the bit got flipped from 0 to 1.

L2.2

Encode direction and state fields for the single rule using the parent's scheme (state , , , fields separated by a single 1). Assume symbols are numbered , . Write the rule-block.

Recall Solution

Fields in order: current state, read symbol, next state, write symbol, direction.

  • read 0
  • write 1

Join with 1 between fields: The exact code is not sacred — any decodable finite string works — but it must be parseable by 's finitely many states.

L2.3

loops on . What does do, and is that a bug?

Recall Solution

loops too. Each iteration of 's simulation loop reproduces one step of ; if never reaches a halting mood, never reaches its own accept/reject, so runs forever. Not a bug — it is correctness. must faithfully mirror . To instead print "loops forever" would require detecting non-halting for arbitrary , which is the (undecidable) Halting Problem.


Level 3 — Analysis

L3.1

The parent builds as a 3-tape machine. Does that make more powerful than a single-tape UTM? Justify.

Recall Solution

No. By the Multi-tape vs Single-tape TM equivalence, any -tape machine can be simulated by a single-tape machine (the single tape stores the tracks with markers for each head). So a multi-tape and a single-tape recognise exactly the same languages. Multi-tape is chosen only for clarity of construction, not extra ability. (There is a polynomial time cost — roughly quadratic — but computability is unchanged.)

L3.2

Consider the language (the "universal language"). Is decidable, recognisable (recursively enumerable), both, or neither? Explain.

Recall Solution

is recognisable but not decidable.

  • Recognisable: run on . If accepts, halts and accepts — so every "yes" instance is eventually confirmed. That is precisely the definition of a recursively enumerable language.
  • Not decidable: a decider must always halt, answering yes and no. But if loops on , loops, giving no answer. A total decider for would decide the Halting Problem, which is impossible. So .

L3.3

Why does the existence of not contradict the undecidability of the Halting Problem?

Recall Solution

Because only runs ; it never predicts 's future without running it. answers "does accept?" by simulation, and that simulation may never finish. The Halting Problem asks for a machine that always halts and tells you in advance whether halts. does the former job (run and echo), not the latter (foretell). No contradiction: universality and undecidability coexist happily.


Level 4 — Synthesis

L4.1

Since is a Turing machine, exists. Explain what computes, and why it is well-formed.

Recall Solution

It computes the same result as , hence the same as .

  • Well-formed because code and data share one alphabet, so is a perfectly legal input string to . A program can be handed to another (or the same) interpreter as plain data.
  • Reading it: the outer simulates the inner , and the inner simulates on . Two layers of interpretation — like running a Python interpreter written in Python. The final verdict equals . This self-application is the seed of Diagonalization.

L4.2

The Church-Turing Thesis says "anything effectively computable is Turing-computable". Explain how the UTM turns this thesis into the concrete promise "one machine can run all software".

Recall Solution
  • The thesis identifies the informal notion "algorithm" with the formal notion "Turing machine".
  • Every algorithm is therefore some , and is a finite string.
  • can run any . So a single fixed device () can execute every algorithm, merely by being handed its code. That is exactly the Stored-Program Computer promise: fixed hardware + swappable program = unlimited functionality. The UTM is the mathematical prototype your laptop physically realises.

L4.3

Suppose someone builds using a different but equally valid encoding scheme . Is a different theorem, or the same idea? Do and recognise the same language?

Recall Solution

Same idea, different clothes. There are infinitely many decodable finite encoding schemes; each yields a valid UTM. (using ) and (using ) both simulate every , so both recognise the universal language — modulo the encoding used to present inputs. A finite translator TM converts to , so the machines are inter-simulable. The encoding is a convention, not a truth.


Level 5 — Mastery

L5.1

Diagonalization from scratch. Using 's self-application, sketch the proof that is undecidable. Name every step.

Recall Solution (walk the figure)

Figure — Universal Turing machine

  1. Assume a decider exists: a TM that always halts and outputs YES if halts on , NO otherwise. (the hypothesis we will destroy)
  2. Build a machine that takes , runs on (feed its own code as data — legal because code is data), then:
    • if says "halts" → loops forever;
    • if says "not halt" → halts. (flip the answer — the "diagonal" move)
  3. Ask: what does do on input ? Look at the red diagonal cell in the figure — the entry where a machine meets its own code.
    • If halts on : by step 2, said "halts", so was built to loop — contradiction.
    • If loops on : said "not halt", so was built to halt — contradiction.
  4. Conclude: can neither halt nor loop consistently, so cannot exist. is undecidable. See Diagonalization and Halting Problem.

The UTM enabled step 2: runs other machines on encodings, which is exactly what does.

L5.2

Counting argument. There are countably many Turing machines but uncountably many languages over . Conclude that some language is not recognised by any TM — and confirm this does not contradict the UTM.

Recall Solution
  • Each has a finite , a string over a fixed alphabet. Finite strings are countable (list them by length, then alphabetically). So TMs are countable.
  • Languages are subsets of ; the set of all subsets is uncountable (Cantor).
  • A countable set of machines cannot cover an uncountable set of languages, so some language has no recogniser — no TM, hence no matter which encoding, no input, describes it.
  • No contradiction: only claims to run machines that exist. It never claimed to recognise languages that no machine recognises. Universality is over the countable family of TMs, exactly the family can encode.

L5.3

Design synthesis. In one paragraph, connect: (a) the fixed-finite-controller property of , (b) the stored-program computer, and (c) why "software" is possible at all.

Recall Solution

keeps a fixed finite control unit and reads its instructions from the tape (). Physically, that is a CPU with a fixed instruction-decoding circuit reading a program stored in the same memory as the data — the von Neumann Architecture and Stored-Program Computer. Because a program is just a string of the same kind as data, one device can be reprogrammed by loading a different string rather than rewiring — that is what "software" means. So the UTM is not only a theorem in the theory of computation; it is the blueprint proving that a single machine plus swappable code can do everything computable.


Recall Final forecast

Cover everything and answer aloud: What single sentence captures why the UTM matters? Answer: One fixed, finite machine can run every algorithm, because a program is just data — which is exactly what makes software (and your computer) possible.