List-valued outputs of word-RAM programs #
A word-RAM program returns one word with halt. A list is returned through memory: halt
returns an address v, and the output is the length-prefixed array
[mem (v + 1), …, mem (v + mem v)] in the memory just before the halting step (outputList).
This mirrors the input convention of State.init, with the length at address 0 and the words
at 1, …, n. In particular, returning address 0 without writing outputs the input itself
(outputList_init). A successful list-valued execution requires the header and every output
cell to have a word-sized address; the final occupied address is v + l.length.
Program.parkHalts replaces every halt i by a jump to a self-loop at label p.length + i.
A halting run of p becomes a run of p.parkHalts that reaches the parked state, which has
the pre-halt data and a control label recording the output register, and stays there
(ExecutesList.runs_parkHalts). A clocked simulator that only produces continuing states can
therefore read the output from its final state.
Main definitions #
Cslib.WordRAM.outputList: the length-prefixed array at an address.Cslib.WordRAM.ExecutesList: a halting run returns the address of a given list.Cslib.WordRAM.Program.ComputesListInTime: a fixed program computes a list-valued function.Cslib.WordRAM.UniformComputableListInPolyTime: a fixed program computes it in polynomially many instructions at every fitting width above a logarithmic threshold.Cslib.WordRAM.Program.parkHalts: halts replaced by self-loops recording the output register.
Main results #
Cslib.WordRAM.outputList_eq_iff: the convention in terms ofBlock.HoldsList.Cslib.WordRAM.Block.holdsList_init:Data.init inputstoresinputstarting at address1.Cslib.WordRAM.Exec.executesList,Cslib.WordRAM.Code.computesListInTime_program: structured certificates, charging the final halt.Cslib.WordRAM.ExecutesList.runs_parkHalts: a halting run ofn ≤ Ninstructions gives anN-step run ofp.parkHaltsto the parked pre-halt state.
The output convention #
Returning address 0 of the initial memory outputs the input.
ExecutesList w p s l n: running p at word size w from s halts after exactly n
instructions, the final halt included, returning an address at which the memory just before
halting holds l as a length-prefixed array. The final occupied address must fit a word,
including the header address when l is empty.
One program returns the list f a at every admitted fitting width within time a w
instructions. The final halt is counted; the mathematical input encoding is a convention.
A fixed program computes a list-valued function in polynomially many instructions in
size a, at every fitting width above a positive logarithmic threshold. Every input must
admit such a width.
Increase a fixed program's time bound and restrict its admitted widths.
A structured execution followed by halt out returns the array at the address in out,
with one more instruction.
A structured certificate leaving the address of f a in register out computes f, with
one more instruction for the final halt.
Parking the halts #
A halting step of p becomes a step of p.parkHalts to the parked label of the output
register.
A list-valued run, parked. If p returns l within n ≤ N instructions, then
p.parkHalts runs for exactly N steps to a parked state: its label is p.length + i and its
data holds l at the address in register i.