Documentation

CslibFrontier.Languages.Probabilistic.Oracle.EvalPure

Evaluating oracle programs against a deterministic oracle #

OracleComp.evalPure h prog runs an oracle program against a total function h : (q : ι) → spec q in the Id monad. It is the deterministic counterpart of OracleComp.evalWith: evaluating with the point-mass oracle fun q => PMF.pure (h q) gives the point mass at evalPure h prog (OracleComp.evalWith_pure_oracle). OracleComp.sumPure combines deterministic oracles for the two sides of spec₁ ⊕ₒ spec₂, and evalPure of a lifted program under sumPure only reads the matching side.

Random-oracle arguments use evalPure to compare an oracle program with its pure specification once the oracle's answers are fixed (CslibFrontier.Languages.Probabilistic.RandomOracle.Invariant).

Main definitions #

Main results #

def Cslib.OracleComp.evalPure {ι : Type u} {spec : OracleSpec ι} {α : Type v} (h : (q : ι) → spec q) (prog : OracleComp spec α) :
α

Evaluate an oracle program deterministically against a pure function h : (q : ι) → spec q in the Id monad.

@[simp]
theorem Cslib.OracleComp.evalPure_pure {ι : Type u} {spec : OracleSpec ι} {α : Type v} (h : (q : ι) → spec q) (a : α) :
evalPure h (pure a) = a
@[simp]
theorem Cslib.OracleComp.evalPure_query {ι : Type u} {spec : OracleSpec ι} (h : (q : ι) → spec q) (q : ι) :
evalPure h (query q) = h q
@[simp]
theorem Cslib.OracleComp.evalPure_bind {ι : Type u} {spec : OracleSpec ι} {α β : Type v} (h : (q : ι) → spec q) (prog : OracleComp spec α) (cont : α → OracleComp spec β) :
evalPure h (prog >>= cont) = evalPure h (cont (evalPure h prog))
@[simp]
theorem Cslib.OracleComp.evalPure_map {ι : Type u} {spec : OracleSpec ι} {α β : Type v} (h : (q : ι) → spec q) (f : α → β) (prog : OracleComp spec α) :
evalPure h (f <$> prog) = f (evalPure h prog)
@[simp]
theorem Cslib.OracleComp.evalPure_mapM {ι : Type u} {spec : OracleSpec ι} {α γ : Type v} (h : (q : ι) → spec q) (f : γ → OracleComp spec α) (xs : List γ) :
evalPure h (List.mapM f xs) = List.map (fun (x : γ) => evalPure h (f x)) xs
@[simp]
theorem Cslib.OracleComp.evalPure_foldlM {ι : Type u} {spec : OracleSpec ι} {α γ : Type v} (h : (q : ι) → spec q) (f : α → γ → OracleComp spec α) (init : α) (xs : List γ) :
evalPure h (List.foldlM f init xs) = List.foldl (fun (acc : α) (x : γ) => evalPure h (f acc x)) init xs
@[simp]
theorem Cslib.OracleComp.evalWith_pure_oracle {ι : Type u} {spec : OracleSpec ι} {α : Type v} (h : (q : ι) → spec q) (prog : OracleComp spec α) :
evalWith (fun (q : ι) => PMF.pure (h q)) prog = PMF.pure (evalPure h prog)

Evaluating an oracle program with PMF.pure (h q) produces the point mass at evalPure h.

def Cslib.OracleComp.sumPure {ι₁ ι₂ : Type u} {spec₁ : OracleSpec ι₁} {spec₂ : OracleSpec ι₂} (h₁ : (q : ι₁) → spec₁ q) (h₂ : (q : ι₂) → spec₂ q) (q : ι₁ ⊕ ι₂) :
spec₁.sum spec₂ q

Combine two deterministic oracles into a deterministic oracle for spec₁ ⊕ₒ spec₂.

@[simp]
theorem Cslib.OracleComp.sumPure_inl {ι₁ ι₂ : Type u} {spec₁ : OracleSpec ι₁} {spec₂ : OracleSpec ι₂} (h₁ : (q : ι₁) → spec₁ q) (h₂ : (q : ι₂) → spec₂ q) (q : ι₁) :
sumPure h₁ h₂ (Sum.inl q) = h₁ q
@[simp]
theorem Cslib.OracleComp.sumPure_inr {ι₁ ι₂ : Type u} {spec₁ : OracleSpec ι₁} {spec₂ : OracleSpec ι₂} (h₁ : (q : ι₁) → spec₁ q) (h₂ : (q : ι₂) → spec₂ q) (q : ι₂) :
sumPure h₁ h₂ (Sum.inr q) = h₂ q
@[simp]
theorem Cslib.OracleComp.evalPure_liftLeft {α : Type v} {ι₁ ι₂ : Type u} {spec₁ : OracleSpec ι₁} {spec₂ : OracleSpec ι₂} (h₁ : (q : ι₁) → spec₁ q) (h₂ : (q : ι₂) → spec₂ q) (prog : OracleComp spec₁ α) :
evalPure (sumPure h₁ h₂) prog.liftLeft = evalPure h₁ prog
@[simp]
theorem Cslib.OracleComp.evalPure_liftRight {α : Type v} {ι₁ ι₂ : Type u} {spec₁ : OracleSpec ι₁} {spec₂ : OracleSpec ι₂} (h₁ : (q : ι₁) → spec₁ q) (h₂ : (q : ι₂) → spec₂ q) (prog : OracleComp spec₂ α) :
evalPure (sumPure h₁ h₂) prog.liftRight = evalPure h₂ prog