NLA-lib Explorer

Example: a partial-correctness corollary through the induced interpretation

Library · Source module

Example: a partial-correctness corollary through the induced interpretation

div is implemented by t := recip y; z := x * t, and recip fails on a word that decodes to zero. The contract of div (NLAlib.Ops.Examples.divSpec) is mode-generic: readability of the operands and a nonzero divisor are needed only for success (Mode.Needs), and are conclusions of a successful call.

Main results

* One mode-generic run lemma (NLAlib.Ops.Examples.scale_wp) gives both statements about dividing a block by a cell. Liberal (NLAlib.Ops.Examples.runsL_scale): if the run succeeds, every entry is a rounded quotient and, if the block is not empty, the divisor is not zero; nothing is assumed of the divisor. Success (NLAlib.Ops.Examples.runs_scale): on a readable block and a nonzero divisor the run succeeds, with n calls of div. * Grounding (NLAlib.Ops.Examples.div_link_liberal, NLAlib.Ops.Examples.div_link_total): the induced interpretation satisfies the contract of div, in liberal mode with no hypothesis, in total mode when the reciprocal is defined away from zero. * Corollaries for the linked program: NLAlib.Ops.Examples.runsL_scale_link by ConditionalRunsL.link (no certificate), and its success companion NLAlib.Ops.Examples.runs_scale_link by ConditionalRuns.link, with n reciprocals and n multiplications in one scratch cell. * A fixture, not a result (the last example): the liberal corollary also holds for a table whose implementation fails. A liberal statement is registered only with its success companion.

Declarations