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.toFLTS: the underlying functional labelled transition system (Cslib.FLTS) of state transitions.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.fst_run_eq_toFLTS_mtr: the state component ofSpec.runagrees withFLTS.mtr.Spec.run_append,Spec.validHistory_append,Spec.totalCost_append: history composition laws.Spec.totalCost_le_length_mul,Spec.totalCost_const,Spec.totalCost_one: uniform and constant history charge bounds.Spec.validHistory_of_forall_valid: total interfaces have no history admissibility obligations.Spec.run_runClient: the history recorded bySpec.runClientreaches the computed final state.Spec.runClient_bind,eval_bind: sequential composition preserves state, answers and history order.eval_eq_liftM:evalagrees withPFunctor.FreeM.liftMintoStateM.
References #
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 empty history is admissible in every state.
Total interfaces have no history admissibility obligations.
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.
eval agrees with interpreting the free monad into StateM D.State via PFunctor.FreeM.liftM
when states, operation answers, and client results share a universe.
Two independent abstract components. A backend must separately justify their independence.