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. 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 #

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.

theorem Cslib.Probability.isPPTOn_sampleDyadicCoin {α : Type} {input : α ↪ List Bool} {bound numerator : α → ℕ} (hbound : Turing.MultiTapeTM.ComputableInPolyTime bound input Turing.MultiTapeTM.encUnary) (hnumerator : Turing.MultiTapeTM.ComputableInPolyTime numerator input Turing.MultiTapeTM.encUnary) :
IsPPTOn input Turing.MultiTapeTM.encBool fun (a : α) => ProbComp.sampleDyadicCoin (bound a) (numerator a)

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.

theorem Turing.MultiTapeTM.ComputableInPolyTime.sampleBinaryNat {α : Type} {input : α ↪ List Bool} {width : α → ℕ} (hwidth : ComputableInPolyTime width input encUnary) :

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 : α) => ProbComp.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.