Documentation

CslibFrontier.Languages.Probabilistic.RandomOracle.Represented

Lazy random oracles behind a represented state #

A game usually keeps its random-oracle tables in its own state: association lists, several caches in a record, or caches for several oracles at once. When each call of such a handler, read through a map rep from the game state to a RandomOracle.Cache, is a lazy RandomOracle.answer, the game has the law of completing the represented cache once and answering every call from the completed table (eval_run_interpret_eq_complete_bind). The per-call hypothesis is the only game-specific step of an eager/lazy argument.

Several oracles are one oracle on the sum of their interfaces. RandomOracle.Cache.sum, re-exported here, joins their caches, so that one represented state serves them all, and bind_complete_sum splits the completed table back into one table per oracle.

Main results #

theorem Cslib.RandomOracle.run_interpret_bind_complete {Query State α : Type} {Response : Query → Type} [DecidableEq Query] [Fintype Query] [∀ (q : Query), Finite (Response q)] (distribution : (q : Query) → PMF (Response q)) (impl : (q : Query) → StateT State PMF (Response q)) (rep : State → Cache Response) (step : ∀ (q : Query) (s : State), PMF.map (fun (z : Response q × State) => (z.1, rep z.2)) (impl q s) = answer distribution q (rep s)) (program : OracleComp Response α) (s : State) :
(((OracleComp.interpret impl program).run s).bind fun (z : α × State) => PMF.map (fun (x : (q : Query) → Response q) => (z.1, x)) (complete distribution (rep z.2))) = (complete distribution (rep s)).bind fun (table : (q : Query) → Response q) => PMF.map (fun (x : α) => (x, table)) (OracleComp.interpret (fun (q : Query) => PMF.pure (table q)) program)

A stateful handler that, read through rep, answers every call as the lazy random oracle answer distribution has the joint law of its result and the completion of its represented final cache: completing the represented initial cache, answering every call from the completed table, and keeping that table.

theorem Cslib.RandomOracle.run_interpret_eq_complete_bind {Query State α : Type} {Response : Query → Type} [DecidableEq Query] [Fintype Query] [∀ (q : Query), Finite (Response q)] (distribution : (q : Query) → PMF (Response q)) (impl : (q : Query) → StateT State PMF (Response q)) (rep : State → Cache Response) (step : ∀ (q : Query) (s : State), PMF.map (fun (z : Response q × State) => (z.1, rep z.2)) (impl q s) = answer distribution q (rep s)) (program : OracleComp Response α) (s : State) :
PMF.map Prod.fst ((OracleComp.interpret impl program).run s) = (complete distribution (rep s)).bind fun (table : (q : Query) → Response q) => OracleComp.interpret (fun (q : Query) => PMF.pure (table q)) program

A stateful handler that, read through rep, answers every call as the lazy random oracle answer distribution has the result law of completing the represented initial cache and answering every call from the completed table.

theorem Cslib.RandomOracle.eval_run_interpret_bind_complete {Query State α : Type} {Response : Query → Type} [DecidableEq Query] [Fintype Query] [∀ (q : Query), Finite (Response q)] (distribution : (q : Query) → PMF (Response q)) (impl : (q : Query) → StateT State ProbComp (Response q)) (rep : State → Cache Response) (step : ∀ (q : Query) (s : State), PMF.map (fun (z : Response q × State) => (z.1, rep z.2)) (impl q s).eval = answer distribution q (rep s)) (program : OracleComp Response α) (s : State) :
(((OracleComp.interpret impl program).run s).eval.bind fun (z : α × State) => PMF.map (fun (x : (q : Query) → Response q) => (z.1, x)) (complete distribution (rep z.2))) = (complete distribution (rep s)).bind fun (table : (q : Query) → Response q) => PMF.map (fun (x : α) => (x, table)) (OracleComp.interpret (fun (q : Query) => PMF.pure (table q)) program)

run_interpret_bind_complete for a closed stateful handler.

theorem Cslib.RandomOracle.eval_run_interpret_eq_complete_bind {Query State α : Type} {Response : Query → Type} [DecidableEq Query] [Fintype Query] [∀ (q : Query), Finite (Response q)] (distribution : (q : Query) → PMF (Response q)) (impl : (q : Query) → StateT State ProbComp (Response q)) (rep : State → Cache Response) (step : ∀ (q : Query) (s : State), PMF.map (fun (z : Response q × State) => (z.1, rep z.2)) (impl q s).eval = answer distribution q (rep s)) (program : OracleComp Response α) (s : State) :
PMF.map Prod.fst ((OracleComp.interpret impl program).run s).eval = (complete distribution (rep s)).bind fun (table : (q : Query) → Response q) => OracleComp.interpret (fun (q : Query) => PMF.pure (table q)) program

A closed stateful handler that, read through rep, answers every call as the lazy random oracle answer distribution has the result law of completing the represented initial cache and answering every call from the completed table.

theorem Cslib.RandomOracle.bind_complete_sum {ι₁ ι₂ : Type u} {spec₁ : OracleSpec ι₁} {spec₂ : OracleSpec ι₂} [Fintype ι₁] [Fintype ι₂] [∀ (q : ι₁), Finite (spec₁ q)] [∀ (q : ι₂), Finite (spec₂ q)] {γ : Type u} (d₁ : (q : ι₁) → PMF (spec₁ q)) (d₂ : (q : ι₂) → PMF (spec₂ q)) (c₁ : Cache spec₁) (c₂ : Cache spec₂) (F : ((q : ι₁) → spec₁ q) → ((q : ι₂) → spec₂ q) → PMF γ) :
((complete (OracleComp.sumHandler d₁ d₂) (c₁.sum c₂)).bind fun (table : (q : ι₁ ⊕ ι₂) → spec₁.sum spec₂ q) => F (fun (q : ι₁) => table (Sum.inl q)) fun (q : ι₂) => table (Sum.inr q)) = (complete d₁ c₁).bind fun (t₁ : (q : ι₁) → spec₁ q) => (complete d₂ c₂).bind fun (t₂ : (q : ι₂) → spec₂ q) => F t₁ t₂

Completing a joined cache completes its two sides independently.