Documentation

CslibFrontier.DataStructure.StateTransition.TotalCost

Bounding the total charge of a history #

Cslib.DataStructure.StateTransitionSpec.totalCost sums state-dependent charges along a history. When each operation's charge is bounded by a weight that does not depend on the state, the total is bounded by the sum of the weights, which no longer needs the intermediate states. A client's cost then follows from counting its operations by kind.

Main results #

theorem Cslib.DataStructure.StateTransitionSpec.totalCost_le_sum_map {D : StateTransitionSpec} {f : D.State → (o : D.Op) → D.State × D.Result o} [D.HasStepFn f] (charge : D.State → D.Op → ℕ) (w : D.Op → ℕ) {s : D.State} {os : List D.Op} (h : ∀ (s : D.State), ∀ o ∈ os, charge s o ≤ w o) :
D.totalCost charge s os ≤ (List.map w os).sum

Charges bounded by state-independent weights on the operations of a history total at most the sum of the weights.