FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of...
Transcript of FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of...
![Page 1: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/1.jpg)
FUNDAMENTALS OFSESSION TYPES
Formal Methods for the Design ofComputer, Communication and Software Systems
Bertinoro, June 4, 2009
Vasco T. VasconcelosUniversity of Lisbon
1
![Page 2: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/2.jpg)
CHALLENGE
• Among the many problems faced in developing web-service based applications, there is a little one that this talk addresses:
• Formally describing the protocol between a service provider a client
• Making sure, at compile time, that a program follows the protocol
2
![Page 3: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/3.jpg)
BINARY PROTOCOLS ONLY
• We concentrate on binary protocols, involving exactly one service provider and one client (at a time)
• Protocols demanding three or more partners are the topic of the next talk
3
![Page 4: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/4.jpg)
OUTLINE
Part I _ The practice
Where, based on an example, we describe a simple service and program it
Part 2 _ The theory
Where we discusss the technology behind a compiler that makes sure programs conform to service descriptions
4
![Page 5: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/5.jpg)
PART ITHE PRACTICE
5
![Page 6: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/6.jpg)
1.PROTOCOL DESCRIPTION
6
![Page 7: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/7.jpg)
OUR RUNNING EXAMPLE
• A simplified distributed auction system with three kinds of players:
• Sellers that want to sell items
• Auctioneers that sell items on their behalf
• Bidders that bid for an item being auctioned
7
![Page 8: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/8.jpg)
THE SELLER’S PROTOCOL
8
![Page 9: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/9.jpg)
THE SELLER’S PROTOCOL
!{selling:
8
![Page 10: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/10.jpg)
THE SELLER’S PROTOCOL
!{selling:
Select option selling on the auctioneer
8
![Page 11: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/11.jpg)
THE SELLER’S PROTOCOL
!{selling:
8
![Page 12: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/12.jpg)
THE SELLER’S PROTOCOL
!{selling: !Item
8
![Page 13: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/13.jpg)
THE SELLER’S PROTOCOL
!{selling: !Item
Send the item to be sold
8
![Page 14: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/14.jpg)
THE SELLER’S PROTOCOL
!{selling: !Item
8
![Page 15: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/15.jpg)
THE SELLER’S PROTOCOL
!{selling: !Item.!Price.
8
![Page 16: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/16.jpg)
THE SELLER’S PROTOCOL
!{selling: !Item.!Price.
Send its price
8
![Page 17: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/17.jpg)
THE SELLER’S PROTOCOL
!{selling: !Item.!Price.
8
![Page 18: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/18.jpg)
THE SELLER’S PROTOCOL
!{selling: !Item.!Price.&{sold:
8
![Page 19: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/19.jpg)
THE SELLER’S PROTOCOL
!{selling: !Item.!Price.
If the item was sold...
&{sold:
8
![Page 20: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/20.jpg)
THE SELLER’S PROTOCOL
!{selling: !Item.!Price.&{sold:
8
![Page 21: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/21.jpg)
THE SELLER’S PROTOCOL
!{selling: !Item.!Price.&{sold: ?Price
8
![Page 22: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/22.jpg)
THE SELLER’S PROTOCOL
!{selling: !Item.!Price.
Read the price
&{sold: ?Price
8
![Page 23: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/23.jpg)
THE SELLER’S PROTOCOL
!{selling: !Item.!Price.&{sold: ?Price
8
![Page 24: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/24.jpg)
THE SELLER’S PROTOCOL
!{selling: !Item.!Price.&{sold: ?Price.end,
8
![Page 25: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/25.jpg)
THE SELLER’S PROTOCOL
!{selling: !Item.!Price.
... and terminate
&{sold: ?Price.end,
8
![Page 26: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/26.jpg)
THE SELLER’S PROTOCOL
!{selling: !Item.!Price.&{sold: ?Price.end,
8
![Page 27: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/27.jpg)
THE SELLER’S PROTOCOL
!{selling: !Item.!Price.&{sold: ?Price.end,
notSold: end}}
8
![Page 28: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/28.jpg)
THE SELLER’S PROTOCOL
!{selling: !Item.!Price.
If not sold terminate
&{sold: ?Price.end,
notSold: end}}
8
![Page 29: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/29.jpg)
THE SELLER’S PROTOCOL
!{selling: !Item.!Price.&{sold: ?Price.end,
notSold: end}}
8
![Page 30: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/30.jpg)
THE TYPE CONSTRUCTORS
!Item Send a value
?Price Receive a value
!{selling: ...} Select an option
&{sold: ..., notSold: ...} Offer a set of options
end Terminate
9
![Page 31: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/31.jpg)
THE AUCTIONEER INTERACTING WITH A SELLER
10
![Page 32: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/32.jpg)
THE AUCTIONEER INTERACTING WITH A SELLER
&{selling:
10
![Page 33: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/33.jpg)
THE AUCTIONEER INTERACTING WITH A SELLER
&{selling:
Offer option selling to sellers
10
![Page 34: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/34.jpg)
THE AUCTIONEER INTERACTING WITH A SELLER
&{selling:
10
![Page 35: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/35.jpg)
THE AUCTIONEER INTERACTING WITH A SELLER
&{selling: ?Item.
10
![Page 36: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/36.jpg)
THE AUCTIONEER INTERACTING WITH A SELLER
&{selling: ?Item.
Receive the item to be sold
10
![Page 37: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/37.jpg)
THE AUCTIONEER INTERACTING WITH A SELLER
&{selling: ?Item.
10
![Page 38: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/38.jpg)
THE AUCTIONEER INTERACTING WITH A SELLER
&{selling: ?Item.?Price.
10
![Page 39: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/39.jpg)
THE AUCTIONEER INTERACTING WITH A SELLER
&{selling: ?Item.?Price.
Receive its price
10
![Page 40: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/40.jpg)
THE AUCTIONEER INTERACTING WITH A SELLER
&{selling: ?Item.?Price.
10
![Page 41: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/41.jpg)
THE AUCTIONEER INTERACTING WITH A SELLER
&{selling: ?Item.?Price.!{sold:
10
![Page 42: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/42.jpg)
THE AUCTIONEER INTERACTING WITH A SELLER
&{selling: ?Item.?Price.!{sold:
Inform that the item was sold...
10
![Page 43: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/43.jpg)
THE AUCTIONEER INTERACTING WITH A SELLER
&{selling: ?Item.?Price.!{sold:
10
![Page 44: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/44.jpg)
THE AUCTIONEER INTERACTING WITH A SELLER
&{selling: ?Item.?Price.!{sold: !Price
10
![Page 45: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/45.jpg)
THE AUCTIONEER INTERACTING WITH A SELLER
&{selling: ?Item.?Price.!{sold: !Price
Send the selling price
10
![Page 46: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/46.jpg)
THE AUCTIONEER INTERACTING WITH A SELLER
&{selling: ?Item.?Price.!{sold: !Price
10
![Page 47: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/47.jpg)
THE AUCTIONEER INTERACTING WITH A SELLER
&{selling: ?Item.?Price.!{sold: !Price.end,
10
![Page 48: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/48.jpg)
THE AUCTIONEER INTERACTING WITH A SELLER
&{selling: ?Item.?Price.!{sold: !Price.end,
... and terminate
10
![Page 49: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/49.jpg)
THE AUCTIONEER INTERACTING WITH A SELLER
&{selling: ?Item.?Price.!{sold: !Price.end,
10
![Page 50: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/50.jpg)
THE AUCTIONEER INTERACTING WITH A SELLER
&{selling: ?Item.?Price.!{sold: !Price.end,
notSold: end}}
10
![Page 51: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/51.jpg)
THE AUCTIONEER INTERACTING WITH A SELLER
&{selling: ?Item.?Price.!{sold: !Price.end,
notSold: end}}
Or inform the item was not sold and
terminate
10
![Page 52: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/52.jpg)
THE AUCTIONEER INTERACTING WITH A SELLER
&{selling: ?Item.?Price.!{sold: !Price.end,
notSold: end}}
10
![Page 53: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/53.jpg)
SELLING AND BUYING...
• ... are complementary activities
• And so are the types that govern them:
• We call them dual
11
![Page 54: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/54.jpg)
SELLING AND BUYING...
• ... are complementary activities
• And so are the types that govern them:
• We call them dual
!{selling: !Item.!Price.&{sold: ?Price.end, notSold: end}}
11
![Page 55: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/55.jpg)
SELLING AND BUYING...
• ... are complementary activities
• And so are the types that govern them:
• We call them dual
!{selling: !Item.!Price.&{sold: ?Price.end, notSold: end}}
The protocol for the seller
11
![Page 56: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/56.jpg)
SELLING AND BUYING...
• ... are complementary activities
• And so are the types that govern them:
• We call them dual
!{selling: !Item.!Price.&{sold: ?Price.end, notSold: end}}
&{selling: ?Item.?Price.!{sold: !Price.end, notSold: end}}
The protocol for the seller
11
![Page 57: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/57.jpg)
SELLING AND BUYING...
• ... are complementary activities
• And so are the types that govern them:
• We call them dual
!{selling: !Item.!Price.&{sold: ?Price.end, notSold: end}}
&{selling: ?Item.?Price.!{sold: !Price.end, notSold: end}}
The protocol for the seller
The protocol for the auctioneer
11
![Page 58: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/58.jpg)
THE BIDDERS PROTOCOL
12
![Page 59: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/59.jpg)
THE BIDDERS PROTOCOL
!{register:
12
![Page 60: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/60.jpg)
THE BIDDERS PROTOCOL
!{register:
Select option register on the
auctioneer
12
![Page 61: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/61.jpg)
THE BIDDERS PROTOCOL
!{register:
12
![Page 62: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/62.jpg)
THE BIDDERS PROTOCOL
!{register: !Name.
12
![Page 63: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/63.jpg)
THE BIDDERS PROTOCOL
!{register: !Name.
Send buyer’s name
12
![Page 64: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/64.jpg)
THE BIDDERS PROTOCOL
!{register: !Name.
12
![Page 65: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/65.jpg)
THE BIDDERS PROTOCOL
!{register: !Name. ?Item.
12
![Page 66: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/66.jpg)
THE BIDDERS PROTOCOL
!{register: !Name. ?Item.
Receive an item on sale
12
![Page 67: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/67.jpg)
THE BIDDERS PROTOCOL
!{register: !Name. ?Item.
12
![Page 68: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/68.jpg)
THE BIDDERS PROTOCOL
!{register: !Name. ?Item.?Price.
12
![Page 69: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/69.jpg)
THE BIDDERS PROTOCOL
!{register: !Name. ?Item.?Price.
Receive its price
12
![Page 70: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/70.jpg)
THE BIDDERS PROTOCOL
!{register: !Name. ?Item.?Price.
12
![Page 71: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/71.jpg)
THE BIDDERS PROTOCOL
!{register: !Name. ?Item.?Price.
!{buy:
12
![Page 72: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/72.jpg)
THE BIDDERS PROTOCOL
!{register: !Name. ?Item.?Price.
!{buy:
Decided to buy...
12
![Page 73: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/73.jpg)
THE BIDDERS PROTOCOL
!{register: !Name. ?Item.?Price.
!{buy:
12
![Page 74: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/74.jpg)
THE BIDDERS PROTOCOL
!{register: !Name. ?Item.?Price.
!{buy: end,
12
![Page 75: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/75.jpg)
THE BIDDERS PROTOCOL
!{register: !Name. ?Item.?Price.
!{buy: end,
... and terminate
12
![Page 76: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/76.jpg)
THE BIDDERS PROTOCOL
!{register: !Name. ?Item.?Price.
!{buy: end,
12
![Page 77: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/77.jpg)
THE BIDDERS PROTOCOL
!{register: !Name. ?Item.?Price.
!{buy: end,
notInterested: end}}
12
![Page 78: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/78.jpg)
THE BIDDERS PROTOCOL
!{register: !Name. ?Item.?Price.
!{buy: end,
notInterested: end}}
Decided not to buy; terminate
12
![Page 79: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/79.jpg)
THE BIDDERS PROTOCOL
!{register: !Name. ?Item.?Price.
!{buy: end,
notInterested: end}}
12
![Page 80: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/80.jpg)
THE AUCTIONEER WHILE INTERACTING WITH BIDDERS
• Recall the type when interacting with sellers:
• Two types? one for interacting with sellers, the other for bidders?
&{register: ?Name.!Item.!Price.
&{buy: end, notInterested: end}}
&{selling: ?Item.?Price.
!{sold: !Price.end, notSold: end}}
13
![Page 81: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/81.jpg)
THE AUCTIONEER ITSELF
• The particular types used to interact with sellers and with bidders are subtypes of this type
• Advantages:
• Bidders do not need to know the protocol for sellers
• The code for bidders may be developed before the introduction of (online) sellers in the auction system
&{register: ?Name. !Item. !Price.
&{buy: end, notInterested: end},
selling: ?Item.?Price.
!{sold: !Price. end, notSold: end}}
14
![Page 82: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/82.jpg)
COMPATIBILITY• The bidder-auctioneer compatibility rest assured. The actual
type for the auctioneer
• is a supertype of
• which is dual of that for the bidder
&{register: ?Name. !Item. !Price.
&{buy: end, notInterested: end},
selling: ...}
&{register: ?Name. !Item. !Price.
&{buy: end, notInterested: end}}
!{register: !Name. ?Item. ?Price.
!{buy: end, notInterested: end}}
15
![Page 83: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/83.jpg)
SYSTEM EVOLUTION
• By far the most common sellers’ complaint is the inability of lowering the initial price after an unsuccessful auction
• The new auctioneer now provides a 3rd choice
“We are very excited
about your item; would you consider lowering
the price?”
&{selling: ?Item.?Price.Selling, register: ...}
Selling = !{sold: !Price. end,
notSold: end,
lowerYourPrice: &{ok: ?Price. Selling,
noWay: end}}
16
![Page 84: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/84.jpg)
COMPATIBILITY ASSURED?
• The old seller still works, it just does not use the new functionality
• The new type is far more complex than the original: additional
recursion and one more ! choice. Expanding recursion we
see that all there remains is one more choice
&{selling: ?Item. ?Price.
!{sold: !Price. end, notSold: end,
lowerYourPrice&{ok: ?Price. Selling,
noWay: end}}}
17
![Page 85: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/85.jpg)
SUBTYPING
Subtype Supertype Variancy
Branch &
Selection !
Input ?
Output !
Less options offered
More options offered
Covariant
More options taken
Less options taken
Contravariant
Input value is subtype
Input value is supertype
Covariant
Output value is supertype
Output value is supertype
Contravariant
• In all cases continuation are covariant
• Recursion “unfolded away” _ co-inductive definition
18
![Page 86: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/86.jpg)
SESSIONS
• Protocols such as the seller-auctioneer-bidder run between exactly two partners at a time:
• seller-auctioneer, or
• auctioneer-bidder
• Each such run is called a session
19
![Page 87: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/87.jpg)
CHANNELS
• An auctioneer must be able to conduct multiple sessions in parallel, with different sellers, with different bidders
• And must not mix the sessions. E.g.,
• Announcing sold to bidder A
• Sending the corresponding Price to bidder B
• Each session is conducted on a different bi-directional communication medium called channel
20
![Page 88: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/88.jpg)
ESTABLISHING SESSIONS
• How are sessions created?
• On channels known to all participants potentially interested on online auctions, e.g., distributed on the www
• We could distinguish
• linear channels - known by one partner
• shared channels - known by any number of partners...
21
![Page 89: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/89.jpg)
CLASSIFYING OPERATIONS
• ...but we prefer to work with a single kind of channel and
distinguish linear from unrestricted (shared) operations
• This gives us greater flexibility and a simplified theory
• All the operations we have seen so far are linear
lin!{selling: lin!Item. lin!Price.
lin&{sold: lin?Price. un end, notSold: un end}} The
interesting end is unrestricted
22
![Page 90: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/90.jpg)
BACK TO SESSION ESTABLISHMENT
• The common knowledge between the three kinds of partners is a shared channel, used to establish linear sessions
• Recall the type of the auctioneer’s session
• The type of the shared channel is
T = lin&{register: ..., selling: ...}
23
![Page 91: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/91.jpg)
BACK TO SESSION ESTABLISHMENT
• The common knowledge between the three kinds of partners is a shared channel, used to establish linear sessions
• Recall the type of the auctioneer’s session
• The type of the shared channel is
T = lin&{register: ..., selling: ...}
S = un?T.S
23
![Page 92: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/92.jpg)
BACK TO SESSION ESTABLISHMENT
• The common knowledge between the three kinds of partners is a shared channel, used to establish linear sessions
• Recall the type of the auctioneer’s session
• The type of the shared channel is
T = lin&{register: ..., selling: ...}
S = un?T.S
Establish a session
23
![Page 93: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/93.jpg)
BACK TO SESSION ESTABLISHMENT
• The common knowledge between the three kinds of partners is a shared channel, used to establish linear sessions
• Recall the type of the auctioneer’s session
• The type of the shared channel is
T = lin&{register: ..., selling: ...}
S = un?T.S
23
![Page 94: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/94.jpg)
BACK TO SESSION ESTABLISHMENT
• The common knowledge between the three kinds of partners is a shared channel, used to establish linear sessions
• Recall the type of the auctioneer’s session
• The type of the shared channel is
T = lin&{register: ..., selling: ...}
S = un?T.SEstablish
more sessions
23
![Page 95: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/95.jpg)
BACK TO SESSION ESTABLISHMENT
• The common knowledge between the three kinds of partners is a shared channel, used to establish linear sessions
• Recall the type of the auctioneer’s session
• The type of the shared channel is
T = lin&{register: ..., selling: ...}
S = un?T.S
23
![Page 96: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/96.jpg)
2.PROGRAMMING
24
![Page 97: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/97.jpg)
WHICH PROGRAMMING LANGUAGE?
• In which language shall we program the protocol?
• Functional?
• Imperative?
• Object-oriented?
• You’ll find all flavours in the literature
• It must incorporate the notion of channels; we shall use a pi-calculus
25
![Page 98: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/98.jpg)
PROGRAMMING THE SELLER
c ! selling.
c ! “psp”.
c ! 100.
c "{
sold " c?(x).print!(“made “ ^ x ^ “euros!”)
notSold " print!(“next time I’ll ask 99.9!”)
}
26
![Page 99: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/99.jpg)
PROGRAMMING THE SELLER
c ! selling.
c ! “psp”.
c ! 100.
c "{
sold " c?(x).print!(“made “ ^ x ^ “euros!”)
notSold " print!(“next time I’ll ask 99.9!”)
}
c is the name of a channel
26
![Page 100: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/100.jpg)
PROGRAMMING THE SELLER
c ! selling.
c ! “psp”.
c ! 100.
c "{
sold " c?(x).print!(“made “ ^ x ^ “euros!”)
notSold " print!(“next time I’ll ask 99.9!”)
}
26
![Page 101: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/101.jpg)
PROGRAMMING THE SELLER
c ! selling.
c ! “psp”.
c ! 100.
c "{
sold " c?(x).print!(“made “ ^ x ^ “euros!”)
notSold " print!(“next time I’ll ask 99.9!”)
}
Select option selling on the auctioneer
26
![Page 102: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/102.jpg)
PROGRAMMING THE SELLER
c ! selling.
c ! “psp”.
c ! 100.
c "{
sold " c?(x).print!(“made “ ^ x ^ “euros!”)
notSold " print!(“next time I’ll ask 99.9!”)
}
26
![Page 103: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/103.jpg)
PROGRAMMING THE SELLER
c ! selling.
c ! “psp”.
c ! 100.
c "{
sold " c?(x).print!(“made “ ^ x ^ “euros!”)
notSold " print!(“next time I’ll ask 99.9!”)
}
Send the item to be sold
26
![Page 104: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/104.jpg)
PROGRAMMING THE SELLER
c ! selling.
c ! “psp”.
c ! 100.
c "{
sold " c?(x).print!(“made “ ^ x ^ “euros!”)
notSold " print!(“next time I’ll ask 99.9!”)
}
26
![Page 105: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/105.jpg)
PROGRAMMING THE SELLER
c ! selling.
c ! “psp”.
c ! 100.
c "{
sold " c?(x).print!(“made “ ^ x ^ “euros!”)
notSold " print!(“next time I’ll ask 99.9!”)
}
Send its price
26
![Page 106: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/106.jpg)
PROGRAMMING THE SELLER
c ! selling.
c ! “psp”.
c ! 100.
c "{
sold " c?(x).print!(“made “ ^ x ^ “euros!”)
notSold " print!(“next time I’ll ask 99.9!”)
}
26
![Page 107: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/107.jpg)
PROGRAMMING THE SELLER
c ! selling.
c ! “psp”.
c ! 100.
c "{
sold " c?(x).print!(“made “ ^ x ^ “euros!”)
notSold " print!(“next time I’ll ask 99.9!”)
}
Wait for an option
26
![Page 108: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/108.jpg)
PROGRAMMING THE SELLER
c ! selling.
c ! “psp”.
c ! 100.
c "{
sold " c?(x).print!(“made “ ^ x ^ “euros!”)
notSold " print!(“next time I’ll ask 99.9!”)
}
26
![Page 109: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/109.jpg)
PROGRAMMING THE SELLER
c ! selling.
c ! “psp”.
c ! 100.
c "{
sold " c?(x).print!(“made “ ^ x ^ “euros!”)
notSold " print!(“next time I’ll ask 99.9!”)
}
If the item was sold...
26
![Page 110: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/110.jpg)
PROGRAMMING THE SELLER
c ! selling.
c ! “psp”.
c ! 100.
c "{
sold " c?(x).print!(“made “ ^ x ^ “euros!”)
notSold " print!(“next time I’ll ask 99.9!”)
}
26
![Page 111: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/111.jpg)
PROGRAMMING THE SELLER
c ! selling.
c ! “psp”.
c ! 100.
c "{
sold " c?(x).print!(“made “ ^ x ^ “euros!”)
notSold " print!(“next time I’ll ask 99.9!”)
}
Read the price
26
![Page 112: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/112.jpg)
PROGRAMMING THE SELLER
c ! selling.
c ! “psp”.
c ! 100.
c "{
sold " c?(x).print!(“made “ ^ x ^ “euros!”)
notSold " print!(“next time I’ll ask 99.9!”)
}
26
![Page 113: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/113.jpg)
PROGRAMMING THE SELLER
c ! selling.
c ! “psp”.
c ! 100.
c "{
sold " c?(x).print!(“made “ ^ x ^ “euros!”)
notSold " print!(“next time I’ll ask 99.9!”)
}If not sold
26
![Page 114: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/114.jpg)
PROGRAMMING THE SELLER
c ! selling.
c ! “psp”.
c ! 100.
c "{
sold " c?(x).print!(“made “ ^ x ^ “euros!”)
notSold " print!(“next time I’ll ask 99.9!”)
}
26
![Page 115: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/115.jpg)
CHANNEL OPERATIONS
c ! “psp” Send value
c?(x) Receive value
c ! selling Select option
c "{sold:..., notSold:...} Branch on option
27
![Page 116: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/116.jpg)
CHANNEL OPERATIONS AND TYPES
c ! selling.
c ! “psp”.
c ! 100.
c "{
sold " c ? (x)...
notSold " ...}
• Collect all operations on channel c
• un qualifier omitted on type end; lin omitted on all other type constructors
28
![Page 117: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/117.jpg)
CHANNEL OPERATIONS AND TYPES
c ! selling.
c ! “psp”.
c ! 100.
c "{
sold " c ? (x)...
notSold " ...}
!{selling:
!Item.!Price.&{
sold: ?Price. end,notSold: end}}
• Collect all operations on channel c
• un qualifier omitted on type end; lin omitted on all other type constructors
28
![Page 118: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/118.jpg)
PROGRAMMING THE BIDDER
c ! register.
c ! “Vasco”.
c ? (item).
c ? (price).
if (item = “psp” and price < 100)
then c ! buy
else c ! notInterested
29
![Page 119: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/119.jpg)
THE CODE AND THE TYPE FOR THE BIDDER
c ! register.
c ! “Vasco”.
c ? (item).
c ? (price).
if (...)
then c ! buy
else c ! notInterested
• Collect all operations on channel c
• Qualifiers omitted on all type constructors as before
30
![Page 120: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/120.jpg)
THE CODE AND THE TYPE FOR THE BIDDER
c ! register.
c ! “Vasco”.
c ? (item).
c ? (price).
if (...)
then c ! buy
else c ! notInterested
!{register:
!Name.?Item.?Price.
!{buy: end,notInterested: end}}
• Collect all operations on channel c
• Qualifiers omitted on all type constructors as before
30
![Page 121: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/121.jpg)
THE AUCTIONEER
• The most sophisticated piece of code
• More later...
c " {
selling " -- handle sellers’ requests
register " -- handle bidders’ requests
}
31
![Page 122: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/122.jpg)
BOOTSTRAPPING
• How do sellers and bidders start sessions?
• By requesting such a session on a, the auctioneer’s public, shared, name:
• The auctioneer’s public name is a shared channel of type
32
![Page 123: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/123.jpg)
BOOTSTRAPPING
• How do sellers and bidders start sessions?
• By requesting such a session on a, the auctioneer’s public, shared, name:
• The auctioneer’s public name is a shared channel of type
Seller = a?(c). c ! selling.c ! “psp”...
32
![Page 124: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/124.jpg)
BOOTSTRAPPING
• How do sellers and bidders start sessions?
• By requesting such a session on a, the auctioneer’s public, shared, name:
• The auctioneer’s public name is a shared channel of type
Seller = a?(c). c ! selling.c ! “psp”...
Bidder = a?(c). c ! register. c ! “Vasco”...
32
![Page 125: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/125.jpg)
BOOTSTRAPPING
• How do sellers and bidders start sessions?
• By requesting such a session on a, the auctioneer’s public, shared, name:
• The auctioneer’s public name is a shared channel of type
Seller = a?(c). c ! selling.c ! “psp”...
Bidder = a?(c). c ! register. c ! “Vasco”...
S = un?T.S
32
![Page 126: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/126.jpg)
BOOTSTRAPPING
• How do auctioneers start sessions?
• By creating a fresh channel and sending it to clients
• We shall distinguish the two ends of a channel
Auctioneer = (!cc’)(
a!c’ |
c " {selling " ... register " ...} |
Auctioneer)
33
![Page 127: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/127.jpg)
BOOTSTRAPPING
• How do auctioneers start sessions?
• By creating a fresh channel and sending it to clients
• We shall distinguish the two ends of a channel
Auctioneer = (!cc’)(
a!c’ |
c " {selling " ... register " ...} |
Auctioneer)
Create the two ends of a channel
33
![Page 128: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/128.jpg)
BOOTSTRAPPING
• How do auctioneers start sessions?
• By creating a fresh channel and sending it to clients
• We shall distinguish the two ends of a channel
Auctioneer = (!cc’)(
a!c’ |
c " {selling " ... register " ...} |
Auctioneer)
33
![Page 129: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/129.jpg)
BOOTSTRAPPING
• How do auctioneers start sessions?
• By creating a fresh channel and sending it to clients
• We shall distinguish the two ends of a channel
Auctioneer = (!cc’)(
a!c’ |
c " {selling " ... register " ...} |
Auctioneer)
Send one end to the client
33
![Page 130: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/130.jpg)
BOOTSTRAPPING
• How do auctioneers start sessions?
• By creating a fresh channel and sending it to clients
• We shall distinguish the two ends of a channel
Auctioneer = (!cc’)(
a!c’ |
c " {selling " ... register " ...} |
Auctioneer)
33
![Page 131: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/131.jpg)
BOOTSTRAPPING
• How do auctioneers start sessions?
• By creating a fresh channel and sending it to clients
• We shall distinguish the two ends of a channel
Auctioneer = (!cc’)(
a!c’ |
c " {selling " ... register " ...} |
Auctioneer)Interact on the
other end
33
![Page 132: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/132.jpg)
BOOTSTRAPPING
• How do auctioneers start sessions?
• By creating a fresh channel and sending it to clients
• We shall distinguish the two ends of a channel
Auctioneer = (!cc’)(
a!c’ |
c " {selling " ... register " ...} |
Auctioneer)
33
![Page 133: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/133.jpg)
MORE PROCESS CONSTRUCTORS
P | Q Parallel composition
(!cc’) Channel creation
if v then P else Q Conditional
34
![Page 134: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/134.jpg)
REFINING THE AUCTIONEER
• Concentrate on the selling option; some pseudo-code first
• Assume a shared repository with operations put, sold, price
c?(item). c?(price). put(item, price)
if sold(item)
then c ! sold. c!price(item)
else c ! notSold
35
![Page 135: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/135.jpg)
THE SHARED AUCTION DATA REPOSITORY
• If shared, it must be accessed by a protocol
• Operation put(item, price) becomes
• where r is the shared name for the repository
r?(d). d ! put. d!item. d!price
36
![Page 136: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/136.jpg)
THE SHARED AUCTION DATA REPOSITORY
• Operations sold(item)/price(item) must be dealt together
• Sessions c and e are now mixed...
• ... but the types remain apart. The type of e is
37
![Page 137: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/137.jpg)
THE SHARED AUCTION DATA REPOSITORY
• Operations sold(item)/price(item) must be dealt together
• Sessions c and e are now mixed...
• ... but the types remain apart. The type of e is
r?(e). e ! wasItSold. e!item.
e " {sold " c !sold. e?(price). c!price,
notSold " c !notSold}
37
![Page 138: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/138.jpg)
THE SHARED AUCTION DATA REPOSITORY
• Operations sold(item)/price(item) must be dealt together
• Sessions c and e are now mixed...
• ... but the types remain apart. The type of e is
r?(e). e ! wasItSold. e!item.
e " {sold " c !sold. e?(price). c!price,
notSold " c !notSold}
!{wasItSold: !Item. &{sold: ?Price.end, notSold: end}}
37
![Page 139: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/139.jpg)
SESSION DELEGATION
• Noticed the copy-cat?
• Why not trust the seller’s channel to the repository? The repository takes care of replying directly to the client
e " {sold " c !sold. e?(price). c!price
notSold " c !notSold}
38
![Page 140: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/140.jpg)
SESSION DELEGATION
• Noticed the copy-cat?
• Why not trust the seller’s channel to the repository? The repository takes care of replying directly to the client
e " {sold " c !sold. e?(price). c!price
notSold " c !notSold}
r?(e). e!wasItSold. e?(item). e!c
38
![Page 141: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/141.jpg)
SESSION DELEGATION
• Noticed the copy-cat?
• Why not trust the seller’s channel to the repository? The repository takes care of replying directly to the client
e " {sold " c !sold. e?(price). c!price
notSold " c !notSold}
r?(e). e!wasItSold. e?(item). e!c
Sending a channel on a channel
38
![Page 142: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/142.jpg)
A TYPE FOR THE REPOSITORY
• The type for the shared channel...
• ... and that for the session it establishes
• The seller is not aware of the delegation; it needs not change its type or its code
39
![Page 143: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/143.jpg)
A TYPE FOR THE REPOSITORY
• The type for the shared channel...
• ... and that for the session it establishes
• The seller is not aware of the delegation; it needs not change its type or its code
S = un ?T.S
39
![Page 144: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/144.jpg)
A TYPE FOR THE REPOSITORY
• The type for the shared channel...
• ... and that for the session it establishes
• The seller is not aware of the delegation; it needs not change its type or its code
S = un ?T.S
T = !{put: !Item. !Price. end,
wasItSold: !Item. !U. end}
U = &{sold: ?Price. end, notSold: end}
39
![Page 145: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/145.jpg)
A TYPE FOR THE REPOSITORY
• The type for the shared channel...
• ... and that for the session it establishes
• The seller is not aware of the delegation; it needs not change its type or its code
S = un ?T.S
T = !{put: !Item. !Price. end,
wasItSold: !Item. !U. end}
U = &{sold: ?Price. end, notSold: end}
The type of the delegated
session
39
![Page 146: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/146.jpg)
PART IITHE THEORY
40
![Page 147: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/147.jpg)
THE PROGRAMME
• The language
• Its typing system and
• Its operational semantics
• What is an error?
• Main result: Typable processes do not reduce to errors
41
![Page 148: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/148.jpg)
THE PROGRAMME
• The language
• Its typing system and
• Its operational semantics
• What is an error?
• Main result: Typable processes do not reduce to errors
Very much standard!
41
![Page 149: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/149.jpg)
1.THE LANGUAGE
42
![Page 150: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/150.jpg)
CHANNEL CREATION
• Variables come in pairs, called co-variables
• Each represents one end of a communication channel
• Interacting threads do not share variables for communication; instead, each thread owns its variable
• This mechanism allows a precise control of resources via a linear type system
43
![Page 151: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/151.jpg)
THE SYNTAX OF PROCESSES, TO START WITH
P ::= Processes:x v.P outputx(x).P inputP | P parallel compositionif v then P else P conditional0 inaction(!xx)P scope restriction
v ::= Values:x variabletrue | false boolean values
44
![Page 152: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/152.jpg)
2.TYPING SYSTEM
45
![Page 153: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/153.jpg)
LINEAR AND UNRESTRICTED TYPES
• Lin (linear) qualified types describe variables that occur in exactly one thread
• Un (unrestricted, shared) qualifier indicates a value that can occur in multiple threads
• Type lin ! (lin bool). un end represents a channel-end that can be used once to output a boolean value (that can be used once) and then behaves as shared channel on which no further operation is possible
46
![Page 154: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/154.jpg)
THE SYNTAX OF TYPESq ::= Qualifiers:
lin linearun unrestricted
p ::= Pretypes:bool booleansend termination?T.T receive!T.T send
T ::= Types:q p qualified pretype
! ::= Contexts:" empty context!, x : T assumption
47
![Page 155: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/155.jpg)
EXAMPLE: VALID AND INVALID PROCESSES
• x is a variable of an arbitrarily qualified type
• a is a variable of an unrestricted type, and
• c a variable of a linear type
x true.x(y)a true | a true | a false
c true | c false
Omit the
trailing 0
48
![Page 156: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/156.jpg)
DUALITY
q ?T.U = q !T.U q !T.U = q ?T.U q end = q end
x1 true | x2(z)x1 true.x1(w) | x2(z).x2 false
x1 true | x2 false
x1 true.x1(w) | x2(z).x2(t)
and are two co-variables
x1 x2
No rule for bool
49
![Page 157: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/157.jpg)
CONTEXT SPLITTING
• An operation central to linear typing systems
• When type checking processes with two sub-processes we pass the unrestricted part of the context to both processes, while splitting the linear part in two and passing a different part to each process
! · ! = !" = "1 · "2 un(T)
", x : T = ("1, x : T) · ("2, x : T)" = "1 · "2 lin(T)
", x : T = ("1, x : T) · "2
" = "1 · "2 lin(T)", x : T = "1 · ("2, x : T)
50
![Page 158: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/158.jpg)
TYPE SYSTEM: INVARIANTS
• Linear channels occur in exactly one thread
• Co-variables have dual types
51
![Page 159: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/159.jpg)
TYPING RULES FOR VALUES
• The rules make sure that linear variables are not discarded without being used
• The base cases of the type system check that there is no linear variable in the context
un(!)! ! false : bool
un(!1, !2)!1, x : T, !2 ! x : T
52
![Page 160: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/160.jpg)
TYPING RULES FOR PROCESSES (1/3)
• The base case checks that there is no linear variable in the context
• Parallel composition crucially takes advantage of context splitting
un(!)! ! 0
!1 ! P !2 ! Q!1 · !2 ! P | Q
53
![Page 161: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/161.jpg)
TYPING RULES FOR PROCESSES (2/3)
• No context splitting for the two branches in the conditional
• The rule for scope restriction captures the essence of co-variables: they must have dual types
!1 ! v : q bool !2 ! P !2 ! Q!1 · !2 ! if v then P else Q
!, x : T, y : T ! P! ! (!xy)P
54
![Page 162: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/162.jpg)
TYPING RULES FOR PROCESSES (3/3)
• The rule for input splits the context into two parts: one to
type check x, the other to type check continuation P
• If x: q?T.U in x(y).P then we use y:T to type check P
• x(y).P uses x at type q?T.U, whereas P may use the same
variable this time at type U
!1 ! x : q ?T.U (!2, y : T) · x : U ! P!1 · !2 ! x(y).P
!1 ! x : q !T.U !2 ! v : T !3 · x : U ! P!1 · !2 · !3 ! x v.P
55
![Page 163: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/163.jpg)
TYPING RULES FOR PROCESSES (SUMMARY)
un(!)! ! 0
!1 ! P !2 ! Q!1 · !2 ! P | Q
!1 ! v : q bool !2 ! P !2 ! Q!1 · !2 ! if v then P else Q
!, x1 : T, x2 : T ! P! ! (!x1x2)P
!1 ! x : q ?T.U (!2, y : T) · x : U ! P!1 · !2 ! x(y).P
!1 ! x : q !T.U !2 ! v : T !3 · x : U ! P!1 · !2 · !3 ! x v.P
56
![Page 164: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/164.jpg)
A SIMPLE SESSION
Unrestricted environment
Unrestricted qualifiers omitted
x : T ! x : T " ! true : bool
x : T ! ! x : T ! x : end, y : bool ! 0
x : T ! =?bool.end ! x(y).0
x : T = lin!bool.?bool.end ! x true.x(y).0
57
![Page 165: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/165.jpg)
LINEAR VALUES ARE CONSUMED
Not unrestricted
Process not typable
x : T ! x : T " ! true : bool
x : T ! ! x : T ! x : end, y : lin bool ! 0
x : T ! =?(lin bool).end ! x(y).0
x : T = lin!bool.?(lin bool).end ! x true.x(y).0
58
![Page 166: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/166.jpg)
A LANGUAGE OF LINEAR CHANNELS ONLY
Process not typable; to be
fixed!
Context splitting not
defined
Parallel composition
! ! x : !(bool).end ! ! true : bool ! · (x : end) ! 0
! ! x true ! ! x true
! = x : !(bool).end ! x true | x true
59
![Page 167: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/167.jpg)
3.OPERATION SEMANTICS
60
![Page 168: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/168.jpg)
STRUCTURAL CONGRUNECE
• Factor out a on processes allowing the syntactic rearrangement of these
• Contribute for a more concise presentation of the reduction relation
P | Q ! Q | P (P | Q) | R ! P | (Q | R) P | 0 ! P
(!xy)P | Q ! (!xy)(P | Q) (!xy)0 ! 0 (!wz)(!xy)P ! (!xy)(!wz)P
61
![Page 169: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/169.jpg)
REDUCTION
(!xy)(x v.P | y(z).Q | R) ! (!xy)(P | Q[v/z] | R)if true then P else Q ! P
if false then P else Q ! Q
P ! Q
(!xy)P ! (!xy)QP ! Q
P | R ! Q | R
P " P ! P ! ! Q! Q! " Q
P ! Q
62
![Page 170: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/170.jpg)
WHAT CAN GO WRONG?
• An obvious case: in a conditional process the value in the condition is neither true nor false
• More interesting:
• Notice: no mention of types or lin/un channel nature
a true | a(z)(!x1x2)(x1 true | x2 true)(!x1x2)(x1(z) | x2(w))
63
![Page 171: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/171.jpg)
WHAT CAN GO WRONG?
• An obvious case: in a conditional process the value in the condition is neither true nor false
• More interesting:
• Notice: no mention of types or lin/un channel nature
a true | a(z)(!x1x2)(x1 true | x2 true)(!x1x2)(x1(z) | x2(w))
Different communication
patterns on the same channel end
63
![Page 172: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/172.jpg)
WHAT CAN GO WRONG?
• An obvious case: in a conditional process the value in the condition is neither true nor false
• More interesting:
• Notice: no mention of types or lin/un channel nature
a true | a(z)(!x1x2)(x1 true | x2 true)(!x1x2)(x1(z) | x2(w))
63
![Page 173: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/173.jpg)
WHAT CAN GO WRONG?
• An obvious case: in a conditional process the value in the condition is neither true nor false
• More interesting:
• Notice: no mention of types or lin/un channel nature
a true | a(z)(!x1x2)(x1 true | x2 true)(!x1x2)(x1(z) | x2(w))
Channels ends with incompatible communication
patterns
63
![Page 174: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/174.jpg)
WHAT CAN GO WRONG?
• An obvious case: in a conditional process the value in the condition is neither true nor false
• More interesting:
• Notice: no mention of types or lin/un channel nature
a true | a(z)(!x1x2)(x1 true | x2 true)(!x1x2)(x1(z) | x2(w))
63
![Page 175: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/175.jpg)
WELL TYPED PROGRAMS DO NOT GO WRONG
• Outline of the proof
1. Type preservation
2. Type safety
3. Compose and done! (details in the book)
If ! ! P and P " Q then ! ! Q
If ! P then P is well formed
64
![Page 176: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/176.jpg)
4.RECURSIVE TYPES
65
![Page 177: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/177.jpg)
RECURSIVE TYPES
• Context splitting not defined...
• ... unless there is type T such that
• Use a finite notation for the solution of the equation
µa.!bool.a
!bool.T = T
x : !bool.T ! x : !bool.T x : !bool.T ! true : bool (x : !bool.T ) · (x : end) ! 0
x : !bool.T ! x true
66
![Page 178: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/178.jpg)
• Shared output channels are of types !a.!T.a which we
abbreviate to *!T
• Unfold/fold recursive types as needed: equi-recursive notion of types
TYPES FOR SHARED CHANNELS
!!bool = !bool.!!bool
! ! x : "!bool ! ! true : bool ! · (x : "!bool) ! 0
! = x : !bool."!bool ! x true
67
![Page 179: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/179.jpg)
EXAMPLE _ TUPLE PASSING ON SHARED CHANNELS
• If x is is shared then there is a risk of interference
• Use the standard encoding...
• ... which is typable
x !u, v".P = xu.x v.Pok if x is
linear
x1 !u, v".P = (!y1y2)x1 y2.y1 u.y1 v.P
x2(w, t).P = x2(z).z(w).z(t).P
x1 : !!(lin?T.lin?U)x2 : !?(lin!T.lin!U)
68
![Page 180: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/180.jpg)
LINEAR CHANNELS THAT BECOME UNRESTRICTED
• Suppose that
• Then
x1 true.(x1(y) | x1(z)) | x2(x).(x2 true | x2 false | x2 true)
x1 : lin!bool.!?bool
x2 : lin?bool.!!bool
69
![Page 181: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/181.jpg)
5.REPLICATION
70
![Page 182: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/182.jpg)
UNBOUNDED BEHAVIOR
• Up until now our language is strongly normalizing
• Providing for unbounded behavior
• Recursion (as in the auctioneer example)
• Replication
• Replication is conceptually simpler ; we go for it
71
![Page 183: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/183.jpg)
SYNTAX AND REDUCTION
• New syntax
• New reduction rule
P ::= . . . Processes:! x(x).P replication
(!xy)(x v.P | !y(z).Q | R) " (!xy)(P | Q[v/z] | !y(z).Q | R)(!xy)(x v.P | y(z).Q | R) " (!xy)(P | Q[v/z] | R)
The replicated process survives reduction
72
![Page 184: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/184.jpg)
TYPING
! ! P un(!)! ! "P
73
![Page 185: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/185.jpg)
TYPING
P can be used multiple times
! ! P un(!)! ! "P
73
![Page 186: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/186.jpg)
TYPING
! ! P un(!)! ! "P
73
![Page 187: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/187.jpg)
“PROCEDURES”
• A procedure that sends a boolean value on a fixed channel c
• c cannot be linear for the body of the procedure must be un
• What if we pass c as parameter?
• The type system controls the linearity of the arguments
• Linear values in procedures must be passed as parameters
p2 : !?end, c : lin!bool "# ! p2(z).c true
!p2(z).c true | p1 x | p1 x " " !p2(z).c true | c true | c true
p2 : ?(lin!bool) ! " p2(z).z true
. . . , p2 : ?(lin!bool) !" # p2(z).z true | p1 c | p1 c
74
![Page 188: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/188.jpg)
6.CHOICE
75
![Page 189: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/189.jpg)
CHOICE _ SYNTAX
P ::= . . . Processes:x ! l.P selectionx " {li : Pi}i!I branching
p ::= . . . Pretypes:!{li : Ti}i!I select&{li : Ti}i!I branch
76
![Page 190: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/190.jpg)
CHOICE _ REDUCTION
j ! I
(!xy)(x ! lj .P | y " {li : Qi}i!I | R) " (!xy)(P | Qj | R)
77
![Page 191: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/191.jpg)
CHOICE _ TYPING
• Duality
• Typing
q !{li : Ti}i!I = q &{li : Ti}i!I q &{li : Ti}i!I = q ! {li : Ti}i!I
!2 ! x : q "{li : Ti}i!I !2 · x : Tj ! P j # I
!1 · !2 ! x ! lj .P
!1 ! x : q &{li : Ti}i!I !2 · x : Ti ! Pi $i # I
!1 · !2 ! x " {li : Pi}i!I
78
![Page 192: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/192.jpg)
7.SUBTYPING
79
![Page 193: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/193.jpg)
MOTIVATION
• Subtyping brings extra flexibility to our type system
• The insistence that arguments in output processes exactly match input parameters in corresponding receivers leads to the rejection of programs that will never go wrong when executed
• We have seen examples in the first part
80
![Page 194: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/194.jpg)
INGREDIENTS
• We need
• A notion of subtyping. T <: U means any value of type T can be safely used in a context where U is expected
• A rule to incorporate subtyping in the type system
! ! v : T T <: U
! ! v : U
81
![Page 195: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/195.jpg)
FINITE SUBTYPING _ CHOICE
• The auctioneer can forget options in order to address sellers or bidders
• Conversely sellers may call more options on the auctioneer (so as to behave as bidders as well)
I ! J Ti <: Ui "i # I
&{li : Ti}i!I <: &{lj : Uj}j!J
I ! J Tj <: Uj "j # J
${li : Ti}i!I <: ${lj : Uj}j!J
82
![Page 196: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/196.jpg)
FINITE SUBTYPING _ I/O
• Input is co-variant; output is contra-variant
• In summary:
• Input operations (?, &) are co-variant; output operations (!, !) contra-variant
• Continuations are always co-variant
• See book for subtyping recursive types
T ! <: T U <: U !
!T.U <: !T !.U !T <: T ! U <: U !
?T.U <: ?T !.U !
83
![Page 197: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/197.jpg)
8.CONCLUSION
84
![Page 198: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/198.jpg)
ALGORITHMIC TYPE CHECKING
• The typing rules cannot be implemented directly for two main reasons. Difficulties
• Implementing the non-deterministic splitting operation
• Guessing the types for nu-bound variables
See book!
85
![Page 199: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/199.jpg)
WE INTRODUCED...
• A (type) language to describe (the protocol part of) services
• A (programming) language to program protocols
• A decidable type checking system that makes sure that “well typed programs do not go wrong”
86
![Page 200: FUNDAMENTALS OF SESSION TYPES · FUNDAMENTALS OF SESSION TYPES Formal Methods for the Design of Computer, Communication and Software Systems Bertinoro, June 4, 2009 Vasco T. Vasconcelos](https://reader036.fdocuments.us/reader036/viewer/2022062920/5f0294f17e708231d404fa75/html5/thumbnails/200.jpg)
LOOKING FOR RESEARCH TOPICS?
• Programs can easily deadlock
• Identify conditions / refine the type system so as to ensure progress
• Context splitting for both parallel and sequential composition
x1 true.y1 false | y2(x).x2(w)
!1 ! x : q ?T.U (!2, y : T ) · x : U ! P
!1 · !2 ! x(y).PSequentialParallel
87