Computational oracle codecs and typed-to-word simulation #
Cslib.OracleCodec (CslibFrontier.Languages.Probabilistic.Oracle.Codec) adapts word-oracle
programs WordOracleComp Op α to typed oracles via OracleCodec.adapt and
OracleCodec.wordOracle. This module supplies the dual typed-to-word direction and strict
IsOraclePPTOn composition rules, with explicit reply caps, reply decoders, and fallback queries
(no hidden encoding typeclasses):
- Fixed-width bit-string codecs (
OracleCodec.bitStrings):n-bit queries withw-bit replies on the single word channel, specializing atw = ntoOracleCodec.bitString n. - Typed-to-word lifting (
OracleCodec.queryWord,OracleCodec.toWord): translates a typed programProbOracleComp (fun _ : Q => R) αintoWordOracleComp Op αby charging a prefixList.take (replyCap q)of each word reply and applyingdecodeReply q. Underc.wordOracle,runWith_wordOracle_toWordandrun_wordOracle_toWordestablish exact joint-state and output bisimulation whenever supported replies fit inreplyCap q;adapt_toWordgives the syntactic round-trip when the cap holds for all replies; andisCostBounded_toWord/isQueryBounded_toWordpreserve query budgets. - Strict
IsOraclePPTOncomposition (IsOraclePPTOn.queryWord,IsOraclePPTOn.wordOracle_state,IsOraclePPTOn.run_wordOracle_open): certifies typed-to-word calls across multi-channelOpviaIsOraclePPTOn.finite_cases, lifts typed stateful handlers to word handlers viac.wordOracle, and substitutes them into strict oracle-PPT word programs viaIsOraclePPTOn.run_interpret_preprocess_openwhile restricting invariant obligations to valid typed queries.
Main definitions #
Cslib.OracleCodec.bitStrings:n-bit queries withw-bit replies on channelUnit.Cslib.OracleCodec.queryWord,Cslib.OracleCodec.toWord: explicit capped typed-to-word query and program translation.
Main results #
Cslib.OracleCodec.adapt_toWord,Cslib.OracleCodec.runWith_wordOracle_toWord,Cslib.OracleCodec.run_wordOracle_toWord: syntactic round-trip and stateful/stateless bisimulation againstc.wordOracle.Cslib.OracleCodec.isCostBounded_toWord,Cslib.OracleCodec.isQueryBounded_toWord: query-budget preservation fortoWord.Cslib.Probability.IsOraclePPTOn.queryWord,Cslib.Probability.IsOraclePPTOn.wordOracle_state,Cslib.Probability.IsOraclePPTOn.run_wordOracle_open: strictIsOraclePPTOncertificates for typed-to-word calls and open statefulwordOraclesubstitution.
n-bit queries with w-bit replies on the single word channel Unit: a request carries a
query if and only if its payload has n bits.
At equal input and output widths, bitStrings n n is bitString n.
Perform one typed query q : Q on the word channel Op: send c.encodeQuery q, read at most
replyCap q bits of the word reply, and decode them with decodeReply q.
Translate a typed oracle program ProbOracleComp (fun _ : Q => R) α into a
WordOracleComp Op α program using c.queryWord replyCap decodeReply, forwarding private coin
draws unchanged.
Syntactic round-trip (adapt ∘ toWord = id): when every encoded reply fits within
replyCap q and decodeReply q left-inverts c.encodeReply q, adapting c.toWord back to the
typed interface recovers program identically.
Stateful runWith bisimulation: running c.toWord replyCap decodeReply program against
c.wordOracle oracle has the exact same joint (α × State) distribution as running program
directly against oracle, provided every supported reply of oracle has encoded length at most
replyCap q and decodeReply q left-inverts c.encodeReply q.
Stateless ProbComp bisimulation: evaluating (c.toWord replyCap decodeReply program).run (c.wordOracle oracle) matches program.run oracle whenever every supported reply of oracle fits
in replyCap q.
toWord preserves cost budgets whenever each encoded word request costs at most the typed
query's cost.
toWord preserves external query budgets (IsQueryBounded).
Performing a single typed query c.queryWord over a finite multi-channel word interface Op is
strict oracle PPT whenever c.encodeQuery, replyCap, and decodeReply are computable in plain
polynomial time.
Lifting a strict oracle-PPT typed stateful handler typed : Caller → Q → StateT State (WordOracleComp External) R through c.wordOracle produces a strict oracle-PPT word handler on
encHandlerCall. The explicit defaultQuery : Q is used only as the dead fallback of Option.getD
after testing (c.decodeQuery request).isSome.
Open stateful substitution through c.wordOracle: certify running an IsOraclePPTOn word
program against c.wordOracle (typed a) from initial a, checking invariant preservation and
reply/state size bounds only on valid typed queries q : Q (with request = c.encodeQuery q).