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;qp;q denotes the sequential composition of pp and qq
  • pqpq denotes the parallel composition of pp and qq
and
  • pqpq 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.

  1. is commutative: pq=qppq=qp
  2. and ;; are associative: (pq)r=p(qr)(pq)r=p(qr), where stands for or ;;
  3. is a partial order
  4. and ;; are monotonic: if pppp and qqqq, then pqpqpqpq
  5. the exchange law: (pq);(rs)(p;r)(q;s)(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{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}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.