Composition and instrumentation of oracle handlers #
preInsert and postInsert attach
per-query effects before answering or after successful answers. Projections that preserve
monadic composition transfer the resulting executions, supports, and finite supports.
Oracle-facing compatibility alias for PFunctor.Handler.preInsert.
Instances For
One-step characterisation of simulateQ (preInsert so nx) on a single query.
Induction principle for proj (simulateQ (so.preInsert nx) oa) parametric in a
motive OracleComp spec β → m β → Prop. The recursion structure of
proj_simulateQ_preInsert is exposed as two cases mirroring OracleComp.inductionOn:
in pure x the projected term reduces to pure x, and in query t >>= k it reduces
to so t >>= k' for some continuation k' u = proj (simulateQ (so.preInsert nx) (k u)).
Tagged @[elab_as_elim] so it is usable as induction oa using simulateQ_preInsert.induct.
Generic strip lemma: given a monad-morphism-style projection proj : ∀ {γ}, n γ → m γ
that preserves pure and bind and discards the inserted side effect on each query,
simulating with preInsert so nx and projecting back recovers simulateQ so. The proof
is the canonical use of simulateQ_preInsert.induct: the parametric motive is instantiated
to the equality with simulateQ so oa, leaving trivial cases.
When nx is constantly pure x, preInsert so nx is the lift of so and the
resulting simulation equals the lifted underlying simulation. Generic analogue of the
run_simulateQ_withTraceBefore_const_one no-op identity.
Oracle-facing compatibility alias for PFunctor.Handler.postInsert.
Instances For
One-step characterisation of simulateQ (postInsert so nx) on a single query.
Induction principle for proj (simulateQ (so.postInsert nx) oa) parametric in a
motive OracleComp spec β → m β → Prop. The recursion structure of
proj_simulateQ_postInsert is exposed as two cases mirroring OracleComp.inductionOn:
in pure x the projected term reduces to pure x, and in query t >>= k it reduces
to so t >>= k' for some continuation k' u = proj (simulateQ (so.postInsert nx) (k u)).
Tagged @[elab_as_elim] so it is usable as induction oa using simulateQ_postInsert.induct.
Generic strip lemma: given a monad-morphism-style projection proj : ∀ {γ}, n γ → m γ
that preserves pure and bind and discards the inserted side effect on each query,
simulating with postInsert so nx and projecting back recovers simulateQ so. The proof
is the canonical use of simulateQ_postInsert.induct: the parametric motive is instantiated
to the equality with simulateQ so oa, leaving trivial cases.
When nx is constantly pure x, postInsert so nx is the lift of so and the
resulting simulation equals the lifted underlying simulation. Generic analogue of the
run_simulateQ_withTrace_const_one no-op identity.