Running a Computation Multiple Times #
This file defines a function replicate oa n that runs the computation oa a total of n times,
returning the result as a list of length n.
Note that while the executions are independent, they may no longer be after calling simulate.
Run the computation oa repeatedly n times to get a list of n results.
Instances For
Tail-recursive variant of replicate, running oa for each entry of a length-n list
built by List.replicateTR. Agrees with replicate via replicateTR_eq_replicate.
Instances For
Bind-style unfolding of replicate, convenient for program-logic proofs.
The tail-recursive replicateTR agrees with the recursive replicate. The
@[simp] annotation lets every later proof about replicateTR reduce to the
recursive form automatically.
The probability of getting a list from replicate is the product of the chances of
getting each of the individual elements.
Possible outputs of replicate n oa are lists of length n where
each element in the list is a possible output of oa.
SimulateQ distributivity #
simulateQ distributes over replicate: simulating a replicated computation
equals running the simulated body n times via monadic recursion.
Index-extraction for (Vector.ofFn id).mapM over an OracleComp: any element in the
support of the monadic mapM has each component lying in the support of the corresponding
inner computation.