# `ReductionBounds.ProtocolCost`
[🔗](https://github.com/zacky1972/reduction_bounds/blob/v0.1.0/lib/reduction_bounds/protocol_cost.ex#L1)

Symbolic participant budgets for finite protocol traces and their prefixes.

Each owned state/event context supplies a nonnegative expression and a
counter that counts that context. Expressions accept natural constants,
`{:charge, name}`, `{:data, slot, :bytes | :structure}`,
`{:integer, slot, :magnitude_bits}`, and `{:add | :mul | :max, left, right}`.
Size references must be required by the context's condition rule.

Contexts assigned to the same participant and counter share the maximum
local budget. The participant budget adds these maxima multiplied by the
corresponding count limits. Charge names are scoped to each participant.
Participants without modeled work events receive no budget claim.

`new/2` and `check_trace/3` validate evidence in Elixir. Use
the protocol cost proof builder and the packaged Lean sources to check the
universal safety theorems (see the proof notes and proof test). No completion, source-code, runtime
reduction, or elapsed-time guarantee follows from these symbolic budgets.

# `t`

```elixir
@type t() :: %ReductionBounds.ProtocolCost{
  bounds: map(),
  conditions: ReductionBounds.ProtocolConditions.t(),
  groups: [map()],
  rules: map(),
  unmodeled_participants: [atom()]
}
```

# `check_trace`

```elixir
@spec check_trace(t(), list(), map()) :: {:ok, map()} | {:error, term()}
```

# `evaluate`

```elixir
@spec evaluate(term(), map()) :: {:ok, non_neg_integer()} | {:error, term()}
```

Evaluates a closed participant budget using that participant's natural charges.

# `new`

```elixir
@spec new(ReductionBounds.ProtocolConditions.t(), map()) ::
  {:ok, t()} | {:error, term()}
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
