Stateful prefix sums implemented by one fixed Word-RAM program #
The abstract state is a list, independently of the tree representation. An operation either
increments one entry or returns the sum of an initial segment. A complete balanced tree stores
n = 2 ^ h entries in 2 n - 1 words. One fixed fourteen-register program dispatches both
operations, with every executed instruction charged, including its final halt.
The representation is supplied at entry. Installing the three operation-argument registers is the external calling convention and is uncharged. Tree construction is a separate obligation; these theorems do not charge or claim a construction algorithm. Natural-number sums and increments must fit the chosen word width. This is a segment tree, not a Fenwick tree.
Main definitions #
spec: array operations and mathematical answers, with word-fit admissibility conditions.program: the fixed dispatcher and register-only calling convention.certificate: a semantic realization on the bounded-word machine.
Main results #
dispatch_spec: per-operation correctness and instruction estimate.instruction_bound: a separate cost certificate, at13 (h + 1) + 12instructions per call.
References #
Instances For
Instances For
Abstract list specification. The admissibility of an update includes the word bound on its new total; a query does not modify the array.
Instances For
Initialize constants and traversal registers, charging all seven instructions.
Instances For
One dispatcher for both operations, independent of size and word width.
Instances For
Fixed code and external argument registers. Decoding reads only the answer register.
Instances For
Mathematical description of charged register setup.
Instances For
A list is represented by a bounded tree, with persistent root and capacity registers.
- bounded : WordRAM.Data.Bounded w x
Instances For
The abstract array length is determined by the persistent tree representation.
Every operation uses the same dispatcher, restores the list representation and returns
the specified result within 13 (h + 1) + 11 structured instructions. All memory outside the
2 * 2 ^ h - 1 words of the tree is preserved.
Semantic correctness and totality of the fixed bounded-word implementation.
Instances For
Separate worst-case instruction certificate, counting the final halt.
The same instruction certificate stated in terms of the abstract array length.
Every actual call preserves the complement of the fixed tree region. In particular, updates do not allocate storage depending on the number of previous operations.
Every admissible adaptive client has a concrete execution with the specified result and
final array, and at most 13 (h + 1) + 12 instructions for each selected operation. The client
controller itself is mathematical; this counts its calls into the fixed machine program.
Concrete zero memory and persistent metadata. Supplying this state is not a charged initialization algorithm.