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 #
Cslib.OracleComp.IsCostBounded.sum_map_queriesWith_le: weighted cost along a run stays within a pathwiseIsCostBoundedbudget.Cslib.OracleComp.queriesWith_liftLeft: requests of an embedded left program undersumPureare its left requests mapped bySum.inl.Cslib.OracleComp.queriesWith_findSomeM?_cons: requests of afindSomeM?step, continuing into the tail only when the step returnsnone.Cslib.OracleComp.queriesWith_findSomeM?_of_forall_eq_none: requests of afindSomeM?search where every step evaluates tononeconcatenate the requests of all steps.
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) :
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 α) :
queriesWith o (List.findSomeM? f (x :: xs)) = queriesWith o (f x) ++ if (evalPure o (f x)).isSome = true then [] else queriesWith o (List.findSomeM? f xs)
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) :
A search in which no step finds anything makes the requests of all its steps, in order.