Documentation

CslibFrontier.Languages.Probabilistic.Oracle.CoinFixing

Fixing private coins of randomized oracle programs #

When every external query q : Query has a finite reply type spec q, a randomized oracle program prog : ProbOracleComp spec α has a finite tree of private coin choices Coins prog distributed according to coinLaw prog : PMF (Coins prog). Fixing ω : Coins prog yields a deterministic oracle program fixCoins prog ω : OracleComp spec α with no private sampling calls:

Main definitions #

Main results #

def Cslib.ProbOracleComp.Coins {Query α : Type} {spec : Query → Type} :
ProbOracleComp spec α → Type

Private coin space of a randomized oracle program: each private sample Fin (k + 1) pairs the drawn value with the continuation's coins, and each external query q branches over every possible reply in spec q.

Instances For
    instance Cslib.ProbOracleComp.finite_coins {Query α : Type} {spec : Query → Type} [∀ (q : Query), Finite (spec q)] (prog : ProbOracleComp spec α) :

    When every external reply type spec q is finite, Coins prog is finite.

    noncomputable def Cslib.ProbOracleComp.coinLaw {Query α : Type} {spec : Query → Type} [(q : Query) → Fintype (spec q)] (prog : ProbOracleComp spec α) :
    PMF prog.Coins

    Product distribution over the private coin choices of prog.

    @[simp]
    theorem Cslib.ProbOracleComp.coinLaw_pure {Query α : Type} {spec : Query → Type} [(q : Query) → Fintype (spec q)] (a : α) :
    theorem Cslib.ProbOracleComp.coinLaw_liftBind_inl {Query α : Type} {spec : Query → Type} [(q : Query) → Fintype (spec q)] (k : ℕ) (cont : Fin (k + 1) → ProbOracleComp spec α) :
    coinLaw (PFunctor.FreeM.liftBind (Sum.inl k) cont) = (ProbComp.unifOracle k).bind fun (c : Fin (k + 1)) => PMF.map (fun (ω : (cont c).Coins) => ⟨c, ω⟩) (cont c).coinLaw
    theorem Cslib.ProbOracleComp.coinLaw_liftBind_inr {Query α : Type} {spec : Query → Type} [(q : Query) → Fintype (spec q)] (q : Query) (cont : spec q → ProbOracleComp spec α) :
    coinLaw (PFunctor.FreeM.liftBind (Sum.inr q) cont) = Probability.PMF.pi fun (y : spec q) => (cont y).coinLaw
    def Cslib.ProbOracleComp.fixCoins {Query α : Type} {spec : Query → Type} (prog : ProbOracleComp spec α) :
    prog.Coins → OracleComp spec α

    Deterministic oracle program obtained by supplying ω : Coins prog for all private samples.

    theorem Cslib.ProbOracleComp.isCostBounded_fixCoins {Query α : Type} {spec : Query → Type} {cost : Query → ℕ} {prog : ProbOracleComp spec α} {n : ℕ} (h : OracleComp.IsCostBounded (Sum.elim (fun (x : ℕ) => 0) cost) prog n) (ω : prog.Coins) :

    Fixing private coins preserves any external query cost budget OracleComp.IsCostBounded.

    theorem Cslib.ProbOracleComp.isQueryBounded_fixCoins {Query α : Type} {spec : Query → Type} {prog : ProbOracleComp spec α} {n : ℕ} (h : prog.IsQueryBounded n) (ω : prog.Coins) :

    Fixing private coins preserves IsQueryBounded.

    theorem Cslib.ProbOracleComp.coinLaw_bind_runWith_fixCoins {Query α : Type} {spec : Query → Type} [(q : Query) → Fintype (spec q)] {State : Type} (oracle : (q : Query) → StateT State PMF (spec q)) (prog : ProbOracleComp spec α) (s : State) :
    (prog.coinLaw.bind fun (ω : prog.Coins) => OracleComp.runWith oracle (prog.fixCoins ω) s) = runWith oracle prog s

    Against any stateful external oracle, sampling ω ← coinLaw prog and running fixCoins prog ω has the joint law of the result and final state of prog (its private samples fresh, as in ProbOracleComp.runWith).

    theorem Cslib.ProbOracleComp.bind_interpret_fixCoins {Query α : Type} {spec : Query → Type} [(q : Query) → Fintype (spec q)] (prog : ProbOracleComp spec α) (table : (q : Query) → spec q) :
    (prog.coinLaw.bind fun (ω : prog.Coins) => OracleComp.interpret (fun (q : Query) => PMF.pure (table q)) (prog.fixCoins ω)) = OracleComp.interpret (OracleComp.sumHandler ProbComp.unifOracle fun (q : Query) => PMF.pure (table q)) prog

    Against any deterministic external oracle table, sampling ω ← coinLaw prog and running fixCoins prog ω has the exact output law of prog.

    theorem Cslib.ProbOracleComp.table_bind_interpret_eq_coinLaw_bind {Query α : Type} {spec : Query → Type} [(q : Query) → Fintype (spec q)] {τ : Type u_1} (μ : PMF τ) (table : τ → (q : Query) → spec q) (prog : ProbOracleComp spec α) :
    (μ.bind fun (t : τ) => OracleComp.interpret (OracleComp.sumHandler ProbComp.unifOracle fun (q : Query) => PMF.pure (table t q)) prog) = prog.coinLaw.bind fun (ω : prog.Coins) => μ.bind fun (t : τ) => OracleComp.interpret (fun (q : Query) => PMF.pure (table t q)) (prog.fixCoins ω)

    Sampling an external deterministic oracle table t ← μ independently of prog's private coins commutes with fixing ω ← coinLaw prog.