2 Machine models
This chapter fixes the machine model that every complexity class in the library is defined from, and the tools for reasoning about it. The base model is the multi-tape Turing machine of Arora and Barak over the alphabet \(\{ 0, 1, \sqcup , \triangleright \} \), with a read-only input tape, \(k\) work tapes, and an output tape; deterministic, nondeterministic, and probabilistic machines share one configuration type and differ only in their transition functions and acceptance conditions. Formalized so far: the model with its time and output semantics; machine combinators with Hoare-style rules for sequential, conditional, looping, and complementing composition, and deciders for complements and unions; the quadratic reduction to one work tape; a fixed six-work-tape universal machine proved universal and polynomially efficiently universal; a weak deterministic time hierarchy; and a logarithmic-cost random access machine whose polynomial-time class equals \(\mathsf{P}\). The main open directions are undecidability of the halting problem (now within reach, since the universal machine is proved to reflect as well as preserve halting), a time hierarchy under the textbook time-constructibility hypothesis, a \(T \log T\) simulation of Turing machines by random access machines, and space-level and variant-model robustness for random access machines.
2.1 Turing machines
The read alphabet is \(\Gamma = \{ 0, 1, \sqcup , \triangleright \} \) and the write alphabet is \(\Gamma _w = \{ 0, 1, \sqcup \} \), so no transition can write the start symbol \(\triangleright \). A head moves left, right, or stays. A tape is a head position \(h \in \mathbb {N}\) together with contents \(\mathbb {N} \to \Gamma \); the type allows any symbol in any cell. Initial tapes have \(\triangleright \) in cell \(0\) and nowhere else, writing at cell \(0\) is a no-op, and moving left at cell \(0\) stays there, so every tape reachable from an initial configuration keeps this marker invariant (statements about arbitrary tapes assume it explicitly). A tape has output \(y \in \{ 0,1\} ^*\) when cells \(1, \dots , |y|\) hold the bits of \(y\) and cell \(|y| + 1\) is blank.
A language is a set of finite binary strings, \(L \subseteq \{ 0,1\} ^*\).
A configuration of a machine with state set \(Q\) and \(k\) work tapes consists of a state, an input tape, \(k\) work tapes, and an output tape, each a named field. The initial configuration on input \(x\) is in the start state, with \(x\) written from cell \(1\) of the input tape, every other tape empty, and every head at cell \(0\).
A deterministic Turing machine with \(k\) work tapes consists of a finite state type \(Q\) with decidable equality, a start state and a halt state, and a transition function
that must move right every head reading \(\triangleright \). One step applies \(\delta \) to the current state and the symbols under the input head, the \(k\) work heads, and the output head, writes on the work and output tapes, and moves all heads; the halt state has no successor. The relation \(c \to ^t c'\) holds when \(c'\) is reached from \(c\) in exactly \(t\) steps, and \(c \to ^* c'\) is its reflexive–transitive closure.
A nondeterministic Turing machine has the same data as a deterministic one except that it has two transition functions \(\delta _0, \delta _1\), each subject to the same rule at \(\triangleright \). Its execution is defined only through the trace: given a choice sequence \(r \in \{ 0,1\} ^T\), run \(T\) steps, using \(\delta _{r_i}\) at step \(i\), and stay put once the halt state is reached. The same structure serves as a probabilistic machine, with \(r\) read as random bits. A deterministic machine embeds by taking \(\delta _0 = \delta _1 = \delta \).
A deterministic machine \(M\) decides \(L\) in time \(T : \mathbb {N} \to \mathbb {N}\) if on every input \(x\) it reaches the halt state within \(T(|x|)\) steps, with output cell \(1\) equal to \(1\) if \(x \in L\) and equal to \(0\) if \(x \notin L\) (Arora–Barak Definition 1.2).
A deterministic machine \(M\) computes \(f : \{ 0,1\} ^* \to \{ 0,1\} ^*\) in time \(T\) if on every input \(x\) it halts within \(T(|x|)\) steps and its output tape has output \(f(x)\). It computes \(f\) if it does so for some \(T\).
A nondeterministic machine \(N\) accepts \(x\) in time \(T\) if some choice sequence of length \(T\) leads to the halt state with output cell \(1\) equal to \(1\). It decides \(L\) in time \(T\) if every trace on every input \(x\) has halted after \(T(|x|)\) steps, and \(x \in L\) exactly when \(N\) accepts \(x\) in time \(T(|x|)\) (Arora–Barak Definition 2.1). Rejection is the absence of an accepting path; it does not require output \(0\).
For a machine \(N\), input \(x\), and clock \(T\), the acceptance probability is the rational number
and the probability of output \(y\) is defined the same way with the output condition in place of acceptance. Both are meaningful when every trace has halted by time \(T\).
If a deterministic machine decides \(L\) in time \(T\), its nondeterministic embedding decides \(L\) in time \(T\). Without a time bound, a deterministic machine and its embedding accept the same strings, where acceptance means reaching the halt state (after some number of steps, along some choice sequence) with output cell \(1\) equal to \(1\).
Every trace of the embedding is the deterministic run, frozen at the halt state; for acceptance without a bound, the trace of the embedding reaches exactly the configurations the deterministic run reaches.
2.2 Output semantics
A deterministic machine \(M\) halts on a program \(p\) (within time \(t\)) if the run from the initial configuration on \(p\) reaches the halt state (within \(t\) steps). It produces \(y\) on \(p\) (within time \(t\)) if moreover the output tape of the halted configuration has output \(y\). The bounded evaluator \(\mathrm{run}(c, t)\) is the configuration after \(t\) steps, standing still once halted.
Let \(M\) be a deterministic machine.
\(M\) produces \(y\) on \(p\) within time \(t\) if and only if \(\mathrm{run}(\mathrm{init}(p), t)\) is halted with output \(y\); in particular bounded production is decidable.
Bounded production is monotone in \(t\), and \(M\) produces \(y\) on \(p\) exactly when it does so within some finite time.
If \(M\) produces \(y\) on \(p\) within time \(t\), it produces \(y\) on the first \(t\) bits of \(p\) within time \(t\).
If \(M\) produces both \(y\) and \(y'\) on \(p\), then \(y = y'\); this holds also for bounded production under two different clocks.
Relate the relational run to the bounded evaluator; a run of \(t\) steps cannot move the input head past cell \(t\).
\(M\) computes \(f\) in time \(T\) if and only if \(M\) produces \(f(x)\) on \(x\) within time \(T(|x|)\) for every \(x\). \(M\) computes \(f\) if and only if \(M\) produces \(f(x)\) on every \(x\).
The first equivalence unfolds the definitions. For the second, take the maximum halting time over the finitely many inputs of each length.
2.3 Combinators and Hoare-style specifications
For predicates \(\mathit{pre}, \mathit{post}\) on (input tape, work tapes, output tape) and a bound \(b \in \mathbb {N}\), the triple \(\{ \mathit{pre}\} \, M\, \{ \mathit{post}\} _b\) holds if \(M\), started in its start state on any tapes satisfying \(\mathit{pre}\), halts within \(b\) steps on tapes satisfying \(\mathit{post}\). The unbounded triple drops the step bound.
On machines with the same \(k\) work tapes: \(\mathrm{seq}(M_1, M_2)\) runs \(M_1\) to completion and then \(M_2\) on the same tapes; \(\mathrm{if}(M_t, M_1, M_0)\) runs the test \(M_t\), rewinds the output head, and runs \(M_1\) if output cell \(1\) holds \(1\) and \(M_0\) otherwise; \(\mathrm{loop}(M_b, M_t)\) alternates the body and the test, rewinding the output head after each test, and halts once the test leaves \(1\) in output cell \(1\); \(\mathrm{complement}(M)\) runs \(M\), rewinds the output head, and exchanges \(0\) and \(1\) in output cell \(1\) (a blank stays blank). In \(\mathrm{seq}\) (from \(M_1\) to \(M_2\)), in \(\mathrm{loop}\) (from the body to the test), and in \(\mathrm{if}\) (from the branch to the final halt state), the handover is a single step in which every head reading \(\triangleright \) moves one cell right, the other heads stay, and no tape cell changes except that a \(\triangleright \) outside cell \(0\) would be overwritten by a blank. After the test in \(\mathrm{if}\) and \(\mathrm{loop}\) the handover takes several steps: one such step; then steps that move the output head left one cell at a time until it reads \(\triangleright \), and then one cell right; and a last step that reads the output cell under the head (cell \(1\) when \(\triangleright \) appears on the output tape only at cell \(0\)) and enters the chosen branch, the body, or the halt state. In each of these steps every input or work head reading \(\triangleright \) moves one cell right and the others stay, and cells change only as in the single-step handover. The machine \(\mathrm{union}(M_1, M_2)\), with \(M_i\) on \(k_i\) work tapes, has \(k_1 + 1 + k_2\) work tapes: it runs \(M_1\) with its output redirected to work tape \(k_1\), halts with \(1\) in output cell \(1\) if cell \(1\) of that work tape holds \(1\), and otherwise rewinds the input and runs \(M_2\) on the last \(k_2\) work tapes and the real output tape.
If \(M\) decides \(L\) in time \(T\), then \(\mathrm{complement}(M)\) decides \(\{ 0,1\} ^* \setminus L\) in time \(2T(n) + 4\).
If \(M_1\) decides \(L_1\) in time \(T_1\) and \(M_2\) decides \(L_2\) in time \(T_2\), then \(\mathrm{union}(M_1, M_2)\) decides \(L_1 \cup L_2\) in time \(10\, T_1(n) + T_2(n)\).
If \(\{ \mathit{pre}\} \, M\, \{ \mathit{post}\} _b\), where \(\mathit{post}\) guarantees that the output tape holds \(\triangleright \) at cell \(0\) and nowhere else, that the output head is at a cell at most \(p\), and that output cell \(1\) holds a symbol satisfying \(\varphi \), then \(\{ \mathit{pre}\} \, \mathrm{complement}(M)\, \{ \mathit{post}'\} _{b + p + 4}\), where \(\mathit{post}'\) says that output cell \(1\) holds the flip of some symbol satisfying \(\varphi \) (\(0\) and \(1\) exchanged, anything else made blank).
For the complement, simulate \(M\), then rewind the output head to \(\triangleright \), step to cell \(1\), and write the flipped symbol. For the union, simulate \(M_1\), rewind its redirected output and read its verdict, and either accept at once or rewind the input and simulate \(M_2\); the transition costs at most \(2T_1(n) + 7\) steps, which is absorbed into \(9\, T_1(n)\) because a decider cannot halt in zero steps (its start state would then be its halt state, leaving a blank verdict cell).
If \(\{ \mathit{pre}\} \, M_1\, \{ \mathit{mid}\} _{b_1}\), the phase-boundary normalization maps tapes satisfying \(\mathit{mid}\) to tapes satisfying \(\mathit{mid}'\), and \(\{ \mathit{mid}'\} \, M_2\, \{ \mathit{post}\} _{b_2}\), then \(\{ \mathit{pre}\} \, \mathrm{seq}(M_1, M_2)\, \{ \mathit{post}\} _{b_1 + 1 + b_2}\).
Simulate \(M_1\) in the first phase, take one transition step, and simulate \(M_2\) in the second phase.
Suppose \(\{ \mathit{pre}\} \, M_t\, \{ \mathit{mid}\} _{b_t}\), where \(\mathit{mid}\) guarantees that every tape holds \(\triangleright \) at cell \(0\) and nowhere else and that the output head is at a cell at most \(p\); that \(\mathit{mid}\) with output cell \(1\) equal to \(1\) (resp. not \(1\)) implies the precondition of \(M_1\) (resp. \(M_0\)) on the tapes obtained by normalizing the input and work tapes and placing the output head at cell \(1\); that \(\{ \mathit{mid}_i\} \, M_i\, \{ \mathit{post}_i\} _{b_i}\) for \(i = 0, 1\); and that both postconditions imply \(\mathit{post}\) after normalization. Then \(\{ \mathit{pre}\} \, \mathrm{if}(M_t, M_1, M_0)\, \{ \mathit{post}\} _b\) with \(b = b_t + p + \max (b_1, b_0) + 5\).
Simulate the test, rewind the output head to read the verdict, then simulate the selected branch.
Let \(\mathit{inv}\) be an invariant and \(v\) a variant with \(v \le K\) under \(\mathit{inv}\). Suppose every iteration of \(\mathrm{loop}(M_b, M_t)\) started from \(\mathit{inv}\) either halts within \(b\) steps satisfying \(\mathit{post}\), or returns to the loop start within \(b\) steps satisfying \(\mathit{inv}\) with \(v\) strictly smaller. Then \(\{ \mathit{inv}\} \, \mathrm{loop}(M_b, M_t)\, \{ \mathit{post}\} _{(K+1) b}\).
Induction on the variant.
2.4 Reduction to one work tape
If a nondeterministic machine \(N\) with \(k \ge 1\) work tapes decides \(L\) in time \(T\), then its single-tape simulator, a machine with one work tape, decides \(L\) in time \(16(k+1)(T(n) + n + 1)^2\). Consequently, for any \(k\), if \(L\) is decided by some \(k\)-work-tape machine in time \(T = O(n^c)\), it is decided by some one-work-tape machine in time \(O(n^{c'})\) for some \(c'\).
Interleave the \(k\) work tapes on one tape in blocks carrying head markers; each simulated step sweeps the used region. For \(k = 0\), pad with a dummy work tape.
If a deterministic machine with \(k\) work tapes decides \(L\) in time \(T\), then some deterministic machine with one work tape decides \(L\) in time \(16(k+1)(T(n) + n + 1)^2\).
Embed as a nondeterministic machine, apply the single-tape simulation, which preserves determinism and the output-\(0\) rejection convention, and convert back.
2.5 Universal simulation
A deterministic machine \(U\) simulates \(M\) under a compiler \(c : \{ 0,1\} ^* \to \{ 0,1\} ^*\) if for every program \(p\): \(U\) halts on \(c(p)\) if and only if \(M\) halts on \(p\), and for every \(y\), \(U\) produces \(y\) on \(c(p)\) if and only if \(M\) produces \(y\) on \(p\).
\(U\) simulates \(M\) under \(c\) in time \(\tau : \{ 0,1\} ^* \times \mathbb {N} \to \mathbb {N}\) if whenever \(M\) halts on \(p\) (resp. produces \(y\) on \(p\)) within \(t\) steps, \(U\) halts on \(c(p)\) (resp. produces \(y\) on \(c(p)\)) within \(\tau (p, t)\) steps. The compiler has additive overhead \(C\) if \(|c(p)| \le |p| + C\) for all \(p\). The clock \(\tau \) is polynomial if \(\tau (p, t) \le a (|p| + t + 1)^e\) for some constants \(a, e\).
A function \(f : \{ 0,1\} ^* \to \{ 0,1\} ^*\) is computable if some deterministic machine, with any number of work tapes, computes \(f\).
A deterministic machine \(U\) is universal if for every \(k\) and every machine \(M\) with \(k\) work tapes there is a computable compiler \(c\) such that \(U\) simulates \(M\) under \(c\). It is efficiently universal for an admissibility predicate on clocks if for every such \(M\) there are a computable compiler \(c\), a constant \(C\), and a clock \(\tau \) such that \(U\) simulates \(M\) under \(c\), \(c\) has additive overhead \(C\), \(U\) simulates \(M\) under \(c\) in time \(\tau \), and \(\tau \) is admissible; it is efficiently universal when the predicate is polynomiality. Computability of \(c\) is essential: without it a machine that copies its input after a leading \(0\) and diverges after a leading \(1\) would be universal, with a compiler that consults the source machine’s halting behavior and output.
Every machine simulates itself under the identity. If \(U_1\) simulates \(U_2\) under \(c_1\) and \(U_2\) simulates \(M\) under \(c_2\), then \(U_1\) simulates \(M\) under \(c_1 \circ c_2\), and likewise for timed simulations with clock \((p, t) \mapsto \tau _1(c_2(p), \tau _2(p, t))\). Additive overheads add; polynomial clocks compose through a compiler with additive overhead; and computable functions are closed under composition.
Unfold the definitions; composition of computable functions sequences two machines.
A machine that simulates a universal machine under a computable compiler is universal. Every machine that is efficiently universal for some admissibility predicate, in particular every efficiently universal machine, is universal.
Compose compilers for the first claim; for the second, forget the overhead data.
The universal machine \(\mathcal{U}\) has six work tapes and is \(\mathrm{seq}(\mathrm{init}, \mathrm{seq}(\mathrm{loop}(\mathrm{body}, \mathrm{haltTest}), \mathrm{extract}))\). On input \(\langle \alpha , x \rangle \) it parses the description \(\alpha \) of a one-work-tape machine, simulates one step per loop iteration, tests for the halt state, and finally copies the simulated output tape to its own output tape.
Let \(M\) be a deterministic machine with \(k\) work tapes that decides \(L\) in time \(T\), and let \(T'(n) = 16(k+1)(T(n) + n + 1)^2\). There is a description \(\alpha _0\) such that for every string \(j\) and every input \(x\), with \(\alpha = \alpha _0 j\), the machine \(\mathcal{U}\) on \(\langle \alpha , x \rangle \) halts within \(\mathrm{utmTime}(\alpha , T'(|x|), |x|)\) steps with output cell \(1\) equal to \(1\) if \(x \in L\) and \(0\) if \(x \notin L\). Here \(\mathrm{utmTime}(\alpha , t, n) = 4(2|\alpha | + 2 + n) + 4 g(\alpha ) + (t+1) s(\alpha ) + 2t + 35\), where \(g(\alpha )\) and \(s(\alpha )\) depend only on \(\alpha \) (Arora–Barak Theorem 1.9, with the quadratic factor coming from the single-tape reduction). The unpadded case, \(j\) empty, is also stated on its own. The underlying linear-time statement is also formalized: for every description \(\alpha \) satisfying a syntactic side condition on its table region (met by every encoded machine, with or without padding), if the one-work-tape machine that \(\alpha \) describes decides \(L\) in time \(T\), then \(\mathcal{U}\) on \(\langle \alpha , x \rangle \) halts within \(\mathrm{utmTime}(\alpha , T(|x|), |x|)\) steps with the same verdict.
Reduce \(M\) to one work tape, encode it, and compose Hoare triples for the parsing, per-step simulation loop, and extraction phases. Descriptions tolerate arbitrary trailing padding.
For every \(k\) and every machine \(M\) with \(k\) work tapes there is a description \(\alpha \) such that \(\mathcal{U}\) simulates \(M\) under the compiler \(p \mapsto \langle \alpha , p \rangle \), and does so in time \((p, t) \mapsto \mathrm{utmTime}(\alpha , 16(k+1)(t + |p| + 1)^2, |p|)\). Consequently \(\mathcal{U}\) is efficiently universal (with additive program overhead \(2|\alpha | + 2\)) and universal.
The phase Hoare triples behind Theorem 29 are applied to arbitrary programs instead of deciders: the single-tape simulation of \(M\), the interpretation of its encoded description, and \(\mathcal{U}\) each preserve halting and exact output within their clocks and diverge whenever the simulated machine diverges. Composing the three simulations gives the clock above. The compiler \(p \mapsto \langle \alpha , p \rangle \) is polynomial-time computable and adds exactly \(2|\alpha | + 2\) bits, and the composed clock is bounded by a polynomial in \(|p| + t + 1\).
Let \(H = \{ p : \mathcal{U} \text{ halts on } p \} \). There are no \(k\), machine \(M\) with \(k\) work tapes, and bound \(T\) such that \(M\) decides \(H\) in time \(T\). The same holds for \(H_V\) for every universal machine \(V\).
Diagonalize: from a decider for \(H\), build a machine that halts on its own description exactly when \(\mathcal{U}\) does not, and compile it through the universality compiler.
2.6 The time hierarchy
\(T : \mathbb {N} \to \mathbb {N}\) is time-constructible if \(T(n) \ge n\) for all \(n\) and some deterministic machine computes \(x \mapsto \mathrm{bin}(T(|x|))\) (least significant bit first) in time \(O(T(n))\) (Arora–Barak Definition 1.12). The formalized hierarchy theorem does not use this notion.
\(g\) is clock-constructible if there are an eight-work-tape machine \(M\) and a constant \(C\) such that, for every input \(x\) and every starting layout in which the input tape holds \(x\) with its head at cell \(1\), every work head is at a cell \(\ge 1\) not reading \(\triangleright \), work tapes \(5\) and \(6\) are blank with their heads at cell \(1\), and the output head is at cell \(1\) with \(\triangleright \) at cell \(0\) and nowhere else, \(M\) started in its start state halts within \(C (g(|x|) + |x| + 1)\) steps with: work tape \(6\) holding the unary clock of length \(g(|x|)\) (cells \(1, \dots , g(|x|)\) equal to \(1\), the rest blank, head at cell \(1\)); every other work tape exactly as it started (so the scratch tape \(5\) is again blank); the input head back at cell \(1\); and the output head at cell \(1\) with \(\triangleright \) still at cell \(0\) and nowhere else. The layout is pinned to the diagonalizer that consumes it.
The function \(n \mapsto n + 1\) is clock-constructible, and if \(g\) is clock-constructible then so is \(n \mapsto g(n)(n+1)\). Hence for every \(k \ge 1\) the function \(n \mapsto (n+1)^k\) is clock-constructible.
\(n + 1\) is constructed by one input sweep. For the product, run the clock for \(g\), move it to the scratch tape, and append it to the clock tape once per input position. Induction on \(k\) gives the powers.
Let \(g\) be clock-constructible with \(g(n) \ge 1\) for all \(n\), and let \((f(n) + n + 1)^2 = o(g(n))\). Then some language lies in \(\mathsf{DTIME}((n+1)^2 (g(n) + 1))\) but not in \(\mathsf{DTIME}(f)\); in fact \(\mathsf{DTIME}(f) \subsetneq \mathsf{DTIME}((n+1)^2 (g(n) + 1))\). In particular, for every \(a \ge 1\), \(\mathsf{DTIME}((n+1)^a) \subsetneq \mathsf{DTIME}((n+1)^{2a+5})\).
The diagonalizer is an eight-work-tape machine built with the combinators. On input \(x\) it forms \(\langle x, x \rangle \) on a work tape, outputs \(0\) if \(x\) fails the syntactic side condition on descriptions, and otherwise runs the clock for \(g(|x|)\), runs a clocked variant of \(\mathcal{U}\) (built from the same initialization, halt-test, and extraction phases) on \(\langle x, x \rangle \) within that budget, and negates the verdict; it runs within a constant times \((n+1)^2 (g(n) + 1)\) steps. A hypothetical decider in time \(f_0 = O(f)\) is reduced to one work tape, and its description, padded with enough zeros, is an input on which the simulation budget \(16(k+1)(f_0(n) + n + 1)^2\) falls below \(g(n)\); there the diagonalizer’s verdict contradicts the decider’s. The polynomial case takes \(g(n) = (n+1)^{2a+3}\).
If \(f\) and \(g\) are time-constructible and \(f(n) \log f(n) = o(g(n))\), then \(\mathsf{DTIME}(f) \subsetneq \mathsf{DTIME}(g)\) (Arora–Barak Theorem 3.1).
Needs a universal simulation with \(O(T \log T)\) overhead (Hennie–Stearns), which the current machine does not provide: its overhead is quadratic through the single-tape reduction. It also needs a bridge from time-constructibility to the pinned clock layout.
2.7 Random access machines
The random access machine is a register machine with indirect addressing, measured by logarithmic cost. Its role is to show that \(\mathsf{P}\) does not depend on the Turing-machine conventions.
A program is a list of instructions over registers \(R_0, R_1, \dots \) holding natural numbers: immediate load, \(\mathrm{add}\), truncated \(\mathrm{sub}\), \(\mathrm{mul}\), indirect \(\mathrm{load}\) (\(R_d := R_{R_a}\)) and \(\mathrm{store}\) (\(R_{R_a} := R_s\)), conditional and unconditional jumps, and \(\mathrm{halt}\); a program counter past the end halts. On input \(x\), \(R_0 = |x|\), \(R_{i+1} = x_i\), and all other registers are \(0\). Each instruction costs \(1\) plus bit lengths of the values it touches: the constant of an immediate load; both operands and the result for \(\mathrm{add}\) and \(\mathrm{mul}\); both operands for \(\mathrm{sub}\) (whose result is no longer than its first operand); the runtime address and the value moved for indirect \(\mathrm{load}\) and \(\mathrm{store}\); the tested register for a conditional jump; nothing more for \(\mathrm{jmp}\) and \(\mathrm{halt}\). Register indices and jump targets written in the program are not charged. The logarithmic time of a run is the total cost of its non-halted steps, and its unit time is the number of those steps. Space is the peak, over the configurations visited, of the total bit length of the addresses and contents of the nonzero registers.
A program decides \(L\) in time \(T\) if on every input \(x\) it halts after logarithmic cost at most \(T(|x|)\) with \(R_0 = 1\) if \(x \in L\) and \(R_0 = 0\) otherwise; deciding in space \(S\) bounds peak space instead. Then \(\mathsf{DTIME}_{\mathrm{RAM}}(T)\) and \(\mathsf{DSPACE}_{\mathrm{RAM}}(S)\) are the languages decided in time \(O(T)\) and space \(O(S)\), and \(\mathsf{P}_{\mathrm{RAM}} = \bigcup _k \mathsf{DTIME}_{\mathrm{RAM}}(n^k)\).
For every \(k \ge 1\) there are a program and a configuration whose run halts after \(k + 1\) steps, with unit time exactly \(k + 1\) and logarithmic time at least \(2^k\).
Load \(2\) into a register and square it \(k\) times; the last multiplication writes \(2^{2^k}\), which has \(2^k + 1\) bits.
\(\mathsf{P} \subseteq \mathsf{P}_{\mathrm{RAM}}\). More precisely, if a deterministic machine \(M\) decides \(L\) in time \(T\), a fixed RAM program built from \(M\) decides \(L\) in logarithmic time \(\beta _M(n, T(n))\), for an explicit bound \(\beta _M(n, t)\) depending only on \(M\), \(n\), and \(t\); so \(L \in \mathsf{DTIME}_{\mathrm{RAM}}(n \mapsto \beta _M(n, T(n)))\).
One fixed RAM program, depending only on the Turing machine, stores the configuration in a sparse interleaved register layout, computes cell addresses at run time, and follows the halting run before copying the verdict to \(R_0\). When \(T\) is bounded by a polynomial, so is \(n \mapsto \beta _M(n, T(n))\).
If \(n + 1 = O(T(n))\), then \(\mathsf{DTIME}_{\mathrm{RAM}}(T) \subseteq \mathsf{DTIME}(T(n)^2)\). More precisely, with no hypothesis on \(T\): if a program \(P\) decides \(L\) in logarithmic time \(T\), a fixed twenty-work-tape machine built from \(P\) decides \(L\) in time \(c_P (n + T(n) + 1)^2\), where \(c_P\) depends only on \(P\).
A twenty-work-tape machine built from the program keeps the public input immutable, stores the mutable registers as a sparse tagged overlay of address/value pairs, and charges each simulated step by the width of its instruction; the charges sum to \(O((n + T(n))^2)\).
\(\mathsf{P}_{\mathrm{RAM}} \subseteq \mathsf{P}\). The proof goes through a second simulator: if a program \(P\) decides \(L\) in logarithmic time \(T\), a fixed twenty-work-tape machine built from \(P\) decides \(L\) in time \(10^9 m_P (n + (m_P + 2) T(n) + m_P + 4)^4\), where \(m_P\) depends only on \(P\).
For each program, a twenty-work-tape machine built from it simulates the program within a fourth-degree polynomial in input length and logarithmic time; the number of RAM steps is at most the logarithmic time.
\(\mathsf{P}_{\mathrm{RAM}} = \mathsf{P}\).
Antisymmetry of the two inclusions.
Under an explicit hypothesis that \(T\) dominates the input length, \(\mathsf{DTIME}(T) \subseteq \mathsf{DTIME}_{\mathrm{RAM}}(T(n) \log T(n))\). What is formalized is only the exact-bound form of Theorem 40, membership in \(\mathsf{DTIME}_{\mathrm{RAM}}(n \mapsto \beta _M(n, T(n)))\); the asymptotic estimate of \(\beta _M\) is open.
In the explicit bound \(\beta _M(n, t)\) of the fixed simulator, each of the \(t + 1\) simulated steps is charged a constant number of words whose width is the bit length of a bound polynomial in \(n + t\), so the core should cost \(O(t \log (n + t))\); the input marshaller’s cost must be bounded as well and absorbed by the domination hypothesis.
\(\bigcup _k \mathsf{DSPACE}_{\mathrm{RAM}}(n^k) = \mathsf{PSPACE}\).
Bound the space of the two existing simulations, charging the sparse register store and the simulated tape contents.
Define register machines without indirect addressing and Boolean (straight-line or bounded-loop) programs, and relate each to the RAM and to Turing machines by explicit simulations, so that their polynomial-time classes equal \(\mathsf{P}\) as theorems rather than as separate class definitions.