Typed views of word oracles #
An oracle game is often stated twice: once for an adversary that sends named word requests and
reads word replies, and once for an adversary over typed queries and replies. An OracleCodec
records how typed queries travel on the word channels: encodeQuery writes a query as a request,
decodeQuery reads the requests that carry a query, and encodeReply writes each reply.
OracleCodec.adapt runs a word program against a typed oracle: a request that carries a query is
forwarded and its reply encoded, and any other request is answered [] without a call. Dually,
OracleCodec.wordOracle is the word oracle that a typed oracle presents. run_adapt and
runWith_adapt say that the two views agree: the typed run of c.adapt P is the word run of P
against c.wordOracle. A word game therefore equals the typed game of the adapted adversary
exactly when its oracle is c.wordOracle of the typed one, that is, when it answers requests
carrying no query with [] and leaves its state unchanged on them, and answers the others
through the typed oracle.
Main definitions #
Cslib.OracleCodec: typed queries and replies on named word channels.Cslib.OracleCodec.wordOracle,Cslib.OracleCodec.adapt: the word oracle of a typed oracle, and a word program run against a typed oracle.Cslib.OracleCodec.id,Cslib.OracleCodec.bitString,Cslib.OracleCodec.comap,Cslib.OracleCodec.withOp: word requests themselves, fixed-width strings, transport along an equivalence of queries, and one copy of a codec per channel.
Main results #
Cslib.OracleCodec.interpret_adapt,Cslib.OracleCodec.run_adapt,Cslib.OracleCodec.runWith_adapt: the typed run of an adapted program is the word run against the word oracle.Cslib.OracleCodec.isCostBounded_adapt,Cslib.OracleCodec.isQueryBounded_adapt: adapting keeps query budgets.Cslib.OracleCodec.adapt_id: adapting along the identity codec changes nothing.
Typed queries q : Q with replies spec q, carried on word requests Op × List Bool with
word replies. Each query has one request, and decodeQuery recognizes exactly these requests;
replies are encoded injectively.
The request carrying a query.
The query carried by a request, if any.
- decodeQuery_eq_some_iff (request : Op × List Bool) (q : Q) : self.decodeQuery request = some q ↔ self.encodeQuery q = request
A request carries a query exactly when it is that query's request.
The word reply to a query.
A query's request carries that query.
Distinct queries have distinct requests.
The word oracle presented by a typed oracle: a request carrying a query is answered through
the oracle and its reply encoded; any other request is answered [] without a call.
Run a word program against a typed oracle. Private samples are kept, and each request is
answered as by c.wordOracle, with the typed oracle as an external call.
The word oracle answers a query's request through the typed oracle.
The word oracle answers a request carrying no query with [].
Adapting keeps returned values.
Adapting preserves sequencing.
Adapting keeps private samples.
A word request becomes the word oracle's answer.
Interpreting the typed calls of the word oracle interprets the word oracle of the typed interpretation.
Typed and word runs agree: interpreting an adapted program with a typed oracle interprets the word program with the word oracle, under the same interpretation of private samples.
Running an adapted program against a typed oracle runs the word program against its word oracle.
Against a stateful typed oracle, the joint law of the result and the final state of an adapted program is that of the word program against the word oracle.
Adapting keeps a cost budget when each query costs at most its request.
Adapting keeps a query budget.
Standard codecs #
Adapting along the identity codec changes nothing.
n-bit strings on the single word channel: a request carries a query exactly when it has
n bits.
Transport a codec along an equivalence of queries and embeddings of replies.
One copy of a single-channel codec on each channel Op: the query (op, q) is the request
of q on channel op.