NLA-lib Explorer

Contracts

Library · Source module

Contracts

A contract is a precondition and a postcondition for a call, on the memory (NLAlib.Ops.OpSpec, NLAlib.Ops.Contract). An interpretation satisfies it in a mode (NLAlib.Ops.Interp.Satisfies): in total mode the call succeeds and the postcondition holds, in liberal mode the postcondition holds if the call succeeds. A contract receives the mode, so that one statement serves both: what is needed only for success is put under NLAlib.Ops.Mode.Needs.

A contract does not receive the tape. It declares a stream and the length of a window, and it is given the entries of that window at the position of the call, and nothing else of the tape.

Every contract of the library is written in operand form, NLAlib.Ops.BlockRel (file NLAlib.Ops.BlockRel): functional, relational and with a window are one structure.

A contract says nothing of counts, workspaces or the tape positions an operation may read: those are fixed by the evaluator and the access model (NLAlib.Ops.evalCounted, NLAlib.Ops.Interp.TapeLocal).

The exactness of tests and index conversions is imposed by the access model (NLAlib.Ops.Interp.IsTest, NLAlib.Ops.Interp.IsIndex); a conversion may fail.

The three statements of the layer, NLAlib.Ops.Routine.Meets, NLAlib.Ops.Interp.Satisfies and NLAlib.Ops.Impl.Satisfies, and their roles are described once, in NLAlib/Ops/README.md ("Three statements") and the header of NLAlib/Ops/Routine.lean.

Main results

* NLAlib.Ops.Interp.Satisfies: an operation satisfies a contract, stated with the call of the interpretation, the liveness of its operands and the unchanged shape of the store. * NLAlib.Ops.Interp.satisfies_total_iff: the statement in total mode. * NLAlib.Ops.Interp.satisfies_iff_callS, NLAlib.Ops.Interp.Satisfies.callS, NLAlib.Ops.Interp.Satisfies.of_callS: the form through the call of the evaluator, which the program logic uses. * NLAlib.Ops.Interp.Satisfies.mono: weakening.

Declarations