TCSLib

177 Complexity — Universal Interpreter

177.1 Overview

This module builds the table interpreter at the heart of the universal Turing machine (Arora–Barak, §1.4.1, Theorem 1.9): a fixed four-tape machine over \(\{ 0,1\} \) whose work tapes hold a serialized transition table, a unary state counter, the simulated work tape, and a virtual-left-boundary marker. It provides the interpreter’s finite control, the complete universal-machine candidate, exact-cost gadget lemmas for every table and state-tape scanning phase, exact interpreter initialization from a canonical serialization, and the assembly of both evaluator clauses from a configuration-level block simulation. Throughout, bit strings are written over \(\{ 0,1\} \) (\(1\) for true, \(0\) for false); the pair encoding \(\langle \alpha , x\rangle \) of two bit strings lists each bit of \(\alpha \) twice, then the unequal delimiter pair \(01\), then \(x\) verbatim; and the buffer tape of a string \(w\) is the two-way infinite tape holding \(w\) in cells \(0,\dots ,|w|-1\) and blanks elsewhere.

177.2 Declarations

Definition 177.1 Finite control of the table interpreter
✓
#

The finite control-state type of the universal machine’s table interpreter: a fixed collection of phases (table rewind, count parsing, initial-state copying and skipping, state rewind, main dispatch, record skipping and reading, next-state copying, record application), each carrying only bounded registers — Boolean flags, record indices below \(9\), a field index below \(8\), and a buffer of eight action bits — together with a sink state for malformed reads. In particular the control is finite and independent of the number of states of the simulated machine; the unbounded simulated state is represented only on a tape.

Definition 177.2 Quadruple of tape entries
✓
#

Given four values \(a, b, c, d\) of a common type, the function on the four-element index type sending index \(0\) to \(a\), index \(1\) to \(b\), index \(2\) to \(c\), and index \(3\) to \(d\). It packages one entry per work tape of a four-tape machine into a single function, without a variable-size register.

Definition 177.3 Administrative interpreter action
✓

For a target control state \(q\), a table-cursor movement \(d_t \in \{ -1, 0, +1\} \), and a state-tape instruction consisting of an optional write and a cursor movement \(d_s\), the four-tape machine action that keeps the input head fixed, writes nothing and stays put on the simulated-work and marker tapes, moves the table cursor by \(d_t\), performs the optional write and the movement \(d_s\) on the state tape, emits no output, and passes to control state \(q\). By default \(d_t = 0\) and the state tape is untouched.

Definition 177.4 Serialization index of a read symbol
✓
#

The position of a tape symbol in the fixed serialization order of the three possible reads: the blank has index \(0\), the bit \(0\) has index \(1\), and the bit \(1\) has index \(2\).

Definition 177.5 Record index within a state block
✓
#

For a pair of read symbols — an input symbol and a work symbol, each blank, \(0\), or \(1\) — the index in \(\{ 0, \dots , 8\} \) of the corresponding transition record within the nine-record block of one coded state: three times the serialization index of the input read (blank \(\mapsto 0\), bit \(0 \mapsto 1\), bit \(1 \mapsto 2\)) plus the serialization index of the work read.

Definition 177.6 Decoding the two-bit movement field
✓
#

Decodes a valid two-bit head-movement field into a movement in \(\{ -1, 0, +1\} \): the bits \(11\) decode to \(-1\) (left), the bits \(10\) decode to \(+1\) (right), and a first bit \(0\) decodes to \(0\) (stay).

Definition 177.7 Decoding the two-bit optional-write field
✓
#

Decodes a valid two-bit optional-write field: the bits \(1b\) mean “write the bit \(b\)”, the bits \(01\) mean “write the blank” (erase the cell), and the bits \(00\) mean “leave the cell unchanged”.

The fixed four-tape machine over \(\{ 0,1\} \) that interprets a serialized transition table. Its four work tapes hold the captured program table, the current simulated state in unary behind a permanent origin marker, the simulated machine’s work tape, and a marker tape recording whether the virtual input head sits at the simulated left boundary. To perform one simulated transition it rewinds the table, skips nine records per unary state symbol while consuming the unary state destructively, selects within the reached block the record indexed by the current simulated reads, buffers its eight fixed action bits, copies the successor-state unary field back onto the state tape, and applies the decoded action, adjusting the input-head movement at the virtual left boundary. The control is finite and independent of the number of coded states; malformed administrative reads enter a non-halting sink state.

Definition 177.9 Unary state-tape representation
✓
#

The tape encoding of a simulated state index \(q \in \mathbb {N}\): cell \(0\) holds the permanent origin marker \(0\), cells \(1, \dots , q\) hold \(1\)s (the unary representation of \(q\)), and all other cells are blank.

Definition 177.10 The complete universal machine candidate
✓

The universal-machine candidate associated with an effective machine-coding scheme: the composite finite-tape machine over \(\{ 0,1\} \) that first virtually runs the scheme’s canonizer to extract the code prefix of the pair-encoded input and produce the canonical serialized table, then captures that table onto a work tape, and finally hands control to the fixed four-tape table interpreter.

Definition 177.11 Interpreter evaluation configuration
✓

Given a base four-tape configuration (supplying the physical input position, the simulated work tape, the boundary-marker tape, and the accumulated output), a control state \(q\), a bit string \(T\) with a table cursor \(p \in \mathbb {Z}\), and a state tape \(\sigma \colon \mathbb {Z} \to \{ 0, 1, \mathrm{blank}\} \) with a state cursor \(s\): the configuration in control state \(q\) whose first work tape is the buffer tape of \(T\) with head at \(p\), whose second work tape is \(\sigma \) with head at \(s\), and which agrees with the base configuration in every other field.

Lemma 177.12 Reads of an evaluation configuration
✓

Consider an interpreter evaluation configuration whose table tape is the buffer tape of a bit string \(T\) with cursor \(p\), whose state tape is \(\sigma \) with cursor \(s\), and whose remaining data come from a base configuration. The four symbols under its work heads are, in order: the symbol of the buffer tape of \(T\) at \(p\), the state symbol \(\sigma (s)\), and the two symbols read by the base configuration on its third and fourth work tapes.

Lemma 177.13 Effect of one administrative action
✓

Applying the administrative action with target control state \(q'\), table movement \(d_t\), optional state-tape write \(w\), and state movement \(d_s\) to an interpreter evaluation configuration with table cursor \(p\) and state tape \(\sigma \) with cursor \(s\) yields the evaluation configuration over the same base with control state \(q'\), table cursor \(p + d_t\), state tape equal to \(\sigma \) updated at \(s\) by \(w\) when a write is present (and \(\sigma \) otherwise), and state cursor \(s + d_s\). The input head, the other two work tapes, and the accumulated output are unchanged.

Consider an evaluation configuration of the table interpreter with control state \(q\), table \(T\) with cursor \(p\), and state tape \(\sigma \) with cursor \(s\) over some base configuration. If the interpreter’s transition function at \(q\), applied to the physical input symbol and the represented reads (the buffer-tape symbol of \(T\) at \(p\), the state symbol \(\sigma (s)\), and the base configuration’s two remaining work reads), is the administrative action with target \(q'\), table movement \(d_t\), optional state write \(w\), and state movement \(d_s\), then one interpreter step takes the configuration to the evaluation configuration with control state \(q'\), table cursor \(p + d_t\), state tape updated by \(w\) at \(s\), and state cursor \(s + d_s\), leaving all other fields unchanged.

Lemma 177.15 Reading the first unconsumed table cell
✓

For bit strings \(l, r\) and a bit \(b\), the buffer tape of the concatenation \(l \cdot b \cdot r\) (holding the string in cells \(0, 1, \dots \) with blanks elsewhere) reads exactly \(b\) at position \(|l|\).

Consider the table interpreter in its table-rewind phase (carrying a Boolean flag and a record index that it merely preserves), in an evaluation configuration over a table \(T\) with table cursor \(j - 1\) for some \(j \le |T|\), and with an arbitrary state tape \(\sigma \) and state cursor \(s\). Then exactly \(j + 1\) interpreter steps bring it to the count-parsing phase with the same flag and index and with the table cursor at \(0\); the state tape, state cursor, and all other data are unchanged.

Suppose the table is \(l \cdot d(\beta ) \cdot 01 \cdot r\), where \(d(\beta )\) doubles each bit of a bit string \(\beta \) and \(01\) is the unequal delimiter pair. Starting the interpreter’s count parser (carrying a Boolean flag and a record index) at table cursor \(|l|\), exactly \(2|\beta | + 2\) steps move the table cursor past the doubled count field and the delimiter to position \(|l| + 2|\beta | + 2\), entering the initial-state copier when the flag is set and the initial-state skipper with the carried index otherwise. No binary arithmetic on the value of \(\beta \) is performed, and the state tape, state cursor, and all other data are unchanged.

Definition 177.18 State window during destructive lookup
✓
#

The state-tape contents during a destructive table lookup, parametrized by the number \(c\) of unary cells already erased and the number \(m\) still remaining: cell \(0\) holds the permanent origin marker \(0\), cells \(c + 1, \dots , c + m\) hold \(1\)s, and all other cells are blank.

Lemma 177.19 The intact window is the state tape
✓

With no cells erased, the state window with \(n\) remaining unary cells — marker \(0\) at the origin, \(1\)s in cells \(1, \dots , n\), blanks elsewhere — coincides with the intact unary state tape encoding the state index \(n\).

Lemma 177.20 A nonempty window reads one at its cursor
✓
#

In a state window with \(j\) erased cells and \(n + 1\) remaining unary cells, the cell at position \(j + 1\) (the current lookup position) holds the bit \(1\).

Lemma 177.21 An exhausted window reads blank at its cursor
✓
#

In a state window with \(j\) erased cells and no remaining unary cells, the cell at position \(j + 1\) is blank.

Lemma 177.22 Erasing one unary symbol
✓
#

Erasing the cell at position \(j + 1\) of a state window with \(j\) erased and \(n + 1\) remaining unary cells (writing the blank there) yields exactly the state window with \(j + 1\) erased and \(n\) remaining cells.

Lemma 177.23 A fully consumed window is marker-only
✓
#

A state window with no remaining unary cells is the same tape regardless of the number of erased cells: the permanent origin marker \(0\) at position \(0\) and blanks everywhere else.

Lemma 177.24 Appending a unary state symbol
✓

Writing the bit \(1\) into cell \(n + 1\) of the intact unary state tape encoding the index \(n\) yields the intact unary state tape encoding the index \(n + 1\).

Lemma 177.25 The intact state tape ends in blank
✓

The intact unary state tape encoding the index \(n\) is blank at position \(n + 1\), immediately after its last unary symbol.

Let \(\sigma \) be a state tape whose cell \(0\) reads the marker bit \(0\) and none of whose cells at positive natural positions reads \(0\) (they may be \(1\) or blank). Let \(q\) be an interpreter control state such that, for every combination of reads whose state-tape read is \(0\), the transition at \(q\) is the administrative action passing to a fixed state \(q'\) and moving the state cursor right, and for every combination whose state-tape read is not \(0\) it is the administrative action staying in \(q\) and moving the state cursor left, in both cases touching nothing else. Then for every natural number \(j\), starting from the evaluation configuration in state \(q\) with state tape \(\sigma \) and state cursor \(j\), exactly \(j + 1\) interpreter steps reach state \(q'\) with state cursor \(1\), leaving \(\sigma \), the table cursor, and all other data unchanged. The hypotheses are deliberately independent of whether the traversed cells are erased blanks or retained unary symbols.

Suppose the table is \(l \cdot 1^n \cdot 0 \cdot r\). From the interpreter’s initial-state skipping phase (carrying a record index) with table cursor \(|l|\), exactly \(n + 1\) steps move the table cursor past the unary field and its terminating \(0\) to position \(|l| + n + 1\) and enter the record-group phase with the carried index; the state tape, state cursor, and all other data are unchanged.

Let \(q\) be an interpreter control state that, on every combination of reads with table read \(1\), stays in \(q\), writes a \(1\) at the state cursor, and moves both the table and state cursors right; and on every combination with table read \(0\) passes to a state \(q'\) with a fixed table movement \(d \in \{ -1, 0, +1\} \) and no other change. Suppose the table is \(l \cdot 1^n \cdot 0 \cdot r\), the state tape is the intact unary encoding of an index \(j\), the table cursor is \(|l|\), and the state cursor is \(j + 1\). Then exactly \(n + 1\) interpreter steps reach \(q'\) with table cursor \(|l| + n + d\), state tape the intact unary encoding of \(j + n\), and state cursor \(j + n + 1\); all other data are unchanged. This single gadget serves both initial-state extraction and live successor-state replacement.

Lemma 177.29 Uniqueness of the state-tape marker
✓

For every state index \(n\), the intact unary state tape encoding \(n\) reads the marker bit \(0\) at position \(0\), and reads \(0\) at no positive natural position.

Lemma 177.30 Installing a permanent marker
✓

Updating the everywhere-blank two-way infinite tape by writing a bit \(b\) at position \(0\) yields the buffer tape of the one-character string \(b\): the tape holding \(b\) in cell \(0\) and blanks elsewhere.

Definition 177.31 Interpreter entry configuration
✓

The interpreter’s entry configuration for a captured table \(T\): control at the interpreter’s start state, physical input head at a given position \(p\) (already parked at the start of the input suffix), first work tape holding the buffer tape of \(T\) with its head at \(|T|\) (the right blank of the table), the other three work tapes blank with heads at \(0\), and no output emitted.

Definition 177.32 Initialization base configuration
✓

The inactive data carried during interpreter initialization, packaged as a base configuration: control at the interpreter’s main dispatch state, physical input head parked at a given position \(p\), table and state tapes blank with heads at \(0\), simulated work tape blank with head at \(0\), the boundary-marker tape holding a single \(1\) in cell \(0\) with its head at position \(1\) (also correct for empty suffixes), and no output emitted.

One step of the table interpreter from its entry configuration on a captured table \(T\) installs the two permanent markers — the origin marker \(0\) on the state tape and the boundary bit \(1\) on the marker tape — and starts the unconditional table rewind: the result is the evaluation configuration over the initialization base whose control is the initial table-rewind phase, with table cursor \(|T| - 1\), the unary state tape encoding the index \(0\), and state cursor \(1\).

Definition 177.34 Serialized transition record
✓
#

The bit-string serialization of one transition record of a one-work-tape machine action over \(\{ 0,1\} \): two bits encoding the input-head movement, two bits encoding the optional work-tape write, two bits encoding the work-head movement, two bits encoding the optional output emission, and finally the optional successor state as a self-delimiting unary field — a single \(0\) when the action halts, and \(1 \cdot 1^{q} \cdot 0\) when the successor state has index \(q\).

Definition 177.35 Canonical record table of a coded machine
✓

The canonical transition table of a coded machine \(M\): the concatenation, over every state of \(M\) in order and over every pair of reads (input read, work read) in the fixed serialization order blank, \(0\), \(1\), of the serialized transition record of the action \(M\) performs at that state and read pair — nine records per state, including all nine read pairs at every live state.

Lemma 177.36 Header shape of the canonical serialization
✓

For every coded machine \(M\) with initial state index \(q_0\) and state count \(m\), there is a bit string \(\rho \) (the transition-record table) such that the canonical serialization of \(M\) equals the pair encoding of the binary digit string of \(m\) with the string \(1^{q_0} \cdot 0 \cdot \rho \); that is, the serialization begins with exactly its doubled count field and delimiter, then the initial state in unary with its terminator, then the record table.

Suppose the captured table \(T\) is the pair encoding of a bit string \(\beta \) (the count field) with a string of the form \(1^n \cdot 0 \cdot \rho \) (the initial state \(n\) in unary, followed by an arbitrary remainder \(\rho \)). Then from the interpreter’s entry configuration with physical input head parked at a position \(p\), exactly \(|T| + 2|\beta | + 2n + 7\) interpreter steps reach the evaluation configuration over the initialization base at \(p\) whose control is the main dispatch state, with table cursor \(2|\beta | + 2 + n + 1\) (just past the serialized header), the unary state tape encoding the index \(n\), and state cursor \(1\). No transition-table lookup is involved yet.

For a coded machine \(M\), a code string \(\alpha \), a configuration of \(M\)’s one-work-tape form on an input \(x\), and a table-cursor value: the four-tape interpreter configuration on the pair-encoded input \(\langle \alpha , x \rangle \) whose control is the main dispatch state when the source is live and halted when the source has halted; whose physical input head represents the source input head, offset past the encoded prefix; whose table tape holds the buffer tape of the canonical serialization of \(M\) at the given cursor (the only administrative coordinate not determined by the source); whose state tape holds the source’s current state index in unary with state cursor \(1\); whose third work tape mirrors the source work tape with the same head; whose marker tape holds a single \(1\) at the origin with its head at the source input position (so it reads \(1\) exactly at the simulated left boundary); and whose accumulated output equals the source output.

Lemma 177.39 Checkpoints preserve halting and output
✓

The interpreter checkpoint representing a source configuration of a coded machine is halted exactly when the source configuration is halted, and its accumulated output equals the source’s accumulated output.

Let \(M\) be a finite-tape machine over \(\{ 0,1\} \), \(D\) a four-tape follower machine, and consider a configuration of \(M\) on an input \(x\). The endpoint configuration of the capture stage — which copies \(M\)’s accumulated output onto a fresh tape and hands control to \(D\) — equals the right-block embedding into the combined machine of the \(D\)-configuration with control at \(D\)’s initial state, the same physical input head as the source, first work tape holding the buffer tape of the captured output string with head at its right blank, and three blank tapes with heads at \(0\), where \(M\)’s work tapes and head positions are retained unchanged as the inactive left block.

Let \(M\) be a finite-tape machine over \(\{ 0,1\} \). For every four-tape configuration of the table interpreter, every assignment of contents and head positions to \(M\)’s work tapes, and every number of steps \(t\): running the combined capture machine (which pairs \(M\) with the fixed table interpreter) for \(t\) steps from the right-block embedding of the interpreter configuration equals the right-block embedding of the interpreter’s own \(t\)-step run, with the inactive tapes and heads unchanged.

Definition 177.42 The startup bound
✓

The startup time bound of the universal machine for a coding scheme on a code string \(\alpha \):

\[ 3|\alpha | + t_c(|\alpha |) + |s| + 2\ell + 2 q_0 + 12, \]

where \(t_c\) is the scheme’s canonizer time bound, \(s\) is the canonical serialization of the machine decoded from \(\alpha \), \(\ell \) is the number of binary digits of that machine’s state count, and \(q_0\) is its initial state index. It depends on \(\alpha \) but not on the input suffix, and includes complete interpreter setup.

Let \(c\) be an effective machine-coding scheme, \(\alpha \) a code string, and \(x\) an input string, and let \(N\) denote the machine decoded from \(\alpha \), with \(\ell \) the number of binary digits of its state count and \(q_0\) its initial state index. Then there exist a time \(t\) not exceeding the startup bound for \(\alpha \) (which is independent of \(x\)) and contents and head positions for the inactive canonizer tapes such that running the complete universal-machine candidate for \(t\) steps from its initial configuration on the pair encoding \(\langle \alpha , x \rangle \) yields exactly the right-block embedding, over those inactive tapes, of the interpreter checkpoint representing the initial configuration of \(N\) on \(x\) with table cursor \(2\ell + 2 + q_0 + 1\) — that is, with the canonical table captured, its cursor parked just past the header, the initial state in unary, a blank simulated work tape, and the virtual-input boundary marker installed.

Lemma 177.44 Cofinal physical run from a block simulation
✓

Let \(M\) and \(U\) be multi-tape machines over \(\{ 0,1\} \) on inputs \(x\) and \(y\) respectively, let \(R\) be a relation between their configurations, and let \(S, B \in \mathbb {N}\). Assume (startup) there is a \(t \le S\) such that the configuration of \(U\) after \(t\) steps from its initial configuration is related to \(M\)’s initial configuration, and (step) whenever a source configuration is related to a target configuration, there is a duration \(d\) with \(1 \le d \le B\) such that running \(U\) for \(d\) further steps yields a configuration related to the source’s successor. Then for every \(n\) there is a time \(t\) with \(n \le t \le S + Bn\) such that the configuration of \(U\) after \(t\) steps is related to the configuration of \(M\) after \(n\) steps. The lower bound \(n \le t\) makes the run cofinal, without assuming that either machine eventually halts.

Let \(c\) be an effective machine-coding scheme, \(U\) a finite-tape machine over \(\{ 0,1\} \), and \(S, B\) functions assigning a bound to each code string. For each code string \(\alpha \) and input \(x\), let a relation be given between configurations of the machine decoded from \(\alpha \) (in one-work-tape form) on \(x\) and configurations of \(U\) on the pair encoding \(\langle \alpha , x \rangle \). Assume: (startup) for all \(\alpha , x\), within some \(t \le S(\alpha )\) steps \(U\) reaches a configuration related to the decoded machine’s initial configuration; (step) every related pair advances — one source step against some \(d\) target steps with \(1 \le d \le B(\alpha )\) — to a related pair; (halting) related configurations are halted simultaneously; and (output) related configurations have equal accumulated output. Then for every \(\alpha \) there is a constant \(C\) such that for every input \(x\): whenever the decoded machine computes an output within \(t\) steps on \(x\), the machine \(U\) computes the same output on \(\langle \alpha , x \rangle \) within \(C(t+1)\) steps; and conversely, every output \(U\) computes on \(\langle \alpha , x \rangle \) within some time is computed by the decoded machine on \(x\) within some time.

Definition 177.46 The eight fixed action bits
✓
#

The eight fixed bits of the serialized record of a one-work-tape machine action, as a function on indices \(0, \dots , 7\): bits \(0, 1\) encode the input-head movement, bits \(2, 3\) the optional work-tape write, bits \(4, 5\) the work-head movement, and bits \(6, 7\) the optional output emission, each in the two-bit encodings of the canonical record grammar.

Definition 177.47 Unary size of the successor field
✓
#

The number of \(1\)s in the self-delimiting unary successor field of a serialized record: \(0\) when there is no successor state (the action halts), and \(q + 1\) when the successor state has index \(q\) (one \(1\) for the live flag and \(q\) for the index).

Lemma 177.48 Shape of a serialized record
✓

The serialized record of any one-work-tape machine action decomposes as its eight fixed action bits, followed by a block of \(1\)s whose length is the unary size of the optional successor field (zero when the action halts, one more than the successor index otherwise), followed by a single terminating \(0\).

Lemma 177.49 Exact-cost skip of the fixed fields
✓

Consider the interpreter’s fixed-field skipping phase, carrying a destination and a count of remaining records, with field register \(f \in \{ 0,\dots ,7\} \) and table cursor \(p\). If \(f + n = 7\), then exactly \(n + 1\) interpreter steps advance the table cursor to \(p + n + 1\) and enter the unary-skipping phase with the same destination and remaining count; no tape cell is inspected or modified, and the state tape, state cursor, and all other data are unchanged.

Definition 177.50 Continuation after a skip request
✓
#

The interpreter control state entered after the last record of a skip request: the record-group phase with index \(i\) when the destination carries an index \(i\), and the action reader (starting at field \(0\) with a cleared bit buffer) when the destination is empty.