Asynchronous runtime semantics for env-open processes #
This file defines the asynchronous-execution layer of the UC framework.
The runtime alternates between process steps (processTick) and
environment-driven events (envTick e) according to a pair of
schedulers; the alphabet of env events is supplied by an
EnvAction Event State (see EnvAction.lean).
The shape of every definition mirrors the synchronous processSemantics
in Runtime.lean: the bundled SPMFSemantics m is threaded uniformly,
so the same constructor serves coin-flip-only protocols, shared-oracle
protocols, and observation-style semantics that introduce failure mass.
The synchronous runtime is the special case in which the env scheduler
always returns processTick and the env alphabet is empty;
processSemantics_eq_processSemanticsAsync_trivial records that
equivalence by name, with processSemanticsProbComp_eq_processSemanticsAsyncProbComp_trivial
giving the ProbComp-specialized form most coin-flip-only protocol
developments will reach for.
Main definitions #
RuntimeEvent Event/RuntimeTrace Event— the observable trace alphabet, a sum ofprocessTickandenvTick e.AsyncRuntimeState Proc State— the joint state threaded through async execution: the residual process state plus the env-action bookkeeping state.ProcessScheduler/EnvScheduler— the two sibling samplers driving the async runtime. The process scheduler reuses the existingSpec.Sampler mfromRuntime.lean; the env scheduler is a separate monadic choice overRuntimeEvent.Concurrent.runStepsAsync— the recursive engine. MirrorsConcurrent.ProcessOver.runStepsfromRuntime.lean, with explicit env-event interleaving.UC.processSemanticsAsync— the headlineSemanticsconstructor.UC.processSemanticsAsyncProbComp— the coin-flip-only specialization, companion toprocessSemanticsProbComp.trivialEnvScheduler— the env scheduler that always returnsprocessTick.
Universe constraints #
The runtime layer requires move types, state types, and the env-event
alphabet to live at universe 0, so that ProbComp and the runtime
monad m : Type → Type fit. This is strictly stronger than the data
layer in EnvAction.lean (which is generic in Event : Type uE)
because the runtime needs m (RuntimeEvent Event) to typecheck, and
m : Type → Type forces RuntimeEvent Event : Type and hence
Event : Type. Concrete env-event alphabets such as
MomentaryCorruption.Alphabet Sid Pid (with Sid Pid : Type) live at
universe 0, so this is not a restriction in practice. The same
universe-0 constraint applies to processSemantics.
Runtime trace alphabet #
One tick of the async runtime: either a process step (no payload, the
actual move is sampled inside the Spec-driven procScheduler) or an
environment event carrying its alphabet symbol.
The sum is non-symmetric on purpose: processTick carries no payload
because the move space at a process step is determined by the process's
Spec, not by the runtime trace; envTick carries the alphabet symbol
because the EnvAction.react reaction is keyed by the symbol.
- processTick {Event : Type} : RuntimeEvent Event
- envTick {Event : Type} (e : Event) : RuntimeEvent Event
Instances For
Instances For
The complete observable trace of one async run.
Async-runtime distributional reasoning compares distributions over
RuntimeTrace × Result, so this is the type forwarding and healing
lemmas work over.
Instances For
Joint runtime state #
Joint state threaded through async execution: the residual process state plus the env-action's bookkeeping state.
The runtime treats this structure opaquely through the ProcessScheduler
and EnvScheduler signatures, so a future reactive variant that adds
per-port pending packet queues (and possibly a queue of pending env
events) can extend this structure without invalidating the scheduler
APIs.
- proc : Proc
The residual process state.
- envState : State
The env-action bookkeeping state.
Instances For
Schedulers #
A process scheduler picks a process-side Spec.Sampler at each step,
parameterized by the joint async-runtime state.
The sampler-side type Spec.Sampler m (specOf st) is the existing one
from Runtime.lean, unchanged. The extra AsyncRuntimeState-dependent
argument lets a scheduler refuse to schedule, e.g., a corrupted
machine's tick.
Instances For
An env scheduler chooses the next runtime event in the monad m.
Returning processTick yields control back to the process layer;
returning envTick e fires e against the env-action. This is the
sibling channel to ProcessScheduler: security definitions over the
async runtime quantify over both schedulers, so that the typed split
between adversary-controlled process scheduling and
environment-controlled env scheduling is preserved.
Instances For
The trivial env scheduler that always returns processTick.
Instantiating processSemanticsAsync at this scheduler with the empty
env alphabet recovers the synchronous processSemantics; see
processSemantics_eq_processSemanticsAsync_trivial.
Instances For
Async core engine #
Async core engine. Iterates fuel ticks, alternating between process
samples and env reactions according to envScheduler. Returns the
final joint state and the observable runtime trace.
Mirrors the recursion shape of Concurrent.ProcessOver.runSteps with
explicit env-event interleaving. The env reaction lives in ProbComp
(EnvAction.react : Event → State → ProbComp State) and is lifted into
the runtime monad m via MonadLiftT ProbComp m. The process sampler
type is unchanged from the synchronous runtime: the
ProcessScheduler carries the existing Spec.Sampler m from
Runtime.lean.
Instances For
Under the empty env alphabet (EnvAction.empty Unit) and the trivial env
scheduler (always processTick), runStepsAsync reduces to
ProcessOver.runSteps with the env state pinned to () and a constant
processTick trace.
This is the operational core of the sync-recovery story: it factors the
async engine into the synchronous ProcessOver.runSteps plus a trivial
trace bookkeeping pass, and is reused by
UC.processSemantics_eq_processSemanticsAsync_trivial.
Construct an async Semantics for the open-process theory.
Threads an env-action channel and an env scheduler. The per-step
process sampler is obtained directly from the closed process's
stepSampler (keyed by the underlying process state, ignoring any
async env state). The bundled SPMFSemantics m plays the same role as
in processSemantics and supports the same instantiations:
coin-flip-only protocols via processSemanticsAsyncProbComp,
shared-oracle protocols via an OracleComp-monad SPMFSemantics built
with simulateQ', and observation-style semantics over
OptionT ProbComp.
The init and envScheduler arguments are quantified over the closed
process p : Closed Party, matching the shape of the synchronous
processSemantics.
Instances For
Coin-flip-only specialization of processSemanticsAsync (m = ProbComp,
sem := SPMFSemantics.ofHasEvalSPMF ProbComp). Companion of
processSemanticsProbComp.
Instances For
Sync recovery #
The synchronous processSemantics is the special case of
processSemanticsAsync instantiated at:
- the empty env alphabet (
EnvAction.empty Unit, with stateUnit); - the trivial env scheduler (always returns
processTick); - an
observethat ignores the env state and the trace.
The proof factors through Concurrent.runStepsAsync_empty_trivial_eq,
which collapses the async engine to ProcessOver.runSteps together with
a constant processTick trace; the observe-side argument then drops the
trace and the unit env state.
The ProbComp specialization of processSemantics_eq_processSemanticsAsync_trivial:
the synchronous processSemanticsProbComp equals the trivial async lift built
from processSemanticsAsyncProbComp with the empty env alphabet, the trivial
env scheduler, and an observe that ignores the env state and the trace.
This is the form most coin-flip-only protocol developments will reach for: it
discharges the m/close/MonadLiftT choices the general theorem leaves
abstract, leaving only the protocol-specific data (init, sampler, fuel,
observe) on each side of the equation.