Word-RAM polynomial time gives Turing-machine polynomial time #
A fixed word-RAM program that runs within polynomially many instructions gives a multi-tape Turing
machine computing the same function in polynomial time, in the sense of
Turing.MultiTapeTM.ComputableInPolyTime. This is the polynomial simulation of random access
machines by Turing machines Cook and Reckhow, for the unit-cost word RAM with a
word size polynomial in the input length.
Conventions #
- Cost model. Unit cost per instruction, the final
haltincluded, onw-bit words whose overflow faults (WordRAM.Executes). Each operation of the basis must have a polynomial-time checked implementation on a unary width and binary operands;Basis.standard,Basis.additive,Basis.arithmeticandBasis.exacthave one (WordRAM.Native). - Input. The instance
ais given as the bit stringencIn a. A polynomial-time machine computes its word listencode a(binary words, framed byencList encNat), and the simulation stores it as the memory ofState.init (encode a): the length at address0and the words at1, …, n. Both conversions are charged. - Word size. The simulating machine computes the word size itself, in unary, as a polynomial in
|encIn a|. In the general theorem the caller supplies this width schedule and its certificate; the corollaries choose a width at least the logarithmic thresholdlogWidth k (size a)and the encoded length of the input words, which makes the input fit. Since the word-RAM predicates promise correctness and the time bound at every admitted fitting width, simulating one such width suffices. - Output. The returned word, in binary (
encNat). - Overhead. Polynomial: the simulator runs
FiniteState.runfor a number of steps polynomial in|encIn a|, each polynomial in the word size and the number of stored cells, which grows by at most one per step (WordBounded.length_resultEncoding_run_le). The parameterized machine time is that ofWordRAM.transport_inO; no closed-form degree is stated.
Limits #
These theorems cover one fixed program (UniformComputableInPolyTime). A width-indexed family
(WordRAM.ComputableInPolyTime) may choose arbitrary, even uncomputable, code at each width, so it
gives Turing-machine polynomial time only with a computable code map, which is not provided. The
size measure must be polynomially bounded in the encoded input length: a polynomial instruction
count in the numeric value of an input number is exponential in its bit length and does not
transfer. Width-dependent word encodings are covered only by the general theorem, with a width
schedule chosen by the caller. Outputs are single words.
Main definitions #
Cslib.WordRAM.initEntries,Cslib.WordRAM.initMemory,Cslib.WordRAM.initState: the stored cells, finite memory and finite simulation state ofState.init.Cslib.WordRAM.WordBounded: registers, memory default and stored cells of a finite simulation state arew-bit words.Cslib.WordRAM.instrTarget,Cslib.WordRAM.labelBound: jump targets and a bound on every control label reachable by a program.Cslib.WordRAM.stateBound: a bound on the encoded size of a word-bounded simulation state.
Main results #
Cslib.WordRAM.denote_initState,Cslib.WordRAM.initMemory_polyTime: initialization is faithful and polynomial-time.Cslib.WordRAM.wordBounded_initState,Cslib.WordRAM.WordBounded.run,Cslib.WordRAM.WordBounded.length_resultEncoding_run_le: from a fitting input, simulation states hold words and their encodings grow polynomially along a run.Cslib.WordRAM.inputFits_of_length_encList_le: a word list fits its own encoded length.Cslib.WordRAM.exists_unary_majorant: a quantity polynomially bounded in the input length has a majorant computable in unary in polynomial time.Cslib.WordRAM.Program.DecidesInTime.computesInTime: a decider computes the indicator.Cslib.WordRAM.Program.ComputesInTime.turingComputableInPolyTime_of_width: the simulation at a supplied polynomial-time width schedule.Cslib.WordRAM.Program.ComputesInTime.turingComputableInPolyTime,Cslib.WordRAM.UniformComputableInPolyTime.turingComputableInPolyTime: uniform polynomial word-RAM time givesTuring.MultiTapeTM.ComputableInPolyTime.
References #
Word bounds on finite simulation states #
The jump or branch target of an instruction, and 0 otherwise.
An upper bound on every control label that a run from label 0 reaches.
A bound on the encoded outcome of a simulation step with r registers, labels at most L,
w-bit words and at most E stored cells.
Registers, the memory default and every stored cell (address and value) of a finite
simulation state are w-bit words.
Reading memory returns a w-bit word.
Setting a register to a word preserves the bound.
Storing a word at a word address preserves the bound.
Changing the control label preserves the bound.
A data instruction keeps every register and stored cell a word.
A continuing step keeps the word bound and stays below the label bound.
A halting step returns a word.
Every outcome of a clocked run from a word-bounded state below the label bound is word-bounded: continuing states keep their words and labels, and halted values are words.
Encoded outcomes along a clocked run from a word-bounded state are bounded by stateBound,
with at most one new stored cell per step.
Initialization #
The finite memory of State.init input.
initMemory stores the input convention of State.init.
The finite simulation state of State.init input, at label 0 with zero registers.
The finite initial state denotes State.init.
From an input that fits, the finite initial state holds only words.
From a fitting input, the encoded outcomes of the first T steps of a clocked run are
bounded by stateBound with |input| + 1 + T stored cells.
Building the initial memory is polynomial-time on framed lists of binary words.
A word list fits every word size at least as large as its encoded length.
Word RAM ⇒ Turing machine #
A decider computes the indicator of its problem, 1 on members and 0 otherwise, with the
same time bound and admitted widths.
A quantity polynomially bounded in the encoded input length has a majorant computable in unary in polynomial time: a fixed polynomial of the input length.
The simulation's initial states are computable in polynomial time when the input words are:
build the memory 0 ↦ n, i + 1 ↦ xᵢ and set zero registers and default.
The simulation's outcomes are polynomially bounded. For a word size and fitting input
words computable in polynomial time, and a step budget polynomial in the input length, the
encoded outcomes of the first steps a steps are bounded by one polynomially bounded function.
Word-RAM time at a polynomial-time width schedule gives Turing-machine polynomial time.
Let p be a fixed program over a basis whose checked operations are polynomial-time on a unary
width and binary operands. Suppose width a is computable in unary in polynomial time, is an
admitted width for a, and the word list encode (width a) a fits it and is computable in
polynomial time from encIn a. If p computes f (Program.ComputesInTime) and its time bound
at width a is polynomial in |encIn a|, then f is computable in polynomial time with binary
output. The simulating machine computes the width, the input words and a step budget, builds the
initial memory and runs the finite-state simulator; all of this is charged.
Polynomial word-RAM time gives Turing-machine polynomial time for a fixed program.
Let p be a fixed program over a basis whose checked operations are polynomial-time on a unary
width and binary operands. Suppose that on every input a whose words fit, at every word size of
at least logWidth k (size a), p halts with f a from State.init (encode a) within
T (size a) instructions, where T is polynomially bounded. If the word list encode a is
computable in polynomial time from the bit string encIn a and size a is polynomially bounded
in |encIn a|, then f is computable in polynomial time with binary output.
The simulating machine chooses a word size polynomial in |encIn a|, at least
logWidth k (size a) and the encoded length of the input words, so the input fits.
Uniform polynomial word-RAM time gives Turing-machine polynomial time, for a width-independent word encoding computable in polynomial time and a size measure polynomially bounded in the encoded input length.