Word-RAM list outputs give Turing-machine polynomial time #
A fixed word-RAM program that returns a list (Program.ComputesListInTime: halt returns the
address of a length-prefixed array) within polynomially many instructions gives a multi-tape
Turing machine computing the same list-valued function in polynomial time, with output
encList encNat. This extends CslibFrontier.Computability.WordRAM.Turing from word outputs to
list outputs.
Construction #
The simulating machine runs the parked program p.parkHalts for its full step budget with the
clocked finite-state simulator FiniteState.run, whose native certificate is polynomial by
Cslib.GenericRAM.FiniteState.runCertificateOf_isPolynomial. Since the parked program never
halts, the run ends in a continuing state holding the memory just before p halted, and its
control label p.length + i records the output register i (ExecutesList.runs_parkHalts). The
machine then selects that register by comparing labels (parkedRegister), reads the array length
L at the returned address and iterates L single-cell reads (readRound), each a scan of the
sparse memory. Everything is charged: the step budget, word size, input words and initial memory
as in the word-output simulation, then the run, the selection and the L reads.
Conventions and limits #
The cost model, input convention and word-size choice are those of
CslibFrontier.Computability.WordRAM.Turing. The output length must be polynomially bounded in the
encoded input length (hlen). This hypothesis is necessary, since a polynomial-time machine
writes polynomially many output bits, and it does not follow from the instruction bound: the
returned array may consist of cells that are never written and read as 0, so its length is
bounded only by 2 ^ w.
Main definitions #
Cslib.WordRAM.parkedRegister,Cslib.WordRAM.parkedOutput: the output register and the output list of a parked finite state.Cslib.WordRAM.readRound: one round of reading consecutive memory cells.Cslib.WordRAM.parkedOutputCertificate: the native reader of a parked state.
Main results #
Cslib.WordRAM.Program.ComputesListInTime.turingComputableInPolyTime_of_width: the simulation at a supplied polynomial-time width schedule.Cslib.WordRAM.Program.ComputesListInTime.turingComputableInPolyTime,Cslib.WordRAM.UniformComputableListInPolyTime.turingComputableInPolyTime: polynomial word-RAM time with a list output givesTuring.MultiTapeTM.ComputableInPolyTimewith outputencList encNat.
References #
Reading the output of a parked state #
The register recorded by a parked control label: register i at label L + i, the first
match among l, or 0 if none matches.
The output list of a parked finite state of a program of length L: the array at the address
in the register recorded by the control label.
A parked state at label L + i outputs the array at the address in register i.
One round of reading consecutive memory cells: on ((fill, memory), (address, values)), where
fill is the value of unwritten cells, append the cell at address to values and advance
address.
j reading rounds append the j cells from address on.
One reading round is cubic, with linear output: one sparse-memory scan and linear copying.
The native certificate of one reading round, cubic in the encoded loop state.
Select the register recorded by the control label among l, by label comparisons.
The initial reading loop state ((default, memory), (v + 1, [])) for the output address
v.
The reader of a parked state: select the output register, read the array length L' at
its address, then read L' consecutive cells.
The reader is polynomial when its input state is, its states hold W-bit words with W
polynomially bounded, and the output length is polynomially bounded.
Word RAM with list outputs ⇒ Turing machine #
Word-RAM time with a list output, 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 returns the list f a (Program.ComputesListInTime)
within a time bound at width a polynomial in |encIn a|, and the length of f a is
polynomially bounded in |encIn a|, then f is computable in polynomial time with output
encList encNat.
Polynomial word-RAM time with a list output 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 returns the list 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 and the length of
f a are polynomially bounded in |encIn a|, then f is computable in polynomial time with
output encList encNat.
Uniform polynomial word-RAM time with a list output gives Turing-machine polynomial time, for a width-independent word encoding computable in polynomial time, a size measure and an output length polynomially bounded in the encoded input length.