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
- NLAlib.Ops.Examples.DOp
- NLAlib.Ops.Examples.DOp.ofNat
- NLAlib.Ops.Examples.DOp.ofNat_ctorIdx
- NLAlib.Ops.Examples.IsRecipMul
- NLAlib.Ops.Examples.ROp
- NLAlib.Ops.Examples.ROp.ofNat
- NLAlib.Ops.Examples.ROp.ofNat_ctorIdx
- NLAlib.Ops.Examples.RecipModel
- NLAlib.Ops.Examples.ScalePost
- NLAlib.Ops.Examples.abortTable
- NLAlib.Ops.Examples.abs_sub_div_le
- NLAlib.Ops.Examples.divCost
- NLAlib.Ops.Examples.divImpl
- NLAlib.Ops.Examples.divSpec
- NLAlib.Ops.Examples.divSpec_post
- NLAlib.Ops.Examples.divSpec_pre
- NLAlib.Ops.Examples.divTable
- NLAlib.Ops.Examples.div_accounts
- NLAlib.Ops.Examples.div_link_liberal
- NLAlib.Ops.Examples.div_link_total
- NLAlib.Ops.Examples.exists_isRecipMul
- NLAlib.Ops.Examples.recipExact
- NLAlib.Ops.Examples.recipModel_exact
- NLAlib.Ops.Examples.runsL_scale
- NLAlib.Ops.Examples.runsL_scale_link
- NLAlib.Ops.Examples.runs_scale
- NLAlib.Ops.Examples.runs_scale_link
- NLAlib.Ops.Examples.scale
- NLAlib.Ops.Examples.scale_wp