Documentation

CslibFrontier.Languages.Probabilistic.RandomOracle.Invariant

Cache invariants of the lazy random oracle #

A run of an oracle program under the lazy random oracle RandomOracle.answer dist only extends its cache, keeps every cached answer in the support of dist, and returns what the program computes against any total oracle extending the final cache (OracleComp.mem_support_runWith_answer_invariant). Completing the final cache to a total oracle with OracleComp.cacheOracle turns facts about deterministic evaluation (OracleComp.evalPure) into facts about the lazy random-oracle run: a program that returns a against every oracle drawn from the pointwise support of dist returns PMF.pure a under RandomOracle.answer dist (OracleComp.map_fst_runWith_answer_eq_pure).

Main definitions #

Main results #

theorem Cslib.OracleComp.mem_support_runWith_answer_invariant {ι : Type u} {spec : OracleSpec ι} {α : Type u} [DecidableEq ι] (dist : (q : ι) → PMF (spec q)) (prog : OracleComp spec α) {cache cache' : RandomOracle.Cache spec} {res : α} (hsupp : ∀ (q' : ι) (v' : spec q'), cache q' = some v' → v' ∈ (dist q').support) (hmem : (res, cache') ∈ (runWith (RandomOracle.answer dist) prog cache).support) :
(∀ (q' : ι) (v' : spec q'), cache q' = some v' → cache' q' = some v') ∧ (∀ (q' : ι) (v' : spec q'), cache' q' = some v' → v' ∈ (dist q').support) ∧ ∀ (h : (q : ι) → spec q), (∀ (q' : ι) (v' : spec q'), cache' q' = some v' → h q' = v') → res = evalPure h prog

Multi-step invariant of runWith (RandomOracle.answer dist): any outcome (res, cache') in the support of a run from cache produces a final cache cache' extending cache whose entries lie in (dist q).support, and res = evalPure h prog for every total function h extending cache'.

noncomputable def Cslib.OracleComp.cacheOracle {ι : Type u} {spec : OracleSpec ι} (dist : (q : ι) → PMF (spec q)) (cache : RandomOracle.Cache spec) (q : ι) :
spec q

Extend a partial cache cache to a total deterministic oracle by returning v when cache q = some v and otherwise choosing an element in (dist q).support.

theorem Cslib.OracleComp.cacheOracle_eq_of_eq_some {ι : Type u} {spec : OracleSpec ι} (dist : (q : ι) → PMF (spec q)) (cache : RandomOracle.Cache spec) {q : ι} {v : spec q} (h : cache q = some v) :
cacheOracle dist cache q = v
theorem Cslib.OracleComp.cacheOracle_mem_support {ι : Type u} {spec : OracleSpec ι} (dist : (q : ι) → PMF (spec q)) {cache : RandomOracle.Cache spec} (hsupp : ∀ (q' : ι) (v' : spec q'), cache q' = some v' → v' ∈ (dist q').support) (q : ι) :
cacheOracle dist cache q ∈ (dist q).support
theorem Cslib.OracleComp.map_fst_runWith_answer_eq_pure {ι : Type u} {spec : OracleSpec ι} {α : Type u} [DecidableEq ι] (dist : (q : ι) → PMF (spec q)) (prog : OracleComp spec α) (a : α) (hprog : ∀ (h : (q : ι) → spec q), (∀ (q : ι), h q ∈ (dist q).support) → evalPure h prog = a) :
PMF.map Prod.fst (runWith (RandomOracle.answer dist) prog fun (x : ι) => none) = PMF.pure a

If an oracle program evaluates to a under every deterministic oracle drawn from the point-wise support of dist, then running it under the lazy random oracle RandomOracle.answer dist from the empty cache yields PMF.pure a.