Documentation

CslibFrontier.Languages.Probabilistic.Oracle.Vector

Running and counting queries of OracleComp.pi and OracleComp.replicate #

Execution (ProbOracleComp.run), simulation (ProbOracleComp.simulate), syntactic query bounds (ProbOracleComp.IsQueryBounded), and exact stateful transcript lengths (OracleComp.withTranscript) for finite tuples (OracleComp.pi) and independent repetitions (OracleComp.replicate) of probabilistic oracle computations.

Main results #

theorem Cslib.OracleComp.isCostBounded_pi {ι : Type} {spec : ι → Type} {cost : ι → ℕ} {m : ℕ} {β : Fin m → Type} {programs : (i : Fin m) → OracleComp spec (β i)} {c : ℕ} (h : ∀ (i : Fin m), IsCostBounded cost (programs i) c) :
IsCostBounded cost (pi programs) (m * c)

Budgets add along OracleComp.pi: if each of m coordinate programs costs at most c, the tuple costs at most m * c.

theorem Cslib.ProbOracleComp.run_pi {Query : Type} {spec : Query → Type} {m : ℕ} {β : Fin m → Type} (programs : (i : Fin m) → ProbOracleComp spec (β i)) (O : (q : Query) → ProbComp (spec q)) :
run (OracleComp.pi programs) O = OracleComp.pi fun (i : Fin m) => (programs i).run O

Running OracleComp.pi against an oracle runs each coordinate program in order.

theorem Cslib.ProbOracleComp.simulate_pi {Query₁ Query₂ : Type} {spec₁ : Query₁ → Type} {spec₂ : Query₂ → Type} (h : (q : Query₁) → ProbOracleComp spec₂ (spec₁ q)) {k : ℕ} {α : Fin k → Type} (p : (i : Fin k) → ProbOracleComp spec₁ (α i)) :
simulate h (OracleComp.pi p) = OracleComp.pi fun (i : Fin k) => simulate h (p i)

Simulating OracleComp.pi under an oracle simulation h simulates each coordinate program in order.

theorem Cslib.ProbOracleComp.simulate_mapM {Query₁ Query₂ β γ : Type} {spec₁ : Query₁ → Type} {spec₂ : Query₂ → Type} (h : (q : Query₁) → ProbOracleComp spec₂ (spec₁ q)) (f : β → ProbOracleComp spec₁ γ) (l : List β) :
simulate h (List.mapM f l) = List.mapM (fun (b : β) => simulate h (f b)) l

Simulating a list traversal under an oracle simulation h simulates each step in order.

theorem Cslib.ProbOracleComp.run_pi_query {Query : Type} {spec : Query → Type} {m : ℕ} (q : Fin m → Query) (O : (x : Query) → spec x) :
(run (OracleComp.pi fun (i : Fin m) => query (q i)) fun (x : Query) => pure (O x)) = pure fun (i : Fin m) => O (q i)

Running a tuple of external queries against a deterministic oracle returns the tuple of answers.

theorem Cslib.ProbOracleComp.isQueryBounded_pi_query {Query : Type} {spec : Query → Type} {m : ℕ} (q : Fin m → Query) :
IsQueryBounded (OracleComp.pi fun (i : Fin m) => query (q i)) m

A tuple of m external queries makes at most m external queries.

theorem Cslib.ProbOracleComp.length_transcript_pi_query {Query : Type} {spec : Query → Type} {m : ℕ} {State : Type} (oracle : (q : Query) → StateT State PMF (spec q)) (q : Fin m → Query) {s s' : State} {result : (i : Fin m) → spec (q i)} {transcript : OracleComp.Transcript spec} (hmem : (result, s', transcript) ∈ (runWith (OracleComp.withTranscript oracle) (OracleComp.pi fun (i : Fin m) => query (q i)) (s, [])).support) :
List.length transcript = m

Every supported stateful execution of a tuple of m external queries logs a transcript of exact length m.

@[simp]
theorem Cslib.ProbOracleComp.run_replicate {Query α : Type} {spec : Query → Type} (k : ℕ) (program : ProbOracleComp spec α) (O : (q : Query) → ProbComp (spec q)) :
run (OracleComp.replicate k program) O = OracleComp.replicate k (program.run O)

Running OracleComp.replicate against an oracle repeats the run of the underlying program.

theorem Cslib.ProbOracleComp.isQueryBounded_replicate {Query α : Type} {spec : Query → Type} (k : ℕ) {program : ProbOracleComp spec α} {q : ℕ} (hq : program.IsQueryBounded q) :

Repeating a q-query-bounded program k times makes at most k * q queries.

theorem Cslib.ProbOracleComp.length_transcript_replicate {Query α : Type} {spec : Query → Type} {State : Type} (oracle : (x : Query) → StateT State PMF (spec x)) (k : ℕ) {program : ProbOracleComp spec α} {q : ℕ} (hq : ∀ {s s' : State} {result : α} {tr : OracleComp.Transcript spec}, (result, s', tr) ∈ (runWith (OracleComp.withTranscript oracle) program (s, [])).support → List.length tr = q) {s s' : State} {results : List α} {transcript : OracleComp.Transcript spec} (hmem : (results, s', transcript) ∈ (runWith (OracleComp.withTranscript oracle) (OracleComp.replicate k program) (s, [])).support) :
List.length transcript = k * q

If every supported execution of program makes exactly q external queries, then every supported execution of OracleComp.replicate k program makes exactly k * q external queries.