Finite communication models shared by Port and request/response analyses.
Each registered work event has exactly one owner and one cost unit. An environment event has neither; its occurrence describes an observation, not a bound on the environment's work. Participants may use different units. No cross-participant sum or numeric cost is computed here.
Contracts declare states, terminal states, event metadata, and transitions.
check_trace/2 checks supplied model events, including unfinished prefixes.
It does not inspect target code, prove progress, or establish runtime charges.
Cycles permit retry and inspection traces; count bounds belong to later
analysis. An accepted finite trace does not establish a bound for every run.
Example
iex> alias ReductionBounds.{PortProtocol, Protocol}
iex> {:ok, contract} = PortProtocol.new()
iex> {:ok, prepare} = Protocol.event(contract, :prepare)
iex> {:ok, trace} = Protocol.check_trace(contract, [prepare])
iex> {trace.final, trace.terminal?}
{:prepared, false}
Summary
Functions
Checks a finite trace. Event diagnostics contain a zero-based occurrence index.
Constructs an event with the contract's declared ownership and unit.
Selects event occurrences assigned to one participant without combining units.
Builds and validates a finite protocol contract.
Validates contracts, including directly constructed structs.
Functions
@spec check_trace(ReductionBounds.Protocol.Contract.t(), [ ReductionBounds.Protocol.Event.t() ]) :: {:ok, ReductionBounds.Protocol.Trace.t()} | {:error, term()}
Checks a finite trace. Event diagnostics contain a zero-based occurrence index.
@spec event(ReductionBounds.Protocol.Contract.t(), atom()) :: {:ok, ReductionBounds.Protocol.Event.t()} | {:error, term()}
Constructs an event with the contract's declared ownership and unit.
@spec events_for(ReductionBounds.Protocol.Trace.t(), atom()) :: [ ReductionBounds.Protocol.Event.t() ]
Selects event occurrences assigned to one participant without combining units.
@spec new(keyword()) :: {:ok, ReductionBounds.Protocol.Contract.t()} | {:error, term()}
Builds and validates a finite protocol contract.
Validates contracts, including directly constructed structs.