Documentation

CslibFrontier.Languages.Probabilistic.QueriesWith.Cost

Cost and request decompositions for deterministic runs #

Connects the request trace OracleComp.queriesWith of a deterministic run to IsCostBounded, summed interfaces liftLeft, and short-circuiting list searches List.findSomeM?.

Main results #

theorem Cslib.OracleComp.IsCostBounded.sum_map_queriesWith_le {ι : Type} {spec : OracleSpec ι} {α : Type} {cost : ι → ℕ} (answer : (q : ι) → spec q) {program : OracleComp spec α} {n : ℕ} (h : IsCostBounded cost program n) :
(List.map cost (queriesWith answer program)).sum ≤ n

A program that stays within n for cost on every path spends at most n along the run against answer. The weighted form of IsQueryBounded.length_queriesWith_le.

theorem Cslib.OracleComp.queriesWith_liftLeft {ι₁ ι₂ : Type} {spec₁ : OracleSpec ι₁} {spec₂ : OracleSpec ι₂} {α : Type} (o₁ : (q : ι₁) → spec₁ q) (o₂ : (q : ι₂) → spec₂ q) (prog : OracleComp spec₁ α) :

The requests of an embedded left program are its own requests, on the left.

theorem Cslib.OracleComp.queriesWith_findSomeM?_cons {ι : Type} {spec : OracleSpec ι} {α β : Type} (o : (q : ι) → spec q) (f : α → OracleComp spec (Option β)) (x : α) (xs : List α) :

The requests of a search: those of its first step, then those of the rest when that step finds nothing.

theorem Cslib.OracleComp.queriesWith_findSomeM?_of_forall_eq_none {ι : Type} {spec : OracleSpec ι} {α β : Type} (o : (q : ι) → spec q) (f : α → OracleComp spec (Option β)) {xs : List α} (h : ∀ x ∈ xs, evalPure o (f x) = none) :
queriesWith o (List.findSomeM? f xs) = List.flatMap (fun (x : α) => queriesWith o (f x)) xs

A search in which no step finds anything makes the requests of all its steps, in order.