Stateful specifications and adaptive clients #
Specifications describe mathematical states, typed operations and admissibility. Clients use
Quang Dao's upstream PFunctor.FreeM; continuations may depend on earlier answers. The state
interpreter and its histories have no computational-model or performance claim. In particular,
pure Lean computation in continuations is not charged as a machine instruction.
Main definitions #
Spec: stateful operation semantics with typed answers and admissibility.Spec.run: the final state and typed observation trace of a history.Spec.ValidHistory: each operation of a history is admissible in the state it reaches.Spec.totalCost: state-dependent charges summed along a history.Spec.signature: the polynomial functor of operations and their observation types.Spec.Client: terminating, potentially infinitely branching adaptive clients.Spec.runClient: mathematical interpretation with the selected operation history.eval: the result and final state of a client, without its history.product: independent abstract components; concrete independence is a realization obligation.
Main results #
Spec.runClient_bind: sequential composition preserves state, answers and history order.Spec.totalCost_append: state-dependent charges compose along a history.
A deterministic abstract state machine with operation-dependent observations. Only admissible operations are constrained by refinement certificates.
- State : Type u
Mathematical states, independent of a storage representation.
- Op : Type v
Operations available to clients.
The observation type returned by each operation.
The specified state transition and observation.
Preconditions under which an operation's implementation must satisfy its contract.
Instances For
The polynomial operation signature, shared with upstream effectful programs.
Instances For
An adaptive client: each continuation may depend on the observed answer. Inductive clients have no infinite execution branch; branching need not be finite.
Instances For
Admissibility splits at the mathematical state reached by the first history.
Two independent abstract components. A backend must separately justify their independence.
Instances For
Total interfaces have no history admissibility obligations.