This is a piece of writing that was supposed to end up in my thesis.
Unfortunately, because of the publish or perish dynamic bad
planning on my part, the interesting part of the piece fell off the
page. Since it’s a small and interesting piece of history, I generalized
the piece a bit, and republished it here. Enjoy!
In 1969, C.A.R. Hoare defined the Hoare triple1 for reasoning about program correctness. Since then, Hoare triples have deeply taken root in the field of program correctness. For example, have a look at the Concrete Semantics book2, where they fully formalize the notion in Isabelle.
These days, researches typically use the following syntax for Hoare triples:
Here, and are first-order logic assertions, such as or . The constant represents a program. For example, , or . Putting this all together, here’s an example of a fully formed Hoare triple:
The meaning of a Hoare triple is a bit involved, but it boils down to the following: assuming holds in some state , if is executed in that state , after that should hold. Naturally, whether this is the case for particular , and depends on what you put in the placeholders. This is the interesting part of Hoare logic: Hoare proposed rules so you can transform and decompose these Hoare triples into smaller parts. Then, if you can prove that the smaller parts are correct, the larger Hoare triple is also correct. While that’s all a bit out of scope for this post, you can imagine such a decomposition and proof exists for the example above.
Now, on to the main part of this post: Hoare originally actually used slightly different syntax:
The difference being that he put brackets around the program, and not around the pre- and postcondition. To the best of my knowledge, to this day the style with braces around the assertions is more widely used. This also seems to be the consensus in the community, e.g. see Derakhshan et al.3
The style switch seems to have been initiated by Susan Owicki in her PhD thesis4, which is the first document that places the braces around the assertions, also to the best of my knowledge. Hoare kept using his original notation, at least until the late 80s.
The reason for changing the notation is not clear. At least one source claims it improves readability, paraphrasing, “especially when reasoning about parallel programs’’5. I don’t really understand that line of reasoning, and I also couldn’t find an example of this in the paper by Krzysztof et al. All I can say is that, having been”raised” with the brackets-outside notation, I also prefer it over the original notation, even though functionally there doesn’t seem to be any difference or limitations.
Generated with BYOB.
License: CC-BY-SA.
This page is designed to last.
⇐ [This site is part of the UT webring] ⇒