4.6.17 · D4Theory of Computation

Exercises — Decidability — decidable (recursive) and recognizable (recursively enumerable) languages

2,876 words13 min readBack to topic

Before we start, one picture fixes the whole vocabulary. Look at the figure below: on the left is a box labelled "TM on w", and three arrows fan out of it to three outcome boxes — a blue ACCEPT box ("yes, halts"), a pink REJECT box ("no, halts"), and a yellow LOOP FOREVER box ("never answers"). The caption underneath states the one distinction that runs through this entire page: a decider only ever lands in ACCEPT or REJECT, while a recognizer is allowed to fall into the yellow LOOP box on non-members. On every input a Turing Machine does exactly one of those three things. Keep this picture open in your head for all 12 problems.

Figure — Decidability — decidable (recursive) and recognizable (recursively enumerable) languages

Level 1 — Recognition

Goal: can you read a definition and say which box a language sits in?

Problem 1.1

A Turing Machine on input ends by entering its accept state after 40 steps. Every input it ever sees, it either accepts or rejects in finite time — it never loops. Is the language (the set of strings accepts) decidable, recognizable, or neither?

Recall Solution 1.1

WHAT the definition asks: a language is decidable when some machine halts on every input and answers yes/no correctly. WHY this machine qualifies: we are told never loops — it always accepts or rejects. That is exactly the "halts on every input" promise. So is a decider, and is decidable. Bonus: every decidable language is also recognizable (a decider already accepts all members), so "decidable" is the strongest true label here. Answer: decidable.

Problem 1.2

Fill the blanks (cloze yourself first):

A language is recognizable iff some TM accepts every member and may loop forever on every non-member. A language is decidable iff some TM halts on every input.

Recall Solution 1.2

Members are always accepted in both cases; the only difference is the behaviour on non-members.

  • Recognizer: on a non-member it may loop forever (or reject) — no promise.
  • Decider: on a non-member it must halt and reject — a real "NO". This one asymmetry is the whole theory.

Level 2 — Application

Goal: apply a definition or the complement rule to a concrete language.

Problem 2.1

Let (this is ). Show it is decidable by describing a machine that always halts, and count the work in terms of DFA transitions the simulation performs on a word of length .

Recall Solution 2.1

WHAT we build: a decider that simulates DFA on . WHY it always halts: a DFA reads exactly one symbol per step and has no way to loop — it consumes the input and stops. Each of the symbols triggers exactly one DFA transition, so the DFA-level work is exactly transitions; then we check whether the final state is accepting. WHAT COUNTS AS A "STEP" (important): we are counting DFA transitions, not the raw moves of the Turing machine that hosts the simulation. A single-tape TM must, per DFA transition, also look up the current state and input symbol in the encoded transition table , which costs a bounded (constant, or at worst polynomial in ) amount of tape shuffling. That overhead does not hide any loop — it is a fixed bounded chunk of work per symbol. So the total TM running time is , still finite, and the decider always halts. WHAT IT LOOKS LIKE: a marker walking left-to-right across , one cell per DFA transition, never backing up (see figure below). Accept iff lands in an accept state after those transitions. Because simulation always terminates, is decidable. Number of DFA transitions on length : exactly (e.g. transitions). Total TM time: — bounded, no hidden loop.

Figure — Decidability — decidable (recursive) and recognizable (recursively enumerable) languages

Problem 2.2

is decidable. A friend claims (all strings not in ) is also decidable. Are they right? Give the construction.

Recall Solution 2.2

They are right. WHY: let decider decide . Build that runs and swaps the answers — accept where rejects, reject where accepts. WHY the swap is legal: swapping only works if the machine reaches an answer to swap. always halts, so always halts too. Hence decides . Answer: yes — decidable languages are closed under complement.

Problem 2.3

A machine recognizes by simulating on . On the input where loops forever on , what does do, and is that a violation of "recognizer"?

Recall Solution 2.3

WHAT does: it faithfully simulates . If loops on , then loops too — it never returns an answer. WHY this is not a violation: a recognizer is only required to accept members. Here (since never accepts), so is allowed to loop on it. Answer: loops, and that is perfectly legal for a recognizer.


Level 3 — Analysis

Goal: explain WHY a proof step is forced, not just that it works.

Problem 3.1

In the theorem " decidable and both recognizable", the direction runs recognizers (for ) and (for ) in parallel, one step each, alternating. Explain precisely why we cannot just run to completion first.

Recall Solution 3.1

Consider an input , so . Then (a recognizer for ) is only obligated to accept members — on this non-member it may loop forever. If our decider ran "to completion" first, it would get stuck in that infinite loop and never reach , which is the machine that would have accepted . WHY alternating (dovetailing) fixes it: every is in exactly one of , so exactly one of is guaranteed to accept in finite time. By taking one step of each in turn, we are guaranteed to reach that finite acceptance without being trapped by the looping machine. Answer: sequential simulation can deadlock on a looping recognizer; dovetailing guarantees we always reach the machine that halts.

Problem 3.2

Show that is not recognizable. (Take as given: is recognizable but undecidable.)

Recall Solution 3.2

Proof by contradiction. Suppose were recognizable. Then both (given recognizable) and (assumed) are recognizable. By the iff theorem, " and both recognizable decidable", we conclude is decidable. But is undecidable (see Halting Problem and Diagonalization). Contradiction. Therefore our assumption was false: is not recognizable.

Problem 3.3

Classify using the labels: (a) recognizable, (b) co-recognizable [meaning its complement is recognizable], (c) decidable. Which hold?

Recall Solution 3.3
  • Recognizable? No — just proved in 3.2.
  • Co-recognizable? Its complement is , which is recognizable. So yes, is co-recognizable.
  • Decidable? Decidable would require both it and its complement recognizable; but it is not recognizable. So no. Answer: co-recognizable only (not recognizable, not decidable).

Level 4 — Synthesis

Goal: build a new argument by chaining known results.

Problem 4.1

Prove: if is decidable and is decidable, then is decidable. Give the machine.

Recall Solution 4.1

Let decide and decide (both always halt). Build decider on input :

  1. Run on — it halts (both halt on every input).
  2. If rejects, then , so ; rejects.
  3. Else run on — it halts.
  4. accepts iff accepts. WHY always halts: it runs two machines that each always halt, in sequence — no loop possible. Hence is decidable. (See Closure Properties.)

Problem 4.2

Prove: if is recognizable and is recognizable, then is recognizable. Why can we run them sequentially here, unlike in Problem 3.1?

Recall Solution 4.2

Let recognize , recognize . Build recognizer on , covering every branch:

  1. Run on .
    • If accepts → go to step 2.
    • If rejects, so ; rejects (halts with NO). This is a legal recognizer action — rejecting a non-member is always allowed.
    • If loops loops too; but then , so , and looping on a non-member is permitted. No obligation is broken.
  2. Run on .
    • If accepts (from step 1) and , so ; accepts.
    • If rejects, so ; rejects.
    • If loops loops; then , a non-member of , so looping is permitted. WHY sequential is fine here: we only need to accept members. For , both and accept in finite time, so the chain reaches "accept". For every non-member, whatever does (reject or loop) is exactly what a recognizer is allowed to do. Contrast with 3.1: there we needed a decider (a real NO on all non-members), so a loop was forbidden and we had to dovetail. Here a loop on non-members is acceptable, so plain sequential simulation is correct. Hence is recognizable.

Problem 4.3

Use "recognizable enumerable" to argue: if a TM can print out all strings of (an enumerator), then is recognizable.

Recall Solution 4.3

Suppose enumerator prints every string of (in some order, repeats allowed) and never prints anything outside . Build recognizer on input : run , and each time prints a string, compare it with . If it ever equals , accept. WHY this recognizes : if , will eventually print (that is what "prints all of " means), so accepts in finite time. If , never prints , so simply keeps waiting — it loops forever, which is exactly the permitted behaviour of a recognizer on a non-member. Hence is recognizable. (This is the "enumerable" in recursively enumerable.)


Level 5 — Mastery

Goal: combine complement, recognizability, and reductions in one shot.

Problem 5.1

A language satisfies: both and are recognizable, and is undecidable. Can such an exist? Justify with a theorem.

Recall Solution 5.1

No, impossible. The iff theorem says: and both recognizable is decidable. That directly contradicts " undecidable." Answer: no such exists. The two conditions "both-sides recognizable" and "undecidable" are mutually exclusive.

Problem 5.2

Give a specific language that is recognizable but not decidable, and a specific language that is not even recognizable. Name them and justify each in one line.

Recall Solution 5.2
  • Recognizable but not decidable: . The Universal Turing Machine recognizes it (accept when accepts); Diagonalization proves no decider exists.
  • Not recognizable: . If it were recognizable, would be decidable (iff theorem) — contradiction (Problem 3.2).

Problem 5.3

Suppose the Halting Problem language is recognizable but undecidable. Determine whether is recognizable. Justify using the same theorem you used for .

Recall Solution 5.3

is recognizable (run on ; accept the moment it halts) and undecidable (a classic result via reduction from ). Now suppose were recognizable. Then both and its complement are recognizable, so by the iff theorem would be decidable — contradiction. Answer: is NOT recognizable.

Problem 5.4 (capstone)

Fit the four languages into the three nested regions: Decidable ⊆ Recognizable ⊆ All languages. State which region each occupies.

Recall Solution 5.4
  • (all strings): decidable — a machine that accepts everything and halts immediately.
  • : decidable (Problem 2.1).
  • : recognizable but not decidable — sits in the recognizable ring outside the decidable core.
  • : not recognizable — sits outside the recognizable ring entirely (only co-recognizable). WHAT THE FIGURE SHOWS (in words): the map is three nested boundaries. The outer rectangle is "All languages". Inside it sits a blue circle labelled "Recognizable (RE)". Inside that, a smaller pink circle labelled "Decidable". The two decidable languages and are printed inside the innermost pink circle. (in yellow) is printed in the blue ring — inside Recognizable but outside Decidable. And is printed in the outer rectangle only, outside the blue circle entirely — it is not recognizable, merely co-recognizable. Reading the picture from inside out is exactly reading the strict inclusions Decidable ⊊ Recognizable ⊊ All.
Figure — Decidability — decidable (recursive) and recognizable (recursively enumerable) languages

Self-test recall

WHY every problem sat where it did
because on non-members a decider must halt (real NO) while a recognizer may loop, and this one asymmetry decides which region a language lives in.
What "dovetailing" buys you
it guarantees you reach the machine that halts without being trapped by the one that loops, turning two recognizers (for and ) into one decider.
Why recognizable is not closed under complement
the accept/reject swap needs a halt to swap, but a recognizer may loop on non-members, so there is nothing to swap to.