Exercises — Turing machines — formal definition, computation, configurations
Before we start, one tiny reminder of the notation used throughout, so line one is readable:
Recall The three-symbol vocabulary you need
- A configuration = tape-left-of-head , current state , tape-from-head-onward . The head sits on the first symbol of .
- reads " yields " — one application of the transition function .
- reads "in state reading : go to state , write , move one cell in direction ( = left, = right)".
- is the blank symbol; the tape is blank everywhere past the input.
Level 1 — Recognition
Exercise 1.1
Given , describe in words exactly what happens in one step.
Recall Solution
In state with the head reading a 1: the machine (a) switches state to , (b) overwrites that cell — the 1 becomes a 0, and (c) moves the head one cell right. All three happen in a single atomic step. The tape to the right of the head is untouched.
Exercise 1.2
A Turing machine is a 7-tuple . Which single component must contain the blank , and which must not?
Recall Solution
- (the tape alphabet) must contain , because the infinite tape is blank past the input and the machine must be able to read that symbol.
- (the input alphabet) must not contain — that is how the machine tells "real input" from "empty tape". Also .
Exercise 1.3
True or false: a configuration (nothing written to the right of ) means the head is reading a blank.
Recall Solution
True. When the right part is empty, the head has walked onto the blank region, so we treat it as . The head reads .
Level 2 — Application
Exercise 2.1
Machine: and .
Write the full yield sequence for input 000.
Recall Solution
- Steps 1–3: each reads
0, writes0back, moves right — so one0moves from the right part into the left part each time. - Step 4: the right part is empty ⇒ head reads ⇒ rule fires ⇒ accept. Number of yield steps: 4.
Exercise 2.2
Machine: . Compute the single yield from configuration .
Recall Solution
We wrote Y over #, then moved left onto the 1. So the 1 becomes the new head symbol, and Y0 sits to its right. The head is now at cell 0 (the left edge).
Exercise 2.3
Continue Exercise 2.2 with — a left move at the left edge. What is the resulting configuration?
Recall Solution
The head is already at cell 0, and we are told to move . By the left-edge convention the head stays put (there is no cell ):
The state changes to , the 1 is rewritten as 1 (unchanged), but the head does not move.
Exercise 2.4
Look at the figure below. A head is on the marked 0. Given , what does the tape look like after three applications (assume the pattern 0 0 0 under a left-to-right sweep)?

Recall Solution
Each step overwrites the current 0 with X and steps right:
After 3 steps the tape reads XXX, head over the blank past them. Result: XXX, head at cell 3 reading .
Level 3 — Analysis
Exercise 3.1
Machine over : but is undefined (no rule). What happens on input 00? Does it accept, reject, or loop?
Recall Solution
Trace: . Now the head reads and there is no transition defined. A partial with no rule for the current (state, symbol) means the machine halts with no move — and since it is not in , this counts as an implicit reject (by convention, an undefined transition sends the machine to ). Answer: reject. (It does not loop — a missing rule is a halt, not an infinite run.)
Exercise 3.2
A language is recognized by TM , and halts on every input. What is the strongest classification of : recognizable, decidable, or neither? Justify.
Recall Solution
Decidable (Turing-decidable / recursive). A TM that recognizes and halts on every input is a decider: for members it says yes, for non-members it says no, and it never loops. Decidable is strictly stronger than merely recognizable; every decidable language is recursive. The "halts on every input" clause is exactly what upgrades recognition to decision.
Exercise 3.3
Explain, without hand-waving, why a mere recognizer cannot always answer "no" for non-members.
Recall Solution
A recognizer only promises: if , then eventually enters . For , the definition places no bound on 's behaviour — may run forever (loop). While it is still running, we cannot conclude "no", because it might accept on the very next step. That inability to ever commit to "no" is precisely the recognizable-but-not-decidable gap; the Halting Problem shows this gap is real and unavoidable.
Exercise 3.4
Consider recognized by the "cross off every other 0" machine. Trace the pass-by-pass 0-counts for input 0000 and for 000000. Which is accepted?
Recall Solution
0000 (length 4 = ):
- Pass 1: 4 zeros → cross every other → 2 zeros left (even, ). Continue.
- Pass 2: 2 zeros → cross every other → 1 zero left. Accept (base case ). ✓
000000 (length 6, not a power of two):
- Pass 1: 6 zeros → 3 zeros left (odd, ). An odd count cannot be halved evenly ⇒ reject. ✗
0000 is accepted; 000000 is rejected.
Level 4 — Synthesis
Exercise 4.1
Design (as a table / prose) a decider for . Confirm it halts on all inputs.
Recall Solution
Idea: walk right to the first blank, remembering the last non-blank symbol in the state.
- — saw an
a, remember "last was a". - — saw a
b, remember "last was b". - , — update memory.
- , .
- — reached end, last symbol was
b⇒ accept. - — last was
a⇒ reject. - — empty input has no last
b⇒ reject.
Halts on all inputs: the head only ever moves right and the input is finite, so it reaches the trailing blank after steps and halts. This is a genuine decider — no state loops in place. (A plain DFA could also do this; the TM just proves it lies inside the decidable class.)
Exercise 4.2
Modify Ex 4.1 so the machine also requires the string be non-empty and start with a. Give the extra rules.
Recall Solution
Add a first-symbol gate using the start state :
- — starts with
b⇒ reject immediately. - — starts with
a, now behave as before (need to end inb). - — empty ⇒ reject.
- Then reuse rules from Ex 4.1 to track the last symbol, accepting only via .
Now the machine accepts exactly -style strings — starts with a, ends with b, length . Still halts in steps (right-only motion).
Exercise 4.3
Using the yield rules, write the complete computation of the Ex 4.1 machine on input ab.
Recall Solution
- Step 1: read
a, writea, go , move right. - Step 2: read
b, writeb, go , move right. - Step 3: read (empty right part), rule ⇒ accept. 3 yield steps; accepts.
Level 5 — Mastery
Exercise 5.1
Prove: if is decidable, then its complement is also decidable.
Recall Solution
Let be a decider for : it halts on every input and accepts iff . Build identical to except swap the two halting states: wherever enters , enters , and vice-versa. Since halts on every input, so does (same steps, same halting point). And accepts rejects . Thus decides , so is decidable. Note: this swap trick fails for mere recognizers — swapping states does not turn a loop into a halt, so recognizable languages are not closed under complement.
Exercise 5.2
Refute (with the cleanest reason): "Every language over is Turing-recognizable."
Recall Solution
False. A counting argument: there are only countably many Turing machines (each is a finite string over a finite description alphabet), hence only countably many recognizable languages. But the set of all languages over is the power set of , which is uncountable (Cantor). Uncountably many languages cannot be covered by countably many machines, so most languages are not even recognizable. The Church–Turing thesis tells us "computable" = "TM-computable", so these languages are genuinely beyond any algorithm.
Exercise 5.3
Show a decision problem is decidable iff both it and its complement are recognizable.
Recall Solution
() If is decidable, its decider recognizes ; by Ex 5.1 is decidable too, hence recognizable. So both are recognizable.
() Suppose recognizes and recognizes . Build that on input runs and in parallel (dovetailing: one step of each, alternately, using multiple tapes). Every is in exactly one of , so exactly one of will accept — and it does so in finitely many steps. When accepts, accepts; when accepts, rejects. Since one of them must halt-accept, always halts ⇒ is a decider ⇒ is decidable.
Recall Self-test cloze (cover and recall)
A TM step does three things at once: change state, write a symbol, and move one cell L or R. Decidable ::: recognized by a TM that halts on every input. Recognizable but not decidable gap ::: the machine may loop forever on non-members. Complement of a decidable language ::: also decidable (swap accept/reject states). Why not every language is recognizable ::: countably many TMs, uncountably many languages.
Connections
Parent: Turing machines — formal definition, computation, configurations (index 4.6.13) · Related: Finite Automata · Pushdown Automata · Nondeterministic Turing Machines · Multitape Turing Machines · Recursive Languages · Recursively Enumerable Languages · Halting Problem · Church-Turing Thesis