Acceptance observation and uniform bit-slice sampling on the randomized word RAM #
Shared acceptance and bit-sampling primitives for randomized word-RAM algorithms:
Cslib.WordRAM.RandCfg.accepts: whether a randomized machine configuration halted with output1.Cslib.WordRAM.bitsAt: readsnwords from memory starting atbaseas a Boolean vector (truewhen the word is1).Cslib.WordRAM.sampleBits: register-parametric structured subroutine drawingnindependent uniform bits viarand oneinto[base, base + n)in6 * n + 3instructions andnrandcalls (Cslib.WordRAM.sampleBits_law), preserving memory outside[base, base + n)and all registers outside{cnt, val, addr}.Cslib.WordRAM.Code.usesRandSrcandCslib.WordRAM.ExecRand.queriesSatisfy_eq_of_usesRandSrc: syntactic source-register check certifyingOracleComp.QueriesSatisfybounds (for exampleRandBitsBoundedwhen everyrandreadsone).
Main definitions #
Cslib.WordRAM.RandCfg.accepts: acceptance predicate onRandCfg.Cslib.WordRAM.bitsAt: Boolean vector read from a contiguous slice of words.Cslib.WordRAM.sampleBits: uniform bit-slice sampling subroutine onCode .standard.Cslib.WordRAM.Code.usesRandSrc: syntactic check that everyrandreads a fixed register.
Main results #
Cslib.WordRAM.bitsAt_update_self: writing atbase + iupdates coordinateiofbitsAt.Cslib.WordRAM.sampleBits_law: exactPMF.uniformOfFintype (Fin n → Bool)law,6 * n + 3instruction bound,n-call budget, and register/memory frame preservation forsampleBits.Cslib.WordRAM.ExecRand.queriesSatisfy_eq_of_usesRandSrc: every oracle query equals the constant held in a preservedrandsource register.
Acceptance observation on RandCfg #
Whether a randomized machine configuration halted with output 1.
Reading and sampling Boolean vectors #
Sample n = regs nReg independent uniform bits via rand one into [regs baseReg, regs baseReg + n), using cnt, val and addr as scratch registers.
Uniform bit-slice sampling. When [one, baseReg, nReg, cnt, val, addr] are distinct
registers with regs zero = 0, regs one = 1, regs baseReg = base and regs nReg = n,
sampleBits halts within 6 * n + 3 instructions and n rand calls, writes 0/1 words across
[base, base + n) whose bitsAt view is distributed uniformly on Fin n → Bool, leaves memory
outside [base, base + n) unchanged, and preserves all registers outside {cnt, val, addr}.
Query-bound transfer for fixed-register rand calls #
When c preserves register s holding u and every rand in c reads s, every oracle
query issued along ExecRand w c x m equals u.