Documentation

Complexity.Computability.Probabilistic.UniformNat

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.

Main results #

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 dyadic range in unary via capped binary decoding. Its exponential expression does not authorize exponential output: the proved linear cap supplies the implementation.

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.

theorem Cslib.Probability.isPPTOn_sampleModNat {α : Type} {input : α ↪ List Bool} {width modulus : α → ℕ} (hwidth : Turing.MultiTapeTM.ComputableInPolyTime width input Turing.MultiTapeTM.encUnary) (hmodulus : Turing.MultiTapeTM.ComputableInPolyTime modulus input Turing.MultiTapeTM.encNat) :
IsPPTOn input Turing.MultiTapeTM.encNat fun (a : α) => sampleModNat (width a) (modulus a)

Approximately uniform residues: reducing a computed number of fair bits modulo a computed modulus is uniformly strict PPT, with binary output.