A fixed-program bounded stack on the word RAM #
A nine-register program dispatches push, pop, and size operations using an encoded operation
tag. The stack occupies a fixed consecutive memory block, with its top at the highest live
address. A pop from an empty stack returns none; other pops return a word and decrease the
length without clearing the old cell. Push requires spare capacity and a fitting value.
The semantic certificate is independent of the separate instruction certificate. Every call includes its final halt; argument delivery and the initial reserved block are calling-convention assumptions. This realizes a bounded restriction of the mathematical stack, not its unrestricted interface. A native instruction theorem for an arbitrary free-monad client still excludes execution of the client's pure controller.
Main definitions #
spec: the mathematical stack with explicit bounded-operation admissibility.program: a single fixed dispatch program, independent of the requested operation.Rep: top-first lists represented by a bottom-first memory block.certificate: semantic realization over native word-RAM traces.
Main results #
execute: actual per-operation execution, representation, and frame guarantee.instruction_bound: at most twelve instructions per admissible operation.initial_rep: a concrete empty represented stack.
References #
The abstract stack interface is shared with Cslib.Algorithms.Lean.Queue. Array indexing and
machine execution reuse the checked WordRAM.Allocation and WordRAM.Structured substrate.
A fixed-capacity restriction of the same mathematical stack interface.
Instances For
Encoded operation tag: push = 0, pop = 1, size = 2.
Instances For
Caller-supplied push value.
Instances For
Persistent number of live entries.
Instances For
Persistent base address of the reserved region.
Instances For
Temporary cell address.
Instances For
Presence bit distinguishing none from a returned zero word.
Instances For
Fixed operation dispatch. No code is generated from an operation or its payload.
Instances For
Calling convention for the fixed dispatch program. Answers inspect only output registers.
Instances For
Persistent register, bounded-word, and live array invariants. Cells above the live prefix may contain old popped values; they are part of the reserved footprint.
- bounded : Data.Bounded w x
Instances For
Reserved memory footprint; it stays fixed through pushes and pops.
Instances For
Actual instructions excluding the final halt.
Instances For
Every admissible operation executes the fixed dispatcher with an exact instruction count, returns the specified answer, and preserves memory outside the reserved region.
Semantic realization of the bounded stack, independently of its performance theorem.
Instances For
Actual instruction count, including dispatch and the final halt, for every native call.
Every admissible call has a separate worst-case bound of twelve native instructions.
Every concrete call preserves all memory outside the same reserved stack block.
The machine stack preserves any disjoint heap representation.
An empty reserved block, with all memory zero and the persistent pointer installed. This is a calling-convention initial state, not an uncharged allocation instruction.
Instances For
One-operation realization and an independent resource certificate compose across arbitrary admissible adaptive clients. The client controller itself is external to the machine code.