a theoretical basis of communication centred programming
play

A Theoretical Basis of Communication-Centred Programming for Web - PowerPoint PPT Presentation

Page 1 A Theoretical Basis of Communication-Centred Programming for Web Service Nobuko Yoshida (Imperial) Kohei Honda (Queen Mary) TiC2006 , July 2006 Page 2 In Collaboration with: Marco Carbone (Queen Mary) Vasco Vasconcelos (Lisbon)


  1. Page 1 A Theoretical Basis of Communication-Centred Programming for Web Service Nobuko Yoshida (Imperial) Kohei Honda (Queen Mary) TiC’2006 , July 2006

  2. Page 2 In Collaboration with: Marco Carbone (Queen Mary) Vasco Vasconcelos (Lisbon) Gary Brown (pi4 technologies) Steve Ross-Talbot (pi4 technologies)

  3. Page 3 Structure of Lectures ➤ Part 1 Basic Theory (Mobile Processes and Types) ➣ 1 Introduction to the π -Calculus ➣ 2 Idioms for Interactions ➣ 3 Session Types ➤ Part 2 Web Services and the π -Calculus ➣ 1 Web Services Choreography Description Language ➣ 2 Global Language and the End-Point Calculus ➣ 3 End-Point Projection and Correctness

  4. Page 4 Protocol Example Scenario: Item Purchasing (Typical W3C example)

  5. Page 5 Challenges ➤ How can we design languages for Web Services? ⇒ use the π -calculus as an underlying formal model = ➤ What are good programming and type disciplines for Web Services? ⇒ use the type theory of the π -calculus (session types) = for structured programming of communication and concurrency ➤ How can we validate correctness of Web Services? = ⇒ use a semantics, type and structured preserving translation from Web Service languages to the π -calculus

  6. Page 6 Syntax ➤ Names: a , b , c ,..., x , y , z ,... . ➤ the Asynchronous π -Calculus (Honda and Tokoro 1991, Boudol 1992) P :: = 0 | a ( x ) . P | a � b � | P | Q | ( ν x ) P | ! a ( x ) . P ➤ cf. CCS def P :: = 0 | a ( x ) . P | a ( b ) . 0 | P | Q | P \{ x } | A = P

  7. Page 7 Computation ➤ CCS Interaction = Synchronisation ( a . P + R ) | ( a . R + Q ) − → P | R ➤ π Interaction = (Synchronisation and) Name-Passing a ( x ) . P | a � b � − → P { b / x } ➣ Internal choice: P ⊕ Q = ( ν c )( c | c . P | c . Q )

  8. Page 8 Binding ➤ Association | is the weakest. ➣ ( ν x ) a ( y ) . P = (( ν x )( a ( y ) . P )) and ( ν x ) P | Q = (( ν x ) P ) | Q ➣ ( ν y ) a ( x ) . P = ( ν y )( a ( x ) . P ) , ( ν y ) ! a ( x ) . P = ( ν y )( ! a ( x ) . P ) . ➤ Free Names fn ( P ) ➣ a ( x ) . b � x � a ( x ) . x ( z ) . 0 ➣ ( ν a ) a ( x ) . x � v � ➣ ( ν a ) a ( x ) . x � v �| b ( x ) . a � x �

  9. Page 9 Structure Congruence ➤ To handle the parts of terms with no computational significance ➤ Inspired by Chemical Abstract Machine (Berry and Boudol 1991) ➤ P ≡ Q ➣ Change of bound names ( α -conversion). ➣ P | 0 ≡ P P | Q ≡ Q | P ( P | Q ) | R ≡ P | ( Q | R ) ➣ ( ν x ) 0 ≡ 0 ( ν xx ) P ≡ ( ν x ) P ( ν xy ) P ≡ ( ν yx ) P ➣ (( ν x ) P ) | Q ≡ ( ν x )( P | Q ) ( x �∈ fn ( Q ))

  10. Page 10 Examples (1) ➤ 0 | 0 | 0 ≡ 0 . ➤ ( ν a )( a � v �| 0 ) ≡ ( ν a ) a � v � . ➤ ( ν a )( b � v �| 0 ) ≡ b � v �| ( ν a ) 0 ≡ b � v � . ➤ ( ν z )( x � z �| z ( w ) . c � w � ) | x ( y ) . z � y � ≡ ( ν z ′ )( x � z ′ �| z ′ ( w ) . c � w �| x ( y ) . z � y � )

  11. Page 11 Reduction Relation x ( y ) . P | x � v � − → P { v / y } Com ! x ( y ) . P | x � v � − → P { v / y }| ! x ( y ) . P Rep → P ′ → P ′ P − P − Par Res → P ′ | Q ( ν x ) P − → ( ν x ) P ′ P | Q − P ′ ≡ Q ′ → P ′ Q ≡ P P − Struct → Q ′ Q −

  12. Page 12 Examples (1): Forwarder Let FW ( ab ) = ! a ( x ) . b � x � . Then FW ( ab ) | a � v � − → b � v �| FW ( ab ) . ➤ FW ( ab ) | a � v �| a � w � − → FW ( ab ) | b � v �| a � w � − → FW ( ab ) | b � v �| b � w � We also have: FW ( ab ) | a � v �| a � w � − → FW ( ab ) | a � v �| b � w � − → FW ( ab ) | b � v �| b � w � ➤ a � v �| FW ( ab ) | FW ( bc ) − → FW ( ab ) | b � v �| FW ( bc ) − → FW ( ab ) | FW ( bc ) | c � v � .

  13. Page 13 Scope Opening ➤ ( ν x )( a � x �| x ( y ) . d � y � ) | a ( z ) . z � w � ≡ ( ν x )( a � x �| x ( y ) . d � y �| a ( z ) . z � w � ) ≡ ( ν x )( x ( y ) . d � y �| a � x �| a ( z ) . z � w � ) → ( ν x )( x ( y ) . d � y �| x � w � ) − → ( ν x ) d � w � ≡ d � w � . −

  14. Page 14 Exercise (1) 1. a � v � | b � w � | FW ( ab ) | FW ( bc ) 2. a � v � | b � w � | ( ν b ′ )( FW ( ab ′ ) | FW ( b ′ c )) 3. ( ν x )( a � x � | x ( y ) . d � y � ) | a ( z ) . z � w �| a ( z ) . z � v � 4. a � x � | x ( y ) . d � y � | a ( z ) . z � w � | x ( z ) . z � v � 5. ( ν x )( a � x � | ! x ( y ) . d � y � ) | a ( z ) . ( z � w � | z � w ′ � )

  15. Page 15 Small Agents (1) def = ( ν x ) ! a ( y ) . y � x � ➤ New Name Creator N ( a ) → N ( a ) | ( ν x ) b � x �| ( ν x ) c � x � N ( a ) | a � b �| a � c � − →− ➤ Identity Receptor FW ( aa ) FW ( aa ) | a � v � − → FW ( aa ) | a � v � def ➤ Equator EQ ( ab ) = ( FW ( ab ) | FW ( ba )) . Note that EQ ( ab ) ≡ EQ ( ba ) . EQ ( ab ) | a � v � EQ ( ab ) | c � a � ∼ = EQ ( ab ) | c � b �

  16. Page 16 Small Agents (2) def ➤ Distributor D ( abc ) = a ( x ) . ( b � x �| c � x � ) def = ( ν c 1 )( D ( abc 1 ) | D ( c 1 cd )) D ( abcd ) ➣ a ( x ) . ( P | Q ) = ( ν c 1 c 2 )( D ( ac 1 c 2 ) | c 1 ( x ) . P | c 2 ( x ) . Q ) def ➤ Killer K ( a ) = a ( x ) . 0 def ➤ Left Binder Br ( ab ) = a ( x ) . FW ( xb ) def ➤ Right Binder Bl ( ab ) = a ( x ) . FW ( bx ) def ➤ Synchroniser S ( abc ) = a ( x ) . FW ( bc )

  17. Page 17 Joyful Hacking in the π -Calculus

  18. Page 18 Synchrony in Asynchrony ➤ Synchronous π -Calculus P :: = 0 | a ( x ) . P | a � b � . P | P | Q | ( ν x ) P | ! a ( x ) . P ➤ Reduction x ( y ) . P | x � v � . Q − → P { v / y }| Q . ➤ Mapping ( ) ⋆ : Synchronous π → Asynchronous π ( x ( y ) . P ) ⋆ = ( ν c )( x � c �| c ( y ) . P ⋆ ) ( x � v � . P ) ⋆ = x ( y ) . ( y � v �| P ⋆ )

  19. Page 19 Polyadicity in Mondadicity ➤ Polyadic π -Calculus ( n ≥ 0) :: = a ( x 1 , x 2 ,..., x n ) . P | a � b 1 , b 2 ,..., b n � . P P | ! a ( x 1 , x 2 ,..., x n ) . P | ··· ➤ x ( y 1 , y 2 ,..., y n ) . P | x � v 1 , v 2 ,..., v n � . Q − → P { v 1 / y 1 }{ v 2 / y 2 } ... { v n / y n }| Q . ➤ We can use the macro a ( c ) . P means ( ν c ) a � c � . P ➤ Mapping ( ) ∗ : Polyadic π → Synchronous π ( x ( y 1 , y 2 ,..., y n ) . P ) ∗ = x ( c ) . c ( y 1 ) . c ( y 2 ) ... c ( y n ) . P ∗ . ( x � v 1 , v 2 ,..., v n � . P ) ∗ = x ( c ) . c � v 1 � . c � v 2 � ... c � v n � . P ∗ .

  20. Page 20 Exercises ➤ Why the following mapping is incorrect? ( x ( y 1 , y 2 ,..., y n ) . P ) ∗ = x ( y 1 ) . x ( y 2 ) ... x ( y n ) . P ∗ . ( x � v 1 , v 2 ,..., v n � . P ) ∗ = x � v 1 � . x � v 2 � ... x � v n � . P ∗ . ➤ Sequencing x 1 ) ; � ˜ x n − 1 ) ; � ˜ a ( ˜ b 2 � ; ... ; ( ˜ b n � ; P a � ˜ x 2 ) ; ... ; � ˜ b 1 � ; ( ˜ b n − 1 � ; ( ˜ x n ) ; P

  21. Page 21 Branching/Selection ➤ Branching/Selection :: = a [( x 1 ) . P 1 & ( x 2 ) . P 2 ] | ! a [( x 1 ) . P 1 & ( x 2 ) . P 2 ] P | a inl � b � . P | a inr � b � . P ··· ➤ a [( x 1 ) . P 1 & ( x 2 ) . P 2 ] | a inl � b � . Q − → P 1 { b / x 1 }| Q a [( x 1 ) . P 1 & ( x 2 ) . P 2 ] | a inr � b � . Q − → P 2 { b / x 2 }| Q ➤ Mapping ( ) ◦ : Branching/Selection π → Polyadic π ( a [( x 1 ) . P 1 & ( x 2 ) . P 2 ]) ◦ = a ( c ) . c ( c 1 c 2 ) . ( c 1 ( x 1 ) . P ◦ 1 | c 2 ( x 2 ) . P ◦ 2 ) ( a inl � b � . Q ) ◦ = a ( c ) . c ( c 1 c 2 ) . c 1 � b � . Q ◦

  22. Page 22 Branching/Selection ➤ Boolean Agent: Tru ( a ) = ! a ( x ) . inl �� Fls ( a ) = ! a ( x ) . inr �� ➤ If-Then-Else: If a then P else Q = a ( c ) c [() . P & () . Q ] ➤ If a then P else Q | Tru ( a ) − → P If a then P else Q | Fls ( a ) − → Q ➤ ( a [() . P & () . Q ]) ◦ = a ( c ) . c ( c 1 c 2 )( c 1 . P ◦ | c 2 . Q ◦ ) ( a inl �� ) ◦ = a ( c ) c ( c 1 c 2 ) . c 1 ( a inr �� ) ◦ = a ( c ) c ( c 1 c 2 ) . c 2

  23. Page 23 Are you fed up with hacking with many name passing?

  24. Page 24 Time for Session Types !

  25. Page 25 Towards Structured Interactions: Sessions ➤ offer flexible programming style for structured interaction in communication-centric distributed software. ➤ statically check safe and consistent compositions of protocols (can be done at run-time or by type inference)

  26. Page 26 Related Work: Session Types (1) ➤ Structured Concurrent Languages (Takeuchi, Honda and Kubo) [PARL94] ➤ Higher-Order Session (Honda, Vasconcelos and Kubo) [ESOP98] ➤ Subtyping (Gay and Hole) [ESOP00, Acta Informatica 05] ➤ COLBA Interface (Vallecillo et al) [FOCLASA02] ➤ Concurrent Haskell (Neubauer and Thiemann) [PADL04]

  27. Page 27 Related Work: Session Types (2) ➤ Multi-threaded Functional Languages (Vasconcelos, Ravara and Gay) [CONCUR04] ➤ Correspondence Assertions (Bonelli, Comagnoni and Gunter) [JFP05] ➤ Distributed Java (Dezani, Yoshida, Ahern and Drossopoulou) [TCG05] ➤ Web Service Description Languages (W3C CDL Working Group) ➤ Microsoft Singularity Operating System (F¨ ahndrich et. al) [EuroSys06]

Recommend


More recommend