Counting Queries Made by a Computation #
This file defines a simulation oracle countingOracle
for counting the number of queries made
while running the computation. The count is represented by a function from oracle indices to
counts, allowing each oracle to be tracked individually.
Tracking individually is not necessary, but gives tighter security bounds in some cases. It also allows for generating things like seed values for a computation more tightly.
def
QueryImpl.withCounting
{ι : Type u}
[DecidableEq ι]
{spec : OracleSpec ι}
{m : Type u → Type v}
[Monad m]
(so : QueryImpl spec m)
:
QueryImpl spec (WriterT spec.QueryCount m)
Equations
- so.withCounting = { impl := fun {α : Type ?u.60} (x : spec.OracleQuery α) => let q := x; tell (OracleSpec.QueryCount.single q.index) *> liftM (so.impl q) }
Instances For
@[simp]
theorem
QueryImpl.withCounting_apply
{ι : Type u}
[DecidableEq ι]
{spec : OracleSpec ι}
{m : Type u → Type v}
[Monad m]
{α : Type u}
(so : QueryImpl spec m)
(q : spec.OracleQuery α)
:
def
countingOracle
{ι : Type u}
[DecidableEq ι]
{spec : OracleSpec ι}
:
QueryImpl spec (WriterT spec.QueryCount (OracleComp spec))
Oracle for counting the number of queries made by a computation. The count is stored as a function from oracle indices to counts, to give finer grained information about the count.
Equations
Instances For
@[simp]
theorem
countingOracle.impl_apply_eq
{ι : Type u}
[DecidableEq ι]
{spec : OracleSpec ι}
{α : Type u}
(q : spec.OracleQuery α)
:
@[simp]
theorem
countingOracle.fst_map_run_simulateQ
{ι : Type u}
[DecidableEq ι]
{spec : OracleSpec ι}
{α : Type u}
(oa : OracleComp spec α)
:
countingOracle
has no effect on the behavior of the computation itself.
@[simp]
theorem
countingOracle.run_simulateQ_bind_fst
{ι : Type u}
[DecidableEq ι]
{spec : OracleSpec ι}
{α β : Type u}
(oa : OracleComp spec α)
(ob : α → OracleComp spec β)
:
@[simp]
theorem
countingOracle.probFailure_run_simulateQ
{ι : Type u}
[DecidableEq ι]
{spec : OracleSpec ι}
{α : Type u}
[spec.FiniteRange]
(oa : OracleComp spec α)
:
@[simp]
theorem
countingOracle.neverFails_run_simulateQ_iff
{ι : Type u}
[DecidableEq ι]
{spec : OracleSpec ι}
{α : Type u}
(oa : OracleComp spec α)
:
theorem
countingOracle.neverFails_simulateQ
{ι : Type u}
[DecidableEq ι]
{spec : OracleSpec ι}
{α : Type u}
(oa : OracleComp spec α)
:
Alias of the reverse direction of countingOracle.neverFails_run_simulateQ_iff
.