Generic Oracle Query Capability #
This file defines HasQuery spec m, a thin capability interface for monads that can issue
queries to an oracle family spec.
OracleComp spec remains the canonical free syntax for explicit oracle computations, structural
induction, and query-bound reasoning. HasQuery is the lighter interface used when a
construction only needs to ask oracle queries, without reifying or analyzing the query syntax.
The key design choice is that HasQuery is just a facade over the existing lifting story:
the primitive single-query syntax OracleQuery spec is itself a HasQuery spec instance, and
any monad that supports MonadLiftT (OracleQuery spec) m automatically gets a HasQuery spec m
instance as well. As a result, the capability composes with the existing SubSpec coercions
and with standard transformer lifts such as StateT, ReaderT, ExceptT, and WriterT.
View a concrete query implementation as query capability in the same monad. This is useful
when instantiating a generic HasQuery construction directly inside an analysis monad such as
StateT σ ProbComp or WriterT ω (OracleComp spec).
Instances For
The primitive single-query syntax OracleQuery spec has the obvious query capability.
Repackage HasQuery as a QueryImpl, for APIs that still consume explicit oracle
implementations.
Instances For
Any lawful lift of OracleQuery spec into m gives query capability in m. This is the
main bridge that makes HasQuery compose with SubSpec lifts and standard transformer lifts.
A QueryHom spec m n is a monad morphism m →ᵐ n that also preserves the distinguished
oracle-query capability for spec. This is the right notion of morphism for proving that a
construction generic over HasQuery spec is natural in the chosen oracle semantics.
Instances For
A monad morphism preserves public randomness when it commutes with the distinguished lifting of plain probabilistic computations into the ambient monad.