Structures For Tracking a Computation's Oracle Queries #
This file defines types like QueryLog and QueryCache for use with
simulation oracles and implementation transformers defined in the same directory.
Type to represent a cache of queries to oracles in spec.
Defined to be a function from (indexed) inputs to an optional output.
Equations
- spec.QueryCache = ((t : spec.Domain) → Option (spec.Range t))
Instances For
Partial Order #
A QueryCache carries a natural partial order where c₁ ≤ c₂ means every cached entry
in c₁ also appears (with the same value) in c₂. The empty cache is the bottom element.
Equations
- One or more equations did not get rendered due to their size.
Equations
- OracleSpec.QueryCache.instOrderBot = { bot := ∅, bot_le := ⋯ }
Query membership #
Check whether a query t has a cached response.
Instances For
Conversion to a set of query-response pairs #
The set of all (query, response) pairs stored in the cache.
Instances For
Cache update #
Add an index + input pair to the cache by updating the function
(wrapper around Function.update).
Equations
- cache.cacheQuery t u = Function.update cache t (some u)
Instances For
Sum spec projections #
Project a cache for spec₁ + spec₂ onto spec₁.
Instances For
Project a cache for spec₁ + spec₂ onto spec₂.
Instances For
Embed a cache for spec₁ into one for spec₁ + spec₂.
Instances For
Embed a cache for spec₂ into one for spec₁ + spec₂.
Instances For
Equations
Equations
Simple wrapper in order to introduce the Monoid structure for countingOracle.
Marked as reducible and can generally be treated as just a function.
idx gives the "index" for a given input
Equations
- OracleSpec.QueryCount ι = (ι → ℕ)
Instances For
Pointwise addition as the Monoid operation used for WriterT.
Equations
- OracleSpec.QueryCount.instMonoid = { mul := fun (qc qc' : OracleSpec.QueryCount ι) => qc + qc', mul_assoc := ⋯, one := 0, one_mul := ⋯, mul_one := ⋯, npow_zero := ⋯, npow_succ := ⋯ }
Equations
Instances For
Log of queries represented by a list of dependent product's tagging the oracle's index.
(t : spec.Domain) × (spec.Range t) is slightly more restricted as it doesn't
keep track of query ordering between different oracles.
Instances For
Query log with a single entry.
Instances For
Update a query log by adding a new element to the appropriate list. Note that this requires decidable equality on the indexing set.
Equations
- log.logQuery t u = log ++ OracleSpec.QueryLog.singleton t u
Instances For
Equations
- OracleSpec.QueryLog.instDecidableEqOfDecidableEq = inferInstanceAs (DecidableEq (List ((t : spec.Domain) × spec.Range t)))
Get all the queries with inputs satisfying p
Equations
- One or more equations did not get rendered due to their size.
Instances For
Count the number of queries with inputs satisfying p.
Instances For
Check if an element was ever queried in a log of queries. Relies on decidable equality of the domain types of oracles.
Instances For
Get only the portion of the log for queries in spec₁.
Equations
Instances For
Get only the portion of the log for queries in spec₂.
Equations
Instances For
View a log for spec₁ as one for spec₁ ++ₒ spec₂ by inclusion.
Equations
Instances For
View a log for spec₂ as one for spec₁ ++ₒ spec₂ by inclusion.
Equations
Instances For
Equations
Equations
A store of pre-generated seed values for oracle queries, indexed by oracle.
Maps each oracle index i to a list of outputs List (spec.Range i).
Instances For
Replace the seed values at index i.
Equations
- seed.update i xs = Function.update seed i xs
Instances For
Append a list of values to the seed at index i.
Equations
- seed.addValues us = Function.update seed i (seed i ++ us)
Instances For
Prepend a list of values to the seed at index i.
Equations
- seed.prependValues us = Function.update seed i (us ++ seed i)
Instances For
Instances For
Take only the first n values of the seed at index i.
Equations
- seed.takeAtIndex i n = Function.update seed i (List.take n (seed i))
Instances For
Pop one value from index i, returning the consumed value and updated seed when nonempty.
Equations
Instances For
Construct a query seed from a list at a single index.