TCSLib

165 Complexity — Bidirectional

165.1 Overview

This module formalizes the robustness of the multi-tape Turing machine model under the restriction to unidirectional (one-way infinite) work tapes, following Arora–Barak, Claim 1.8. Since the project’s tapes are \(\mathbb {Z}\)-indexed, the claim is rendered as: every machine computing a function within a time bound is simulated, with the same number of work tapes and constant-factor slowdown, by a machine over an enlarged alphabet whose work heads never visit a negative cell. The simulator folds each work tape at the origin, storing the payloads of a nonnegative cell and of its mirror negative cell together in one physical cell, alongside a Boolean origin flag written during a one-step initialization phase. The chapter records the folding coordinate arithmetic, the translated read/write/move operations with their correctness lemmas, the step-by-step simulation invariants, and the safety invariant guaranteeing nonnegative head positions on arbitrary enlarged-alphabet inputs.

165.2 Declarations

Definition 165.1 Unidirectional tape use
✓

Let \(M\) be a multi-tape Turing machine over a finite alphabet \(\Gamma \). The predicate asserts that \(M\) uses its work tapes unidirectionally: for every input string over \(\Gamma \), every number of steps \(t \in \mathbb {N}\), and every work tape of \(M\), the position of that work tape’s head after running \(M\) for \(t\) steps from its initial configuration on the input is nonnegative.

Definition 165.2 Enlarged folded alphabet
✓
#

The enlarged tape alphabet used to fold a two-way infinite tape over a base alphabet \(\Gamma \): its symbols are triples \((b, u, v)\) where \(b\) is a Boolean origin flag and \(u\) and \(v\) are two independent payloads, each either a symbol of \(\Gamma \) or blank. The intent is that a nonnegative physical cell \(p\) carries the content \(u\) of the simulated cell \(p\) and the content \(v\) of the simulated cell \(-p-1\).

Definition 165.3 Embedding of the base alphabet
✓
#

The injection of a base alphabet \(\Gamma \) into the folded alphabet sending a symbol \(a\) to the triple whose origin flag is unset, whose first payload is \(a\), and whose second payload is blank.

Definition 165.4 Folded head coordinate
✓
#

The coordinate-folding map \(\varphi \colon \mathbb {Z}\to \mathbb {Z}\) defined by \(\varphi (z) = z\) when \(z \ge 0\) and \(\varphi (z) = -z-1\) otherwise. It maps each negative cell \(z\) onto the nonnegative cell \(-z-1\); in particular \(\varphi (0) = \varphi (-1) = 0\), so \(\varphi \) is not the absolute value.

Definition 165.5 Side of an integer coordinate
✓
#

The Boolean recording on which side of the fold an integer coordinate \(z\) lies: true when \(z \ge 0\) and false when \(z \lt 0\).

Definition 165.6 Canonical packing of a folded symbol
✓
#

The canonical packing of a folded-alphabet triple into an optional cell content: the untagged triple with both payloads blank is sent to the physical blank, and every other triple is kept as an actual symbol. This ensures that a physical cell never stores a symbol carrying no information.

Definition 165.7 Unpacking of a physical cell
✓
#

The unpacking of a physical cell content over the folded alphabet — either a folded triple or blank — into a folded triple, interpreting a physical blank as the untagged triple with both payloads blank.

Lemma 165.8 Unpacking inverts packing
✓

For every folded-alphabet triple \(v\) — a Boolean flag together with two payloads, each a base symbol or blank — unpacking the canonical packing of \(v\) returns \(v\) itself.

Definition 165.9 Folding of a work tape
✓
#

Given a two-way infinite tape content \(t \colon \mathbb {Z}\to \Gamma \cup \{ \square \} \) over a base alphabet \(\Gamma \) (with \(\square \) the blank), the folded tape assigns to each nonnegative physical cell \(p\) the canonical packing of the triple consisting of the flag “\(p = 0\)”, the content \(t(p)\), and the content \(t(-p-1)\); every negative physical cell is blank.

Definition 165.10 Translation of a head move across the fold
✓
#

Given the current side of the fold, an origin flag, and a simulated move direction \(d \in \{ -1, 0, +1\} \), this operation returns the physical move to perform together with the new side: moves translate directly on the nonnegative side and are reversed on the negative side, while a crossing between simulated cells \(0\) and \(-1\) (detected by the origin flag) flips the side without issuing a physical move.

Lemma 165.11 Folded coordinates are nonnegative
✓
#

For every integer \(z\), the folded coordinate — equal to \(z\) when \(z \ge 0\) and to \(-z-1\) otherwise — is nonnegative.

Lemma 165.12 Correctness of the translated move
✓

Let \(z\) be an integer and \(d \in \{ -1,0,+1\} \) a move direction; write \(\varphi (z)\) for the folded coordinate (\(z\) when \(z \ge 0\), else \(-z-1\)) and \(\sigma (z)\) for the side of \(z\) (whether \(z \ge 0\)). Then the translated move computed from \(\sigma (z)\), the flag “\(\varphi (z) = 0\)”, and \(d\) is correct in both components: adding its physical displacement to \(\varphi (z)\) gives \(\varphi (z+d)\), and its returned side equals \(\sigma (z+d)\).

Definition 165.13 Reading the active payload
✓
#

Reading a physical cell over the folded alphabet relative to a side: after unpacking the cell (a physical blank unpacks to the untagged triple of blanks), return the first payload when the side is the nonnegative one and the second payload otherwise.

Lemma 165.14 Folded reads agree with the virtual tape
✓

For every tape content \(t \colon \mathbb {Z}\to \Gamma \cup \{ \square \} \) over a base alphabet \(\Gamma \) and every integer \(z\), reading the folded tape of \(t\) at the physical position \(\varphi (z)\) on the side of \(z\) returns exactly the original content \(t(z)\), where \(\varphi (z) = z\) for \(z \ge 0\) and \(\varphi (z) = -z-1\) otherwise.

Definition 165.15 Writing to the active payload
✓

Writing a possibly blank base symbol \(a\) into a physical cell over the folded alphabet, relative to a side: unpack the cell, replace the first payload by \(a\) when the side is the nonnegative one and the second payload otherwise, keep the origin flag and the untouched payload, and repack canonically (so a fully blank untagged result becomes a physical blank).

Lemma 165.16 Folded writes commute with virtual updates
✓

Let \(\Gamma \) be an alphabet with decidable equality, \(t \colon \mathbb {Z}\to \Gamma \cup \{ \square \} \) a tape content, \(z\) an integer, and \(a\) a possibly blank symbol. Updating the folded tape of \(t\) at the physical cell \(\varphi (z)\) by the side-relative write of \(a\) (on the side of \(z\)) yields exactly the folded tape of the pointwise update of \(t\) at \(z\) by \(a\); here \(\varphi (z) = z\) for \(z \ge 0\) and \(\varphi (z) = -z-1\) otherwise.

Definition 165.17 Translation of a machine action
✓

Given, for each of \(k\) work tapes, the current side of the fold and the physical cell under the head, this translates an action of a \(k\)-work-tape machine over a base alphabet \(\Gamma \) with state set \(S\) into an action over the folded alphabet whose states pair a state of \(S\) with a side for each tape (or are absent, meaning halt): writes become side-relative folded writes, moves are translated across the fold using the origin flags stored in the scanned cells, the emitted output symbol is embedded, and the successor state is paired with the updated sides.

Definition 165.18 Folding of a configuration
✓

The folded image of a configuration \(c\) of a \(k\)-work-tape machine over a base alphabet \(\Gamma \) with state set \(S\) on an input \(x\): a configuration over the folded alphabet on the symbol-wise embedded input, whose control state is the state of \(c\) paired with the side of each work head, whose work tapes are the folded tapes of those of \(c\), whose work head positions are the folded coordinates \(\varphi \) of those of \(c\), and whose input head position and output are transported along the embedding.

Lemma 165.19 Folded input symbol
✓

For every configuration \(c\) of a \(k\)-work-tape machine over a base alphabet \(\Gamma \) on an input \(x\), the possibly absent input symbol scanned in the folded configuration of \(c\) equals the image under the alphabet embedding of the input symbol scanned in \(c\) (with absence mapped to absence).

In the folded image of a configuration \(c\) of a \(k\)-work-tape machine over a base alphabet, for each work tape the origin flag obtained by unpacking the physical cell under that tape’s head equals the truth value of the statement that the folded head coordinate of that tape is \(0\).

Let \(\Gamma \) be an alphabet with decidable equality, \(a\) an action of a \(k\)-work-tape machine over \(\Gamma \) with state set \(S\), and \(c\) a configuration of such a machine on an input \(x\). Applying to the folded configuration of \(c\) the translated action — formed from each work head’s current side and the physical cells under the folded heads — yields the folded configuration of the result of applying \(a\) to \(c\).

Definition 165.22 Decoding of an embedded input symbol
✓
#

The partial inverse of the alphabet embedding: a folded triple whose origin flag is unset, whose first payload is a base symbol \(a\), and whose second payload is blank decodes to \(a\); every other folded triple decodes to nothing.

Definition 165.23 The stationary halting action
✓
#

The action of a \(k\)-work-tape machine that halts immediately: it does not move the input head, writes nothing and issues no move on any work tape, emits no output symbol, and has no successor state.

Definition 165.24 The initialization action
✓

The single initialization action of the folding simulator, parametrized by a target base state \(q\): without moving any head and without emitting output, it simultaneously writes the origin marker — the folded triple with flag set and both payloads blank — at the current cell of every work tape, and passes control to the state \(q\) with every tape recorded as being on the nonnegative side.

Definition 165.25 Guarded start action
✓

The action taken from the simulator’s fresh initial state when scanning a possibly absent folded input symbol: if the scanned symbol is absent or decodes to a base symbol, perform the initialization action toward a given base state \(q\); if it lies outside the range of the alphabet embedding, perform the same origin-marking writes but halt instead of entering \(q\). Thus no simulated transition precedes the validity check on the first input symbol.

Lemma 165.26 Start action on embedded inputs
✓

For every base state \(q\) and every possibly absent base symbol, the guarded start action evaluated at the image of that symbol under the alphabet embedding equals the plain initialization action toward \(q\): embedded symbols never trigger the halting guard.

Definition 165.27 The folding simulator machine
✓

For a multi-tape machine \(M\) over a finite alphabet \(\Gamma \) with decidable equality, the simulating machine over the folded alphabet: it has the same number of work tapes as \(M\), and its states are either a fresh initial state or a state of \(M\) paired with a side for each work tape. From the fresh state it performs the guarded initialization; thereafter it decodes the scanned input symbol (executing the stationary halt if the symbol lies outside the embedding’s range), reads the active payload of each work tape, and executes the translation of the corresponding transition of \(M\).

Let \(M\) be a multi-tape machine over a finite alphabet \(\Gamma \) with decidable equality and let \(c\) be a configuration of \(M\) on an input \(x\) over \(\Gamma \). One step of the folding simulator of \(M\) on the folded configuration of \(c\) equals the folded configuration of one step of \(M\) on \(c\).

Let \(M\) be a multi-tape machine over a finite alphabet \(\Gamma \) with decidable equality and let \(x\) be an input over \(\Gamma \). One step of the folding simulator from its initial configuration on the symbol-wise embedded input \(x\) yields exactly the folded configuration of the initial configuration of \(M\) on \(x\).

Let \(M\) be a multi-tape machine over a finite alphabet \(\Gamma \) with decidable equality, \(x\) an input over \(\Gamma \), and \(t \in \mathbb {N}\). Running the folding simulator for \(t+1\) steps from its initial configuration on the symbol-wise embedded input equals the folded configuration of running \(M\) for \(t\) steps from its initial configuration on \(x\).

Lemma 165.31 Writes preserve the origin flag
✓

For every side \(s\), every physical cell content \(w\) over the folded alphabet, and every possibly blank base symbol \(a\), the origin flag obtained by unpacking the result of the side-relative write of \(a\) into \(w\) equals the origin flag obtained by unpacking \(w\).

Lemma 165.32 Translated moves stay nonnegative
✓
#

Let \(p\) be a nonnegative integer, \(s\) a side, and \(d \in \{ -1,0,+1\} \) a move direction. Then \(p\) plus the physical displacement of the translated move computed from \(s\), the flag “\(p = 0\)”, and \(d\) is still nonnegative.

Definition 165.33 The safety invariant
✓

The safety invariant on a configuration \(c\) of a \(k\)-work-tape machine over the folded alphabet whose states are either a fresh initial state or a base state paired with per-tape sides, on an arbitrary folded-alphabet input: the control state of \(c\) is not the fresh initial state (it may be halted), every work head position is nonnegative, and on every work tape the origin flag obtained by unpacking each nonnegative cell \(p\) is set exactly when \(p = 0\).

Let \(c\) be a configuration of a \(k\)-work-tape machine over the folded alphabet, on an arbitrary folded-alphabet input, satisfying the safety invariant (control not in the fresh initial state, nonnegative heads, correct origin flags at all nonnegative cells). Then for every assignment of sides to the work tapes and every base-machine action \(a\), applying the translation of \(a\) — relative to those sides and the cells under the heads of \(c\) — again yields a configuration satisfying the safety invariant.

Lemma 165.35 The halting action preserves safety
✓

If a configuration of a \(k\)-work-tape machine over the folded alphabet, on an arbitrary folded-alphabet input, satisfies the safety invariant, then so does the configuration obtained from it by applying the stationary halting action.

Let \(M\) be a multi-tape machine over a finite alphabet with decidable equality and let \(c\) be a configuration of the folding simulator of \(M\), on an arbitrary folded-alphabet input, satisfying the safety invariant. Then the configuration obtained after one step of the simulator also satisfies the safety invariant.

Let \(M\) be a multi-tape machine over a finite alphabet with decidable equality. For every input over the folded alphabet — including inputs containing symbols outside the range of the alphabet embedding — the configuration reached after one step of the folding simulator from its initial configuration satisfies the safety invariant.

For every multi-tape machine \(M\) over a finite alphabet with decidable equality, the folding simulator of \(M\) has nonnegative heads: for every input over the folded alphabet, every number of steps, and every work tape, the position of that tape’s head in the corresponding initialized run is nonnegative.

Let \(\Gamma \) be a finite alphabet with decidable equality, let \(M\) be a multi-tape Turing machine over \(\Gamma \), and suppose \(M\) computes a function \(f \colon \Gamma ^* \to \Gamma ^*\) within a time bound \(T \colon \mathbb {N}\to \mathbb {N}\). Then there exist a finite alphabet \(\Gamma '\) with decidable equality, an injection \(e \colon \Gamma \hookrightarrow \Gamma '\), a machine \(M'\) over \(\Gamma '\), and a constant \(c \in \mathbb {N}\) such that: in every initialized run of \(M'\) no work head ever visits a negative cell, \(M'\) has the same number of work tapes as \(M\), and \(M'\) computes \(f\) through the embedding \(e\) within the time bound \(n \mapsto c \cdot (T(n) + 1)\).