Documentation

CslibFrontier.Languages.Probabilistic.Oracle.Substitution.RunLog

Logged runs of oracle queries and query-renaming substitutions #

ProbOracleComp.runLog executes a randomized oracle program against a memoryless oracle while appending each (query, reply) pair to the transcript. This module provides the basic equations for pure, query, map, single-query programs do let reply ← query q; return f reply (together with their IsQueryBounded 1 witness), and query-renaming substitutions ProbOracleComp.simulate (fun q => ProbOracleComp.query (encode q)).

Main results #

@[simp]
theorem Cslib.ProbOracleComp.runLog_pure {Q R α : Type} (a : α) (oracle : Q → ProbComp R) :
(pure a).runLog oracle = pure (a, [])

Returning a value makes no oracle call and leaves the log empty.

@[simp]
theorem Cslib.ProbOracleComp.runLog_query {Q R : Type} (q : Q) (oracle : Q → ProbComp R) :
(query q).runLog oracle = (fun (reply : R) => (reply, [(q, reply)])) <$> oracle q

A single external query runs oracle q once and records (q, reply).

theorem Cslib.ProbOracleComp.runLog_map {Q R α β : Type} (f : α → β) (A : ProbOracleComp (fun (x : Q) => R) α) (oracle : Q → ProbComp R) :
(f <$> A).runLog oracle = Prod.map f id <$> A.runLog oracle

Deterministic postprocessing transforms the returned value and keeps the logged transcript.

theorem Cslib.ProbOracleComp.runLog_query_bind_pure {Q R α : Type} (q : Q) (f : R → α) (oracle : Q → ProbComp R) :
(do let reply ← query q pure (f reply)).runLog oracle = (fun (reply : R) => (f reply, [(q, reply)])) <$> oracle q

One external query followed by a pure return logs (q, reply) and transforms the reply.

theorem Cslib.ProbOracleComp.IsQueryBounded.query_bind_pure {Q R α : Type} (q : Q) (f : R → α) :
(do let reply ← ProbOracleComp.query q pure (f reply)).IsQueryBounded 1

One external query followed by a pure return makes at most one oracle call on every path.

theorem Cslib.ProbOracleComp.runLog_simulate_query {Q T R α : Type} (encode : Q → T) (A : ProbOracleComp (fun (x : Q) => R) α) (oracle : T → ProbComp R) :
(simulate (fun (q : Q) => query (encode q)) A).runLog oracle = (fun (result : α × List (Q × R)) => (result.1, List.map (fun (entry : Q × R) => (encode entry.1, entry.2)) result.2)) <$> A.runLog fun (q : Q) => oracle (encode q)

Substituting each query q with query (encode q) runs A against oracle ∘ encode and renames every logged request by encode.