Sampling bounded indices in strict polynomial time #
Each sampler uses a fixed number of fair bits. sampleBinaryNat takes a unary bit width and
returns the sampled value in binary. The bounded-index samplers instead saturate binary decoding
at a computed cap, so both their intermediate states and their unary outputs remain polynomially
bounded. The dyadic range is at most 2 * (bound + 1), including zero. No unbounded rejection
loop is used. Public sampler premises use plain deterministic certificates.
The scalar dyadic-size, logarithm, numeric-decoding and modulus helpers used in these proofs remain legacy-backed. The plain sampler interface does not establish their direct-machine internalization.
Main results #
Turing.MultiTapeTM.ComputableInPolyTime.unary_dyadicSize: efficient unary range size.Cslib.Probability.isPPTOn_sampleBinaryNat: uniform sampling with binary output.Turing.MultiTapeTM.ComputableInPolyTime.sampleBinaryNat: sample a computed bit width.Cslib.Probability.isPPTOn_sampleModNat: approximately uniform residues, for a computed bit width and modulus.Cslib.Probability.isPPTOn_sampleDyadicIndex: exact uniform sampling in the dyadic range.Cslib.Probability.isPPTOn_sampleBoundedIndex: capped sampling with a rejection sentinel.Cslib.Probability.isPPTOn_sampleDyadicCoin: exact capped dyadic probabilities.
References #
Adapted from Computability/Probabilistic/UniformNat.lean on the cslib crypto branch at
5ff69ca93402e7c947208dc56396d6d86203ccd8, using the tidy machine calculus and shared bit folds.
Compute the linearly capped dyadic range from a unary bound in plain polynomial time.
A unary bit width gives a uniformly strict PPT sampler with binary natural output.
An efficiently supplied unary bound gives a strict PPT exact dyadic sampler.
Efficient unary parameters give a strict PPT coin with the specified dyadic law.
An efficiently supplied unary bound gives a strict PPT capped index sampler.
Sample a binary natural using an efficiently computed unary bit width.
Approximately uniform residues: reducing a computed number of fair bits modulo a computed modulus is uniformly strict PPT, with binary output.