Specifications of Available Oracles #
An OracleSpec ι specifies a collection of oracles indexed by ι, given as the map sending
each index to the output type of that oracle. It is the same data as a PFunctor, and the
bridge toPFunctor / ofPFunctor exposes that algebra: oracle specifications can be combined
with + (a disjoint sum of oracle sets), *, OracleSpec.sigma, and OracleSpec.pi. The
empty specification []ₒ provides no oracles.
This file also defines the standard sampling specifications coinSpec, unifSpec, and
probSpec.
An OracleSpec ι specifies a set of oracles indexed by ι.
Defined as a map from each input to the type of the oracle's output.
Instances For
Instances For
Instances For
Instances For
Instances For
Typeclass data on indices and answer types #
Domain and Range are reducible, so a global instance concluding C spec.Domain or
C (spec.Range t) for a generic spec is indexed as C ι, respectively C (?spec ?t): a
candidate for every C _ goal, with spec undetermined. Instance search then invents a
specification through ofFn, and either times out (VCVio#772) or answers an ordinary
DecidableEq, Fintype, or Inhabited goal through oracle-specification data. The only such
instances left are the fintype and inhabited projections of the retiring IsUniformSpec.
Index equality is an ordinary [DecidableEq ι] hypothesis, and data on answer
types are ordinary [DecidableEq (spec.Range t)], [Fintype (spec.Range t)], or
[Inhabited (spec.Range t)] hypotheses, quantified over t when a statement ranges over
arbitrary queries. Specifications built with ofFn reduce to their answer types, so
unifSpec, coinSpec, and A →ₒ B need no instances of their own; + combines the
per-branch instances of its summands.
Instances For
spec₁ + spec₂ specifies access to oracles in both spec₁ and spec₂.
The input is split as a sum type of the two original input sets.
This corresponds exactly to addition of the corresponding PFunctor.
The ordinary instance reducibility assigned by the instance command lets its HAdd.hAdd
projection reduce while checking dependent implicit types such as
(spec₁ + spec₂).Range (.inl t), without unfolding combined specifications during ordinary
reducible-transparency tactic matching.
Deliberately not @[simp]: toPFunctor occurs inside the (instance-carrying)
type of an OracleComp, so rewriting with this under a simulateQ/liftM strands
the goal in a form the simulateQ_query family can no longer match.
The answer types of a sum specification inherit the per-branch instances of its summands.
These are indexed on the HAdd.hAdd head of the combined specification, so they apply only to
goals about a sum.
Given an indexed set of OracleSpec, specify access to all of the oracles,
by requiring an index into the corresponding oracle in the input.
Instances For
spec₁ * spec₂ represents an oracle that takes in a pair of inputs for each set,
and returns an element in the output of one oracle or the other.
The corresponds exactly to multiplication in PFunctor.
Given an indexed set of OracleSpec, specify access to an oracle that given an input to
the oracle for each index returns an index and an output for that index.
Instances For
Specifies access to no oracles, using the empty type as the indexing type.
Instances For
Access to a coin flipping oracle. Because of termination rules in Lean this is slightly
weaker than unifSpec, as we have only finitely many coin flips.