Stateful query implementations #
QueryImpl.Stateful I E σ is a thin abbreviation for handlers that implement
an export interface E by running StateT σ (OracleComp I). It is the
unbundled stateful-handler layer used by state-separating proofs: the handler
and initial state are supplied separately instead of being bundled in a package
record.
A stateful implementation of export queries E using import queries I.
QueryImpl.Stateful I E σ is the raw handler shape
QueryImpl E (StateT σ (OracleComp I)): each export query may inspect and
update private state σ, while making import queries in I.
The surrounding QueryImpl.Stateful namespace develops the state-separating
composition API for these handlers. Composition can use the canonical product
state, via link and par, or an explicit Frame that describes how two
component states are embedded as separated lawful state lenses inside a larger
state.
Instances For
State frames #
A frame specifying how two component states sit inside a larger state.
The component projections are state lenses in the sense of
PFunctor.Lens.State: each one has a getter and a putter satisfying the
standard very-well-behaved lens laws. The separated field says the two lenses
are non-interfering: each update leaves the other view unchanged, and the two
updates commute. Composition operators such as linkWith and parSumWith use
this explicit frame to run handlers over a larger state than the canonical
product state.
- left : PFunctor.Lens.State σ σ₁
Lens selecting and updating the left component state.
- right : PFunctor.Lens.State σ σ₂
Lens selecting and updating the right component state.
- left_isVeryWellBehaved : self.left.IsVeryWellBehaved
The left component lens satisfies
PutGet,GetPut, andPutPut. - right_isVeryWellBehaved : self.right.IsVeryWellBehaved
The right component lens satisfies
PutGet,GetPut, andPutPut. - separated : self.left.IsSeparated self.right
The two component lenses are non-interfering separated views of the source state.
Instances For
The canonical product-state frame.
Instances For
Reshape the result of a linked handler run back into the source state described by a frame.
The input carries an output value, the updated left component state, and the
updated right component state. The frame writes those component states back into
the original source state s.
Instances For
Basic handlers and evaluation #
The identity stateful handler forwards each query to the same interface, threading a trivial state.
Instances For
Lift a stateless implementation into a stateful implementation with trivial state.
Instances For
Run a stateful handler from an explicit initial state, discarding the final state.
Instances For
Run a stateful handler from the default initial state, discarding the final
state. This is convenient for heap states, where default = Heap.empty, and
for product states assembled from default components.
Instances For
Run a stateful handler from an explicit initial state, keeping the final state.
Instances For
Run a stateful handler from the default initial state, keeping the final state.
Instances For
A stateful handler that transparently forwards lifted queries also forwards every lifted computation.
The hypothesis is query-local: each lifted input query runs as the same query in the base interface and leaves the state unchanged. The conclusion lifts this to all computations by free-monad induction.
Transport a stateful handler along a state equivalence.
Instances For
Sequential composition #
Sequential composition of two stateful handlers using an explicit state frame.
The frame specifies how the outer state σ₁ and inner state σ₂ are viewed
and updated inside the combined state σ. The linked handler reads both
component states from the source state, runs the usual nested simulation, then
writes back the updated outer and inner states through the frame lenses.
Instances For
Sequential composition of two stateful handlers. The outer handler exports
E and imports M; the inner handler exports M and imports I.
Instances For
Structural form of linked simulation through an explicit state frame.
Structural form of linked simulation as nested simulations.
Absorb a stateful outer handler and starting state into the client computation.
Instances For
Program-level linked-game reduction with explicit initial states.
Parallel composition #
A typed routing of a named export interface into a two-component parallel composition.
Each external query is owned by exactly one component. The equivalence transports between the external response type and the selected component response type.
Instances For
The tagged component query selected by an export route.
Instances For
The canonical route for the sum of two export interfaces.
Instances For
An export route with no aliases.
This says the named external interface is injective into the tagged component query space. It is the right assumption for transporting query-count predicates from a routed interface to its component interfaces without double-counting aliases.
- target_injective : Function.Injective self.target
The route does not alias two external query names to one tagged component query.
Instances For
A named export interface that is equivalent to the sum of two component interfaces.
This is the strongest route law: every component query is exposed exactly once, and every external query is a named presentation of a tagged component query.
The query-domain equivalence induced by the route.
The route's tagged target agrees with
targetEquiv.
Instances For
Forget an equivalence route to a no-alias lawful route.
Instances For
The canonical equivalence route for the sum of two export interfaces.
Instances For
Parallel composition of two stateful handlers over a named export interface using an explicit state frame and ambient import interface.
The frame specifies where each side's private state lives in the shared source state. A left query updates only the left view, and a right query updates only the right view. The frame's separation law records that these two updates are non-interfering.
Instances For
Parallel composition of two stateful handlers over a named export interface and canonical product state.
Instances For
Parallel composition of two stateful handlers using an explicit state frame and ambient import interface. The export interface is the canonical sum.
Instances For
Routed parallel composition over an ambient import interface whose two
component import embeddings are known to have disjoint query images. The
implementation is the same as parRouteWith; the extra hypothesis is available
to downstream proofs that need sum-like import separation.
Instances For
Parallel composition of two stateful handlers using an explicit state frame and disjoint sum import and export interfaces.
Instances For
Parallel composition of two stateful handlers over disjoint sum interfaces.