2 ms·
You missed my favorite quote from any computer science paper: "Axiomatics of Jumps [...] "Just recently, however, Hoare has shown that there is, in fact, a r
by mcguire 12y ago
You missed my favorite quote from any computer science paper:
"Axiomatics of Jumps
[...]
"Just recently, however, Hoare has shown that there is, in fact, a rather simple way to give an axiomatic definition of go to statements; indeed, he wishes quite frankly that it hadn't been quite so simple. For each label L in a program, the programmer should state a logical assertion α(L) which is to be true whenever we reach L. Then the axioms
{α(L)} go to L {false}
plus the rules of inference
{α(L)} S {P} ⊢ {α(L)} L:S {P}
are allowed in program proofs, and all properties of labels and go to's will follow if the α(L) are selected intelligently. One must, of course, carry out the entire proof using the same assertion α(L) for each appearance of the label L, and some choices of assertions will lead to more powerful results than others.
"Informally, α(L) represents the desired state of affairs at label L; this definition says essentially that a program is correct if α(L) holds at L and before all "go to L" statements, and that control never "falls through" a go to statement to the following text. Stating the assertions α(L) is analogous to formulating loop invariants. Thus, it is not difficult to deal formally with tortuous program structure if it turns out to be necessary; all we need to know is the "meaning" of each label."
(p. 289-290)
Not only does "he wishes quite frankly that it hadn't been quite so simple" make me giggle like a schoolgirl for several minutes every time I see it, but it's also a really beautiful formalism.
Not that anyone would ever do it in practice....