Precondition inference from intermittent assertions and application to contracts on collections

  • Authors:
  • Patrick Cousot;Radhia Cousot;Francesco Logozzo

  • Affiliations:
  • Courant Institute of Mathematical Sciences, New York University and École Normale Supérieure, Paris;Centre National de la Recherche Scientifique, Paris and École Normale Supérieure, Paris and Microsoft Research, Redmond;Microsoft Research, Redmond

  • Venue:
  • VMCAI'11 Proceedings of the 12th international conference on Verification, model checking, and abstract interpretation
  • Year:
  • 2011

Quantified Score

Hi-index 0.00

Visualization

Abstract

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 definitely leads to an assertion violation (e.g., for separate static analysis). We define precisely and formally the contract inference problem from intermittent assertions inserted in the code by the programmer. Our definition 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 abstract 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.