Documentation

CslibFrontier.DataStructure.Stack.Controller

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 #

Main results #

References #

The stack is Stack.Memory. This example is a composition test, not a new stack algorithm.

Push the input and pop it; replace a zero answer by another push and pop of one.

The client's calls on the stack at L.

Allocate a stack of capacity one and run the client on it.

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.