Fixed-program implementations of dynamic data structures #
An implementation has one structured program, one output register, and a register-only calling
convention. Each call replaces designated input registers with encoded words, preserving all
other registers and the entire memory. Argument encoding, external delivery, and result decoding
are not charged; all
instructions of the operation, including its final halt, are charged. Initialization is a
separate obligation expressed by the initial representation hypothesis. Argument encoding
depends on the requested operation, without access to the maintained machine data.
Certificates require bounded configurations and bounded arguments, and a successful exact machine execution for every admissible operation. Determinism supplies correctness for every execution. The generic history theorem then preserves all observations and adds actual costs. The same single compiled program is used at every call; the interface does not generate code from the requested operation.
Evaluating calls #
P.eval w fuel o x delivers the arguments, runs the fixed program and decodes the operation's
typed observation. It returns some (y, answer, cost), with final data y for the next call and
a cost that already includes halt. fuel bounds each structured loop's iterations per entry,
not the total instruction count. Exhaustion, a machine fault or decoder rejection returns
outer none; a successful empty stack pop instead has observation none.
Evaluation does not establish admissibility or check untouched memory for word bounds.
C.execOp_of_eval hr hv he turns a successful evaluation he into exact execution evidence
using representation hr and admissibility hv. Argument delivery and decoding remain
uncharged. Whole-client bounds remain separate resource proofs.
See the checked examples in ComplexityTests/WordRAMDynamic.lean for typed stack observations, the seven-body/eight-charged push and certificate lifting, and ComplexityTests/WordRAMPrefixSums.lean for repeated calls retaining persistent data.
Main definitions #
DynamicProgram: fixed code, an input-register convention, and an output decoder.DynamicProgram.eval: typed call evaluation with halt-inclusive instruction cost.DynamicProgram.ExecOp: execution of a call, including the final halt charge.DynamicCertificate: representation, word bounds, and per-operation semantic machine proofs.
Main results #
DynamicProgram.ExecOp.executes: calls execute the same flat program.DynamicCertificate.execOp_of_eval: certify an evaluated admissible call.DynamicCertificate.realization: machine certificates instantiate shared adaptive execution.DynamicCertificate.instruction_bound: separate native instruction-cost certificates.
A single program serving all operations through a fixed register calling convention.
- code : Code Basis.standard r
The same code is executed for every operation.
- output : Fin r
Register returned by the final halt instruction.
Registers overwritten by externally supplied operation arguments.
Encoded arguments, independent of the maintained machine state.
Interpretation of the final register tuple as the operation's typed observation.
Instances For
Deliver operation arguments without changing maintained memory or non-input registers.
Instances For
Registers outside the calling convention retain their contents.
Argument delivery preserves bounded words when the arguments fit.
Evaluate one typed call, delivering its arguments and decoding its observation. The returned
cost includes the final halt. fuel bounds iterations of each structured loop per entry, not
instructions; exhaustion, a machine fault, or decoder failure returns none.
This interpreter does not check the initial state's global word bound or operation admissibility.
Use DynamicCertificate.execOp_of_eval to connect a successful call to certified execution.
Instances For
Native evidence for one call: instruction count including halt and the memory transcript.
- instructions : ℕ
Number of executed machine instructions, including the final halt.
All reads and writes, in execution order.
Instances For
A bounded machine call with native execution evidence independent of any resource bound.
Instances For
Successful typed evaluation supplies an exact operation trace when the delivered state is bounded. Evaluator success alone does not imply a bound on untouched memory.
Every call is an execution of one fixed flat machine program. The returned register tuple is observed at the final state; the designated output register is also the halt value.
A call preserves bounded words, including every word in the observed register tuple.
Calls are deterministic in their final representation, observation, and instruction count.
A call's final state and instruction count agree with any structured execution of the code.
The write transcript supplies a frame rule for a call, including register-only delivery.
Per-operation semantic proof obligations tied to fixed bounded-word code.
Performance claims are supplied separately, as Stateful.Bound certificates.
Abstract state represented by the persistent machine data.
Represented configurations contain only machine words.
- arguments_fit {s : D.State} (o : D.Op) : D.valid s o → ∀ (i : Fin r), P.input i = true → Fits w (P.encode o i)
Admissible arguments fit the machine's word size.
- execute {s : D.State} {x : Data r} (o : D.Op) : self.rep s x → D.valid s o → ∃ (y : Data r) (n : ℕ), Exec w P.code (P.prepare o x) y n ∧ P.decode o y.regs = some (D.step s o).2 ∧ self.rep (D.step s o).1 y
A machine execution implements an admissible operation.
Instances For
A represented state and an admissible operation supply the word bounds needed to turn typed evaluation into a certified call, including its final halt charge.
Fixed-program certificates realize the common dynamic specification, without choosing a cost.
Instances For
A separate per-operation instruction estimate supplies a reusable resource certificate.
A uniform constant instruction bound follows from an existential per-operation execution.
Adaptive client execution, final representation, and linear total instruction bound for a uniform constant per-operation instruction certificate.
Lift a per-operation pointwise memory frame from Exec to ExecOp.
Lift a per-operation Modifies bound from Exec to ExecOp.
Lift a per-operation pointwise memory frame across an adaptive client execution.
Lift a per-operation Modifies bound across an adaptive client execution.
The same native evidence separately bounds memory probes by the instruction charge.