An adaptive stack client executed entirely on the word RAM #
The client pushes its input, pops it, and replaces a returned zero by another push and pop of
one. Its fixed controller explicitly executes initialization, argument preparation and branch
instructions. Input placement follows WordRAM.Data.init; no additional heap initialization is
needed because the reserved stack starts empty.
Main definitions #
roundTrip: push the argument register and pop its value back.code: initialize one reserved cell and execute the adaptive controller.client: the same adaptive computation over the abstract stack interface.
Main results #
execute: the whole controller returnsmax n 1, leaving its stack empty.refines: the fixed machine controller implements the abstract adaptive client.executes: a halting flat program, with all controller costs and its final halt charged.positive_polytime: a reusable polynomial RAM-time certificate for the complete client.
References #
The stack implementation and specification are those of WordRAM.Stack and
Algorithms.Lean.Queue. This example is a certificate-composition test, not a new stack algorithm.
Push the argument register, then pop it; argument tags and clearing are real instructions.
Instances For
One reserved stack cell at address two, outside the singleton input at address one.
Instances For
Fixed adaptive code: replace a popped zero using another pair of stack operations.
Instances For
The word-valued function computed by the adaptive stack controller.
Instances For
The same fixed controller has a constant, hence polynomial, RAM instruction bound.
The size parameter is the numerical magnitude n; the admissible width is logarithmic in it.