171 Complexity — Single Tape
171.1 Overview
This module proves the in-model analogue of [AB09, Claim 1.6]: a Turing machine with \(k\) work tapes over a finite alphabet \(\Gamma \) (and separate read-only input and write-only output tapes) is simulated by a machine with a single work tape over an enlarged finite alphabet, with quadratic slowdown \(c \cdot (T(n)+1)^2\). The single tape stores the \(k\) source tapes interleaved, with head positions marked in the cells; each source step is simulated by a forward reading sweep and a backward writing sweep across the visited zone. Combined with alphabet reduction ([AB09, Claim 1.5]) this yields a one-work-tape machine over the binary alphabet with the same quadratic slowdown.
171.2 Declarations
Let \(M\) be a Turing machine over an alphabet \(\Gamma \), with a read-only input tape, a write-only output tape, and no work tapes. This constructs a machine with the same states and exactly one work tape: each transition performs the input-head movement, output emission, and state change of the corresponding transition of \(M\), while writing nothing on the added work tape and keeping its head stationary.
For a Turing machine \(M\) over an alphabet \(\Gamma \) and a configuration \(c\) of \(M\) on an input \(x\), this produces the configuration of a one-work-tape machine with the same state, input-head position, and output as \(c\), whose single work tape is entirely blank with its head at the origin.
Let \(M\) be a Turing machine over an alphabet \(\Gamma \) with no work tapes, and let \(M'\) be the machine obtained from \(M\) by adding one unused work tape. For every configuration \(c\) of \(M\) on an input \(x\), one transition of \(M'\) applied to the embedding of \(c\) (same state, input position, and output; blank added tape with head at the origin) equals the embedding of the configuration obtained by one transition of \(M\) from \(c\); this also holds when \(c\) is halted.
Let \(M\) be a Turing machine over an alphabet \(\Gamma \) with no work tapes that computes a function \(f\) on words over \(\Gamma \) within time \(T\), i.e. on every input \(x\) the run of \(M\) has halted after \(T(\left\lvert x\right\rvert )\) steps with output \(f(x)\). Then the machine obtained from \(M\) by adding one unused work tape also computes \(f\) within time \(T\).
For an alphabet \(\Gamma \) and \(k \in \mathbb {N}\), a sweep cell is a tuple consisting of a tape index \(i \in \{ 0, \dots , k-1\} \), an optional payload symbol from \(\Gamma \) (absence meaning blank), a Boolean head flag, and a second Boolean flag in which the forward sweep records the head flag of the corresponding cell of the preceding block.
The visit rule of the forward sweep. Its control state is a table assigning to each tape index an optional symbol and a Boolean flag. On visiting a sweep cell for tape \(i\), the table entry for \(i\) becomes the cell’s payload if the cell’s head flag is set (otherwise the recorded symbol is unchanged), paired with that head flag; the cell keeps its payload and head flag and stores the Boolean previously held in the table, which is the head flag of tape \(i\) in the preceding block.
The visit rule of the backward sweep, parametrised by an action \(\alpha \) of the simulated \(k\)-work-tape machine. Its control state is a table of Booleans, one per tape (the head flags seen in the block to the right). On visiting a sweep cell for tape \(i\): the new table records the cell’s head flag; the payload is overwritten by the symbol \(\alpha \) writes on tape \(i\) when this cell carries the head (and kept otherwise); the new head flag is taken from the right-neighbour table, from the current cell, or from the stored left-neighbour flag according as \(\alpha \) moves head \(i\) left, keeps it in place, or moves it right; and the stored left-neighbour flag is cleared.
For a configuration \(c\) of a machine with \(k\) work tapes, a tape index \(i\), and a coordinate \(j \in \mathbb {Z}\), the Boolean that is true exactly when the head of work tape \(i\) in \(c\) is at coordinate \(j\).
The block of \(k\) sweep cells encoding coordinate \(j \in \mathbb {Z}\) of a configuration \(c\) of a \(k\)-work-tape machine: the cell for tape \(i\) carries the symbol of tape \(i\) at coordinate \(j\) and the flag indicating whether head \(i\) is at \(j\). When a Boolean parameter is set, the cell additionally records whether head \(i\) is at \(j-1\); otherwise that field is false.
The control table that the forward sweep holds immediately before reading the block at coordinate \(j\) in a configuration \(c\): for each tape \(i\) it contains the symbol currently scanned by head \(i\) if that head lies at a coordinate strictly less than \(j\) (and nothing otherwise), together with the flag indicating whether head \(i\) is at coordinate \(j-1\).
Let \(c\) be a configuration of a \(k\)-work-tape machine and \(j \in \mathbb {Z}\). Transducing the block encoding coordinate \(j\) (with unrecorded left-neighbour flags) by the forward-sweep visit rule, starting from the control table associated with \(j\), yields exactly the control table associated with \(j+1\) together with the same block with left-neighbour head flags recorded.
Let \(c\) be a configuration of a \(k\)-work-tape machine, \(\alpha \) an action of that machine, and \(j \in \mathbb {Z}\). Folding the backward-sweep visit rule for \(\alpha \) over the reversed block encoding coordinate \(j\) (with recorded left-neighbour flags), starting from the table of head flags at coordinate \(j+1\), yields the table of head flags at coordinate \(j\) together with the reversed block encoding coordinate \(j\) of the configuration obtained by applying \(\alpha \) to \(c\).
Given a family of blocks indexed by integer coordinates and a start coordinate \(j\), the zone of size \(n\) is the concatenation of the \(n\) consecutive blocks at coordinates \(j, j+1, \dots , j+n-1\), in ascending order.
Let \(c\) be a configuration of a \(k\)-work-tape machine, \(j \in \mathbb {Z}\), and \(n \in \mathbb {N}\). The forward sweep over the concatenation of the \(n\) unread blocks at coordinates \(j, \dots , j+n-1\), started from the control table at \(j\), ends in the control table at \(j+n\) and produces the corresponding blocks with left-neighbour head flags recorded.
Let \(c\) be a configuration of a \(k\)-work-tape machine, \(\alpha \) an action of that machine, \(j \in \mathbb {Z}\), and \(n \in \mathbb {N}\). The backward sweep for \(\alpha \) over the reversed concatenation of the \(n\) read-marked blocks at coordinates \(j, \dots , j+n-1\), started from the table of head flags at coordinate \(j+n\), ends in the table of head flags at \(j\) and produces the reversed unread blocks of the configuration obtained by applying \(\alpha \) to \(c\).
The enlarged alphabet of the single-tape simulator over a source alphabet \(\Gamma \) with \(k\) tapes: a symbol is either a data symbol from \(\Gamma \) (used unchanged for input and output), or an internal sweep cell, or a distinguished boundary marker. Formally it is the disjoint union of \(\Gamma \) with the set of sweep cells extended by one extra element.
The injection of the source alphabet \(\Gamma \) into the enlarged sweep alphabet, sending each symbol to the corresponding data symbol.
The distinguished boundary marker of the enlarged sweep alphabet: a non-blank symbol distinct from every data symbol and from every internal cell, including cells with blank payload.
The map tagging a sweep cell as an internal symbol of the enlarged sweep alphabet.
The partial decoding of an optionally scanned enlarged symbol: a data symbol decodes to the underlying symbol of \(\Gamma \), while everything else (a blank, an internal cell, or a boundary marker) decodes to nothing.
The finite state space of the single-tape simulator of a \(k\)-work-tape machine with state set \(S\) over \(\Gamma \). Its phases are: initialization, carrying a counter in \(\{ 0, \dots , k\} \); a return-to-origin walk; left extension of the zone, carrying a source state and a counter; the forward reading sweep, carrying a source state and a table assigning to each tape an optional symbol and a Boolean; right extension, additionally carrying a counter; and the backward writing sweep, carrying a source state, the scanned input symbol, the collected reads, and a table of Booleans. No unbounded tape coordinate enters the state, so the state space is finite.
For a one-work-tape machine, the action that keeps the input head stationary, writes nothing on the work tape (preserving the scanned cell) while moving its head in a given direction \(d\), emits no output, and makes a given optional state the next state.
The single-work-tape simulator of a machine \(M\) with \(k\) work tapes over a finite alphabet \(\Gamma \): a machine over the enlarged sweep alphabet, with one work tape, whose finite control realises the phases of the simulation. Initialization writes the marked origin block and its two boundary markers. Each simulated step extends the stored zone by a blank block on the left, sweeps forward reading the marked payloads while recording left-neighbour head flags in the cells, extends the zone on the right, performs the source transition on the input head and output, and sweeps backward rewriting the cells, carrying right-neighbour head flags in its control.
The blank block of \(k\) sweep cells: the cell for tape \(i\) carries index \(i\), no payload, a head flag equal to a given mark, and a cleared left-neighbour flag. With the mark set it is the initialized origin block; with the mark cleared it is a fresh guard block.
Let \(c\) be a configuration of a \(k\)-work-tape machine and \(j \in \mathbb {Z}\) a coordinate such that no work-tape head of \(c\) is at \(j\) and every work tape of \(c\) is blank at \(j\). Then the unread block encoding coordinate \(j\) equals the blank unmarked block.
Every block encoding a single coordinate of a configuration of a \(k\)-work-tape machine is a list of length \(k\), in both its unread and read-marked forms.
A zone of \(n\) consecutive blocks of a configuration of a \(k\)-work-tape machine has length \(n \cdot k\).
For any family of blocks indexed by \(\mathbb {Z}\) and any \(j \in \mathbb {Z}\) and \(n, m \in \mathbb {N}\), the zone of \(n+m\) blocks starting at \(j\) is the concatenation of the zone of \(n\) blocks starting at \(j\) with the zone of \(m\) blocks starting at \(j+n\).
For an input word \(x\) over \(\Gamma \), the transport of an input-head position on \(x\) (one of \(\left\lvert x\right\rvert +2\) positions, including the two endmarkers) to the numerically identical position on the symbol-wise encoded input, which has the same length.
Moving the input head one step in any direction commutes with the transport of head positions from an input word to its symbol-wise encoding.
Let \(c\) be a configuration of a \(k\)-work-tape machine on input \(x\), and let \(d\) be a configuration of any machine over the enlarged sweep alphabet on the symbol-wise encoded input whose input head is at the transported position of \(c\)’s input head. Then decoding the input symbol scanned by \(d\) yields exactly the input symbol scanned by \(c\).
The canonical simulator configuration representing a source configuration \(c\) between simulated steps, parametrised by a start coordinate \(j\), a block count \(n\), and an absolute cell \(z\). The control is in the left-extension phase carrying the state of \(c\) (halted when \(c\) is halted); the input head is at the transported position of \(c\)’s input head; the output holds the symbol-wise encoding of \(c\)’s output. The work-tape head scans a boundary marker at cell \(z\); the cells above it hold the encoded blocks for coordinates \(j, j+1, \dots , j+n-1\) in ascending order, closed by a second boundary marker, and all remaining cells are blank.
Consider the two-way infinite partial tape assembled from a position \(z \in \mathbb {Z}\), a list \(r\) of optional symbols occupying cells \(z, z+1, \dots \), and a list \(l\) occupying cells \(z-1, z-2, \dots \) (all unlisted cells blank). Overwriting the cell at \(z\) with a value \(b\) yields the tape assembled from \(z\), \(l\), and the list whose first entry is \(b\) followed by the tail of \(r\).
Consider a one-work-tape configuration in forward-facing zipper form: work head at cell \(z\), a list \(r\) occupying cells \(z, z+1, \dots \), a list \(l\) occupying cells \(z-1, z-2, \dots \), an input-head position, and an accumulated output. Applying an action that writes a symbol \(b\) at the current cell, moves the work head left, moves the input head in a given direction, optionally emits one output symbol, and enters a given optional state produces the backward-facing zipper at \(z-1\): cells \(z, z+1, \dots \) hold \(b\) followed by the tail of \(r\), cells \(z-1, z-2, \dots \) hold \(l\), the input head has moved in the given direction, and the output is extended by the emitted symbol.
Consider a one-work-tape configuration in backward-facing zipper form: work head at cell \(z\), a list \(r\) occupying cells \(z, z-1, \dots \), and a list \(l\) occupying cells \(z+1, z+2, \dots \). Applying the sweep action that writes a symbol \(b\) at the current cell, moves the work head right, leaves the input head and output unchanged, and enters a state \(q'\) yields the forward-facing zipper at \(z+1\): cells \(z, z-1, \dots \) hold \(b\) followed by the tail of \(r\), and cells \(z+1, z+2, \dots \) hold \(l\).
For the single-tape simulator of a machine \(M\) with \(k\) work tapes: from any forward-facing zipper configuration whose control is in the initialization phase with counter \(0\), running exactly \(k\) transitions writes, one cell per step while moving right, the encoded marked blank block over the next \(k\) cells, ending in the initialization phase with counter \(k\) and with the work head advanced by \(k\) cells; the input head, output, and remaining tape contents are unchanged.
For the single-tape simulator of a machine \(M\) with \(k\) work tapes and any source state \(q\): from any backward-facing zipper configuration whose control is in the left-extension phase carrying \(q\) with counter \(0\), running exactly \(k\) transitions writes the encoded unmarked blank block in reversed cell order while moving left, ending in the left-extension phase with counter \(k\) and the work head moved left by \(k\) cells; the input head and output are unchanged.
The right guard block of \(k\) sweep cells determined by a read table \(s\): the cell for tape \(i\) carries index \(i\), no payload, a cleared head flag, and a left-neighbour flag equal to the Boolean recorded for tape \(i\) in \(s\) — the head flag of the last scanned block.
For the single-tape simulator of a machine \(M\) with \(k\) work tapes, a source state \(q\), and a read table \(s\): from any forward-facing zipper configuration whose control is in the right-extension phase carrying \(q\) and \(s\) with counter \(0\), running exactly \(k\) transitions writes the guard block determined by \(s\) while moving right, ending in the right-extension phase with counter \(k\), still carrying \(q\) and \(s\), with the work head advanced by \(k\) cells; the input head and output are unchanged.
Folding the identity visit rule — which returns its control state and each visited cell unchanged — over any list of cells returns the initial state and the unchanged list.
In a backward-facing zipper configuration (work head at cell \(z\), a list \(r\) occupying cells \(z, z-1, \dots \), a list \(l\) occupying cells \(z+1, z+2, \dots \)), applying the sweep action that writes a symbol \(b\) at the current cell without moving, leaves the input head and output unchanged, and enters a state \(q'\) replaces the first entry of \(r\) by \(b\) and the control state by \(q'\), leaving everything else fixed.
Let \(M\) be a machine with \(k\) work tapes over a finite alphabet \(\Gamma \) and let \(x\) be an input word. Running the single-tape simulator for exactly \(2k+2\) transitions from its initial configuration on the symbol-wise encoded input reaches the canonical between-steps configuration representing the initial configuration of \(M\) on \(x\), with a zone of one block at coordinate \(0\) and work head at absolute cell \(-1\).
Applying a stationary phase-change action — no write, no head movement, no output — to a forward-facing zipper configuration replaces only the control state and leaves the tape, input head, and output unchanged.
Applying a stationary phase-change action — no write, no head movement, no output — to a backward-facing zipper configuration replaces only the control state and leaves the tape, input head, and output unchanged.
Let \(M\) be a machine with \(k \ge 1\) work tapes and let \(c\) be a configuration of \(M\) in a non-halted state \(q\) such that every work-tape head of \(c\) is at a coordinate at least \(a\) and every work tape of \(c\) is blank at \(a-1\). From the canonical between-steps configuration for \(c\) with a zone of \(n\) blocks starting at \(a\), running the simulator for exactly \(k + 1 + (n+1)k + 1\) transitions extends the zone by a blank block at \(a-1\), performs the forward sweep over all \(n+1\) blocks — collecting the scanned symbol of every source tape into the control and recording left-neighbour head flags in the cells — and ends in the right-extension phase carrying \(q\) and the completed read table for coordinate \(a+n\), with the read-marked encoded blocks enclosed by boundary markers on the tape and the input head and encoded output preserved.
Let \(M\) be a machine with \(k \ge 1\) work tapes and let \(c\) be a configuration with a state \(q\) such that every work-tape head of \(c\) is at a coordinate strictly less than \(a+n\) and every work tape of \(c\) is blank at \(a+n\). From the configuration reached after the forward sweep — the right-extension phase carrying \(q\) and the read table for coordinate \(a+n\), with the read-marked encoded blocks for coordinates \(a-1, \dots , a+n-1\) on the tape between boundary markers — running exactly \(k + 1 + (n+2)k + 1\) transitions writes the right guard block, performs the transition of \(M\) from \(q\) on the scanned input symbol and the collected work-tape symbols (moving the input head and emitting output accordingly), sweeps backward applying that action to every block, and reaches the canonical between-steps configuration of the resulting source configuration with a zone of \(n+2\) blocks starting at \(a-1\).
Let \(M\) be a machine with \(k \ge 1\) work tapes and let \(c\) be a configuration in a non-halted state \(q\) whose work-tape heads all lie in the interval \([a, a+n)\) and whose work tapes are blank at \(a-1\) and at \(a+n\). Then, from the canonical between-steps configuration for \(c\) with a zone of \(n\) blocks starting at \(a\), exactly \((2n+5)k + 4\) transitions of the single-tape simulator reach the canonical between-steps configuration for the configuration obtained by one step of \(M\) from \(c\), with a zone of \(n+2\) blocks starting at \(a-1\) and the absolute work-head position lowered by \(k\).
The exact number of simulator transitions elapsed after \(t\) source steps, as a function \(\sigma _k : \mathbb {N} \to \mathbb {N}\) defined recursively by \(\sigma _k(0) = 2k+2\) and \(\sigma _k(t+1) = \sigma _k(t) + (4t+7)k + 4\).
The function \(\sigma _k\) defined by \(\sigma _k(0) = 2k+2\) and \(\sigma _k(t+1) = \sigma _k(t) + (4t+7)k + 4\) satisfies, for all \(k, t \in \mathbb {N}\),
The function \(\sigma _k\) defined by \(\sigma _k(0) = 2k+2\) and \(\sigma _k(t+1) = \sigma _k(t) + (4t+7)k + 4\) satisfies \(\sigma _k(t) \le (9k+6)(t+1)^2\) for all \(k, t \in \mathbb {N}\).
Let \(M\) be a machine with \(k \ge 1\) work tapes over a finite alphabet, let \(x\) be an input word, and suppose the run of \(M\) from its initial configuration on \(x\) has not halted at any time \(t \lt \tau \). Then for every \(t \le \tau \), running the single-tape simulator for exactly \(\sigma _k(t)\) transitions (the exact simulation time after \(t\) source steps) from its initial configuration on the symbol-wise encoded input reaches the canonical between-steps configuration representing the configuration of \(M\) after \(t\) steps, with a zone of \(2t+1\) blocks starting at coordinate \(-t\) and work head at absolute cell \(-tk - 1\).
In-model analogue of [AB09, Claim 1.6]. Let \(\Gamma \) be a finite alphabet and let \(M\) be a Turing machine over \(\Gamma \) (read-only input tape, write-only output tape, any number of work tapes) that computes a function \(f\) on words over \(\Gamma \) within time \(T : \mathbb {N} \to \mathbb {N}\), i.e. on every input \(x\) the run of \(M\) has halted after \(T(\left\lvert x\right\rvert )\) steps with output \(f(x)\). Then there exist a finite alphabet \(\Gamma '\), an embedding \(e : \Gamma \hookrightarrow \Gamma '\), a machine \(M'\) over \(\Gamma '\) with exactly one work tape, and a constant \(c \in \mathbb {N}\) such that, on every symbol-wise encoded input \(e(x)\), the run of \(M'\) has halted after \(c \cdot (T(\left\lvert x\right\rvert ) + 1)^2\) steps with output the symbol-wise encoding \(e(f(x))\).
Let \(M\) be a Turing machine over the binary alphabet (read-only input tape, write-only output tape, any number of work tapes) that computes a function \(f\) on binary words within time \(T : \mathbb {N} \to \mathbb {N}\), i.e. on every input \(x\) the run of \(M\) has halted after \(T(\left\lvert x\right\rvert )\) steps with output \(f(x)\). Then there exist a machine \(M'\) over the binary alphabet with exactly one work tape and a constant \(c \in \mathbb {N}\) such that \(M'\) computes \(f\) within time \(n \mapsto c \cdot (T(n) + 1)^2\). This combines the one-work-tape simulation ([AB09, Claim 1.6]) with alphabet reduction ([AB09, Claim 1.5]).