Linearity, Control Effects, and Behavioral Types

  • Luís Caires
  • Jorge A. Pérez
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10201)


Mainstream programming idioms intensively rely on state mutation, sharing, and concurrency. Designing type systems for handling and disciplining such idioms is challenging, due to long known conflicts between internal non-determinism, linearity, and control effects such as exceptions. In this paper, we present the first type system that accommodates non-deterministic and abortable behaviors in the setting of session-based concurrent programs. Remarkably, our type system builds on a Curry-Howard correspondence with (classical) linear logic conservatively extended with two dual modalities capturing an additive (co)monad, and provides a first example of a Curry-Howard interpretation of a realistic programming language with built-in internal non-determinism. Thanks to its deep logical foundations, our system elegantly addresses several well-known tensions between control, linearity, and non-determinism: globally, it enforces progress and fidelity; locally, it allows the specification of non-deterministic and abortable computations. The expressivity of our system is illustrated by several examples, including a typed encoding of a higher-order functional language with threads, session channels, non-determinism, and exceptions.


Type System Linear Logic Reduction Rule Typing Rule Functional Language 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.



Thanks to the anonymous reviewers for useful remarks and suggestions. This work has been partially sponsored by FCT PEst/UID/CEC/04516/2013; by FCT CLAY PTDC/EEI-CTP/4293/2014; by EU COST Actions IC1201 (BETTY), IC1402 (ARVI), and IC1405 (Reversible Computation); and by CNRS PICS project 07313 (SuCCeSS).


  1. 1.
    Andreoli, J.-M.: Logic programming with focusing proofs in linear logic. J. Log. Comput. 2(3), 297–347 (1992)MathSciNetCrossRefzbMATHGoogle Scholar
  2. 2.
    Ariola, Z.M., Herbelin, H.: Minimal classical logic and control operators. In: Baeten, J.C.M., Lenstra, J.K., Parrow, J., Woeginger, G.J. (eds.) ICALP 2003. LNCS, vol. 2719, pp. 871–885. Springer, Heidelberg (2003). doi: 10.1007/3-540-45061-0_68 CrossRefGoogle Scholar
  3. 3.
    Atkey, R., Lindley, S., Morris, J.G.: Conflation confers concurrency. In: Lindley, S., McBride, C., Trinder, P., Sannella, D. (eds.) A List of Successes That Can Change the World. LNCS, vol. 9600, pp. 32–55. Springer, Heidelberg (2016). doi: 10.1007/978-3-319-30936-1_2 CrossRefGoogle Scholar
  4. 4.
    Barber, A.: Dual intuitionistic linear logic. Technical report LFCS-96-347 University of Edinburgh (1996)Google Scholar
  5. 5.
    Benton, P.N., Bierman, G.M., de Paiva, V.: Computational types from a logical perspective. J. Funct. Program. 8(2), 177–193 (1998)MathSciNetCrossRefzbMATHGoogle Scholar
  6. 6.
    Benton, N., Bierman, G., Paiva, V., Hyland, M.: A term calculus for intuitionistic linear logic. In: Bezem, M., Groote, J.F. (eds.) TLCA 1993. LNCS, vol. 664, pp. 75–90. Springer, Heidelberg (1993). doi: 10.1007/BFb0037099 CrossRefGoogle Scholar
  7. 7.
    Boreale, M.: On the expressiveness of internal mobility in name-passing calculi. Theor. Comput. Sci. 195(2), 205–226 (1998)MathSciNetCrossRefzbMATHGoogle Scholar
  8. 8.
    Caires, L.: Types and logic, concurrency and non-determinism. In: Abadi, M., Gardner, P., Gordon, A.D., Mardare, R. (eds.) Essays for the Luca Cardelli Fest, pp. 69–83. Microsoft Research TR MSR-TR–104 (2014)Google Scholar
  9. 9.
    Caires, L., Pérez, J.A.: Multiparty session types within a canonical binary theory, and beyond. In: Albert, E., Lanese, I. (eds.) FORTE 2016. LNCS, vol. 9688, pp. 74–95. Springer, Heidelberg (2016). doi: 10.1007/978-3-319-39570-8_6 CrossRefGoogle Scholar
  10. 10.
    Caires, L., Pérez, J.A., Pfenning, F., Toninho, B.: Behavioral polymorphism and parametricity in session-based communication. In: Felleisen, M., Gardner, P. (eds.) ESOP 2013. LNCS, vol. 7792, pp. 330–349. Springer, Heidelberg (2013). doi: 10.1007/978-3-642-37036-6_19 CrossRefGoogle Scholar
  11. 11.
    Caires, L., Pfenning, F.: Session types as intuitionistic linear propositions. In: Gastin, P., Laroussinie, F. (eds.) CONCUR 2010. LNCS, vol. 6269, pp. 222–236. Springer, Heidelberg (2010). doi: 10.1007/978-3-642-15375-4_16 CrossRefGoogle Scholar
  12. 12.
    Caires, L., Pfenning, F., Toninho, B.: Towards concurrent type theory. In: Types in Language Design and Implementation, pp. 1–12 (2012)Google Scholar
  13. 13.
    Caires, L., Pfenning, F., Toninho, B.: Linear logic propositions as session types. Math. Struct. Comput. Sci. 26(03), 367–423 (2016)MathSciNetCrossRefzbMATHGoogle Scholar
  14. 14.
    Capecchi, S., Giachino, E., Yoshida, N.: Global escape in multiparty sessions. Math. Struct. Comput. Sci. 26(2), 156–205 (2016)MathSciNetCrossRefzbMATHGoogle Scholar
  15. 15.
    Carbone, M., Honda, K., Yoshida, N.: Structured interactional exceptions in session types. In: Breugel, F., Chechik, M. (eds.) CONCUR 2008. LNCS, vol. 5201, pp. 402–417. Springer, Heidelberg (2008). doi: 10.1007/978-3-540-85361-9_32 CrossRefGoogle Scholar
  16. 16.
    Carbone, M., Lindley, S., Montesi, F., Schürmann, C., Wadler, P.: Coherence generalises duality: a logical explanation of multiparty session types. In: CONCUR 2016, pp. 3:1–33:15 (2016)Google Scholar
  17. 17.
    Carbone, M., Montesi, F., Schürmann, C., Yoshida, N.: Multiparty session types as coherence proofs. In: Proceedings of CONCUR 2015. LIPIcs, vol. 42, pp. 412–426. Schloss Dagstuhl (2015)Google Scholar
  18. 18.
    Cardelli, L.: Typeful Programming. IFIP State-of-the-Art Reports: Formal Description of Programming Concepts, pp. 431–507 (1991)Google Scholar
  19. 19.
    Nicola, R., Hennessy, M.: CCS without \(\tau \)’s. In: Ehrig, H., Kowalski, R., Levi, G., Montanari, U. (eds.) CAAP 1987. LNCS, vol. 249, pp. 138–152. Springer, Heidelberg (1987). doi: 10.1007/3-540-17660-8_53 CrossRefGoogle Scholar
  20. 20.
    DeLine, R., Fähndrich, M.: Typestates for objects. In: Odersky, M. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 465–490. Springer, Heidelberg (2004). doi: 10.1007/978-3-540-24851-4_21 CrossRefGoogle Scholar
  21. 21.
    Demangeon, R., Honda, K., Hu, R., Neykova, R., Yoshida, N.: Practical interruptible conversations: distributed dynamic verification with multiparty session types and python. Formal Methods Syst. Des. 46(3), 197–225 (2015)CrossRefzbMATHGoogle Scholar
  22. 22.
    Ehrhard, T., Regnier, L.: Differential interaction nets. Theor. Comput. Sci. 364(2), 166–195 (2006)MathSciNetCrossRefzbMATHGoogle Scholar
  23. 23.
    Ferreira, C., Lanese, I., Ravara, A., Vieira, H.T., Zavattaro, G.: Advanced mechanisms for service combination and transactions. In: Wirsing, M., Hölzl, M. (eds.) Rigorous Software Engineering for Service-Oriented Systems. LNCS, vol. 6582, pp. 302–325. Springer, Heidelberg (2011). doi: 10.1007/978-3-642-20401-2_14 CrossRefGoogle Scholar
  24. 24.
    Gardner, P., Laneve, C., Wischik, L.: Linear forwarders. Inf. Comput. 205(10), 1526–1550 (2007)MathSciNetCrossRefzbMATHGoogle Scholar
  25. 25.
    Gay, S., Vasconcelos, V.T.: Linear type theory for asynchronous session types. J. Funct. Program. 20(1), 19–50 (2010)MathSciNetCrossRefzbMATHGoogle Scholar
  26. 26.
    Griffin, T.: A formulae-as-types notion of control. In: POPL 1990, pp. 47–58 (1990)Google Scholar
  27. 27.
    Honda, K.: Types for dyadic interaction. In: Best, E. (ed.) CONCUR 1993. LNCS, vol. 715, pp. 509–523. Springer, Heidelberg (1993). doi: 10.1007/3-540-57208-2_35 Google Scholar
  28. 28.
    Honda, K., Vasconcelos, V.T., Kubo, M.: Language primitives and type discipline for structured communication-based programming. In: Hankin, C. (ed.) ESOP 1998. LNCS, vol. 1381, pp. 122–138. Springer, Heidelberg (1998). doi: 10.1007/BFb0053567 CrossRefGoogle Scholar
  29. 29.
    Hüttel, H., Lanese, I., Vasconcelos, V.T., Caires, L., et al.: Foundations of session types and behavioural contracts. ACM Comput. Surv. 49(1), 3 (2016)CrossRefGoogle Scholar
  30. 30.
    Kobayashi, N., Pierce, B.C., Turner, D.N.: Linearity and the pi-calculus. In: 23rd Symposium on Principles of Programming Languages, POPL 1996, pp. 358–371. ACM (1996)Google Scholar
  31. 31.
    Krishnaswami, N.R., Turon, A., Dreyer, D., Garg, D.: Superficially substructural types. In: ICFP 2012, pp. 41–54 (2012)Google Scholar
  32. 32.
    Lindley, S., Morris, J.G.: Embedding session types in Haskell. In: 9th International Symposium on Haskell, Haskell 2016, pp. 133–145 (2016)Google Scholar
  33. 33.
    Militão, F., Aldrich, J., Caires, L.: Rely-guarantee protocols. In: Jones, R. (ed.) ECOOP 2014. LNCS, vol. 8586, pp. 334–359. Springer, Heidelberg (2014). doi: 10.1007/978-3-662-44202-9_14 Google Scholar
  34. 34.
    Mostrous, D., Vasconcelos, V.T.: Affine sessions. In: Kühn, E., Pugliese, R. (eds.) COORDINATION 2014. LNCS, vol. 8459, pp. 115–130. Springer, Heidelberg (2014). doi: 10.1007/978-3-662-43376-8_8 CrossRefGoogle Scholar
  35. 35.
    Orchard, D.A., Yoshida, N.: Effects as sessions, sessions as effects. In: Proceedings of the POPL 2016, pp. 568–581. ACM (2016)Google Scholar
  36. 36.
    Parigot, M.: \(\lambda \upmu \)-calculus: an algorithmic interpretation of classical natural deduction. In: Voronkov, A. (ed.) LPAR 1992. LNCS, vol. 624, pp. 190–201. Springer, Heidelberg (1992). doi: 10.1007/BFb0013061 CrossRefGoogle Scholar
  37. 37.
    Pérez, J.A., Caires, L., Pfenning, F., Toninho, B.: Linear logical relations for session-based concurrency. In: Seidl, H. (ed.) ESOP 2012. LNCS, vol. 7211, pp. 539–558. Springer, Heidelberg (2012). doi: 10.1007/978-3-642-28869-2_27 CrossRefGoogle Scholar
  38. 38.
    Pfenning, F.: Structural cut elimination. In: 10th Annual IEEE Symposium on Logic in Computer Science, LICS 1995, pp. 156–166. IEEE Computer Society (1995)Google Scholar
  39. 39.
    Plotkin, G.D.: A powerdomain construction. SIAM J. Comput. 5(3), 452–487 (1976)MathSciNetCrossRefzbMATHGoogle Scholar
  40. 40.
    Sangiorgi, D., Walker, D.: The \(\pi \)-Calculus: A Theory of Mobile Processes. Cambridge University Press, Cambridge (2001)zbMATHGoogle Scholar
  41. 41.
    Scalas, A., Yoshida, N.: Lightweight session programming in scala. In: 30th European Conference on Object-Oriented Programming, ECOOP 2016, pp. 21:1–21:28 (2016)Google Scholar
  42. 42.
    Toninho, B., Caires, L., Pfenning, F.: Dependent session types via intuitionistic linear type theory. In: PPDP 2011, pp. 161–172 (2011)Google Scholar
  43. 43.
    Toninho, B., Caires, L., Pfenning, F.: Functions as session-typed processes. In: Birkedal, L. (ed.) FoSSaCS 2012. LNCS, vol. 7213, pp. 346–360. Springer, Heidelberg (2012). doi: 10.1007/978-3-642-28729-9_23 CrossRefGoogle Scholar
  44. 44.
    Toninho, B., Caires, L., Pfenning, F.: Higher-order processes, functions, and sessions: a monadic integration. In: Felleisen, M., Gardner, P. (eds.) ESOP 2013. LNCS, vol. 7792, pp. 350–369. Springer, Heidelberg (2013). doi: 10.1007/978-3-642-37036-6_20 CrossRefGoogle Scholar
  45. 45.
    Tov, J.A., Pucella, R.: Stateful contracts for affine types. In: Gordon, A.D. (ed.) ESOP 2010. LNCS, vol. 6012, pp. 550–569. Springer, Heidelberg (2010). doi: 10.1007/978-3-642-11957-6_29 CrossRefGoogle Scholar
  46. 46.
    Tov, J.A., Pucella, R.: A theory of substructural types and control. In: OOPSLA 2011, pp. 625–642 (2011)Google Scholar
  47. 47.
    Tov, J.A., Pucella, R.: Practical affine types. In: POPL 2011, pp. 447–458 (2011)Google Scholar
  48. 48.
    Wadler, P.: Propositions as sessions. In: ICFP 2012, pp. 273–286. ACM (2012)Google Scholar

Copyright information

© Springer-Verlag GmbH Germany 2017

Authors and Affiliations

  1. 1.NOVA LINCS and Departamento de InformáticaFCT, Universidade Nova de LisboaLisbonPortugal
  2. 2.University of Groningen & CWIAmsterdamThe Netherlands

Personalised recommendations