Continuation-style chains (Spec.Chain) #
A Chain n is a self-contained recipe for an n-round protocol:
at each level it carries the current round's Spec and a transcript-indexed
continuation to the next level. There is no external state type, no
Stage : Nat → Type, and no round index family.
Converting to a Spec via Chain.toSpec uses only Spec.append.
State-machine constructions are derived: Chain.ofStateMachine
builds a chain from (σ, step, next, s₀) and then forgets σ.
Main definitions #
Spec.Chain— depth-indexed telescope: round spec + continuation.Spec.Chain.toSpec— convert a chain into a concreteSpec.Chain.replicate— constant rounds (recoversSpec.replicate).Chain.ofStateMachine— build from a state machine (recoversSpec.stateChain).
Three composition mechanisms #
| Mechanism | State? | Transcript-dependent? | Use when |
|---|---|---|---|
Spec.replicate | No | No | Uniform rounds (same spec, independent) |
Spec.stateChain | Yes (Stage i) | Yes | State machine with explicit state type |
Spec.Chain | No (baked in) | Yes | Continuation-style, no external state |
Chain is the most fundamental: it requires no external state type, yet
supports full transcript dependence. stateChain is a specialization
(recovered by Chain.ofStateMachine), and replicate is a further
specialization (recovered by Chain.replicate).
Toy examples #
The GrowingMessages section builds a protocol whose message type grows
at each step (Fin 1, Fin 2, …) without mentioning any state type.
A self-contained recipe for an n-round protocol. At each level,
carries the current round's Spec and, for each possible transcript,
the recipe for the remaining rounds. No external state type.
Instances For
Convert a chain into a concrete Spec via iterated append.
Instances For
Constructors #
Constant rounds: same spec every round, continuation ignores the transcript.
Instances For
Build a chain from a state machine. The state σ is consumed
during construction and does not appear in the resulting Chain.
Instances For
Bridge to existing API #
Converting a state-machine chain recovers Spec.stateChain with
constant stage family and round index erased.
Transcript operations #
Split a transcript of an (n+1)-round chain into the first round's
transcript and the remainder.
Instances For
Combine a first-round transcript with a remainder.
Instances For
Strategy composition #
Output family for strategy composition along a chain. This is the intrinsic analog of
Transcript.stateChainFamily: a family on the remaining chain is lifted to a family on
transcripts of the flattened Spec.
Instances For
Compose strategies along a chain with a transcript-dependent output family. The step function sees the current round spec packaged as the remaining chain, and returns the next family member indexed by the transcript of that round.