Running an oracle program against a stateful or logging oracle #
A.runState O runs A : ProbOracleComp spec α against a stateful oracle O: each private sample
is a fresh uniform draw, and each external query q runs O q, a program that reads and updates
the oracle's state. The result is a StateT program, so (A.runState O).run s is the closed
sampler that starts the oracle in state s and returns the result with the final state.
A.runLog O runs A against the oracle O and records every query with its reply, oldest first.
This is the challenger of a forgery experiment, which later checks a forgery against the log of
signing or tagging queries. A.runLogWith O lets the oracle read the log so far and refuse a
query: O log q = none answers default and records nothing, as a one-time signing oracle does
after its first query. A memoryless oracle O gives runLogWith fun _ q => some (O q), which is
runLog O.
On every supported run, a program with at most n queries leaves a log of length at most n.
This is the instance, for the log length, of a general bound: if each query raises a measure of
the oracle state by at most its cost, a run raises it by at most the program's cost budget.
Main definitions #
Cslib.ProbOracleComp.runState: run against a stateful oracle.Cslib.ProbOracleComp.runLogWith,Cslib.ProbOracleComp.runLog: run against an oracle, logging every answered query with its reply.
Main results #
Cslib.ProbOracleComp.runState_pure,runState_bind,runState_map,runState_query,runState_sample:runStateis the monad morphism answering queries withOand sampling with fresh coins.Cslib.ProbOracleComp.eval_runState: the law of a stateful run isrunWithagainst the evaluated oracle.Cslib.ProbOracleComp.runState_lift: against a memoryless oracle, the stateful run isrunwith the state unchanged.Cslib.ProbOracleComp.measure_runState_le: a run raises a measure of the oracle state by at most the cost budget, when each query raises it by at most its cost (OracleComp.IsCostBounded.measure_lefor this handler).Cslib.ProbOracleComp.logOracle_run: one call of the logging oracle.Cslib.ProbOracleComp.runLog_sample: a private sample leaves the log empty.Cslib.ProbOracleComp.runLogWith_map: mapping the program's result keeps the log.Cslib.ProbOracleComp.IsQueryBounded.length_runLogWith_le,Cslib.ProbOracleComp.IsQueryBounded.length_runLog_le: a program with at mostnqueries leaves a log of length at mostn.Cslib.ProbOracleComp.forall_mem_runLogWith,Cslib.ProbOracleComp.forall_mem_runLog: every logged pair is a reply that the oracle's answering program can produce.
Stateful oracles #
Run A with fresh uniform private coins, answering each external query q with the stateful
program O q.
A sequenced program runs its first part, then the continuation from the state it reached.
The law of a stateful run is runWith against the evaluated oracle.
Against a memoryless oracle, the stateful run is run, and the state is unchanged.
If each query q raises the measure μ of the oracle state by at most cost q, a run of a
program whose queries cost at most n raises it by at most n. Private samples keep the state.
This is OracleComp.IsCostBounded.measure_le for the handler of runState.
Logging oracles #
Run A against an oracle that reads the log so far, returning the result and the log of
answered queries with their replies, oldest first. A refused query (O log q = none) is answered
with default and not logged.
Run A against the oracle O, returning the result and the log of its queries with their
replies, oldest first.
An oracle that never refuses and ignores the log is runLog.
Mapping the program's result maps the result of the logged run and keeps the log.
On every supported run, a program with at most n queries leaves a log of length at most
n.
On every supported run, a program with at most n queries leaves a log of length at most
n.
Every logged pair is a possible reply: a property of query-reply pairs that holds for
every reply of every program the oracle runs holds for every pair in the log of runLogWith.
Every logged pair is a possible reply: a property of query-reply pairs that holds for
every reply of a memoryless oracle O holds for every pair in the log of runLog.