Choreographies as Functions
2021, arXiv (Cornell University)
Abstract
Choreographic programming is an emerging programming paradigm for concurrent and distributed systems, whereby developers write the communications that should be enacted and then a distributed implementation is automatically obtained by means of a compiler. Theories of choreographic programming typically come with strong theoretical guarantees about the compilation process, most notably: the generated implementations operationally correspond to their source choreographies and are deadlock-free. Currently, the most advanced incarnation of the paradigm is Choral, an object-oriented choreographic programming language that targets Java. Choral deviated significantly from known theories of choreographies, and in particular introduced the possibility of expressing higher-order choreographies (choreographies parameterised over choreographies) that are fully distributed. As a consequence, it is unclear whether the usual guarantees of choreographic programming can still hold in the more general setting of higher-order choreographies. In this article, we introduce Chorλ, the first functional choreographic programming language: it introduces a new formulation of the standard communication primitive found in choreographies as a function, and it is based upon the λ-calculus. Chorλ is the first theory that explains the core ideas of higher-order choreographic programming (as in Choral). Interestingly, bridging the gap between practice and theory requires developing a new evaluation strategy and typing discipline for λ terms that accounts for the distributed nature of computation in choreographies. We illustrate the expressivity of Chorλ with a series of examples, which include also reconstructions of the key examples found in the original presentation of Choral. Our theory supports all the expected properties of choreographic programming. By offering the first interpretation of choreographies as terms in λ-calculus, our work also serves to bridge the gap between the communities of functional and choreographic programming. 2012 ACM Subject Classification Theory of computation → Lambda calculus; Theory of computation → Distributed computing models; Computing methodologies → Distributed programming languages
References (46)
- Elvira Albert and Ivan Lanese, editors. Formal Techniques for Distributed Objects, Components, and Systems -36th IFIP WG 6.1 International Conference, FORTE 2016, Held as Part of the 11th International Federated Conference on Distributed Computing Techniques, DisCoTec 2016, Heraklion, Crete, Greece, June 6-9, 2016, Proceedings, volume 9688 of Lecture Notes in Computer Science. Springer, 2016.
- Davide Ancona, Viviana Bono, Mario Bravetti, Joana Campos, Giuseppe Castagna, Pierre- Malo Deniélou, Simon J. Gay, Nils Gesbert, Elena Giachino, Raymond Hu, Einar Broch Johnsen, Francisco Martins, Viviana Mascardi, Fabrizio Montesi, Rumyana Neykova, Nich- olas Ng, Luca Padovani, Vasco T. Vasconcelos, and Nobuko Yoshida. Behavioral types in programming languages. Foundations and Trends in Programming Languages, 3(2-3):95-230, 2016.
- Franco Barbanera, Ugo de'Liguoro, and Rolf Hennicker. Connecting open systems of communicating finite state machines. J. Log. Algebraic Methods Program., 109, 2019. doi:10.1016/j.jlamp.2019.07.004.
- Mario Bravetti and Gianluigi Zavattaro. Towards a unifying theory for choreography conform- ance and contract compliance. In Markus Lumpe and Wim Vanderperren, editors, Software Composition, 6th International Symposium, SC 2007, Braga, Portugal, March 24-25, 2007, Revised Selected Papers, volume 4829 of Lecture Notes in Computer Science, pages 34-50.
- Springer, 2007. doi:10.1007/978-3-540-77351-1\_4.
- Alessandro Bruni, Marco Carbone, Rosario Giustolisi, Sebastian Mödersheim, and Carsten Schürmann. Security protocols as choreographies. In Daniel Dougherty, José Meseguer, Sebastian Alexander Mödersheim, and Paul D. Rowe, editors, Protocols, Strands, and Logic -Essays Dedicated to Joshua Guttman on the Occasion of his 66.66th Birthday, volume 13066 of Lecture Notes in Computer Science, pages 98-111. Springer, 2021. doi:10.1007/ 978-3-030-91631-2\_5.
- Marco Carbone, Kohei Honda, and Nobuko Yoshida. Structured communication-centered programming for web services. ACM Trans. Program. Lang. Syst., 34(2):8:1-8:78, 2012. doi:10.1145/2220365.2220367.
- Marco Carbone and Fabrizio Montesi. Deadlock-freedom-by-design: multiparty asynchronous global programming. In Roberto Giacobazzi and Radhia Cousot, editors, Procs. POPL, pages 263-274. ACM, 2013. doi:10.1145/2429069.2429101.
- Luca Cardelli and Andrew D. Gordon. Mobile ambients. Theor. Comput. Sci., 240(1):177-213, 2000. doi:10.1016/S0304-3975(99)00231-5.
- 9 Giuseppe Castagna, Mariangiola Dezani-Ciancaglini, and Luca Padovani. On global types and multi-party sessions. In Formal Techniques for Distributed Systems, pages 1-28. Springer, 2011.
- David Castro-Perez and Nobuko Yoshida. Compiling first-order functions to session-typed parallel code. In Louis-Noël Pouchet and Alexandra Jimborean, editors, CC '20: 29th International Conference on Compiler Construction, San Diego, CA, USA, February 22-23, 2020, pages 143-154. ACM, 2020. doi:10.1145/3377555.3377889.
- Alonzo Church. A set of postulates for the foundation of logic. Annals of Mathematics, 33(2):346-366, 1932. URL: http://www.jstor.org/stable/1968337.
- Luís Cruz-Filipe and Fabrizio Montesi. Choreographies in practice. In Albert and Lanese [1], pages 114-123. doi:10.1007/978-3-319-39570-8_8.
- Luís Cruz-Filipe and Fabrizio Montesi. Procedural choreographic programming. In FORTE, volume 10321 of Lecture Notes in Computer Science, pages 92-107. Springer, 2017.
- Luís Cruz-Filipe and Fabrizio Montesi. A core model for choreographic programming. Theor. Comput. Sci., 802:38-66, 2020. doi:10.1016/j.tcs.2019.07.005.
- Luís Cruz-Filipe, Fabrizio Montesi, and Marco Peressotti. Communications in choreographies, revisited. In Proceedings of the 33rd Annual ACM Symposium on Applied Computing, SAC 2018, Pau, France, April 09-13, 2018, pages 1248-1255. ACM, 2018. doi:10.1145/3167132.3167267.
- Luís Cruz-Filipe, Fabrizio Montesi, and Marco Peressotti. Certifying choreography compilation. In Antonio Cerone and Peter Csaba Ölveczky, editors, Theoretical Aspects of Computing -ICTAC 2021 -18th International Colloquium, Virtual Event, Nur-Sultan, Kazakhstan, September 8-10, 2021, Proceedings, volume 12819 of Lecture Notes in Computer Science, pages 115-133. Springer, 2021. doi:10.1007/978-3-030-85315-0\_8.
- Luís Cruz-Filipe, Fabrizio Montesi, and Marco Peressotti. Formalising a turing-complete choreographic language in coq. In Liron Cohen and Cezary Kaliszyk, editors, 12th International Conference on Interactive Theorem Proving, ITP 2021, June 29 to July 1, 2021, Rome, Italy (Virtual Conference), volume 193 of LIPIcs, pages 15:1-15:18. Schloss Dagstuhl -Leibniz- Zentrum für Informatik, 2021. doi:10.4230/LIPIcs.ITP.2021.15.
- Mila Dalla Preda, Maurizio Gabbrielli, Saverio Giallorenzo, Ivan Lanese, and Jacopo Mauro. Dynamic choreographies: Theory and implementation. Log. Methods Comput. Sci., 13(2), 2017. doi:10.23638/LMCS-13(2:1)2017.
- Romain Demangeon and Kohei Honda. Nested protocols in session types. In Maciej Koutny and Irek Ulidowski, editors, CONCUR 2012 -Concurrency Theory -23rd International Conference, CONCUR 2012, Newcastle upon Tyne, UK, September 4-7, 2012. Proceedings, volume 7454 of Lecture Notes in Computer Science, pages 272-286. Springer, 2012. doi: 10.1007/978-3-642-32940-1\_20.
- Whitfield Diffie and Martin E. Hellman. New directions in cryptography. IEEE Trans. Inf. Theory, 22(6):644-654, 1976. doi:10.1109/TIT.1976.1055638.
- Saverio Giallorenzo, Ivan Lanese, and Daniel Russo. Chip: A choreographic integration process. In Hervé Panetto, Christophe Debruyne, Henderik A. Proper, Claudio Agostino Ardagna, Dumitru Roman, and Robert Meersman, editors, Procs. OTM, part II, volume 11230 of Lecture Notes in Computer Science, pages 22-40. Springer, 2018. doi:10.1007/978-3-030-02671-4_2.
- Saverio Giallorenzo, Fabrizio Montesi, and Marco Peressotti. Choreographies as objects. CoRR, abs/2005.09520, 2020. URL: https://arxiv.org/abs/2005.09520.
- Saverio Giallorenzo, Fabrizio Montesi, Marco Peressotti, David Richter, Guido Salvaneschi, and Pascal Weisenburger. Multiparty Languages: The Choreographic and Multitier Cases. In 35th European Conference on Object-Oriented Programming, ECOOP 2021, July 12-17, 2021, Aarhus, Denmark (Virtual Conference), LIPIcs. Schloss Dagstuhl -Leibniz-Zentrum fuer Informatik, 2021. To appear. Pre-print available at https://fabriziomontesi.com/files/ gmprsw21.pdf.
- Matthew Hennessy. A distributed Pi-calculus. Cambridge University Press, 2007.
- Andrew K. Hirsch and Deepak Garg. Pirouette: higher-order typed functional choreographies. Proc. ACM Program. Lang., 6(POPL):1-27, 2022. doi:10.1145/3498684.
- Kohei Honda, Aybek Mukhamedov, Gary Brown, Tzu-Chun Chen, and Nobuko Yoshida. Scribbling interactions with a formal foundation. In Raja Natarajan and Adegboyega K. Ojo, editors, Distributed Computing and Internet Technology -7th International Conference, ICDCIT 2011, Bhubaneshwar, India, February 9-12, 2011. Proceedings, volume 6536 of Lecture Notes in Computer Science, pages 55-75. Springer, 2011. doi:10.1007/978-3-642-19056-8\ _4.
- Kohei Honda, Nobuko Yoshida, and Marco Carbone. Multiparty asynchronous session types. J. ACM, 63(1):9, 2016. Also: POPL, pages 273-284, 2008. doi:10.1145/2827695.
- Hans Hüttel, Ivan Lanese, Vasco T. Vasconcelos, Luís Caires, Marco Carbone, Pierre-Malo Deniélou, Dimitris Mostrous, Luca Padovani, António Ravara, Emilio Tuosto, Hugo Torres Vieira, and Gianluigi Zavattaro. Foundations of session types and behavioural contracts. ACM Comput. Surv., 49(1):3:1-3:36, 2016. doi:10.1145/2873052.
- Intl. Telecommunication Union. Recommendation Z.120: Message Sequence Chart, 1996.
- Sung-Shik Jongmans and Petra van den Bos. A predicate transformer for choreographies- computing preconditions in choreographic programming. In Peter Müller, editor, Programming Languages and Systems -31st European Symposium on Programming, ESOP 2022, Proceedings, volume To appear of Lecture Notes in Computer Science. Springer, 2022.
- Tanakorn Leesatapornwongsa, Jeffrey F. Lukman, Shan Lu, and Haryadi S. Gunawi. TaxDC: A taxonomy of non-deterministic concurrency bugs in datacenter distributed systems. In Proc. of ASPLOS, pages 517-530, 2016.
- Alberto Lluch-Lafuente, Flemming Nielson, and Hanne Riis Nielson. Discretionary in- formation flow control for interaction-oriented specifications. In Narciso Martí-Oliet, Peter Csaba Ölveczky, and Carolyn L. Talcott, editors, Logic, Rewriting, and Concur- rency, volume 9200 of Lecture Notes in Computer Science, pages 427-450. Springer, 2015. doi:10.1007/978-3-319-23165-5_20.
- Hugo A. López and Kai Heussen. Choreographing cyber-physical distributed control systems for the energy sector. In Ahmed Seffah, Birgit Penzenstadler, Carina Alves, and Xin Peng, editors, Procs. SAC, pages 437-443. ACM, 2017. doi:10.1145/3019612.3019656.
- Hugo A. López, Flemming Nielson, and Hanne Riis Nielson. Enforcing availability in failure- aware communicating systems. In Albert and Lanese [1], pages 195-211. doi:10.1007/ 978-3-319-39570-8_13.
- Shan Lu, Soyeon Park, Eunsoo Seo, and Yuanyuan Zhou. Learning from mistakes: a com- prehensive study on real world concurrency bug characteristics. In Proc. of ASPLOS, pages 329-339, 2008.
- Fabrizio Montesi. Choreographic Programming. Ph.D. Thesis, IT University of Copenhagen, 2013.
- Fabrizio Montesi. Introduction to Choreographies. Cambridge University Press, 2022. To appear.
- Fabrizio Montesi and Nobuko Yoshida. Compositional choreographies. In Pedro R. D'Argenio and Hernán C. Melgratti, editors, CONCUR 2013 -Concurrency Theory -24th International Conference, CONCUR 2013, Buenos Aires, Argentina, August 27-30, 2013. Proceedings, volume 8052 of Lecture Notes in Computer Science, pages 425-439. Springer, 2013. doi: 10.1007/978-3-642-40184-8\_30.
- Tom Murphy VII, Karl Crary, Robert Harper, and Frank Pfenning. A symmetric modal lambda calculus for distributed computing. In 19th IEEE Symposium on Logic in Computer Science (LICS 2004), 14-17 July 2004, Turku, Finland, Proceedings, pages 286-295. IEEE Computer Society, 2004. doi:10.1109/LICS.2004.1319623.
- Roger M. Needham and Michael D. Schroeder. Using encryption for authentication in large networks of computers. Commun. ACM, 21(12):993-999, 1978. doi:10.1145/359657.359659. 41 Object Management Group. Business Process Model and Notation. http://www.omg.org/spec/BPMN/2.0/, 2011.
- Peter W. O'Hearn. Experience developing and deploying concurrency analysis at facebook. In Andreas Podelski, editor, Static Analysis -25th International Symposium, SAS 2018, Freiburg, Germany, August 29-31, 2018, Proceedings, volume 11002 of Lecture Notes in Computer Science, pages 56-70. Springer, 2018. doi:10.1007/978-3-319-99725-4\_5.
- OpenID Foundation. OpenID Specification. https://openid.net/developers/specs/, 2014.
- Johannes Åman Pohjola, Alejandro Gómez-Londoño, James Shaker, and Michael Norrish. Kalas: A verified, end-to-end compiler for a choreographic language. In June Andronick and Leonardo de Moura, editors, 13th International Conference on Interactive Theorem Proving, ITP 2022, August 7-10, 2022, Haifa, Israel, volume 237 of LIPIcs, pages 27:1-27:18. Schloss Dagstuhl -Leibniz-Zentrum für Informatik, 2022. doi:10.4230/LIPIcs.ITP.2022.27.
- Zongyan Qiu, Xiangpeng Zhao, Chao Cai, and Hongli Yang. Towards the theoretical foundation of choreography. In WWW, pages 973-982, United States, 2007. IEEE Computer Society Press.
- John Vollbrecht, James D. Carlson, Larry Blunk, Dr. Bernard D. Aboba, and Henrik Levkowetz. Extensible Authentication Protocol (EAP). RFC 3748, June 2004. URL: https://rfc-editor. org/rfc/rfc3748.txt, doi:10.17487/RFC3748.