Query Implementations with State Monads #
This file gives lemmas about QueryImpl spec m when m is something like StateT σ n.
TODO: should generalize things to MonadState once laws for it exist.
Push an outer oracle interpretation through the base monad of a
StateT-valued query implementation.
Instances For
Running a StateT handler and then interpreting its base oracle
computations is the same as first mapping the handler's base through the
outer interpreter.
Output-only corollary of simulateQ_mapStateTBase_run.
Given implementations for oracles in spec₁ and spec₂ in terms of state monads for
two different contexts σ₁ and σ₂, implement the combined set spec₁ + spec₂ in terms
of a combined σ₁ × σ₂ state.
Instances For
Reassociate a nested state transformer into one product state.
The outer state is the first component of the product; the inner/base state is the second component. This is the state-transformer analogue of reassociating handler stacks into an explicit joint state before applying projection lemmas.
Instances For
Indexed version of QueryImpl.parallelStateT. Note that m cannot vary with t.
dtumad: The Function.update thing is nice but forces DecidableEq.
Instances For
Lift a stateful query implementation to a (state × Bool)-stateful version that threads
the boolean (bad) flag unchanged. The output value and updated state come from the
underlying impl; the second Bool component is preserved verbatim across each query.
Instances For
Lift a stateful query implementation to a (state × Bool)-stateful version that OR-updates
the boolean (bad) flag with a predicate f evaluated on the pre-state and produced output.
The flag is monotone: if it was already true, it stays true.
Instances For
Run-shape of withBadFlag: the lifted implementation maps the underlying run by tagging
each (value, state) pair with the unchanged bad flag b.
Run-shape of withBadUpdate: the lifted implementation maps the underlying run by
appending the OR-updated bad flag b || f t s vs.1.
If the state type is Subsingleton, then we can represent simulation in terms of simulate',
adding back any state at the end of the computation.
Running a computation under a flattened nested-state implementation is the same as running the original nested computation and reassociating the final states into a product.
Output-only corollary of simulateQ_flattenStateT_run.
Running an adversary-side StateT handler under an outer stateful
interpreter produces the same distribution as the flattened product-state
handler, up to reassociating ((output, localState), outerState) and
(output, (localState, outerState)).