Invariant-based programming: Difference between revisions

Content deleted Content added
No edit summary
Bluebot (talk | contribs)
bold formatting title using AWB
Line 1:
'''Invariant based programming''' is a programming methodology where [[Formal specification|specifications]] and [[Invariant (computer science)|invariants]] are written before the actual program statements. Writing down the invariants during the programming process has a number of advantages: it requires the programmer to make his intentions about the program behavior explicit before actually implementing it, and invariants can be evaluated dynamically during execution to catch common programming errors. Furthermore, if strong enough, invariants can be used to prove the [[Formal verification|correctness]] of the program based on the [[Formal semantics|formal semantics]] of program statements. A combined programming and specification language, connected to a powerful formal proof system, will generally be required for full verification of non-trivial programs. In this case a high degree of automation of proofs is also possible.
 
Most existing programming languages are not ideal for invariants-first programming, since the main organizing structures in algorithmic code are control flow blocks such as [[For loop|<tt>for</tt> loops]], [[While loop|<tt>while</tt> loops]] and [[If statement|<tt>if</tt> statements]]. This forces the programmer to make decisions about control flow before writing the invariants. Furthermore, most programming languages do not have good support for writing specifications and invariants, since they lack quantifier operators and one can typically not express higher order properties such as permutation of arrays well.
 
Writing invariants before program statements has been considered in a number of different forms by, e.g, M.H. van Emden, [[Edsger Dijkstra|E.W. Dijkstra]], [[John_CJohn C._Reynolds Reynolds|J.C. Reynolds]] and [[Ralph-Johan Back|R-J Back]].
 
 
[[Category:Computer science]]