State-Projection Lemmas for simulateQ #
This file collects the equational state-projection theorems for simulateQ over StateT-valued
query implementations. They are pure equalities on distributions, with no relational, coupling, or
TV-distance content, and so live at the SimSemantics layer alongside StateT.lean rather than in
ProgramLogic.
Main results #
OracleComp.map_run_simulateQ_eq_of_query_map_eq(and its_inv'variant): if every oracle step ofimpl₁becomes the correspondingimpl₂step after mapping the state byproj, then the full simulation does too.OracleComp.run'_simulateQ_eq_of_query_map_eq(and variants): therun'(output-only) projection corollaries.QueryImpl.StateOrnament: a package for the recurring pattern where one stateful handler refines another by carrying extra bookkeeping state.QueryImpl.fixSndStateT+OracleComp.simulateQ_run_eq_of_snd_invariant: support-based decomposition for product state spaces where one component is invariant.QueryImpl.extendState+OracleComp.extendState_run_proj_eq: auxiliary-state lift, the inverse direction offixSndStateT.
Layering #
This file is below ProgramLogic and is depended on by both ProgramLogic/Relational/SimulateQ
(which proves the genuinely relational corollaries) and OracleComp/QueryTracking/* files that
need to project away bookkeeping state from cached / programmed / seeded oracles.
State-projection: all states #
State-projection transport for simulateQ.run.
If each oracle call under impl₁ becomes the corresponding impl₂ call after mapping the state
with proj, then the full simulated runs agree under the same projection.
run' projection corollary of map_run_simulateQ_eq_of_query_map_eq.
State-projection: invariant-gated #
Invariant-gated state-projection theorem: if proj commutes with each oracle
step under a state invariant inv that is preserved by every step, then it
commutes with the full simulation starting from any state satisfying inv. This
is the natural strengthening of map_run_simulateQ_eq_of_query_map_eq for
projections that only agree on a reachable subset of states.
Query-step invariant preservation lifts to any full simulation. This is the
support-preservation half of map_run_simulateQ_eq_of_query_map_eq_inv',
exposed separately for projected continuations after a simulated prefix.
Invariant-gated state-projection theorem for a simulated prefix followed by a stateful continuation.
run' projection corollary of map_run_simulateQ_eq_of_query_map_eq_inv'.
A state ornament packages the data needed to project a decorated stateful query implementation onto a base implementation.
The decorated implementation may carry extra bookkeeping state. The projection
only needs to commute with each query on states satisfying inv, and inv must
be preserved by each query step.
- inv : σ → Prop
- proj : σ → τ
Instances For
A state ornament projects full simulations of the decorated implementation onto simulations of the base implementation.
Output-only corollary of QueryImpl.StateOrnament.run_eq.
Fixing one component of a product state #
If the Q-component of product state (σ × Q) is invariant under all oracle queries
starting from q₀, then the full simulateQ computation decomposes: running with (s, q₀)
produces the same result as running the projected implementation on s alone, with q₀
appended back.
This generalizes map_run_simulateQ_eq_of_query_map_eq from all-states commutativity to
support-based invariance.
run' projection corollary of simulateQ_run_eq_of_snd_invariant.
Extending state with an auxiliary component #
Extend a stateful query implementation with an auxiliary state component Q.
The base implementation runs on the σ component. The auxiliary update may inspect the query
input, the pre-state, the produced output, the post-state, and the old auxiliary value.
Inverse direction of QueryImpl.fixSndStateT: extendState adds a passive auxiliary, while
fixSndStateT projects one away. Together they witness the universal property of the product
state space.
Instances For
Extend a stateful query implementation with an auxiliary component on the
left of the product state. This is the same construction as extendState, but
it matches handlers whose state is ordered as (auxiliary, baseState).
Instances For
Forgetting the auxiliary Q component commutes with the full simulation.
Running so.extendState aux and projecting away the Q component agrees with running so
directly on the σ component, irrespective of the initial Q value or the auxiliary update.
This is the universal-property statement: the Q component is genuinely passive in the sense
that it does not influence the σ-side of the simulation.
run' projection corollary of extendState_run_proj_eq: dropping both the auxiliary Q
and the σ state of the extended simulation gives the same output distribution as the base
simulation.
Forgetting the left auxiliary Q component commutes with the full
simulation. This is the left-product analogue of extendState_run_proj_eq.
run' projection corollary of extendStateLeft_run_proj_eq.