Composing two-party protocols #
Role-aware composition of strategies and counterparts along Spec.append, Spec.replicate,
and Spec.stateChain. Each combinator dispatches on the role at each node (sending or receiving)
to compose the two-party strategies correctly.
For binary composition, compWithRoles and Counterpart.append use Transcript.liftAppend
for the output type (factored form). The flat variants (compWithRolesFlat,
Counterpart.appendFlat) take a single output family on the combined transcript.
A lawful monad whose independent effects may be swapped.
This is the exact extra structure needed for the sequential-composition execution theorems once both sides may perform effects after a sender move is observed: the composed prover may prepare suffix state before the counterpart finishes its sender-side observation, so proving the usual factorization law requires commuting those independent effects.
- seq_assoc {α β γ : Type u} (x : m α) (g : m (α → β)) (h : m (β → γ)) : h <*> (g <*> x) = Function.comp <$> h <*> g <*> x
Instances
Compose role-aware strategies along Spec.append with a two-argument output family
lifted through Transcript.liftAppend. The continuation receives the first phase's
output and produces a second-phase strategy.
Instances For
Compose role-aware strategies along Spec.append with a single output family
on the combined transcript. The continuation indexes via Transcript.append.
Instances For
Extract the first-phase role-aware strategy from a strategy on a composed
interaction. At each first-phase transcript tr₁, the remainder is the
second-phase strategy with output indexed by Transcript.append.
Instances For
Recompose a role-aware strategy from its prefix decomposition.
Compose counterparts along Spec.append with a two-argument output family
lifted through Transcript.liftAppend. The continuation maps the first phase's
output to a second-phase counterpart.
Instances For
Compose counterparts along Spec.append with a single output family on the
combined transcript. The continuation indexes via Transcript.append.
Instances For
Counterpart.append equals appendFlat composed with mapOutput packAppend.
This lets proofs that decompose an arbitrary strategy via splitPrefixWithRoles +
appendFlat still work when Reduction.comp uses the non-flat append.
Compose per-node-monad counterparts along Spec.append with a two-argument
output family lifted through Transcript.liftAppend. At each node, the recursive
composition is lifted through the node's BundledMonad via Functor.map.
Instances For
Executing a flat composed strategy/counterpart factors into first executing the prefix interaction and then executing the suffix continuation.
Executing a flat composed strategy/counterpart factors into first executing the prefix interaction and then executing the suffix continuation.
Executing a factored composed strategy/counterpart (using compWithRoles and
Counterpart.append) factors into first executing the prefix interaction and then
executing the suffix continuation. Outputs are transported via packAppend.
Role swapping commutes with replication.
n-fold counterpart iteration on spec.replicate n, threading state β
through each round.
Instances For
n-fold role-aware strategy iteration on spec.replicate n, threading state α
through each round.
Instances For
Compose counterparts along a state chain with stage-dependent output. At each stage,
the step transforms Family i s into a counterpart whose output is
Family (i+1) (advance i s tr). The full state chain output is
Transcript.stateChainFamily Family.
Instances For
Compose role-aware strategies along a state chain with stage-dependent output.
At each stage, the step transforms Family i s into a strategy whose output is
Family (i+1) (advance i s tr). The full state chain output is
Transcript.stateChainFamily Family.
Instances For
Compose per-node-monad counterparts along a state chain with stage-dependent output.
At each stage, the step transforms Family i s into a counterpart whose output is
Family (i+1) (advance i s tr). The full state chain output is
Transcript.stateChainFamily Family.