Precondition Inference from Intermittent Assertions and Application to Contracts on Collections
Programmers often insert assertions in their code to be optionally checked
at runtime, at least during the debugging phase. In the context of design by contracts,
these assertions would better be given as a precondition of the method/procedure
which can detect that a caller has violated the procedure's contract in a way which
denitely leads to an assertion violation (e.g., for separate static analysis). We dene
precisely and formally the contract inference problem from intermittent assertions
inserted in the code by the programmer. Our denition excludes no good run even
when a non-deterministic choice (e.g., an interactive input) could lead to a bad one
(so this is not the weakest precondition, nor its strengthening by abduction, since
a terminating successful execution is not guaranteed). We then introduce new ab-
stract interpretation-based methods to automatically infer both the static contract
precondition of a method/procedure and the code to check it at runtime on scalar
and collection variables.
2011-vmcai-Precondition inference from intermittent assertions and application to contracts on collections.pdf — PDF document, 403 kB (413269 bytes)