An adaptive stack client compiled to one word-RAM program #
The client pushes its input and pops it; if the answer is zero, it pushes one and pops again. It
computes max n 1. Over the memory oracle it is program: allocate a stack of capacity one, then
run the client's calls through Stack.Memory's methods (run_eq_link). The refinement of
Stack.Memory transfers the abstract client's answer, admissibility and cost to program
(program_spec). realize certifies program as one uniform native emitter
(realizes_program), and the argument-installation prefix with a halt makes it a flat program.
No instruction is stepped by hand.
Main definitions #
client: the adaptive client over the bounded stack of capacity one.run,program: its calls on a stack's layout, and the allocating memory program.positive: the word-valued functionmax n 1.
Main results #
run_eq_link:runis the client linked to the stack's methods.program_spec: the answer, the admissible memory history and the memory cost.realizes_program: the native certificate.positive_polytime: one flat program computespositivein constant, hence polynomial, time.
References #
The stack is Stack.Memory. This example is a composition test, not a new stack algorithm.
The client's calls on the stack at L.
Allocate a stack of capacity one and run the client on it.
run is the client linked to the stack's methods.
The word-valued function computed by the client.
The native certificate. One uniform emitter, chosen before every width, input and
memory, runs program from any memory whose frontier leaves room for the stack.
Correctness through the refinement. From a memory whose frontier leaves room, program
returns positive n, its memory history is admissible, and it costs at most fifteen memory
units: two for the allocation and three for each of at most four stack calls.
The client, compiled to one flat word-RAM program, computes positive in constant time at
every width of at least three bits per input bit.