Skip to main content

TM transforming ⊔w⊔ to ⊔ww⊔

Short answer

The TM marks the leftmost unmarked symbol of w (0→x, 1→y), goes to the first blank, writes a copy (0→a, 1→b), then returns to the left blank and repeats. After copying all symbols, it converts all marks back to 0/1, yielding ⊔ww⊔.

Construct a Turing machine to transform ⊔w⊔ to ⊔ww⊔. [Exact target string is hard to read in the scan.]

Interpretation. The input is ⊔w⊔ with w ∈ {0,1}*; the output is ⊔ww⊔ (the second copy of w follows directly after the first). If instead ⊔w⊔w⊔ is wanted, only the last two phases change slightly.

Idea. Process w from left to right. Mark the leftmost unmarked symbol (0 as x, 1 as y), go right to the first blank, and write a copy there (a for 0, b for 1). Rewind to the left blank and repeat. When no unmarked symbol remains, rewind and convert x, a to 0 and y, b to 1.

M: states q0, q1, qA, qB, qR, qF, qC, qa. Tape alphabet {0, 1, x, y, a, b, ⊔}. S = stay.

StateReadWriteMoveNext
q0⊔sameRq1
q1x / ysameRq1
q10xRqA
q11yRqB
q1⊔sameSqa
q1a / bsameLqF
qFx / ysameLqF
qF⊔sameRqC
qA0 / 1 / x / y / a / bsameRqA
qA⊔aLqR
qB0 / 1 / x / y / a / bsameRqB
qB⊔bLqR
qR0 / 1 / x / y / a / bsameLqR
qR⊔sameRq1
qCx / a0RqC
qCy / b1RqC
qC0 / 1sameRqC
qC⊔sameSqa
  • q1: find the leftmost unmarked symbol. qA / qB: carry a 0 / 1 to the end and write a / b. qR: rewind to the left blank.
  • When q1 reaches a or b, everything has been copied: qF returns to the left blank, then qC converts the marks.

Processing ⊔01⊔

[q0]⊔01
⊔[q1]01
⊔x[qA]1
⊔x1[qA]
⊔x[qR]1a
⊔[qR]x1a
[qR]⊔x1a
⊔[q1]x1a
⊔x[q1]1a
⊔xy[qB]a
⊔xya[qB]
⊔xy[qR]ab
⊔x[qR]yab
⊔[qR]xyab
[qR]⊔xyab
⊔[q1]xyab
⊔x[q1]yab
⊔xy[q1]ab
⊔x[qF]yab
⊔[qF]xyab
[qF]⊔xyab
⊔[qC]xyab
⊔0[qC]yab
⊔01[qC]ab
⊔010[qC]b
⊔0101[qC]
⊔0101[qa]

Final tape: ⊔0101⊔ = ⊔ww⊔ with w = 01. For w = ε the machine halts at once in qa.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Theory of Computation chapter 4 questions →