robin milner a calculus of communicating systems 1980

Upload: gustavo-engenheiro

Post on 03-Jun-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    1/176

    Lecture Notes in

    om pu te r Sc ience

    Edi ted by G G oos and J Hartmanis

    9

    Robin M ilner

    A Calculus of

    Communicating

    Systems

    Springer Verlag

    Berl in Heidelberg

    New York 1980

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    2/176

    Editorial Boar d

    W . Brauer P. Br inch Ha ns en D. Gr ies C. M oler G. Seegm iJIler

    J..q;toer N. Wirth

    u tho r

    Ro bin Milner

    University of Ed inburgh

    Dept. of Co m puter Science

    James Clerk M axwe ll Bui lding

    The K ing s B ui ldings

    Mayf ie ld Road

    Edinburgh EH9 3JZ

    Great Br i tain

    AM S Sub ject Classificat ions (1979): 68 -02

    CR Subject Classif icat ions (1974): 4.30 , 5.20, 5.2 2, 5.24

    ISBN 3-540-10235 -3 Spr inger-Ver lag Ber l in Heidelberg N ew York

    ISBN 0 38? 10235 3 Springer-Ver lag New York H eidelberg B er l in

    L ib ra ry o f C ong re ss C a ta log ing in Pub l i ca t ion Da ta . M i lne r , Rob in . A ca lcu lus o f

    com mu n ica t ing sys tems . Lec tu re no tes in compu te r sc ience ; 92 ) B ib l iog raphy : p .

    Inc ludes index, t . Ma ch ine th eory . 2 . Formal langu ages . I. T i tle . 11. Ser ies .

    C IA26?.M53 . 511 .3 80 -21 068

    T h i s w o r k i s s u b j e c t t o c o p y r i g h t. A l l r i g h ts a r e r e s e rv e d , w h e t h e r th e w h o l e o r p a r t

    o f th e m a te r ia l i s conce rned , spec i f i ca l l y thos e o f t rans la t ion , rep r in t ing , re -use o f

    i l lus t ra t ions , b roadcas t ing , rep roduc t ion by pho to cop y ing mac h ine o r s im i la r means ,

    a n d s t o r a g e in d a t a b an k s. U n d e r 5 4 o f t h e G e r m a n C o p y r i g h t L a w w h e r e c o p i e s

    a r e m a d e f o r o t h e r t h a n p r i v a t e u s e, a f e e i s p a y a b l e o t h e p u b l is h e r , t h e a m o u n t o f

    t h e f e e t o b e d e t e r m i n e d b y a g r e e m e n t w i t h t h e p u b l is h e r .

    b y S p r i n g e r- V e r l a g B e r l in H e i d e l b e r g 1 9 8 0

    P r i n te d i n G e r m a n y

    Pr in t ing and b ind ing : Be l tz O f fse td ruck , Hemsbach /Be rgs t r .

    9 1 4 5 / 3 1 4 0 - 5 4 3 2 1 0

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    3/176

    w o r k w a s m a i n l y d o n e d u ri n g m y s i x -m o n th appo_ n - - t , f r c m

    ~ t 1 97 9 t o J a n ua r y 1 98 0, a t t h e O m m o ut e r S c ie n ce d e o al b ~ en t i n

    A a rh u s U ni ve rs it y, ~ k . A l t ho u gh m u c h o f t h e g r ou n d w o r k h a d b e e n

    done previously it was mainly in response to their encouragement (to

    make the theory more accessible and related to practice), and to their

    informed criticism, that th e materia l reac hed a scmewhat coherent form.

    I an deeply grateful to them and their students for allowing me to

    lecture once a week on what was, at first, a loosely connected set of

    ideas, and for the welccming enviromnent in which I was able to put

    the ideas in order. I also thank Edinburg h University for awarding me

    five months sabbatical leave subsequently, whi ch helpe d me to cc~plete

    the task in a reasonabl e time.

    The calculus presented here 9~e w out of work which was inspired

    by Dana Scott's theory of computation, though it has since diverged

    in some respects. At every stage I have been influenced by Gordon

    Plotkin; even where I cannot trace particular ideas to him I have

    bee n gre atly illtmlinated by our discussions and by his chance remarks,

    and without th em the outccme would certainly be less than it is. I

    wou ld also like to thank others with whom I have worked: George Milne,

    with whom I worked out the Laws of Flow Algebra; Matthew Hennessy, wi th

    wh cm the notion of observation equivalence developed; and Tony Hoare,

    whose parallel work cn different but strongly related ideas, expressed

    in his Ccamtmicating Se quent ial Processes , has be en a str ong stimulus.

    Many peopl e have g iven detailed and helpful criticisms of the manu-

    script, and thus improved its final form. In particular I thank Michae l

    Gordon and David MacQueem, wh o went through it all in detail in a Seminar

    at the Information Sciences Institute, Unive rsity of California; this

    not onl y exposed same mistakes and obscurities but ga ve me mor e csnfidence

    in the part s they did n't criticise.

    Finally, I a m very thank~=ul to Doro thy McKie and Gin a Temple for

    their patience an d skill in the long and involved task of typing.

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    4/176

    O.

    .

    2

    3.

    I n t r o d u c t i o n

    P u r p o s e - C h a r a c t e r - R e l a t e d ~ r k - E v o l u t i o n - O u t l i n e .

    E m p e r i m e n t i n 9 o n N o n d e t e r m i n i s t i c M a c h i n e s

    T r a d i t i o n a l e q u i v a l e n c e o f f i n it e s t a t e a c c e p to r s - E x p e r ~ t i n g

    u p o n a c c e p t o r s - B e h a v i o u r a s a t r e e - A l g e b r a o f R S T s -

    U n o b s e r v a b l e a c t i c n s .

    S [ n c h r o n i z a t i c n

    M u t u a l e x p e r i m e n t a t i o n - C o m p o s i t i o n , r e s t r i c t i o n a n d r e l a b e l l i n g -

    E x t e n d i n g t h e A l g e b r a o f S T s - A s i n p l e ~ l e : b i n a r y s e m a p h o r e s -

    T h e S T E x p a n s i o n T h e o r e m .

    A c a s e s t u d y i n s y n c h r o n iz a t i c n a n d p r o o f t e ~ i q u e s

    A s c h e d u l i n g p r o b l e m - B u i l d i n g t h e s c h e d u l e r a s a P e t r i N e t -

    O b s e r v a t i o n e q u i v a l e n c e - P r o v i n g t h e s c h e d ul e r .

    4. Ca se st ud ie s in value-cc~6~1~dnication

    5.

    6

    7.

    R e v i e w - P a s s i n g v a l u e s - A n e x a n p l e :

    A n e x a m p l e : Z e r o s e a r c h i n g .

    D a t a F l o w - D e r i v a t i o n s -

    S y n t a x a n d S e m a n t i c s o f C C S

    I n t r o d u c t i o n - S y n t a x - S e m a n t i c s b y d e r i v a t i o n s - D e f i n i n g b e h a v i o u r

    i d e n t i f i e r s - S o r t s a n d p r o g r a m s - D i r e c t e q u i v a l e n c e o f b e h a v i o u r

    p r o g r a m s - C o n g r u e n c e o f b e h a v i o u r p r o g r a m s - C o n g r u e n c e o f b e h a v i o u r

    e x p r e s s i o n s a n d t h e E x p a n s i o n ~ n e o r e m .

    C u , , ~ ~ c a t i o n T r e e s (C T s) a s a m o d e l o f C C S

    C T s a n d t h e d y n a m i c o p e r a t i c n s - C 'f s a n d t h e s t a t i c o p e r a t i o n s -

    C T s d e f i n e d b y r e c u r s i o n - A ~ c a c t i o n s a n d d e r i v a t i o n s o f C T s -

    S t ro ng e qu i va l en c e o f C Ts - E q ua l it y i n t he C T m o de l - S ~ .

    C b ~ t i c n ~ _ i i v a l e nc e a n d i t s p r o p e r ti e s

    R e v i e w - O b s e r v a t i o n e q ui % ra l en ce i n C C S - O b s e r v a t i o n o o n g r u e n c e -

    L a w s o f o b s e r v a t i o n c o n g r u e n c e - P r o o f t e d % n i q u e s - P r o o f o f T h e o r ~ n

    7 . 7 - F u r t h e r e x e r c i s e s .

    1 9

    3 3

    4 7

    6 5

    8 4

    9 8

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    5/176

    8

    9

    i0.

    II.

    V J

    S o m e p r o o f s a b o u t D a t a S t r u c t u r e s

    I n t r o d u c t i o n R e g i s t e r s a n d m a m o r i e s C h a i n i n g o p e r a t i o n s

    P u s h d c ~ s a n d q u e ue s .

    T r a n s l a t i c n i n t o C C S

    D i s c u s s i o n T h e l a n g u a g e P S o r t s a n d a u x i l i a r y d e f i n i t i c n s

    T r a n s l a t i o n o f P A d d i n g p z o c e d u r e s t o P P r o t e c t i o n o f r e s o u r ce s .

    ~ t e z m i n a c y a n d C o n fl u e nc e

    D is c u ss io n S tr on g c on fl ue nc e ~ i t e g ua rd s a nd t he u se o f

    c c n f l u e n c e S t r c n g d e t e r m i n a c y: C o n f l u e n t d e t e z m i n a t e C C S

    P r o o f i n D C C S: t h e s c h e d u l e r a g a i n a b s e r v a t i c n c o n f l u e n c e a n d

    d e t e z m i n a c y .

    C o n c l u s i o n

    W h a t h a s b e e n a c h i e v e d ? I s O C S a p r o g r a m m i n g l a n g u a g e ?

    T h e q u e s t i o n o f f a i r n e s s T h e n o t i o n o f b e h a v i o u r D i r e c t i o n s

    f o r f u r t h e r w o r k .

    ~ : P ro pe rt ie s o f c c~ gr ue nc e a nd e qu iv a le nc e.

    1 1 1

    1 2 6

    1 3 8

    1 5 8

    1 6 6

    R e f e r e n c e s 1 6 9

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    6/176

    CHAPTER 0

    Introduction

    O .i P u ~ s e

    These notes present a calculus of concurrent systems. The presentation

    is part ly infozrflal, and aime d at practice; we unfold th e calculus throu gh

    the med ium of examples each of which illustrates first its expressive power,

    and second the techniques which it offers fo r verifying properties of a

    system.

    A useful calculus, of cGmputing systems as of anything else, must have

    a high level of articulacy in a full sense of the word implying not only

    rid ness in expression but also flexibility in manipulation. It should be

    possible to describe existing systems, to specify an d progr ~n new systems,

    and to argue mathematically about them, all witho ut leaving the notational

    frame ~rk of the calculus.

    These are demanding criteria, and it may be impossible to mee t them

    even for the full range of concurrent syst~ns which are the proper concern

    of a ccmputer scientist, let alone for syste~ns in general. But the attempt

    n~st be made. We believe that our calculus succeeds at least to this extent:

    the sane notations are used both in defining a nd in reasoning about systems,

    a n d - as our examples will s how - it appears to be applicable not only to

    prograns (e.g. operating systems or parts of them) but als o to data struc-

    tures and, at a certa in level of abstraction, to hard ware systems. Fo r

    the latter however, w e d o not claim to reach the detailed level at which

    the correct functicr/ng of a sy s t ~ depends on timing considerations.

    Apa rt from artioulacy, we aim at an underlying, theory whose b asis is

    a small well-k nit collection of ideas and whic h justifies the manipulations

    of the calculus. ~nis is as important as generality - perhaps even mere

    in~portant. An y theory wil l be superseded sooner or latem; during its life,

    understanding it and assessing it are only possible and worthwhile if it

    is seen as a logical 9~owth f rcm rather fe wb as ic assumptions and concepts.

    We take this further in the next section, where we introduce our chosen

    conoeptual basis.

    One purpose of th ese notes is to provide mater ial for a graduate course.

    With this in mind (indeed, the notes grew as a graduate course at Aarhus

    University in A u t ~ 1979) we have tried to find a good expository sequence,

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    7/176

    a n d h a v e c m i t t e d s c m e p a r t s o f t h e t h e o r y - w h i c h w i l l a p p e a r i n t e c h n i c a l

    p u b l i c a t i o n s - i n f a v o u r o f c a s e s t u d i e s . T h e r e a r e p l e n t y o f e x e r c i s e s ,

    a n d a n y o n e w h o b a s e s a c o u r s e o n t h e n o t e s s h o u l d b e a b l e t o t h i n k o f o t h e r s ;

    o n e p l e a s a n t f e a t u r e o f c o n c u r r e n t s y s t e m s i s t h e w e a l t h a n d v a r i e t y o f

    s m a l l b u t n o n - t r i v i al e ~ m ap l e s ' W e c o u l d h a v e i n c l u de d m a n y m o r e e x a m p l e s

    i n t h e t e x t , a n d t h e r e b y g i v e n g r e a t e r e v i d e n c e f o r t h e f a i r l y w i d e

    a p p l i c a b i l i t y o f t h e c a l c u l us ; b u t , s i n c e o u r m a i n a i m i s t o p r e s e n t

    i t as a c a lc u l us , i t s e e m e d a g o o d r u l e t h a t e v e r y e x a m p l e p r o g r a m o r

    s y s t e ~ s h o u l d b e s u b j e c t e d t o s c r ne p r o o f o r t o s a m e m a n i p u l a t i o n .

    O . 2 C h a r a c t e r

    O u r c a l c u l u s i f f o u n d e d o n t w o c e n t r a l i de a s . T h e f i r s t i s O b s e r v a t i o n ;

    w e a i m t o d e s c r i b e a o o n c u r r e n t s y s t e m f u l l y e n o u g h t o d e t e r m i n e e ~ m c t l y

    w h a t b e h a v i o u r w i l l b e s e e n o r e x p e r i e n c e d b y a n e x t e r n a l o bs e r v er . T h u s

    t h e a p p r o a c h i s t h o ~ o u g h l y e x t e n s i o n a l ; t w o s y s t e m s a r e i n d i s t i n g u i s h a b l e

    i f w e c a n n o t t e l l t h e ~ a p a r t w i t h o u t p u l l i n g t h e gn a p a r t . W e t h e r e f o r e

    g i v e a f o m a a l d e f i n i t i o n o f o b s e r v a t i o n e q u i v a l e n c e ( in C h a p t e r 7 ) a n d

    i n v e s t i g a t e i t s p r o p e r t i e s .

    T h i s b y n o m e a D ~ p r e v e n t s u s f r c m s t u d y i n g t h e s t r u c t u r e o f s y s t e ms .

    E v e r y i n t e r e s t i n g c o n c u r r e n t s y s t e m i s b u i l t f rc rn i n d e p e n d e n t a g e n t s w h i c h

    c c m m u n i c a t e , a n d s ~ n c h r o n i z e d c o m m u n i c a t i o n i s o u r s e c o n d c e n t r a l i de a.

    W e r e g a r d a c u t~ t~ ni ca ti on b e t w e e n t w o c o m p o n e n t a g e n t s a s a n i n d i v i s i b l e

    a c t i o n o f t h e c c r~ 0o si te s y s te m , a n d t h e h e a r t o f o u r a l g e b r a o f s y s t e m s

    i s c o n c ur r e n t c c ~ s i t i o n , a b i n a r y o p e r at i o n w h i c h c c ~ e s t w o i n d e-

    p e n d e n t a g e n t s , a l l o w i n g t h e g n t o co m a~ a ni c at e . I t i s a s e e n t r a l f o r u s

    a s s e q u e n t i a l c cm io os it io n i s f o r s e q u e n t i a l p r o g r a m m i n g , a n d i n d e e d s u b s u m e s

    t h e l a t t e r a s a s p e c i a l c a s e . S i n c e f o r u s a p r o g r a m o r s y s t e m d e s c r i p t i o n

    i s j u s t a t el ~n o f t h e c a l c u l u s , t h e s t r u c t u r e o f t h e p r o g r a m o r s y s t e m

    ( i ts i n t e n s i o n ) i s r e f l e c t e d i n t h e s t r u c t u r e o f t h e t e r m . O u r ~ n an i pu l at i on s

    o f t e n c o n s i s t o f t r a n s f o z n d n g a te z m, y i e l d i n g a t e r m w i t h d i f f e r e n t i n t e n -

    s i o n b u t i d e n t i c a l b e h a v i o u r ( e x t en s i on ) . S u c h t r a n s f o z m a t i o n s a z ~ f a n i l i a r

    i n s e q u e n t i a l p ro gr an mi in g, w h e r e t h e e x t e n s i o n m a y j u s t b e a m a t h e m a t i c a l

    f u n c t i o n ( t he i n p u t / o u t p u t b e /q a vi o ur ) ; f o r c o n c u r r e n t s y s t e m s h o w e v e r ,

    i t s ee r, c l e a r t h a t f u n c t i o n s a r e i n a d e q u a t e a s e x t e n s i o n s .

    T h e s e t w o c e n t r a l i d e a s a r e r e a l l y o ne . F o r w e s u p p o s e t h a t t h e o n l y

    w a y t o o b s e r v e a s y s t e m i s t o o.xL municate w i t h i t, w h i c h r 0 a ke s t h e o b s e r v e r

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    8/176

    a n d s y s t e m t o g e t h e r a l a r g e r s y s t e m. T h e o t h e r s i d e o f t h i s o o i n i s

    t h a t t o p l a c e t w o c cr ~p on en ts i n ~ c a t i o n ( i . e . t o c c ~ p o s e t he m)

    i s j u s t t o l e t t h e m o b s e r v e e a c h o t h er . I f o b s e r v i n g a n d c u t ~ u ~ c a t i n g

    a r e t h e s~ n e , i t f o l l o w s t h a t o n e c a n n o t O b s e r v e a s y s t e ~ w i t h o u t i t s

    p a r t i ci p a t i on . T h e a na l o g y w i t h q u a n t u m p h y si c s m a y o r m a y n o t b e s u p e r-

    f i c i a l, b u t t h e a p p r o a c h i s u n i f y i n g a n d a p p e a r s n a t u r a l .

    W e c a l l t h e c a l c u l u s C C S ( C a lc u l u s o f C ~ m . ~ n i c a t i n g S y s t e m s ) . T h e

    t e m p s o f C C S s t a n d f o r b e h a v i o u r s ( e x t e n s i o n s ) o f s y s t e m s a n d a r e s u b j e c t

    t o e q u a t i o n a l l aw s. T h i s g i v e s u s a n a l g e b r a , a n d w e a r e i n a g r e e m e n t

    w i t h v a n E ro de B o a s a n d J a n s s e n [ EH J] w h o a r g u e t h a t ~ r e g e ' s p r i n c i p l e

    o f o c m p o s i t i o n a l i t y o f m e a n i n g r e q u i r e s a n a l g e b r a i c f r a m ew o r k. B u t C C S

    i s s ~ a t m o r e t h a n a l g eb r a ; f o r e x a m pl e , d e r i v a t i v e s a n d d e r i v a t i o ns

    o f t e r m s p l a y a n i n p o r t a n t p a r t i n d e s c r i b i n g t h e d y n a m i c s o f b e h a v i o u r s .

    T h e v a r i e t y o f s y s t e m s w h i c h c a n b e e x p r e s s e d a n d d i s c u s s e d i n C C S

    i s i l l u s t r a t e d b y t h e e x a n p l e s i n t h e t e x t: a n a g e n t f o r s c h e d u l i n g

    t a s k p e r f o m a a n c e b y s e v e r a l o t h e r a g e n t s ( C h a p te r 3) ; ' d a ta f lo w'

    c c ~ p u t a t i o n s a n d a c o n c u r r e n t n% ~ re r ic a l a l g o r i t h m ( C h a p t e r 4 ) ; n ~ mn o ry

    d e v i c e s a n d d a t a s t r u c t u r e s ( C h a p t e r 8 ); s e m a n t i c d e s c r i p t i o n o f a

    p a r a l l e l p r o gr a nl m in g l a n g u a g e ( C h a p t e r 9 ) . I n a d d i t i o n , G . M i l n e [ M l n 3 3

    m o d e l l e d a n d v e r i f i e d a p e r i p h e r a l h a r d w a r e d e v i c e - a c a r d r e a d e r - u s in g

    a n e a r l i e r v e r s i o n o f t h e p r e s e n t i d ea s .

    A f t e r t h e s e r e ma r k s, t h e c h a r a c t e r o f t h e c a l cu l u s i s b e s t d i s c o v e r e d

    b y a q u i c k l o o k t h r o u g h C h a p t e r s 1 - 4 , i g n o r i n g t e d a n i c a l d e t a i l s . O . 5

    ( Ou tl in e) m a y a l s o h e l p , b u t t h e n e x t t w o s e c t i o n s a r e n o t e s s e n t i a l f o r

    a q u i c k a p p r a i s a l .

    O . 3 R e l a t e d W o r k

    A t p r e s e n t, t h e m o s t f u l l y d e v e l o p e d t h e o r y o f c o n c u r r e n c y i s t h a t

    o f P e t r i a n d h i s c o l l e a g u e s . ( Se e f o r e x a m p l e C . A . P e t r i , I n t r o d u c t i o n

    t o G e n e r a l N e t ~ h e o r y [ Pe t3 , a n d H . J . G e n r ic h , K . L a u t e n b a c h , P . S .

    T h i a g a r a j a n , A n O v e r v i e w o f N e t Y ~l eo ry [ GL T] .) I t i s i ~ p o r t a n t t o

    c o n t r a s t o u r c a l c u l u s w i t h N e t T h e o r y , i n te z~ as o f u n d e r l y i n g c o n c e p t s .

    F o r N e t T h eo r y , a ( p e rh a p s th e) b a s i c n o t i o n i s t h e c o n c u r r e n c ~

    r e l a t i o n o v e r t h e p l a c e s ( co nd it io ns ) a n d t r a n s i t i o n s ( ev en ts ) o f a

    s y s t e m ; i f t w o e v e n t s ( s a y ) a r e i n t h i s r e l at i o n , i t i n d i c a t e s t h a t

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    9/176

    t h e y a ~ e c a u s a l l y i n d e p e n d e n t a n d m a y o c c u r i n e i t h e r o r d e r o r s i m u l -

    t a n e o u s l y . T h i s r e l a t i o n i s c o n s p i c u o u s l y a b s e n t i n o u r t h e o r y , a t

    l e a s t a s a b a s i c n o t i o n. H e n w e o ~ p o s e t w o a g e n t s it i s t h e s y n c h r o n i -

    z a t i o n o f t h e i r m u t u a l c c~ am ln ic at io ns w h i c h d e t ~ e s t h e c c ~ o o s i t e ; w e

    t r e a t t h e i r i n d e p e n d e n t a c t i o ns a s o c c u r r i n g i n a r b it r a r y o r d e r b u t n o t

    s i m u l t a n e o u s l y . T h e r e a s o n i s t h a t w e a s sL lr e o f o u r e x t e r n a l o b s e r v e r

    t h a t h e c a n m a k e o n l y o n e o b s e r v a t io n a t a ti m e; t h i s i ~ p l ie s t h a t h e

    i s b l i n d t o t h e p o s s i b i l i t y t h a t t h e s y s t ~ n c a n s u p p o r t t w o o b s er v a t i o n s

    s i m u l t a n e o u s l y , s o t h i s p o s s i b i l i t y i s i r r e l e v a n t t o t h e e x t e n s i o n o f

    t h e s y s t e a i n o u r s e n s e. T h i s a s s u m p t i o n i s c e r t a i n l y o p e n t o ( ex te ns iv e )

    d e b a t e , b u t g i v e s o u r c a l c u l u s a s i n p l i c i t y w h i c h w o u l d b e a b s e n t o t h e r -

    w i s e. T o a n s w e r th e n a t u r a l o b j e c t i o n t h a t i t is u n w i e l d y t o c o n s i d e r a l l

    p o s s i b l e s e q u e n c e s ( i n t er l e a vi n g s ) o f a s e t o f c a u s a l l y i n d e p e n d e n t e v e n t s ,

    w e r e f e r t h e r e a d e r t o o u r c a s e s t u d i e s , f o r e x a n p l e i n C h a p t e r s 3 a n d 8 ,

    t o s a t i s f y h i m s e l f t h a t o u r m e t h o d s c a n a v o i d t h i s u n wi e l d i n e s s a l m o s t

    ~Zetely

    C n t h e o t h e r h a n d, N e t T h e o r y p r o v i d e s m a n y s t r o n g a n a l y t i c t e c h ni q u e s;

    w e m u s t j u s t i f y t h e p r o p o s a l o f a n o t h e r th e o ry . T h e e m p ha s i s i n o u r c a l c u l u s

    i s u p o n s y n t h e s i s a n d u p o n e x t e n si o n ; a l g e b r a a p p e a r s t o b e a n a t u r a l t o o l

    f o r e x p r e s s i n g h o w s y s t e m s a r e b u i l t , a n d i n s h o w i n g t h a t a s y s t e m m e e t s i t s

    s p e c i f i c a t i o n w e a r e d e m a n d i n g p r o p e r t i e s o f i t s e x t e n s i o n . ~ a c t i v i t y

    o f p r o g r a m m i n g - m o r e g e n e r a l l y , o f s y s t e m s y n t h e s i s - f a l l s n a t u r a l l y

    i n t o C C S , a n d w e b e l i e v e o u r a p p r o a c h t o b e m o r e a r t i c u l a t e i n t h i s r e s p e c t

    t h a n N e t T h e o r y , a t le a_ st o n p r e s e n t e v i d e n c e . I t r e m a i n s f o r u s t o

    d e v e l o p a n a l y t i c t e c h n i q u e s t o m a t c h t h e s e o f ~ N e t T h e o r y , w h o s e a c h i e v e -

    m e n t s w i l l b e a v a l u a b l e g u i de .

    A s a b r i d g e b e t w e e n N e t T h e o r y a n d p r o g r a m m i n g l a n g ua g e s f o r c o n c u r -

    r e n cy , w e s h o u l d m e n t i o n t h e e a r l y w o r k o f K a r p a n d M i l l e r [ KM ] o n p a r a l l e l

    p r o g r a m s c h e m at a . T h i s w o r k b e a r s a r e l a t i o n t o N e t T h e o r y i n y i e l d i n g a n

    a n a l y s i s o f p r o p e r t i e s o f c o n c u r r e n t s y s t e m s , s u c h a s d e a d l o c k a n d l iv e n e s s ;

    i t a l s o e s m e s c l o s e r t o p r o g r a m m i n g ( in t h e c c n v e n t i o n a l s e n s e ) , b e i n g a

    g e n e r a l i s a t i c n o f t h e f a m i l i a r n o t i o n o f a s e q u e n t i a l f l o w c h a r t .

    I n r e c e n t p r o p o s a l s f o r c o n c u r r e n t p r o gr a m m i n g l a n g u ag e s t h e r e i s a

    t r e n d t o w a r d s d i r e c t c c r m ~ n i c a t i o n b e t w e e n c c ~ i0 on en ts o r m o d u l e s , a n d a w a y

    f r o m c ~ i ~ u n i c a t i o n t h r o u g h s h a r e d r e g i s t e r s o r v a r i a b l e s . E x a m p l e s a re :

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    10/176

    N. Wirt h MCDUIA: A language for modul ar multiprogramling , [Wir];

    P. Brinch Hanse n Distributed Processes; a concurrent programming ccnoept ,

    [Bri 2]; C.A.R. Hoar e C~ti~nicating Sequential Processes , [Hoa 3].

    Hoare's monitors [Hoa 2] gave a discipline for the administrat ion of

    shared resources in concurren t programming. Thes e papers have help ed

    towards understanding the art of concurrent programming. Our calculus

    differs frcm all of them in two ways: first, it is not in the accepted

    sense an imperative l anguage - ther e are no commands, only expressions;

    second, it has evolve d as part of a mathemati cal study. In the author's

    v i ~ it is hard to do mathematics with imperative languages, though one

    may add mathematics (or logic) to them to get a proof methodology, as in

    the well-k nown assertion met hod or Hoare's axicmatic method.

    One of the main encumbrances to proof i n imperative languages is the

    presence of a more-or-le ss global m~mo ry (th e assignable variables). ~his

    was recogniz ed by Hoare in Communicating Sequential Processes ; although

    CSP is imperative Hoare avoids one aspect of global m~nory whic h makes

    concarrent programs hard to analyse, by forbidding any member o f a set of

    concurrent programs to alter the value of a variable mentioned by another

    m ~ . This significant step brings CSP quite close to our calculus, the

    more so because the treatment of eutmunication is similar and expressed in

    similar notation. Indeed, algorithms can often be translated easily from

    one to the other, and it is reasonable to hope that a semantics and proof

    theory for CSP can be developed frGm CCS. Hoare, in his paper and more

    recently, gives encouragin g evidencs for the expressivene ss of CSP.

    We now turn to two models ba sed on non-synchronized o~t,manication.

    One, wit h strong expressive power, is Hewitt's Acto r Systems; a recent

    reference is [HAL]. Here the ~ c a t i o n discipline is that each

    message sent by an actor will, after finite time, arrive at its destination

    actor ; no structure over wait ing messages (e.g. ordering by send-time)

    is imposed. This, t ogether wit h the dynamic creation of actors, yields

    an interesting programming method. Hc~ever, it see~ns to the author that

    the fluidity of structure in the model, and the need to handle the

    collection of waiting messages, poses difficulties for a tractable

    extensional theory.

    Anot her non-synch ronized model, deliberately less expressive, was

    first studied by Kah n and relx)rted by h im and MacQueen [KMQ]. Here the

    interc~Li~t.~nication f agent s is vi a un bou nde d buffers and queues, the

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    11/176

    w h o l e b e i n g d e te r m i n a t e . P r o b l e m s h a v e a r i s e n i n e x t e n d i n g i t t o n o n -

    d e t e r m i n a t e s y s t e m s , b u t m a n y n o n - t r i v i a l a l g o r i t h m s f i n d t h e i r b e s t

    e x p r e s s i o n i n t h i s m ed it ~n , a n d i t i s a n e x a m p l e o f a p p l i c a t i v e ( i . e.

    n o n - i m p e r a t iv e ) p ro gr ar ml in g w h i c h y i e l d s t o e x t e n s i o n a l t r e a t m e n t b y

    t h e s e m a n t i c t e c h n i q u e s o f S c o t t. M o r e o v e r , W a d g e [ Wa d] h as r e c e n t l y

    s h o w n h o w s i m p l e c a l c u l a t i o n s c a n d e m o n s t r a t e t h e l i v e m e s s o f s u c h

    s y s t e m s .

    A l u c i d o c ~ p a r a t i v e a c c o u n t o f t h r e e a p p r o a c h e s - H e w i t t , K a h n /

    M a c Q u e e n a n d M i l n e r - i s g i v e n i n [ M Q] .

    I n C h a p t e r 9 of t h e s e n o t e s w e s h o w h o w o n e t y p e o f c o n c u r r e n t

    l a n g u ag e - w h e r e c c m m m n i c a t io n i s v i a s h a r e d v a r i a b l e s - m a y b e d e r i v e d

    f r c ~ o r e x p r e s s e d i n t e r m s o f C C S . T h i s p r o v i d e s s a n e e v i d e n c e t h a t o u r

    c a l c u l u s i s r i c h i n e x p r e s s i o n , b u t w e c e r t a i n l y d o n o t c l a i m t o b e a b l e

    t o d e r i v e e v e r y l a n g u a g e f o r c o n c u r r e nc y .

    A r a t h e r d i f f e r e n t s t y l e o f p r e s e n t i n g a c o n c u r r e n t s y s t e m i s

    e xe r~ ol if ie d b y t h e p a t h e x p r e s s i o n s o f C a m p b e l l a n d H a b e r m a n n [ C a H ] .

    H e r e t h e a c t i v e p a r t s o f t h e s y s t e m a r e d e f i n e d s e p a r a t el y f r o m t h e

    c o n s t ra i n t s ( e . g . t h e p a t h e x pr e ss i o ns ) w h i c h d i c t a t e h o w t h e y m u s t

    s y n c h r o n i z e . M o r e r e c e n t w o r k b y L a u e r , S h i e l d s a n d o t h e r s - m a i n l y

    a t N e w c a s t l e - s h o ws t h a t t h i s m o d e l i n d e e d y i e l ds t o m a t h e m a t i c a l

    a n a l y s i s . A v e r y d i f f e r e n t e x a m p l e o f t h i s s e p a r a t i o n i s t h e e l e g a n t

    w o r k o f M a g g i o l o - S c h e t t i ni e t a l [ ~ ] ; h e r e t h e c o n s t r ai n t s a re

    p r e s e n t e d n e g a t i v e l y , b y s t a t i n g w h a t c o n j u n c t i o n s o f s t a t e s ( of s e p a r a t e

    c c n p o n e n t a g en ts ) m a y n o t o c c u r . T h i s a p p r o a c h h a s a n a d v a n t a g e f o r

    s y s t e m s w h o s e c r m p o n e n t s a r e l a r g e l y i n d e p e n d e n t ( th e a u t h o r s c a l l i t

    l o o s e c o u p l i n g ) , s i n c e t h e n o n l y f e w c o n s t r a i n t s n e e d t o b e e x p r e s s e d .

    T h i s s e c t i o n h a s s h o w n t h e s u r p r i s i n g v a r i e t y o f p o s s i b l e t r e a t m e n t s

    o f c o n c u r r e n t s y s t e m s . I t i s n o t h i n g l i k e a c c ~ p r e h e n s i v e s u r v e y , a n d

    t h e a u t h or i s a w a re t h a t i m p o r t a n t w o r k h a s n o t b e e n me n t i o n ed , b u t i t

    w i l l s e r v e t o p r o v i d e s c ~ e p e r s p e c t i v e o n t h e w o r k p r e s e n t e d h e r e.

    O . 4 E v o l u t i o n

    % Tu is w o r k e v o l v e d f rc ~n a n a t t er ~o t t o t r e a t c ~ L ~ n i c a t i o n m a t h e m a t i -

    c a l ly . I n M i l n e r : P r oc e ss e s: a m a t h e m a t i c a l m o d e l o f ~ t i n 9 a g e n ts

    [ M i l 1 1 a m o d e l o f i n t e r a c t i n g a g e n t s w a s c o n s t r u c t e d , u s i n g S c o t t ' s

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    12/176

    t h e o r y o f d c r m~ m s . ~ h i s w a s r e f i n e d a n d g r e w m o r e a l g e b r a i c i n G . M i l n e

    a n d M i l n e r : " C o n c u r r e n t P r o o e s s e s a n d t h e i r s y n t a x " E M M 3 A t t h i s

    p o i n t w e p r o p o s e d n o p r o g r a m m i n g l a n gu a g e, b u t w e r e a b l e t o p r o v e

    p r o p e r t i e s o f d e f i n e d c o n ~ n t b e h a v i o u rs . F o r e x a mp l e , M i l n e i n h i s

    P h . D . T h e s i s " A m a t h e m a t i c a l m o d e l o f c o n c u r r e n t c o m p u t a t i o n " [ Ml n]

    p r o v e d p a r t i a l c o r r e c t n e s s o f a p i e c e o f h a r d w a r e , a c a r d - r e a d er , b u i l t

    f r o m f o u r s e p a r a t e c c ~ p o n e n t s a s d e t a i l e d i n i t s h a r d w a r e d e s c r i p t i o n .

    O u r m o de l a t t hi s st ag e dr e w u p on Pl ot ki n' s a nd Sa~yth's P ~ e r ~

    c o n s t r u c t i o n s , [ P I o i , S a ~ y ] . w h i c h e x t e n d e d S c o t t ' s t h e o r y t o a d m i t

    n o n - d e t e n m i n i s m . P a r t o f o u r a l g e b r a i s s t u d i e d i n d e p t h i n [ M i l 2 ].

    A t t h i s p o i n t t h e r e w e r e t w o c r u c i a l d e v e l o ~ a e n t s . F i r s t - a s w e

    h a d h o p e d - o u r b e h a v i o u r d e f i n i t io n s l o o k e d c o n s i d e r a b ly l i k e p r o g ra m s ,

    a n d t h e r es cm %b la nc e w a s i n c r e a s e d b y m e r e l y i m p r o v i n g n o t a t i o n . T h e

    r e s u l t , e s s e n t i a l l y t h e l a n g u a g e o f C C S , i s r e p o r t e d i n [ M i i 3 ] a n d

    w a s p a r t l y p ~ t e d b y d i s c u s s io n s w i t h H o a r e a n d S c ot t . ( Fo r c o m pl e t e ne s s ,

    t w o o t h e r p a p e r s [ M i l 4 , 5] b y t h e a u t h o r a r e i n c l u d e d i n t h e r e f e r e n c e

    l i s t. E a c h g i v e s a s l i g h t l y d i f f e r e n t p e r s p e c t i v e f r o m [ M i l 3 ], a n d

    d i f f e r e n t e x a m pl e s . ) T h e s e c o n d d e v e l o l m ~ n t w a s t o r e a l i s e t h a t t h e

    r es ul ti ng l an gu ag e h as m a n y i nt er pr et at io ns ; a n d t ha t t he P c ~ r ~

    m o d e l , a n d v a r i a n t s o f i t, m a y n o t b e t h e c o r r e c t o n e s. A c r i t e r i o n w a s

    n e e d e d , t o r e j e c t t h e w r o n g i n t e r p r e t a t i o n s . F o r t h i s p u r p o s e , w e t u r n e d

    t o o b s e r v a t i o n e q u iv a l e n ce ; t w o b e h a v i o u r e x p r e s s i on s s h o u l d h a v e t h e

    s a n e i n t e r p r e t a t i o n i n t h e m o d e l i f f i n a l l c o n t ex t s t h e y a r e i n d i s ti n g u i s h -

    a b l e b y o b s e r v a t i o n .

    I t n o w t u r n s o u t t h a t a d e f i n i t i o n o f o b s e r v a t i o n e q u i v a l e n c e ( fo r

    w h i c h a d m i t t e d l y t h e r e a r e a f e w a l t e r n a t iv e s ) d e t e m n i n e s a m o d e l , u p

    t o i s c~ o r p hi s m , a n d m o r e o v e r y i e l d s a l g e b r a i c l a w s w h i c h a r e o f p r a c t i c a l

    u s e i n a r g u i n g a b o u t be 2~ ir io ur s. W e h a v e s t r o n g h o p e f o r a s e t o f l a w s

    w h i c h a r e i n s o m e s e n s e co m p l e t e ; i n f a c t t h e l a w s g i v e n i n C h a p t e r s 5

    a n d 7 h a v e b e e n s h o w n c c ~ o l et e f o r a s i n p l i f i e d c l a s s o f f i n i t e ( t en ~ in a ti n g)

    b e h a v i o u r s . I n t h i s ca s e , " c o m p l e t e " m e a n s t h a t i f t w o b e h a v i o u r e x p r e s s i o n s

    a r e o b s e r v a t i o n - e q ui v a l e n t i n al l c o n t e x t s t h e n t h e y m a y b e p r o v e d e q u a l

    b y t h e l a w s; t h i s c o m p l e t e n e s s i s s h o w n i n [H M] .

    0 . 5 O u t l i n e

    I n C h a p t e r 1 w e d i s c u s s i n f o r m al l y t h e i d e a o f e xp e r i m e n t i n g o n , o r

    o b s e r v i n g , a n o n - de t e 2 xn i n i st i c a g e n t ; t h i s l e a d s t o t h e n o t i o n o f

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    13/176

    s y n d 0 m o n i s a t i o n t r e e ( S T ) a s t h e b e h a v i o u r o f a n a g e n t . C h a p t e r 2 d i s -

    c t ~ s e s m t u a l e x p e ri m e n t, o r c ~ m L ~n i c a ti c n , b e t w e e n a g e n ts , a n d d ev e l o p s

    a n a l g e b r a o f S T s . I n C h a p t e r 3 w e d o a s m a l l c a s e - s t u d y ( a s c h e d u l i n g

    s y st e m) a n d p r o v e s c x ne t hi n g a b o u t i t, a n t i c i p a t i n g t h e f o r m a l d e f i n i t i o n

    o f o b s e r v a t i on e q u i v a l e n c e a n d i t s p r o p e r t ie s t o b e d e a l t w i t h f u l l y i n

    C h a p t e r 7 .

    C h a p t e r 4 e n r i c h e s o u r c u l, ud ni ca ti on s - u p t o n o w t h e y h a v e b e e n j u s t

    s y n d l r o n i z a t i o n s - t o a l l o w t h e p a s s i n g o f v a l u e s f r c m o n e a g e n t t o a n o t h er ,

    a n d i l l u s t ra t e s t h e g r e a t e r e x p r e s s i v e p ~ e r i n t w o m o r e e x ar ~ l es ; c n e i s

    a k i n t o D a t a F l o w , a n d t h e o t h e r i s a c o n c u r r e n t a l g o r i t h m f o r f i n d i n g a

    z e r o o f a c o n t i n u o u s f u n c t i o n. T h e n o t i o n o f d e r i v a t i v e o f a b e h a v i o u r

    i s i nt r o d u c e d , a n d u s e d i n t h e s e c c n d e x a m p l e .

    I n C h a p t e r 5 w e d e f i n e C C S f o r ma l l y, g i v i n g i t s d y n am i c s i n t e r ms

    o f d e r i v a t i o n s ( d e r i v a t iv e s e q u e n c e s ) . ~ h i s y i e l d s o u r s t r o n g c o n g r u e n c e

    r e l a ti o n , u n d e r w h i c h t w o p ro g r a m s a r e c c n g r u e n t i f f t h e y h a v e e s s e n t i a l l y

    t h e s a m e d e r i v a t i o n s , a n d w e e s t a b l i s h s e v e r a l l a w s o b e y e d b y t h e co n g r u e n c e .

    I n C h a p t e r 6 w e p r e s e n t c ~ m l u n i c a t i c n t r e e s ( C T s , a g e n e r a l i s a t i o n o f ST s)

    a s a m o d e l w h i c h o b e y s t h e s e l a ws ; t h i s m o d e l i s n o t n e c e s s a r y f o r t h e

    f u r t h e r d e v e l o p m e n t , b u t m e a n t a s a n a i d t o u n d e r s t a n d i n g .

    C h a p t e r 7 i s t h e c o r e o f t h e t h e o r y; o b s e r v a t i o n e q u i v a l e n c e i s

    t r e a t e d i n d e p th , a n d f r o m i t w e g a i n o u r m a i n c o n g r u e n c e r e l at i o n ,

    o b s e r v a t i o n c o n g ru e n ce , u n d e r w h i c h t w o p r o g r a n s a r e c o n g r u e n t ~ i ff t h e y

    c a n n o t b e d i s t in g u i s h e d b y o b s e r v at i o n i n a n y c on t ex t . H a v i n g d e r i v e d

    s c m e p r op e r t i e s o f t h e c o n g r u en c e , w e u s e t h e m i n C h a p t e r 8 t o p r o ve t h e

    c o r r e c t b e h a v i o u r o f t w o f u r t h e r s y st e m s, b o t h t o d o w i t h d a t a s t r uc t u r es .

    I n C h a p t e r s 9 a n d I O w e l o o k a t s a n e d e r i v e d A lg e b r a s. O n e t a k es t h e

    f o r m o f a n i m p er a t i v e c o n c u r r e n t p r o g r a m m i n g l a n g u ag e , w i t h a s s i s t

    s t a t e m e n t s , c o b e g i n - c o e n d s t a t e m e n t s , a n d p r o c e d u r e s . I n e f f e c t , w e

    s h o w h o w t o t r a n s l a t e t h i s l a n g u a g e d i r e c t l y i n t o C C S . T h e o t h e r i s a

    r e s t r i c t i o n o f C C S i n w h i c h d e t e r m i n a c y i s g ua r a nt e e d , a n d w e i n d i c a te

    h o w p r o o f s a b o u t s u c h p r o g r a m s c a n b e s i r ~ l e r t h a n i n th e g e n e r a l c a s e .

    F i n a ll y , i n C h a p t e r i i w e t r y t o e v a l u a t e w h a t h a s b e e n a c h i ev e d ,

    a n d i n d i c a t e d i r e c t i o n s f o r f u t u r e r e s e a r c h .

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    14/176

    CHAPTER

    E x p e ri m e n ti n g o n n o n d e t e n n i n i s t i c m a c h i n e s

    i o i

    T a k e a p a i r

    = { a , b , c , d } :

    T r a d i t i o n a l e q u i v a l e n c e o f f i n i t e s t a t e a c c e p t o r s

    S , T o f n o n d e t e z a d n i s t i c a c c e p t o rs o v e r t h e a l p h a b e t

    T

    T h e a c c e p t i n g s t a t e s o f S a n d T a r e s 2 a n d t 2 r e s p e c t i v e l y ; i n n o n -

    d e t e r m i n i s t i c a c c e p t o r s w e c a n a l w a y s m a k e d o , a s h e r e , w i t h a s i n g l e d ea d

    a c c e p t i n g s t a t e .

    A s t an d ar d ~ t t h at S a n d T a re e qu iv al en t, m e a ni n g t h at t h ey

    a c c e p t t h e s a m e l a n g u a g e ( s et o f s t r i n g s ), r u n ~ a s f ol l o w s .

    t i) t o r e p r e s e n t t h e l a n g u a g e a c c e p t e d s t a r t i n g f r c m s t a t e s i ( r es p t i) , w e

    g e t a s e t o f e q u a t i o n s f o r

    S , a n d f o r T :

    s O = as I t O = at 1

    s I = bs 2 + cs 3 t I = bt 2

    S 2 = ~ t I = ct 3

    S 3 = ds 0 t 2 =

    t 3 = d t 0

    + a t ~

    H e r e a s u s u a l + s t a n d s fo r u n i o n o f l a n g u a g e s, e f o r t h e l a n g u a g e

    c o n t a i n i n g ~ n l y t h e 6 ~ p t y s t r i n g , a n d w e c a n t h i n k o f t h e s y m b o l a

    f o r a f u n c t i o n o v e r l a n g u a g e s : a s = a ( s ) = { a ~ ; ~ E s } .

    N o w b y s in lo le s u b s t i t u t i o n w e d e d u c e

    s O = a (b c + cds0) .

    B y a p p l y i n g t h e d i s t r i b u t i v e l a w a ( s + s ) = a s + a s w e d e d u c e

    s O = a b ~ + a c d s 0

    T a k i n g s i ( r e s p

    s t a n d i n g

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    15/176

    1 0

    a n d w e c a n g o f u r t h e r, u s i n g a s t a n d a r d r u l e f o r s o l v i n g s u c h e q u a t i o n s k n o w n

    as Arden s rule, to get

    s = (acd)*abe .

    F o r T i t i s e v e n s i m p l er ; w e g e t d i r e c t l y ( w i th o u t u s i n g d i s t r i b u t iv i t y )

    t = ab~ + acd t

    a n d t h e u n i q u e s o l v a b i l i t y o f s u c h e q u a t i o n s t e l l s u s t h a t s = t O , s o S

    a n d T a r e e q u i v a l e n t a c c e p t o r s .

    B u t a r e t h e y e q u i v a l en t , i n a l l u s e f u l s e n s e s ?

    1 . 2 E x p e r i m e n t i n u p o n a c c e p t o r s

    T h i n k d i f f e r e n t l y a b o u t a n a c c e p t o r o v e r { a , b , c , d > . I t i s a b l a c k

    b o x, w h o s e b e h a v i o u r y o u w a n t t o i n v e s t i g at e b y a s k i n g i t t o a c c e p t s y m b o l s

    o n e a t a t i m e. S o e a c h b o x h a s f o u r b u t t o n s , o n e f o r e a c h s y mb o l :

    S b

    a a

    i

    s d T b t

    t

    T h e r e a r e f o u r a t o m i c e x p e r ~ t s y o u c a n d o, c n e f o r e a c h s y mb o l. D o i n g a n

    a - e x p e r i m e n t o n S ( s e c re t l y i n s t a t e s , b u t y o u d o n t k n o w t ha t) c o n -

    s i s t s i n t r y i n g t o p r e s s t h e a - b u t t o n , w i t h t w o p o s s i b l e o u t c c m e s i n g e n er a l :

    (i) Fail ure - the but ton is locked;

    ( i i ) S u c c e s s - t h e b u t t o n i s u n l o c k ed , a n d g o e s d o w n ( an d

    s e c r e t l y a s t a t e t r a n s i t i c n o c c u r s ) .

    I n f a c t w e c a n n o t d i s t i n g u i s h b e t w e e n S a n d T , i n t h e i r i n i t i a l s t a t e s,

    b y a n y s i n g l e a t c n d c e x p e r i m e n t ; t h e a - e x p e r i m e n t s u c c e e d s i n e a c h c as e , a n d

    the other th ree fail.

    A f t e r a s u c c e s s f u l a - e x p e r i m e n t o n e a c h m a c h i ne , w h i c h m a y y i e l d

    a

    S b l s 1 ~ d T

    b

    t t

    t

    a

    i

    d

    w e m a y t r y a n o t h e r a tc ~t ic e x p e r i m e n t , i n o u r a i m t o s e e i f t h e m a c h i n e s a r e

    e q u i v a l e n t o r n o t . C l e a r l y a b - e x p e r i m e n t n o w s u c c e e d s f o r S a n d f a i l s

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    16/176

    11

    f o r T , t h o u g h t h e o t h e r t h r e e e x p e r ~ t s f a i l t o d i s t i n g u i s h t h e~ . A f t e r

    t r y i n g t h e b - e x p e r i m e n t , t he n , c a n w e c o n c l u d e t h a t S a n d T a r e n o t

    e q u i v a l e n t ?

    N o , b e c a u s e S s r e s p o n s e t o th e a - e xp e r i m e n t c o u l d h a v e b e e n d if f e r e n t

    ( fo r a l l w e k n ow ) a n d l o c k e d t h e b - b u t t o n , w h i l e T s r e s p o n s e c o u l d h a v e

    b e e n d i f f e r e n t ( fo r a l l w e k n o w - a n d i t c o u l d i nd e e d ) a n d u n l o c k e d t h e

    b - b u t t o n . F o l l o w i n g t h i s a r g L m ~ n t f u r t h e r , w e m a y f e e l f o r c e d t o a d m i t t h a t

    n o f i n i t e a m o u n t o f e x p e r i m e n t c o u l d p r o v e t o u s t h a t S a n d T a r e, o r a r e

    not, equivalent .

    B u t s u p p o s e

    (i) I t i s t h e w e a t h e r a t a n y m c n ~ n t w h i c h d e t e r m i n e s t h e c h o i c e o f

    t r a n s i t i o n ( in c a s e o f a m b i g u i t y, e . g . T a t t O u n d e r a n

    a-experiment) ;

    ( i i ) T h e w e a t h e r h a s o n l y f i n i t e l y m a n y s t a t e s - a t l e a s t a s f a r

    a s c h o i c e - r e s o l u t i o n i s c o n c e r n e d ;

    ( ii i) W e c a n c o n t r o l t h e w e a t h e r .

    F o r s a n e m a c h i n e s t h e s e a s s u n p t i o n s a r e n o t s o o u t r a g e o u s ; f o r e x a m p l e , o n e

    o f t w o p u l s e s m a y a l w a y s a r r i v e f i r s t w i t h i n a c e r t a i n t e m p e r a t u re r a n ge , a n d

    o u t s i d e t h i s r a n g e t h e o t h e r m a y a l w a y s a r r i v e f i r st . ( At t h e b o u n d a r y o f

    t h e r a n g e w e h a v e t h e w e l l - k n o w n g l i t c h p r o b l e m , w h i c h w e s h a l l i g n o r e h e re .)

    N c ~, b y c o n d u c t i n g a n a - e x p e r i m e n t a n S a n d T u n d e r a l l w e a t h e r c o n -

    d i t i o n s ( al wa ys i n t h e i r s t a r t s t at e s , w h i c h w e h a v e t o a s s u m e a r e r e c o v e r -

    a b l e ) , w e c a n f i n d t h a t S s b - b u t t o n i s a l w a y s u n l o c k e d , b u t t h a t T s

    b - b u t t o n i s s c ~ e t i m e s l o c k e d, a n d w e c a n c o n c l u d e t h a t t h e m a c h i n e s a r e n o t

    e q u i v a l e n t .

    I s t h i s s e n s e o f e q u i v a l e n c e , i n w h i c h S a n d T a r e n o t e q u i v a l e n t ,

    a m e a n i n g f u l o n e ? W e s h a l l f i n d t h a t w e c a n m a k e i t p r e c i s e a n d s h al l a d o p t

    i t - p a r t l y b e c a u s e i t y i e l d s a n i c e t h e or y , p a r t l y b e c a u s e i t i s a f i n e r

    ( s~ al le r) e q u i v a l e n c e r e l a t i o n t h a n t h e s t a n d a r d c n e ( wh ic h w e c a n a l w a y s

    r e c o v e r b y i n t r o d u c i n g t h e d i s t r i b u t i v e l a w u s e d i n i. i) , b u t m o r e f o r t h e

    f o l l o w i n g r e a s o n . I m a g i n e t h a t t h e b - b u t t o n s o n S a n d T a r e h i d d e n .

    T h e n i n a l l w e a t h e r s e v e r y s u c c e s s f u l e x p e r ~ t u p o n S u n l o c k s s a m e

    v i s i b l e b u t t o n :

    S ( w it h b h i d d e n) i s n o t d e a d l o c k a b l e

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    17/176

    12

    whil e in sc~e weathers, and after same experiments, all of T s visible

    buttons will be lo~ked:

    T (with b hidden) is deadlockable.

    We wish to think of a nondeterministic choice in such machines as being

    resolved irreversibly, at a particular manent, by information flowing into

    the system from an unseen source; if a deadlock can thus arise in one machine

    b u t n o t i n a n o t he r , w e d o n o t r e g a r d t h e m a s b e h a v i ou r a l l y e qu i v a le n t .

    1.3 Behaviou r as a tree

    Because we r eject the distributive law a(x + y) = ax + ay , we can no

    longer take language s (sets of strings) as the behav iour s of our machines .

    W e p r o c e e d t o a n a l t er n a ti v e . F r c m n o w o n w e w i l l u s e N I L i n s t e a d o f e

    to stand for a behavi our whic h can do nothing (= admits no experiment) ; we

    s h al l a l so u s e G r e e k l e tt e rs f or o u r ~ i s - i.e . na m e s o f b u t to n s - s o y o u

    should consider ~,~,y ,5 as replace~_nts for a,b,c,d in our sinple example.

    First, take the transition graph for S and unfold it into a tree wit h

    states as node labels and symbols as arc labels:

    B

    Because state na~es are pre sent we hav e lost no information; the state trans-

    ition graph can be recovered frcm such a tree. But the experimenter cannot

    see the state - he can only see the transitions. This leads us to drop the

    node labels, an d take the infinite tree

    a s t h e b e h a v i o u r o f S . a - -

    I Definiti on A label is a n~m ber of a given (fixed) label set A .

    We are using ~,B,Y,.. to stand for labels. (The use of the wor d label in

    place of symbol will be further motiv ated later.)

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    18/176

    3

    I Definiti on A sort is a subset of A

    We sh all usually use L,M,N, .. to stand for sorts. We shall also ofte n use

    t h e w o r d a ~ e n t i n p l a c e o f m a d l i n e o r a cc e pt or , s o

    S is an acceptor over the alphabet Z

    b e c o m e s

    S is an agent of sort L

    Definit ion A Rigi d Synchroniza tion Tree (RST) of sort L is a rooted,

    u no r de re d , f i n i t e l y b r a n ~ t r e e e a c h o f w h o s e a r c s i s l a b e l l e d b y a

    m e m b e r o f L .

    Thus the tr ee in th e las t diagr an is an RS T of so rt {~, B, ~, 8} . (It is also

    a n R S T o f a n y l a r g e r s or t. )

    W h y r ig id ? B e c a u s e i t i s t h e b e h a v i o u r o f a r i g i d a g e n t - o n e w h i c h

    c a n m a k e n o t r a n s i t i o n e x c e p t t h a t c o r re s p o n d i ng t o a n a t o m i c e x pe ri m en t. W e

    shall soon meet other transitions.

    Why synchronizaticn ? Because we shall later see how the oammunication

    of two age nts c an be rep resented in fozrcing their joint tree frcm the ir

    separate trees. Then the joint tree wil l not be rigid, in general, since

    intercuf, dnication betw een cc~po nent agen ts i s not observable.

    Notice that finit e RSTs can be represente d as expressions:

    B / / ~ i s ( BN I L + ~ NI L )

    ~ ~ is ~ B N IL + ~ N I L

    and usuall y there is more than one natur al expression:

    (~NIL 7NI L) , or

    s ~ r I n

    +

    +

    c~LL + BNIL) + yNIL .

    Indeed, + is both oactuutative and associative, since we decla red RSTs to

    be unordered trees - and NIL is easily seen to be a zero for summation.

    T o j u s t i f y t h e s e r e m a rk s w e n c ~ d e f i n e t h e a l g e b r a o f R S Ts .

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    19/176

    14

    i . 4 A l g e b r a o f R S T s

    I g n o r i n g s o r t s f o r a m c n ~ n t , w e h a v e a n e l e m e n t a r y a l g e b r a o v e r R S T s,

    w h o s e o p e r a t i o n s a r e :

    N I L n u l l a ry o p e r a t io n )

    N I L i s t h e t r e e ;

    + b i n a r y o p e r a t i o n )

    + A i s t h e t r e e ~ i d e n t i f y r o o t s ) ~

    u n a r y o p e r a t i o n , f o r e a c h ), ~ A)

    T h e y o b e y t h e f o l l c ~ i n g l a w s , a s y o u c a n e a s i l y s e e :

    A s s o c i a t i v i t y x + y + z ) = x + y ) + z

    Ccurnu tativ ity x + y = y + x

    N u l l i t y x + N I L = x

    I n f a ct , t h e s e l a w s a r e c ca lo le te : a n y t r u e e q u a t i c n b e t w e e n R S T e x p r e s s i o n s

    c a n b e d e d u c e d f r c m t h em .

    I f w e c o n s i d e r s o r ts , a n d l e t R S T b e t h e s e t o f R S T s o f s o r t L ,

    t h e n N I L i s o f s o r t L f o r a n y L :

    N I L ~ R S T .

    F u r t h e r , + t a k e s t r e e s o f s o r t L , M r e s p e c t i v e l y t o a t r e e o f s o r t L u M :

    + E R S T R S T R S T L u ,

    a n d ~ t a k e s a t r e e o f s o r t L t o a t r e e o f s o r t L u { l } :

    W e s h a l l u s u a l l y f o r g e t a b o u t s o r t s f o r t h e p r e s e n t , b u t t h e r e a r e t i m e s

    l a t e r w h e n t h e y w i l l b e e s s e n ti a l .

    C o n s i d e r n o w s o l v i n g r e c u r s i v e e q u a t i o n s o v e r R S T s . W e w i s h t h e e q u -

    a t i o n s f o r o u r a g e n t S o f l . 1

    s O = ~s I s I = ~s + ys 3

    s 2 = NI L s 3 = 6s

    t o d e f i n e t h e i n f in i t e) b e h a v i o u r o f S a s a n R S T o f s o r t { ~ , 8 , Y , 8 } -

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    20/176

    15

    T h i s s e t o f e q u a t i o n s h a s a u n i q ue , s o l u t i o n f o r t h e v a r i a b l e s s 0 ' s 3 ;

    y o u c a n s e e t h i s b y t h e f a c t t h a t t h e e n t i r e t r e e c a n b e d e v e l o p e d t o p - d o w n

    t o a n y d e p t h :

    s O

    E x e r c i s e i . 1

    = = = ... an d so on.

    N o t e v e r y s e t o f r e c u r s i v e e q u a t i o n s h a s a u n i q u e s o l u t i on ;

    c o n s i d e r t h e s i m p l e e q u a t i o n

    s = s

    w h i c h i s s a t i s f i e d b y a n y R S T ( or a n y t h i n g e l s e , f o r t h a t m a t t e r) .

    A g a i n , s cr ne s e t s o f e q u a t i o D ~ d e f i n e n o R S T a t a l l. C o n s i d e r t h e e q u a t i o n

    s = s + ~ N I L ;

    a s o l u t i o n w o u l d h a v e t o b e i n f i n i t e ly b r a n c h i n g a t t h e ro o t. E v e n i f w e

    a l l o w e d i n f i n i t e l y b r a n c h i n g R S T s, s o t h a t

    w o u l d b e a s o l u t i o n, i t w o u l d n o t b e u n i q u e s i n c e s + t w o u l d a l s o

    b e a s o l u t i o n f o r a n y t . W e d e f e r t h i s p r o b l e m t o C h a p t e r 5.

    C a n y o u f i n d a c o n d i t i o n o n a s e t o f e q u a t i o n s

    Q

    i

    s =

    s i =

    o o o

    S n

    (with RST expres sions invol ving s O ,.. ,s

    o n t h e r i g h t - h a n d s id es )

    w h i c h e n s u r e s t h a t i t p o s s e s s e s a u n i q u e s o l u t i o n i n R S T s ?

    ( H i n t : c o n s i d e r c y c l e s o f c - t r a n s i t i o n s i n t r a n s i t i o n g r a p hs . )

    1 . 5 U n o b s e r v a b l e a c t i o n s

    U n d e r t h e c o n v e n t i o n a l d e f i n i t i o n , a n o n d e t e r m i n i s t i c a c c e p t o r m a y

    h a v e t r a n s i t i o n s l a b e l l e d b y ~ ~ t h e n u l l s t r i n g . C o n s i d e r R , a m o d i -

    ficati on of our S of i.I (reverting bri efl y to Rcn~ml alphabet):

    R a ~ ~ d ~ ~

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    21/176

    6

    (The loop fomaed by the d-tr ansi tion is irrel evant to our ccrnparison.)

    In the conventional sense, R and S are equivalent. But what does the

    c - t r a n s i t io n m e a n, i n o u r m o r e m e c h a n i s t i c i n t e rp r e t a ti o n ? I t m e a n s t h a t

    R in state r i (i.e. after the a-button has been pressed) may at any time

    ' and that if a b-e xpe rim ent is nev er attesloted

    ove silently to state r I ,

    it wil l do so.

    Thus, if we attespt a b-expe riment on R , after the successful a-

    e x p e ri m e n t, t h e r e a r e s c ~e w e a t h e r c o n d i t i o n s i n w h i c h w e f i n d t h e b -

    b u t t o n p e a m a n e n t l y l o ck e d; i f o n t h e o t h e r h a n d w e a t t ~ a c - e x p e r i me n t

    (after the a-experiment) we shall in all weat her conditions find the

    c-butto n eventually unlocke d (eventually, becau se although R may take a

    little t ~ to decide on its e-transition, it will do so since no b-

    experiment is attespted).

    E xe rc is e 1 .2 U se t hi s a s t he b as is o f a n ~ t t ha t n o p ai r o f R, S

    a n d T a r e e q u iv a l e nt . A r i g o r o u s b a s i s f o r t h e a r ~ t w i l l b e g i v e n

    later.

    Let us retu rn to our Greek alphabet, and ask how we should write the

    equations specifying R's behaviour. We choose the symbol T in place of

    e (to avoid confusion with the null string), and use it as a new unary

    o p e r at i o n u p o n b e h a v i o u r s .

    r0,..,r are:

    r 0 = ~r

    r 2 = NIL

    We are ass~aing that

    The equat ions dete_~mining the behavio urs

    r i = 8r + xr~

    r 3 = ~r

    T A (the fixed label set).

    r I = yr

    Definit ion A Synchroni zation Tree (ST) of sort L is a rooted, unordered,

    f in i te ly b r an c hi n g t re e e a c~ o f w h o s e a rc s i s l a be l le d b y a ~ r o f

    L u { ~ }

    Thus a rigid ST (an RST) is just an ST wit h no arcs labelled T ;

    t h e b e h a v i o u r o f a n a g e n t w h i c h c a n m a k e n o s i l e n t t r a ns i t io n s .

    S i n c e w e a r e t a k i n g t h e u n a r y o p e r a t i o n

    we can of course deduce the ST-behaviour of R . It is

    it is

    T o v e r S T s t o b e g i v e n b y

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    22/176

    17

    Y

    y -

    STs are a sinlole and useful notion of behaviour. They are just the

    unfoldings of behavio ur equations, whic h in turn follow directly fran

    transition graphs. Of course in this way different transition graphs can

    y i e l d t h e s a n e S T , f rc rn w h i c h w e c a n b e c e r ta i n t h a t t h e y a r e i n d i s ~ s h -

    able by experiment

    Exercise 1.3 Convince yourse1_f that the transition graphs

    have the same unfolding.

    However, differe nt STs or transition graphs yielding different STs)

    may be indistinguishable by experiment. This is true even for RSTs;

    c o n s i d e r t h e s i m p l e p a i r

    each of whic h adaits a single ~-experiment and then nothing else.

    But it is even more true in the case of unobservable actions. Later

    we shall study an equivalence relation, c~servation equivalence, over STs,

    which ca n for finite STs) be axicmatized by a finite set of equations

    added to those given in 1.4 above. To get a foretaste of the equivalence

    consider the following exercise.

    E x e r c i s e 1 .4 E x a m i D ~ e a c h o f th e f o l l o w in g p a i r s o f s ~ p l e S T s a n d t r y t o

    d e ci d e b y i nf oz m al ~ t , a s i n E xe r ci se 1. 2 a bo ve , w h i ch a r e o b se r va t io n

    equivale nt i.e. indistinguishable by experiment). Yo u may reasonably

    conclude that four pairs are equivalent, or that si x pairs are equivalent,

    b u t y o u s h o u l d a l s o f i n d t h a t t h e n o t i o n o f e q u i v a le n c e i s n o t y e t p re ci se .

    E h e p o i n t o f t h i s e x e r c i s e i s t h a t i t i s n o t t r i v i a l t o c a p t u r e o u r i n f o z m a l

    arguments b y a precise notion.

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    23/176

    o

    ~

    o

    c

    ~

    o

    ~

    v

    O

    ~

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    24/176

    C h a p t e r 2

    S y n c h r o n i z a t i o n

    2 . 1 M u t u a l e x p e r i m e n t a t i o n

    ~ h e s uc c e s s o f an s - e x p e r i m e n t e n a b l es t h e m a c h i n e t o p r o c e e d to

    o f f e r f u r t h e r e x p e r i m e n t s ) ; i t a l s o a l l o w s t h e o b s e r v e r t o p r o c e e d t o

    a t t e m p t f u r t h e r e x p e r i m e n t s ) . T h i s s u g g e s t s a n ~ b v i o u s s y m m e t r y ; w e

    w o u l d l i k e t o r e p re s e n t t h e o b s e r v e r a s a m a c h i ne , t h e n t o r e p r e s e n t t h e

    c c m p o s i t e o b s e r v e r / m a c h i n e a s a m a c h i ne , t h e n t o u n d e r s t a n d h o w t h i s

    m c h i n e b e h a v e s f o r a n e w o b s er v e r .

    H o w s h o u l d t w o m a c h i n e s i n t e r ac t ?

    S ~ T 0

    W e m u s t s a y w h i c h e x p e r i m e n t s o f f e r e d b y S m a y c o m b i n e w i t h o r c cr ap le me nt )

    w h i c h ex p e r i m e n t s o f T t o y i e l d a n i n t er a c ti o n . R a t h e r t h a n s e t u p a

    l a b e l c o r r e s p o n d e n c e e . g . a + + ~ , ~ + + n) f o r e a c h m a c h i n e c c m b i n a t i o n ,

    w e i n t r o d u c e a l i t tl e s t r u c tu r e o n o u r l a b e l s e t A .

    We ass~ne a fixe d set A of names. We use ~, B, y, ... to stand for

    names

    W e a s s u m e a s e t ~ o f c o - n a m es , d i s j o i n t f r c ~ A a n d i n b i j e c t i o n

    w i t h i t; t h e b i j e c t i o n i s - ):

    o~ ~A) ~

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    25/176

    2

    na~ es L) = {n~ne l) ; 16L} .

    N O W c o n s i d e r t h e p a i r o f m ac h i n e s

    Y

    S : { ~ S ~ }

    Y

    T h e n a t u r a l c a n d i d a t e , p e r h a p s , f o r t h e cc r ~b i ne d m a c h i n e

    p i c t u r e d t h u s :

    S l i t

    m a y b e

    or:

    T 1_

    \ _/

    T h e i n t u i t i o n i s t h a t c c~ o l e m e n t a r y p o r t s , o n e i n e a c h m a c h i n e , a r e

    l i n k e d a n d h i d d e n l a b e ls r e m o v e d ) , s i n o e t h e s e l i n k s r e p r e s e n t m u t u a l

    o b s e r v a t i o n , w h i l e o t h e r p o r t s s t i l l s u p p o r t e x t e r n a l o b s e r v a t i o n .

    B u t u n d e r t h i s s c h e m e t h e r e a r e t w o d i s a d v a n t a g e s . F i r s t , c o n s i d e r

    r

    R: {8,~}

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    26/176

    21

    We can form RII[SIIT) and (RIiS) IT:

    each of sort {~,~} bu t clea rly different. S's offer s of 8-experiments

    are observe d by T in the first case, but by R in the second case. So

    II is no t associ ative.

    Second, it is usef ul to allo w that S's 8-experiment-offers

    (or 8-capabilities as we shall sometimes call them) may be obs erved by

    either R or T (that is, each 8-experiment cn S may be done by either

    R or T, but not both) ; this makes S into a resource shared by R

    and T.

    The solution is to factor cc~biD~tion into two separate operations:

    one to link ports, the other to hi__~ them. We shall use the %Dr d

    .composition for the first of th ese operations, and the second we shall

    call restriction.

    2.2 Cc~0osition, restr ictic n and relab ellin g

    T h e c c s p o s i te R I S o f o u r t w o m a c h i n e s R a n d S m a y b e p i c t u r e d

    i s

    r

    whil e for (RIS) IT we get

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    27/176

    22

    8

    ~ h a t is , f o r e a c h I , i n f o i ~ r / ng U I V w e l i n k e v e r y p o r t l a b e l l e d

    i n U t o e v e r y p o r t l a b e l l e d [ i n V .

    E x e r c i s e 2 . 1 F r c m R 1 ( SI T) a s a p i c t u r e , a n d c c n v i n c e y o u r s e l f b y o t h e r

    ~ ex am pl es t h a t - o n p i c t u r e s - c o m p o s i t i o n i s a n a s s o c i a t i v e a n d c c ~ sa u-

    t a t i v e o p e r a t i o n .

    B e f o r e d e f i n i n g c c ~ p o s i t i c n o f b e h a v i o u rs , l e t u s l o o k a t t w o o t h e r

    o p e r a t i o n s o n p i c t u r e s .

    F o r e a c h ~ , w e d e f i n e a p o s t f i x e d r e s t r i c t i o n o p e r a t i o n \ 5,

    w h i c h o n p i c t u r e s j u s t m e a n s h i d e t h e p o r t s l a b e l l e d ~ o r ~ , i .e .

    i t d r o p s t h e l a b e l s

    R J S ) \ ~

    I i

    a n d ~ f r c m p i c t u r e s , t h u s r e d u c i n g t h e i r s o r t .

    ( = R N S )

    ((RIS) IT)\8\Y\~

    s T i t

    \ _

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    28/176

    23

    E x e r c i s e 2 . 2

    W h i c h o f t h e f o l l o w i ng a r e i d e n t i c a l a s p i c t u r e s?

    (i) (( RI S) IT)\B\\~ (v) (RI (Sl T)\ 6)\ Bky

    (ii ) ((RI S)kS IT)k y\: (vi) (RI (SlT)\ x)\B\~

    (iii ) ((RI S) yIT) \B\~ (vii) ((RIT) 6 IS) \B\y

    ( i v ) ( ( RX y IS ) I T )X B \6 ( v i i i ) ( ( R I T ) k 6 1 S \ 6 ) \ B \ y

    N o t e: \ a b i n d s t i g h t e r t h a n I , s o t h a t U : V ~ m e a n s

    u v ~ ) .

    B e s id e s it s u s e w i t h c c ~ i t i c ~ , t h e r e s t ri c t i on o pe r a t i on b y it s el f

    c o r r e s p o n d s t o a s i n p l e , r a t h e r c o n c re t e , a c t i o n : - t h a t o f h i d i n g o r

    ' i n t e rn a l \ s i ng ' c e r t a i n p o r t s o f a m a c h i n e . C o m p a r e t h e r e ~ a r k s o n h i d i n g

    t h e b - b u t t o n s o f t w o m a c h i n e s , a t t h e e n d o f 1. 2.

    N o t e t h a t w e c a n d e f i n e S l iT , w h e r e S : L a n d T : M , b y

    Sll T = ( S I T ) \ ~ I . . . \ ~ n w h e r e { ~ l , . . O , a n } = n a m e s ( L ~ ) .

    W e s h a l l h e n c e f o r t h a b a n d o n t h e u s e o f u p p e r c a s e l e t t e r s f o r m a c h i n e s .

    T h e r e i s a f i n e d i s t i n c t i o n b e t w e e n t h e i d e a s o f (i) a m a c h i n e w h i c h m a y

    m o v e t h r o u g h s t a t e s b u t ~ + _h e s a m e m a c h i n e ( a p h y s i c a l n ot io n) a n d

    (ii) a m a c h i n e - s t a t e p a i r , i . e . a w a y o f s p e c i f y i n g a b e h a v i o u r w i t h a

    d e f i n i t e s t a r t ( a m o r e m t h e m a t i c a l n o t i on , e x e m p l i f i e d b y t h e n o n n a l

    d e f i n i t i o n o f F i n i t e - s t a t e A c c e p t o r a s c o n s i s t i n g o f a s t a t e s et , a t r a n s i -

    t i o n r e l a t i o n , a s e t o f a c c e p t i n g s t a t e s a n d a s t a r t st a t e ) o O u r l o w e r

    c a s e l e t t er s c o r r e s p o n d t o t he l a t t e r i d e a - i n d ee d , t h e y d e n o te t h e s p e c i -

    f i e d b e h a v i o u r s ( h e re a s ST s ) , a n d i t i s t h e s e w h i c h a r e t h e d c ~ a i n o f o u r

    a l g e b r a ; w e s h a l l s o o n s e e w h a t r l s e t c . m e a n a s b e h a v i o u r s o

    W e a l s o h a v e a n o t h e r u s e f o r u p p e r c a s e l et t er s ; w e s a y t h a t S : L + M

    ( w h e re L , M a r e s o r ts ) i s a r e a b e l l i n g f r c m L t o M i f

    ( i) i t i s a b i j e c t i o n ;

    (ii) i t r e s p e c t s c c ~ l e m e n t s

    ( i . e o S ( ~) = S ( ~) f o r ~ , ~ e L ) o

    W e d e f i n e t h e p o s t f i x e d r e l a b e l l i n ~ o p e r a t i o n I S ], o v e r ( p i c tu r e s o f)

    m a c h i n e s o f s o r t L , a s s i m p l y r e p l a c i n g e a c h l a b e l l e L b y S ( 1 ).

    T h u s f o r r , t a s a b o v e w e h a v e

    ~ I t = I

    -

    Y

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    29/176

    24

    a n d S : { f l, y ,8 , ~ } { S t y , e , [ } , g i v e n b y

    s ~ ) = 6 , s ~ ) = y , s ~ ) = ~ , s ~ ) = s

    i s a r e l a be l l i n g; w e t h e n h a v e

    r ) [ ] =

    W e s h a l l u s e c o n v e n i e n t a b b r e v i a t i o n s i n w r i t i n g r e l a b e l l i ng s e x p l i ci t l y .

    T h u s

    i i / ~ I , . . . , n / ~ n o r 1 1 1 2 i n / ~ l S 2 ~ n

    ( w he r e e l , . O . , a n a r e d i s t i n c t n a n e s , a n d I i , .. . , I n a r e l a b e l s w i t h

    d i s t i n c t n a re s ) s t a n d s f o r t h e r e l a b e l l i n g S : L M g i v e n b y

    ( i) S ( ~ i ) = I i f e i ~ L

    ( i i ) S ( ~ i) = I i f m i ~ L

    ( i i i ) S( 1 ) = I i f n a m e ( 1 ) ~ { e l , . . . , a n }

    p r o v i d e d t h a t t h e f u nc t i o n s o d e f i n e d i s a r e l a b e ll i n g . S o i n p l a c e o f

    ( r l t ) [ ~ a b o v e, w e w r i t e

    ( r lt ) [~ / 8 , ~ / 8 ] o r ( r ] ) [ ~ e / 8 ~ ] .

    W h e n w e s e e t h e l aw s o f th e F l o w A l g e b r a ( la ws f o r t he C ~ i t i o n ,

    R e s t r i c t i o n a n d R e l a b e l l i n g o p e ra t i on s ) i n T h e o r e m 5 . 5, w e s h a l l s e e t h a t

    r e l a b e l l i n g d i s t r i b u t e s o v e r o c~ i0 o si ti on , s o t h a t w e h a v e

    ( r I t ) [ ~ / ~ , ~ / 8 ] = r [ ~ / B , e / 6 ] ] t [ ~ / ~ , c / 8 ]

    ( as y o u c a n r e a d i l y c he ck ) - e v e n t h o u g h i n s t r i c t f o z m a l i t y ~ / B , e / 8

    s t a n d s f o r a d i f f e r e n t m e l a b e l l i n g i n e a c h c a s e, b e c a u s e r , t a n d r ] t

    p o s s e s s d i f f e r e n t s o r t s .

    2 . 3 E x t e m f ~ n @ t h e A l g e b r a o f S y n c h r o n i z a t i o n T r e e s

    W e m u s t n o w a d d o u r t h r e e n e w o p e r a ti o n s t o t h e a l g e b r a o f S T s , u s i n g

    i n t u i t i o n a b o u t t h e o p e r a t i o n a l m e a n i n g o f t h e s e tr e e s. I n f u t u r e w e

    c o n t i n u e t o u s e I t o r a n g e o v e r A , a n d u s e ~ ,~ t o r a n g e o v e r A u{ T} .

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    30/176

    5

    Cc~oo sition I : ST x ST STLu

    C o n s i d e r t w o S T s

    t = ~ u =

    F o r t h e i r ~ i t e , f o u r a c t io n s a r e p os si bl e, t l u

    (because t does), so one branc h of tlu will be

    This branc h represents independ ent actio n by one ccrsponent, and simila r

    b r a n c h e s e x i s t f o r a 8 - ex p er i me n t o n t a n d a n m - e x p e r i m e n t o n u . N o n e

    of these three branche s represents interaction betwe en t and u; but

    there is a possible interaction, sinoe u s m-offer ccmpl~ments t s

    e-offer. Since this actio n is internal (no t observable) we use T and

    r e p r e s e n t i t i n t h e c o m p o s i t e t r e e b y a b r a n c h

    P u t t i n g a l l t h e b r a n c h e s t o g e t h e r y i e l d s

    a d m i t s a n e - e x p e r i m e n t

    N o w c c ~ p o s i t i o n o f t a n d u h a s b e e n d e f i n e d i n t e zm s o f c c ~ p o s i t i o n

    of their sons; clearly this amounts to a recursive definit ion of 1

    M o r e p r e ci s el y , s i n c e e v e r y t r e e m a y b e w r i t t e n i n t h e f o z m

    t = ~ ~iti , ~i~Au{~}

    l_

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    31/176

    26

    E x e r c i s e 2 . 3 ( C o n s i d er o n l y f i n i t e S T s ) .

    (i) P r o v e b y ~ d u c t i o n o n t h e d e p t h o f t t h a t t l N I L = t .

    ( i i) W o r k o u t t l u f o r t = a / ~ 8 a n d u = I ~; c h o o s e s a n e

    o t h e r e x a m p l e s .

    ( i i i ) P r o v e b y i n d u c t i o n o n t h e s tw n o f t h e d e p t h s o f t r e e s t h a t

    tl u = ul t an d t I(ulv) = (tlu) Iv.

    W e s h o u l d c r i t i c i z e t w o a s p e c t s ( at l e a s ~ ) o f o u r d e f i n it i o n .

    C o n si d e r in g o u r f i r st e x a m pl e o f S T ~ s i t i o n , i t c a n w e l l b e a r g ue d

    t h a t t h e f o r m w e g a v e f o r t l u f a i ls t o r e p r e s e n t t h e p o s s i b l e c o n -

    c u r r e n t a c t i v i t y o f t a n d u - f o r e x a m p l e , w e m a y t h i n k t h a t a

    g - e xp e r im e nt o n t c a n b e p e r f or m e d s ~ t a n e o u s l y w i t h a n W - e x pe r i m en t

    o n u , w h i l e ( l o o k in g a t y o u r r e s u l t f o r E x e r c i s e 2 .3 (i i) a ls o) t h e S T

    f o r t l u m e r e l y i n d i c at e s t h a t t h e t w o e x p e r i m e n t s m a y b e p e r f o r m e d i n

    e i t h e r o r d e r. I n d e e d, S T s i n n o w a y r e p r e s e n t t r u e c o n c u r r e n c y .

    T w o n o t c o m p l e t e l y c o n v i n c i n g d e f e n c e s c a n b e g i v e n . F i r s t , S T s

    a r e s i mp l e , a n d t r a c t a b i l i t y i n a m o d e l h a s g r e a t a d v a n t a g e s ; s e c o n d ,

    i n s o f a r a s w e w i s h a ' b e h a v io u r - o b j ec t ' t o t e l l u s h o w a s y s t e m m a y

    a p p e a r t o a n o b s e r v e r w h o i s o n l y c a p a b l e o f o n e e x p e r i m e n t a t a t i m e ,

    w e f i n d i t p o s s i b l e t o i g n o r e t r u e c o n c u r r e n c y . Y o u a r e u r g e d t o

    c o n s i d e r t h i s q u e s t i o n i n g r e a t e r d e p t h .

    T h e s e c o n d a s p e c t f o r c r i t i c i s ~ i s t h e i n t ro d u c t i o n o f T t o r ep r e s e n t

    s u c c e s s f u l ' m u t ua l o b s e r v a t i o n s ' . I f w e h a d n o n e e d f o r i t i n d e f i n i n g I,

    w e c o u l d l e a v e i t o u t o f o u r t h e o r y a l t o ge t h e r.

    A g a i n , t h e r e a r e t w o d e f e n c e s , b u t t h i s t i m e c o n v i n c i n g o n e s . F i r s t ,

    c o n s i d e r r e p l a c i n g t he t h i r d t e r m i n t h e r e c u r s i v e d e f i n i t i o n o f t l u -

    n a m e l y t h e t e a m [ T ( t i l u j) - b y j u s t [ ( t i I ) ;

    i n t u i t i v e l y , a n i n t e r n a l a c t i o n j u s t v a n i s h e s . I t t u r n s o u t t h a t 1

    i s n o l o n g e r a n a s s o c i a ti v e o p e r at i o n , w h i c h c o n f li c t s s t r o n g l y w i t h o u r

    a s s u m p t i o n t h a t t h e j o i n t b e h a v i o u r o f t / kr ee a g e n t s s h o u l d i n n o w a y

    d e p e n d u p o n t h e o r d e r i n w h i c h w e w i r e t h e m t o g e t h e r b e f o r e t h e y d o a n y -

    t h i n g '

    E x e r c i s e 2 . 4 W i t h t h i s n e w d e f i n i t i o n w o r k o u t t I u l v ) a n d ( t l u ) I v

    f o r t = e , u = a , v = 8 t o j u s t i f y t h e a b o v e a s s e r t i o n .

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    32/176

    27

    T h e s e c o n d d e f e n c e i s t h a t w e m u s t s c ~ e h o w e x p r e s s , i n t h e S T t lu )\ ~

    w h e n t = a A B , u = I ~, t h e p o s s i b i l i t y t h a t c c m a u n i c a t i o n b e t w e e n t

    a n d u c a n p r e v e n t a n y B - e x p e r i m en t .

    E x e r c i s e 2. 5 U n d e r t h e n o n a a l d e f i n i t i o n o f

    w o r k o u t t h a t

    t l u ) \ ~ = T ~ B

    i n t h i s c a s e .

    I, an d of \~ see below) ,

    T h i s S T d o e s i n d e e d r e p r e s e n t p o s s i b l e p r e v e n t i o n o f a 8 - e x p e r i m en t ,

    a n d u n l e s s w e l e a v e S T s a n d d e r i v e d m o d e l s ) a l t o g e t h e r i t i s h a r d t o

    s ee h o w s uc h d ea dl oc k p h e ~ c an h e r ep re se nt ed w i th o ut z.

    R e s t r i c t i o n \ ~ : S T S T L _ { ~ , ~ } ~ cA )

    W e w i s h t o d e n y a l l ~ - a n d m - e x p e r i m e n t s , s o t h a t t \ ~ i s f o r m e d

    b y p r u n i n g a w a y a l l b r a n c h e s a n d s lA b- br an ch es l a b e l l e d ~ o r e . C o n s i d e r i n g

    t =

    a g a i n , w e s e e t h a t

    tlu) \~ =

    M o r e f o r m a l l y , f o r t = ~ . i t i w e h a v e

    D e f i n i t i o n t \ ~ = ~ - ~ i t i ~ )

    A n o b v i o u s a l t e r n a t i v e t o t he r e s t r i c t i on o p e r a t i o n w o u l d b e t o d e f i n e

    \ l f o r e a c h m e ~ b e r i o f A b y

    t\l ui~ l~i ti\l) ;

    i n o t h e r w o r d s , w e m i g h t c h o o s e t o r e s t r i c t n a ~ e s a n d o o - n a m e s i n d e pe n d e nt l y ,

    i n s t e a d o f b o t h a t o n c e . ~ n i s w o u l d , o f c o u r s e , h a v e a c o r r e s p o n d i n g l y

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    33/176

    8

    d i f f e r e n t e f f e c t o n p i c t ur e s . T h e r e a s o n f o r o u r c h o i c e i s i n f a c t to

    d o w i t h t h e a l g e b r a o f p i c t u r e s ( F l o w A l g e b r a ) u n d e r I, \ e a n d [ S] ;

    i t h a s a p a r t i c u l a r l y s i m p l e a l g e b r a i c t h e o r y [ ~M , M i l 2 ] , w h i c h w e

    h a v e n o t f o u n d f o r t h e s u g g e s t e d a l t e r n a t i v e .

    R e a b e l l i n I S ]: S T + S T ( S : L M a r e l a b e l l i n g )

    T h i s o p e r a t i o n i s a s s i m p l e o n S T s a s i t i s o n p i c t u r e s ; i t j u s t

    a p p l i e s t h e r e l a b e l l i n g S t o a l l l a b e l s i n t h e t r e e . M o r e f o r m a l l y ,

    f o r t = _ u i t i w e h a v e

    D e f i n i t i o n t [ S ] = _ ~S (~ )

    (ti[S])

    1

    w h e r e w e n o w a d o p t t h e c o n v e n t i o n t h a t S ( T ) = f o r a n y r e l a b e l l i n g S .

    A n i m F ~ r t a n t ( t h o ug h n o t t h e o nl y) u s e o f r e l a b e l l i n g i s i n c a s e s

    w h e r e w e h a v e s e v e r a l i n s t a n c e s o f a s i n g l e a g e n t r i n a s y s t e m, b u t

    e a c h w i t h d i f f e r e n t l a b e l l i n g, s o t h a t u n d e r e c ~ p o s i t i o n t h e y a r e p r o p e r l y

    l i n k e d. W e h a v e o n l y t o d e f i n e s e v e r a l ' o p i e s '

    r i = r[S i]

    o f t h e g e n e r i c a g e n t r , a n d t h e n c c ~ p o s e t h e r .

    O n e m i g h t h a v e a l l o w e d m o r e g e n e r a l r e l a b e l li n g s, u s i n g m a n y - o n e

    f u n c t i o n s o v e r A ( so t h a t d i f f e r e n t l y l a b e l l e d p o r t s c c m e t o b e a r t h e

    s a n e l a b el ) o r e v e n r e l a t i o n s i n p l a c e o f f u n c t i o n s ( so t h a t o n e p o r t

    c o u l d ' sp li t' i n t o t w o d i f f e r e n t l y l a b e l l e d p o r t s ) . S u f f i c e i t t o s a y

    t h a t th i s c r e a t e s p r o b l e m s i n t h e a x i c m a t i z a t i o n o f F l o w A l g e b r a . T h e

    p r e s e n t c h o i c e a l l o w s p l e n t y o f s c o p e .

    2 . 4 A s i m p l e e xa r ~o le : b i n a r y S ~ n a p h o r e s

    A b i n a r y s e m a p h o r e s , o f s o r t { ~ ,~ } , m a y b e p i c t u r e d

    [

    r

    TO g a i n t h e s ~ ,a t :t ~ o re ( D i j k s t r a s P O p e r a t i o n ) w e m u s t p e r f o r m a

    e x t: ex i m e n t; w e r e l e a s e i t t h e V o p e r a t i o n ) b y a ~ - e x ~ r ~ m e n t .

    s ~ s

    1[

    C l e a r l y

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    34/176

    9

    e x p r e s s e s t h e a p p r o p r i a t e b e h a v i o u r ( a l o n g t h i n S T ') . I m a g i n e a

    g e n e r i c a g e n t p , w h o s e c r i t i c a l s e c t i o n w e r e p r e s e n t b y a s e q u e n c e

    of atomic actions (experiments upo n a resource, say), and who se

    n o n - c r i % i c a l s e c t i o n w e i g no r e:

    p = ~ 6 ~ p .

    W e w i s h t o p l a c e s e v e r a l i n st a nc e s o f p

    P i = P [ S i ] = ~ i 6 i ~ P i ( w he r e S i = ~ i 8i / ~6 )

    i n ~ c a t i o n w i t h s , a n d d e r i v e t h e o c m p os i t e S T. C o n s i d e r j u s t

    t w o c o pi e s o f p ( i = 1 , 2 ) a n d f o r m

    q = (pllP21S)\~\

    w h i c h m a y b e p i c t u r e d a s s h o wn :

    ~1

    a 2

    p s p

    61 62

    q

    We e a s i l y d e r i v e a n e q u a t i o n f o r t h e a z ~ p o s i t e ST q u s i n g th e E x p an s io n

    Theorem - g i v e n i n 2 .5 - r e p e a t e d l y . Y ou s h o u l d r e a d t h a t s e c t i o n w i t h

    r e f e r e n c e t o t h e e x p a n s io n w h i ah f o l l o w s :

    q = ( ~a 8 1 ~p l I ~ 2 6 2 P 2 ~ S ) ~ \

    = T ~ I s ~ p l i P 2 1 S s ) ~ \ ) + T p ~ I ~ 2 6 2 ~ P 2 i s )

    ~ ~

    = re161( (#Pl IP2 I~s) ~\~) + ~ 2 8 2 ((Pll#P2 lSs) ~\~)

    = T~161T ( Pl IP2 Is) ~\~) + T~262~ ( Pl I 2 Is) \~\# )

    = ~e181 Tq + T~262T

    S O q i s t h e S T g i v e n r e c u r s i v e l y b y

    ~I ~2

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    35/176

    30

    a n d e x a c t l y e x p r e s s e s t h e f a c t t h a t t h e c r i t i c a l s e c t i o n s o f P l a n d

    P 2 c a n n e v e r o v e r l a p i n t i m e , i . e . a s e q u e n c e l i k e ~ I ~ 2 B I . . . i s n o t

    p o s s i b l e .

    I n f a ct , a n n - b o u n d e d s ~ m a p h o r e ( n_ > i) c a n b e c o n s t r u c t e d a s

    s = s l s l I s

    n

    n t i m e s

    t h i s i s a n e x a n p l e o f c c ~I oc si ti on w h i c h e f f e c t s n o l i n k a g e , b u t w i l l y i e l d

    a m u l t i - w a y l i n k a ge w i t h u s e r a g e n ts .

    T h e 2 - b o u n d e d s e m a p h o r e s ,

    B

    c~3

    P B 3 P

    w i t h 3 u s er s , c a n b e p i c t u r e d

    i

    D i a g r a m f o r ( p i I p 2 1 P 3 1 S 2 ) \ ~ \ ~

    s 2

    ( s2 s b o r d e r , a n d i t s t w o c o l l e c t o r n o d e s , a r e f ic t i t i o u s ; t h e y a r e j u s t

    u s e d h e r e t o a v o i d d r a w i n g 1 2 l i n k s i n t h e p i c t u r e ) .

    E x e r c i s e 2 . 6 A s p r a c t i c e i n u s i n g t h e E x p a n s i o n T h e o r ~ n , d e v e l o p t h e

    e x p r e s s i o n q = ( p l [ p 2 1 P 3 1S l S ) \ ~ \ ~ , a n d d r a w p a r t o f t h e S T t o o o n v i n o e

    y o u r s e l f t h a t a t m o s t t w o c r i t i c a l s e c t i o n s c a n b e s i m u l t a n e o u s l y a c t i v e .

    C a n y o u e v e n d e r i ve a s e t o f m u t u a l l y r e c u r s i v e b e h a v i o u r e q u a ti o n s , f o r

    w h i c h q i s t h e s o l u t i o n ? I t s a b i t l e n g t h y, b u t p o s s i b l e . T h e

    d e v e l o p m e n t i s s h o r t e r i f y o u t a k e ~ i = ~ 2 = ~ 3 =~ , B 1 = ~ 2 = B3 = 8 ; i .e . d e a l

    w i t h ( p l p l p l sl s ) \ ~ \ ~ i n s t e a d; t h e n t h e S T w i l l n o t d i s t i n g u i s h t h e

    c r i t i c a l s e c t i o n s o f e a c h c o p y o f p , b u t y o u s h o u l d b e a b l e t o s h o w

    t h a t a t a n y p o i n t i n t i m e t h e e x c e s s o f e s o v e r B s p e r f o r m e d

    l i e s i n t h e r a n g e [ 0 ,2 3 .

  • 8/11/2019 Robin Milner a Calculus of Communicating Systems 1980

    36/176

    31

    2 . 5 T he S T ~ p a n s i o n T h e o r e m

    W e co n si d er t re e s e x p r e s s e d i n t h e f o rm

    t = [ ~ i t i .

    l ~ i ~ n

    F o r a s e t { ~ l , . . . , e k } = A o f na m e s , w e a b b r e v i a t e

    \ ~ 1 \ ~ 2 . . . \ ~ k b y \ A .

    T h e o r e m 2 . 1 ( T h e E x p a n s i o n T he or em _)

    L e t t = ( t

    I t 1 . . . . I t

    \ A , w h e r e e a c h t i s a s ~ n a s a b o v e .

    T h e n t = ~ { ~ ( ( t l l ' I t l l ' I t m ) \ A ) ; l _ < i _ < m , ~t.'l a s t l ~m a nd o f

    t i ,

    n r~ (V) ~A}

    + ~ { T( (t lI .. .I t .' l . .. It .' l . . . I tm ) \ A ); 1 < i < j _ < m ,

    i 3

    It ' a su~Inand of ti, ~tj' a sun, and of tj }

    P r o o f O m i t t e d ; i t u s e s p r o p e r t i e s o f t h e F l o w o p e r a t i o n s $, \ ~ a n d

    [ S ], a n d c a n b e d o n e b y i n d u c t i o n o n m .

    T h e t h e o r e ~ s t a t e s t h a t e a c h b r a n c h o f t c o r r e s p o n ds e i t h e r t o a n

    u n r e s t r i c t e d a c t i o n o f s c ~ e t i , o r t o a n i n t e r n a l c c ~ m u n i c a t i o n b e t w e e n

    t . a n d t . ( i < j ). F o r e x a m p l e c o n s i d e r

    l 3

    ( ( a t + ~ t ) I ( ~ u + y u ) I ~ v + ~ v ) ) \ ~ \ ~ ;

    t h e t h e o r e m g i v e s u s

    ( u n r e s t r i c t e d a c t i o n s )

    + ~ ( ( ( ~ t + s t ) i ( ~ u + ~ u ) I v ) \ ~ \ ~ )

    + T ( t l u ]