Total certification and conditional proof rules
Library · Source module
Total certification and conditional proof rules
The canonical certificate is NLAlib.Ops.Algorithm: one fixed program, jointly realized contracts and successful execution with mandatory full accounting. The conditional judgments below are the proof calculus used to build it; a raw ConditionalRuns, ConditionalRunsL or Impl.Satisfies theorem is not that certificate.
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. In detail:
* NLAlib.Ops.Routine.Meets (NLAlib/Ops/Routine.lean) is also what a caller uses: a tree with an interface meets a specification. * Operation models are made of NLAlib.Ops.Interp.Satisfies statements. * NLAlib.Ops.Impl.Satisfies E I md C, the implementation E satisfies the contract C over the interpretation I, is the second statement with the call replaced by the run of a tree. It is obtained from a routine judgment (NLAlib.Ops.Routine.Meets.satisfies), not stated by authors. The two are exchanged by linking:
* grounding (NLAlib.Ops.Interp.link_satisfies): if the implementation of o in a table satisfies C over I, then the operation o of the induced interpretation satisfies C. An algorithm that is certified this way is an operation for the algorithms above it. * the bridge (NLAlib.Ops.Impl.Satisfies.runs, NLAlib.Ops.Impl.Satisfies.runs_rel): a satisfaction statement in total mode gives the top-level statement NLAlib.Ops.ConditionalRuns, with the static counts and workspace of the tree. The hypotheses on handles and operands are those of the contract, once.
Such a statement is introduced in operand form through NLAlib.Ops.Impl.satisfies_rel (from the blocks that are read) or, for an exact one, NLAlib.Ops.Impl.satisfies_fn_of_run (the run of the tree is the block function).
A satisfaction statement in liberal mode says nothing of success: an implementation that fails satisfies every contract (NLAlib.Ops.Impl.satisfies_liberal_abort, NLAlib.Ops.Interp.link_satisfies_liberal_of_abort). A liberal statement is never a result by itself. Algorithm requires total correctness in its own type, rather than looking up a separately named success theorem.
Main results
* NLAlib.Ops.Impl.Satisfies: a tree implements the contract of an operation. * NLAlib.Ops.Interp.link_satisfies, NLAlib.Ops.Interp.link_satisfies_kept, NLAlib.Ops.Interp.link_isFn: grounding. * NLAlib.Ops.Impl.Satisfies.runs, NLAlib.Ops.Impl.Satisfies.runs_rel, NLAlib.Ops.Impl.Satisfies.runsL: the bridge to the top-level statements. * NLAlib.Ops.Interp.IsFn.satisfies_rel: a functional operation satisfies a relational contract that its values satisfy.
Declarations
- NLAlib.Ops.Algorithm
- NLAlib.Ops.Algorithm.body_ne_abort
- NLAlib.Ops.Algorithm.correct_exec
- NLAlib.Ops.Algorithm.link
- NLAlib.Ops.Algorithm.mapPost
- NLAlib.Ops.Algorithm.not_nonempty
- NLAlib.Ops.Algorithm.ofWp
- NLAlib.Ops.Algorithm.run
- NLAlib.Ops.Algorithm.run_ne_none
- NLAlib.Ops.Algorithm.wellTyped
- NLAlib.Ops.Impl.Satisfies
- NLAlib.Ops.Impl.Satisfies.runs
- NLAlib.Ops.Impl.Satisfies.runsL
- NLAlib.Ops.Impl.Satisfies.runs_rel
- NLAlib.Ops.Impl.satisfies_fn_of_run
- NLAlib.Ops.Impl.satisfies_liberal_abort
- NLAlib.Ops.Impl.satisfies_rel
- NLAlib.Ops.Interp.IsFn.satisfies_rel
- NLAlib.Ops.Interp.IsFn.satisfies_rel_of_pre
- NLAlib.Ops.Interp.link_isFn
- NLAlib.Ops.Interp.link_satisfies
- NLAlib.Ops.Interp.link_satisfies_kept
- NLAlib.Ops.Interp.link_satisfies_liberal_of_abort
- NLAlib.Ops.Program.Certifies.map_post