Hoare logicHoare logic is a formal system developed by the British computer scientist C. A. R. Hoare, and subsequently refined by Hoare and other researchers. It was published in Hoare's 1969 paper "An axiomatic basis for computer programming". The purpose of the system is to provide a set of logical rules in order to reason about the correctness of computer programs with the rigour of mathematical logic. Hoare acknowledges earlier contributions from Robert Floyd, who had published a similar system for flowcharts. The central feature of Hoare logic is the Hoare triple. A triple describes how the execution of a piece of code changes the state of the computation. A Hoare triple is of the form
This is called "partial correctness". If "C" terminates and at termination "Q" is true, the expression exhibits "total correctness". Termination would have to be proved separately. Hoare logic has axioms and inference rules for all the constructs of a simple imperative programming language. The assignment axiom states that after the assignment any predicate holds for the variable that was previously true for the right-hand side of the assignment:
An example of a valid triple is:
See alsoReferences
Categories: Computer science | Logic in computer science |
|
This article is licensed under the GNU Free Documentation License. It uses material from Wikipedia article. Browse Wikipedia for more information. |