Documentation

CslibFrontier.Languages.Probabilistic.UniformNat.ModIndex

Residue samples capped at the modulus #

sampleModIndex width bound draws sampleModNat width bound and caps the result at bound. For 0 < bound every residue is already below bound, so the cap changes nothing (sampleModIndex_eq_sampleModNat); for bound = 0 the sampler returns 0. The cap keeps the unary encoding of the output polynomially bounded for every bound; its certificate is Cslib.Probability.isPPTOn_sampleModIndex in CslibFrontier/Computability/Probabilistic/UniformNat/ModIndex.lean.

Main definitions #

Main results #

noncomputable def Cslib.ProbComp.sampleModIndex (width bound : ℕ) :

Sample a modular residue via ProbComp.sampleModNat width bound, capped at bound so its unary encoding is polynomially bounded even when bound = 0. When 0 < bound, every residue modulo bound is strictly below bound, so sampleModIndex width bound = sampleModNat width bound.

@[simp]
theorem Cslib.ProbComp.sampleModIndex_eq_sampleModNat (width : ℕ) {bound : ℕ} (hbound : 0 < bound) :
sampleModIndex width bound = sampleModNat width bound

When 0 < bound, sampleModIndex width bound equals sampleModNat width bound.