Bounded repetition of probabilistic programs #
OracleComp.replicate collects the results of an ordinary List.mapM traversal in execution
order. Closed runs draw independent samples, even when the output type is infinite. Efficiency
is certified separately in Computability.Probabilistic.Repeat.
Main definitions #
Cslib.OracleComp.replicate: collect a bounded number of runs.Cslib.OracleComp.countTrue,.testProbabilityLT: count successes and test rational thresholds.
Main results #
Cslib.OracleComp.replicate_add,.replicate_snoc: split an execution into segments.Cslib.ProbComp.eval_replicate: finite outputs have the independent product law.Cslib.ProbComp.eval_replicate_iid: the independent law on arbitrary output types.Cslib.ProbComp.eval_replicate_map: transport a sampling law through repeated draws.Cslib.ProbComp.eval_replicate_splice: draw one coordinate first without changing the joint law.Cslib.ProbComp.eval_countTrue: the success count is a sum of independent indicators.Cslib.ProbComp.countTrue_le: every supported success count respects the trial budget.Cslib.ProbComp.eval_replicate_of_uniform: realize the joint law from independent finite seeds.Cslib.ProbComp.eval_replicate_of_uniformList: collect independent draws from one flat bit list.
References #
Adapted from Languages/Probabilistic/Repeat.lean on the cslib crypto branch at
5ff69ca93402e7c947208dc56396d6d86203ccd8, using the existing typed program interface and list
traversal.
Collect the results of a bounded number of runs in execution order.
Instances For
Zero runs return the empty list.
count + 1 runs make one run, then count more, and list its result first.
Split repeated runs into two consecutive segments.
Split off the last draw of a repeated program.
Deterministic postprocessing commutes with collecting the draws.
Count the true results of a bounded number of runs of a Boolean program.
Instances For
Compare an empirical acceptance rate with a rational threshold by natural cross-products. Accuracy theorems require a positive count and denominator; the program is total at zero.
Instances For
A supported collected result has the prescribed length and supported entries.
Draw one designated coordinate first, then insert it between independent prefix and suffix draws. This preserves the complete joint law, including repeated sample values.
An encoded sampling law lifts to repeated draws without requiring either type to be finite or the encoding to be injective. The order and multiplicity of all draws are preserved.
Independent repetition on arbitrary output types, including integers and failure options. Unlike the finite-product specialization, this law needs no finiteness assumption.
Repeated closed runs have the independent product law for any finite output distribution.
Counting successful repeated trials is the sum of independent Boolean indicators.
Repeated closed runs use independent uniform seeds, including at count zero. The output type need not be finite.
One flat uniform bit list supplies independent seeds for every repeated run, including zero repetitions and zero-width seeds.