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
.
def
OracleComp.replicate
{ι : Type u}
{spec : OracleSpec ι}
{α : Type v}
(n : ℕ)
(oa : OracleComp spec α)
:
OracleComp spec (List α)
Run the computation oa
repeatedly n
times to get a vector of n
results.
Equations
- OracleComp.replicate n oa = mapM (fun (x : Unit) => oa) (List.replicate n ())
Instances For
def
OracleComp.replicateTR
{ι : Type u}
{spec : OracleSpec ι}
{α : Type v}
(n : ℕ)
(oa : OracleComp spec α)
:
OracleComp spec (List α)
Equations
- OracleComp.replicateTR n oa = mapM (fun (x : Unit) => oa) (List.replicateTR n ())
Instances For
@[simp]
theorem
OracleComp.replicate_zero
{ι : Type u}
{spec : OracleSpec ι}
{α : Type v}
(oa : OracleComp spec α)
:
@[simp]
theorem
OracleComp.replicateTR_zero
{ι : Type u}
{spec : OracleSpec ι}
{α : Type v}
(oa : OracleComp spec α)
:
@[simp]
theorem
OracleComp.replicate_succ
{ι : Type u}
{spec : OracleSpec ι}
{α : Type v}
(oa : OracleComp spec α)
(n : ℕ)
:
@[simp]
@[simp]
theorem
OracleComp.probFailure_replicate
{ι : Type u}
{spec : OracleSpec ι}
{α : Type v}
(oa : OracleComp spec α)
(n : ℕ)
[spec.FiniteRange]
:
@[simp]
theorem
OracleComp.probOutput_replicate
{ι : Type u}
{spec : OracleSpec ι}
{α : Type v}
(oa : OracleComp spec α)
(n : ℕ)
[spec.FiniteRange]
(xs : List α)
:
The probability of getting a vector from replicate
is the product of the chances of
getting each of the individual elements.
theorem
OracleComp.support_eq_setOf_probOutput_eq_zero
{ι : Type u}
{spec : OracleSpec ι}
{α : Type v}
[spec.FiniteRange]
(oa : OracleComp spec α)
:
@[simp]
theorem
OracleComp.support_replicate
{ι : Type u}
{spec : OracleSpec ι}
{α : Type v}
[spec.FiniteRange]
(oa : OracleComp spec α)
(n : ℕ)
:
Possible ouptuts of replicate n oa
are lists of length n
where
ecah element in the list is a possible output of oa
.
theorem
OracleComp.support_replicate'
{ι : Type u}
{spec : OracleSpec ι}
{α : Type v}
[spec.FiniteRange]
[DecidableEq α]
(oa : OracleComp spec α)
(n : ℕ)
:
Version of support_replicate
using List.all
instead of quantifiers.
Requires decidable equality on the output type of the computation.
@[simp]
theorem
OracleComp.mem_finSupport_replicate
{ι : Type u}
{spec : OracleSpec ι}
{α : Type v}
[spec.FiniteRange]
[spec.DecidableEq]
[DecidableEq α]
(oa : OracleComp spec α)
(n : ℕ)
(xs : List α)
: