Invariant based programming: basic approach and teaching experiences - Archive ouverte HAL Accéder directement au contenu
Article Dans Une Revue Formal Aspects of Computing Année : 2008

Invariant based programming: basic approach and teaching experiences

Résumé

Program verification is usually done by adding specifications and invariants to the program and then proving that the verification conditions are all true. This makes program verification an alternative to or a complement to testing. We describe here another approach to program construction, which we refer to as , where we start by formulating the specifications and the internal loop invariants for the program, before we write the program code itself. The correctness of the code is then easy to check at the same time as one is constructing it. In this approach, program verification becomes a complement to coding rather than to testing. The purpose is to produce programs and software that are correct by construction. We present a new kind of diagrams, , where program specifications and invariants (rather than the control) provide the main organizing structure. Nesting of invariants provide an extension hierarchy that allows us to express the invariants in a very compact manner. We have studied the feasibility of formulating specifications and loop invariants before the code itself has been written in a number of case studies. Our experience is that a systematic use of figures, in combination with a rough idea of the intended behavior of the algorithm, makes it rather straightforward to formulate the invariants needed for the program, to construct the code around these invariants and to check that the resulting program is indeed correct. We describe our experiences from using invariant based programming in practice, both from teaching programmers how to construct programs that they prove correct themselves, and from teaching invariant based programming for CS students in class.

Mots clés

Fichier principal
Vignette du fichier
PEER_stage2_10.1007%2Fs00165-008-0070-y.pdf (834.79 Ko) Télécharger le fichier
Origine : Fichiers produits par l'(les) auteur(s)
Loading...

Dates et versions

hal-00477903 , version 1 (30-04-2010)

Identifiants

Citer

Ralph-Johan Back. Invariant based programming: basic approach and teaching experiences. Formal Aspects of Computing, 2008, 21 (3), pp.227-244. ⟨10.1007/s00165-008-0070-y⟩. ⟨hal-00477903⟩

Collections

PEER
56 Consultations
1079 Téléchargements

Altmetric

Partager

Gmail Facebook X LinkedIn More