Processing math: 100%

24 June 2011

In Praise of Algebra

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;q denotes the sequential composition of p and q
  • pq denotes the parallel composition of p and q
and
  • pq means that all possible executions of p are also possible executions of q

Several obvious properties follow from our intuition of what programs are, so we choose to make them axioms.

  1. is commutative: pq=qp
  2. and ; are associative: (pq)r=p(qr), where stands for or ;
  3. is a partial order
  4. and ; are monotonic: if pp and qq, then pqpq
  5. the exchange law: (pq);(rs)(p;r)(q;s)
  6. the empty program ε is an identity for both and ;

Now it is possible to define Hoare triples as follows. {p}q{r}=p;qr The fun begins: Several axioms of Hoare triples follow from the algebra. For example, the rule of consequence ppand{p}q{r}andrrimply{p}q{r} is true because {p}q{r}=p;qrp;qrrrppp;qrrr=pp{p}q{r}rr

By symmetry, there are other triples one might wish to define. pq;rp;qrpq;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.