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.
A partial dependent answer table, ordered by extension of cached responses.
Look up the response stored at an oracle index.
Instances For
Package a partial dependent answer function as a cache.
Instances For
Cache lookup is injective.
A cache and its dependent optional lookup table contain the same data.
Instances For
Agreement with answer functions #
A total answer function agrees with a cache if it returns every cached response.
Instances For
Every cache is extended by some total answer function.
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.
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
Number of live entries in a query cache, as an ℝ≥0∞ resource.
Instances For
Cache update #
Add an index + input pair to the cache by updating the function
(wrapper around Function.update).
Instances For
An answer function agrees with cache.cacheQuery t u iff it agrees with cache and returns
u on t, provided t was not already cached.
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
Embedding a left-component cache commutes with caching a left-component query.
Embedding a right-component cache commutes with caching a right-component query.
Per-index natural counts with the ordinary pointwise additive algebra.
Additive writer instrumentation uses Multiplicative (QueryCount ι) as its
monoidal payload; query counts themselves retain the standard function instances.
Instances For
The query count recording one query at index i and none elsewhere.
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.
A QueryLog spec is morally a free monoid on Idx spec.toPFunctor, with
identity [] and product (++). By Mathlib reducibility this is exactly
FreeMonoid (Idx spec.toPFunctor) = TraceList spec.toPFunctor, so a
trace-valued boundary description such as BoundaryAction.emit (in
PolyFun/Interaction/UC/OpenProcess.lean) and a per-call QueryLog-valued
writer share the same underlying free-monoid carrier.
We do not declare a global Monoid (QueryLog spec) instance: doing so
would conflict with the [EmptyCollection ω] [Append ω] → Monad (WriterT ω M)
instance Mathlib already provides for WriterT (QueryLog spec) M, which the
existing WriterTBridge/mvcgen proof infrastructure relies on. The
QueryImpl.withTrace/withLogging API instead uses the Append-based
Monad (WriterT _ _) directly via QueryImpl.withTraceAppend.
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.
Instances For
Get all the queries with inputs satisfying p
Instances For
Count the number of queries with inputs satisfying p.
Instances For
Lookup by oracle occurrence #
The n-th answer in the log for queries to oracle t, if it exists.
Instances For
If getQueryValue? log t n = some u, then the n-th t-filtered entry of
log is ⟨t, u⟩.
Converse: if the n-th t-filtered entry is ⟨t, u⟩, then
getQueryValue? log t n = some u.
Every entry of log.getQ (· = t) has its first component equal to t.
If the t-filtered log has at least n + 1 entries, then the indexed
lookup succeeds.
Prepending an entry whose oracle index does not match t leaves the
t-indexed view of the log unchanged.
The first matching entry is the zeroth indexed query value.
Prepending a matching entry shifts later indexed lookups by one.
The entry immediately following a prefix is found at the prefix's count of matching oracle queries.
Query-log counting is the OracleSpec specialization of PolyFun's
generic occurrence count on erased polynomial traces.
Query-log lookup is the OracleSpec specialization of dependent lookup
on PolyFun traces.
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₁.
Instances For
Get only the portion of the log for queries in spec₂.
Instances For
View a log for spec₁ as one for spec₁ + spec₂ by inclusion.
Instances For
View a log for spec₂ as one for spec₁ + spec₂ by inclusion.
Instances For
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.
Instances For
Updates at distinct seed indices commute.
Append a list of values to the seed at index i.
Instances For
Replacing an index after appending there discards the appended values.
Appending at one seed index commutes with replacing a distinct index.
Prepend a list of values to the seed at index i.
Instances For
Instances For
Take only the first n values of the seed at index i.
Instances For
Pop one value from index i, returning the consumed value and updated seed when nonempty.
Instances For
Construct a query seed from a list at a single index.