Runtime execution semantics for open processes #
This file bridges the structural OpenProcess layer to the bundled
sub-probabilistic semantics (UC.Semantics) by defining how to execute
a closed process.
The core runtime primitives (Spec.Sampler, sampleTranscript,
StepOver.sample, ProcessOver.runSteps) are parameterized by an
arbitrary monad m : Type → Type. This generality lets the execution
intermediate monad carry additional capabilities, such as shared oracle
access (random oracles, CRS, …), while the bundled
SPMFSemantics m fixes how those capabilities are collapsed into the
externally visible SPMF Unit.
Common instantiations:
m = ProbCompwithsem := SPMFSemantics.ofHasEvalSPMF ProbCompfor coin-flip-only protocols. UseprocessSemanticsProbComp.m = OracleComp (unifSpec + roSpec)with a hand-rolledSPMFSemanticswhose internal monad isStateT σ ProbCompand whose interpreter issimulateQ' impl. UseprocessSemanticsOraclefor protocols in the random oracle model, whereimplcombines aunifSpecidentity lift withrandomOracle(or anyQueryImpl).Observation-style semantics that deliberately carry failure mass, for example
m = OptionT ProbCompwithSPMFSemantics.ofHasEvalSPMF (OptionT ProbComp). This is what cryptographic smoke tests (OTP-style privacy, guess games) use so that theguardbranch contributes a real failure mass to the resultingSPMF Unit.
Main definitions #
Spec.Sampler m specprovides anm Xcomputation at each node of aSpectree, resolving each move in the intermediate monad.Spec.sampleTranscriptexecutes a sampler to produce a full transcript inm.StepOver.sampleruns one step by sampling a transcript and applying the continuation.ProcessOver.runStepsiteratessamplefor a fixed number of steps.UC.processSemanticsconstructs aSemantics (openTheory Party)from a bundledSPMFSemantics m, an initial state, a step sampler, a fuel count, and an observation function. The resulting semantics observes closed systems throughsem.evalDist.UC.processSemanticsProbCompis the specialization form = ProbCompwith its canonicalSPMFSemantics.UC.processSemanticsOracleconstructs semantics for protocols with shared oracle access, collapsing the oracle layer throughsimulateQ'.
Universe constraints #
The runtime layer requires the spec and state type universes to be 0,
since ProbComp : Type → Type operates in Type. This is satisfied by
concrete protocols whose move types and state types live in Type.
Uniform selection from a nonempty finite type as a ProbComp primitive,
realized by reducing to uniform selection on Fin (Fintype.card X) via the
classical equivalence Fintype.equivFin. This is the tree-node analogue of
PMF.uniformOfFintype, landing in ProbComp so that it can be plugged
directly into per-node components of a Sampler ProbComp spec.
Instances For
Canonical uniform sampler on a Spec.Fintype-ornamented spec, built by
recursion on the ornament: each node samples uniformly from its move
space using probCompUniformOfFintype, and the continuation samplers
are produced recursively from the per-branch ornament.
This is the interaction-spec analogue of SampleableType for
OracleSpec: concrete spec trees whose move types all carry Fintype
and Nonempty synthesize an instance of Spec.Fintype spec
automatically, yielding Sampler.uniform spec as the canonical
coin-flip-only sampler for downstream runtime semantics
(processSemanticsProbComp, etc.).
Instances For
Instance-argument form of Sampler.uniform.
Instances For
Smoke test: typeclass synthesis builds a Spec.Fintype instance for a
concrete spec, and Sampler.uniformI elaborates against it.
Run one step of a ProcessOver by sampling a transcript from the step's
spec and applying the continuation to get the next state.
Instances For
Run fuel steps of a process, starting from state s, using a
state-dependent sampler at each step.
Instances For
Construct a Semantics for the open-process theory, parameterized by a
surface execution monad m together with a bundled SPMFSemantics m.
The execution runs entirely in m: per-step samplers come from the
OpenProcess's stepSampler field, multi-step iteration threads them,
and the observer extracts the final judgment as an m Unit value. The
bundled sem then collapses the m Unit game into a SPMF Unit via
Semantics.evalDist.
See processSemanticsProbComp for the coin-flip-only specialization
and processSemanticsOracle for the shared-oracle specialization.
Instances For
processSemanticsProbComp is the specialization of processSemantics
for m = ProbComp with its canonical SPMFSemantics
(SPMFSemantics.ofHasEvalSPMF).
This is the right entry point for coin-flip-only protocols with no
shared oracles and no deliberate failure mass.
Instances For
processSemanticsOracle constructs semantics for protocols with shared
oracle access (random oracles, CRS, etc.).
The surface monad is OracleComp superSpec, where superSpec describes
all oracles available during execution. The bundled SPMFSemantics
interprets those oracle queries by simulateQ' impl into
StateT σ ProbComp, initializing the oracle state to initOracle and
projecting onto the output to obtain the final SPMF Unit.
For a protocol in the random oracle model, a typical instantiation is:
superSpec := unifSpec + (D →ₒ R)(uniform sampling plus hash oracle)impl := HasQuery.toQueryImpl.liftTarget _ + randomOracle(identity onunifSpec, lazy-cached on the hash)initOracle := ∅(empty random oracle cache)