Realizing memory clients with private coins #
A memory client with private coins is a ProbOracleComp Memory.Op.Result program: it calls the
memory oracle and draws uniform coins. It runs against (Memory.spec w).toRandomized.withCoins,
the memory oracle beside uniform sampling. Linking a client of a randomized specification
through a memory refinement with its coins passed through (RandomizedRefinement.withCoins)
produces exactly such a program. RealizesRand certifies one uniform native emitter for a family
of them, as Realizes does for deterministic clients, with the same emitter, scratch bank,
frontier and register frame. The certificate gives the exact law instead of a single run. At
word size w, from native data whose memory abstraction is s, the emitted code's result words
and memory state have the law of (Memory.spec w).toRandomized.withCoins.run (p d) s, read
through the result encoding (ExecRandLaw). Every path runs within C * (time d s + 1)
instructions and makes at most calls d s rand calls. Both are worst-case bounds that hold on
every path, not expected ones.
Deterministic parts are certified by Realizes, including every certificate realize builds,
and enter unchanged (Realizes.toRand). A coin is one rand instruction (RealizesRand.coin).
Sequencing (RealizesRand.bind) needs the continuation's domain and budgets at every supported
intermediate state; these obligations become part of the visible domain. Branching on the live
words is RealizesRand.branch. A flat program from the native list-input convention halts within
its bound on every path, respects the rand budget and has the law of the client
(RealizesRand.exists_init_program). Runtime-bounded loops are in
CslibFrontier.Computability.WordRAM.Realization.RandomLoop.
Main definitions #
RealizesRand.Spec,RealizesRand.Witness: the canonical contract and supplied data.RealizesRand: uniform native realization of a memory client with private coins, with its law, a worst-case instruction bound and a worst-caserandbudget.
Main results #
Realizes.toRand: deterministic certificates are randomized ones with norandcall.Realizes.Witness.toRand,RealizesRand.coinWitness,RealizesRand.Witness.bind: supplied deterministic entry, coin and shared-bank sequential data.RealizesRand.coin: a uniform draw from[0, n], for a live wordn.RealizesRand.bind,RealizesRand.branch: sequencing and branching.RealizesRand.consequence,RealizesRand.congr: weakening and transport along equal clients.RealizesRand.exists_init_program: a flat program withRandHaltsWithin,RandCallsBoundedand the law of its halting configurations.
The randomized certificate is original infrastructure over the existing realization kernel, the
structured randomized semantics ExecRandLaw and the randomized specifications of
DataStructure.StateTransition.Randomized; no execution semantics or client language is added.
The existing pathwise execution, joint-law and register-frame contract for specified resource parameters and a specified emitter. Both existential and supplied witnesses use it.
Uniform native realization of a family of memory clients with private coins. The emitter,
scratch size and exchange constant precede every runtime argument, word width and initial
memory, and the register conventions are those of Realizes. From admissible entry data, the
emitted code terminates on every path within C * (time d s + 1) instructions and calls d s
rand calls, keeps every register outside the scratch bank and the frontier, and the result words
together with the memory state have the law of the client's run, read through output.
Retain specified randomized realization data with the same existing law contract. It changes neither the oracle model nor the observation or supported-path semantics.
- scratchSize : ℕ
Auxiliary registers, excluding results and the reserved extra slot.
- factor : ℕ
Exchange factor for the original visible time grade.
- code {r : ℕ} (frontier : Fin r) : (Fin k → Fin r) → (Fin (l + self.scratchSize + 1) → Fin r) → Code B r
One emitter, fixed before layout, width, memory and random outcomes.
- code_spec : Spec B p input output safe time calls self.scratchSize self.factor fun {r : ℕ} => self.code
The canonical original execution and law contract.
Forget supplied resources and code while retaining the original randomized judgment.
Deterministic parts. A deterministic certificate, for instance one built by realize,
realizes the same client with coins available and unused: its law is the point mass at the
deterministic run, its time is the memory charge plus local work, and it makes no rand call.
The existential randomized entry supplied by the deterministic witness construction.
Strengthen the visible domain, and enlarge the time and rand budgets on it. The entry word
and memory bounds may be used.
Pointwise equal clients have the same certificates.
A coin. Drawing uniformly from [0, n], for a live word n, is one rand instruction
into the result slot.
The existential coin realization supplied by coinWitness.
Sequencing. One uniform continuation emitter consumes the original environment and the
first computation's answer. Its domain and budgets must hold at every supported intermediate
answer and state, within the uniform budgets T and R; these obligations join the visible
domain. The laws compose by PMF.bind, the times and rand budgets add.
The existential sequential realization supplied by the shared-bank constructor.
Branching on a test of the live words. Only the selected alternative's domain and budgets are required; the test and the jump are absorbed by the exchange constant.
Flat programs. Each static coordinate of the result has one flat exact-basis program from
the native list-input convention. On an input list whose first k words encode the environment,
it halts on every path within its bound, makes at most the budgeted rand calls, and the halting
output word together with the memory state has the law of the client's run from the whole input
memory, read at that coordinate. The rest of the input list is arbitrary memory content, such as
a graph the client reads. The argument installation is absorbed into the exchange constant; the
bound includes the trailing halt.