Resource contracts across stateful interfaces #
A client contract combines admissibility, a postcondition and a bound on state-dependent operation charges. Semantic modules transport these contracts using separate method budgets; native realizations then interpret the charges as additive measures of execution evidence. This supports proofs at several interface levels without choosing a backend in the client proof.
These are operation-cost contracts. Pure results and host-language continuations incur no charge in this interpretation. A total machine-time theorem additionally needs certificates for the controller, argument preparation and result decoding. Existence of native executions does not assert that every execution of a nondeterministic backend terminates.
Main definitions #
Spec.CostHoare: a semantic client contract with an initial-state-dependent budget.Module.ChargeBound: lower method costs are bounded by upper operation charges.
Main results #
Spec.CostHoare.bind: compose contracts using an intermediate postcondition.Module.ChargeBound.client: transfer costs along an adaptive linked client.Module.ChargeBound.comp: compose resource certificates through hidden representations.Spec.CostHoare.link: transport a contract to a lower interface.Spec.CostHoare.realize,Spec.CostHoare.run: native correctness, bounds and existence.
Admissibility and a postcondition, together with a bound on charged operations. The budget is evaluated at the initial state; it does not charge pure Lean computation.
Instances For
Forget the resource bound while retaining semantic correctness.
Returning a value has zero operation cost.
A call exposes its specified answer and charges the supplied operation budget.
Compose budgets at the intermediate abstract state, retaining answer-dependent costs.
Strengthen the precondition and weaken the postcondition or budget.
Every supplied native execution satisfies the contract and its interpreted resource bound.
A represented initial state has a native execution meeting the contract and budget.
Method budgets compose along the actual answer-dependent history of a client.
Resource refinements compose while keeping the intermediate representation hidden.
A method budget and a lower native certificate supply an upper native certificate.
Transport a client contract and its budget across an interface implementation.