Implementing Oracle Queries in Other Monads #
This file defines a type QueryImpl spec m to represent implementations
of queries to spec in terms of the monad m.
Specifies a way to implement queries to oracles in spec using the monad m.
This is defined in terms of a mapping of input elements to oracle outputs,
which extends to a mapping on OracleQuery spec by copying over the continuation,
and then further to OracleComp spec by preserving the pure and bind operations.
See QueryImpl.map_query and HasSimulateQ for these two operations.
Instances For
Two query implementations are the same if they are the same on all query inputs.
Embed an oracle query into a new functor by applying the implementation to the input value before applying the continuation of the element.
Instances For
Gadget for auto-adding a lift to the end of a query implementation.
Equations
- QueryImpl.liftTarget n impl t = liftM (impl t)
Instances For
Lifting an implementation to the original monad has no effect.
Identity implementation for queries, sending q : OracleQuery spec α to itself.
Equations
Instances For
Version of QueryImpl.id that automatically lifts into OracleComp spec rather than
just implementing queries in the lower level OracleQuery spec monad
Equations
- QueryImpl.id' spec = QueryImpl.liftTarget (OracleComp spec) (QueryImpl.id spec)
Instances For
Given that queries in spec lift to the monad m we get an implementation via lifting.
Equations
- QueryImpl.ofLift spec m t = liftM (OracleQuery.query t)
Instances For
View a function from oracle inputs to outputs as an implementation in the Id monad.
Can be used to run a computation to get a specific value.
Equations
- QueryImpl.ofFn f = f
Instances For
Version of ofFn that allows queries to fail to return a value.
Equations
- QueryImpl.ofFn? f = f
Instances For
Implement a single oracle as evaluation of a Polynomial.
Equations
- QueryImpl.ofPolynomial p = QueryImpl.ofFn fun (t : R) => Polynomial.eval t p
Instances For
Implement a single oracle as the evaluation of an `MvPolynomial.
Equations
- QueryImpl.ofMvPolynomial p = QueryImpl.ofFn fun (t : σ → R) => (MvPolynomial.eval t) p
Instances For
Implement a single oracle as indexing into a Vector.
Equations
- QueryImpl.ofVector v = QueryImpl.ofFn fun (t : Fin n) => v[t]
Instances For
Oracle context for ability to query elements of a vector v.
Equations
- QueryImpl.ofListVector v = QueryImpl.ofFn fun (t : Fin n) => v[t]