Yesterday was Turing's 99th birthday. By coincidence, we had a treat at Queen Mary — a talk by C.A.R. Hoare. This is a very brief summary of what was said.
Consider an algebra whose variables range over (possibly non-deterministic) programs:
- p;qp;q denotes the sequential composition of pp and qq
- p∗qp∗q denotes the parallel composition of pp and qq
- p≤qp≤q means that all possible executions of pp are also possible executions of qq
Several obvious properties follow from our intuition of what programs are, so we choose to make them axioms.
- ∗∗ is commutative: p∗q=q∗pp∗q=q∗p
- ∗∗ and ;; are associative: (p∘q)∘r=p∘(q∘r)(p∘q)∘r=p∘(q∘r), where ∘∘ stands for ∗∗ or ;;
- ≤≤ is a partial order
- ∗∗ and ;; are monotonic: if p≤p′p≤p′ and q≤q′q≤q′, then p∘q≤p′∘q′p∘q≤p′∘q′
- the exchange law: (p∗q);(r∗s)≤(p;r)∗(q;s)(p∗q);(r∗s)≤(p;r)∗(q;s)
- the empty program εε is an identity for both ∗∗ and ;;
Now it is possible to define Hoare triples as follows. {p}q{r}=p;q≤r{p}q{r}=p;q≤r The fun begins: Several axioms of Hoare triples follow from the algebra. For example, the rule of consequence p′≤pand{p}q{r}andr≤r′imply{p′}q{r′}p′≤pand{p}q{r}andr≤r′imply{p′}q{r′} is true because {p′}q{r′}=p′;q≤r′⇐p′;q≤r∧r≤r′⇐p′≤p∧p;q≤r∧r≤r′=p′≤p∧{p}q{r}∧r≤r′
By symmetry, there are other triples one might wish to define. p≤q;rp;q≥rp≥q;r It turns out that two of these lead to laws associated with Plotkin triples (reduction in structural operational semantics) and, respectively, Dijkstra triples (`going backwards'). The other triple is new.
In summary, this algebra acts as a meeting point for various approaches to defining semantics for languages.
To see what are the consequences of the exchange law, how weakening the axioms allows various useful models, and a lot more see: C.A.R. Hoare, A. Hussain, B. Moller, P.W. O'Hearn, R.L. Petersen, Struth, On Locality and the Exchange Law for Concurrent Processes.
No comments:
Post a Comment
Note: (1) You need to have third-party cookies enabled in order to comment on Blogger. (2) Better to copy your comment before hitting publish/preview. Blogger sometimes eats comments on the first try, but the second works. Crazy Blogger.