Abstract
Session types guarantee that message-passing processes adhere to predefined communication protocols. Prior work on session types has focused on deterministic languages but many message-passing systems, such as Markov chains and randomized distributed algorithms, are probabilistic. To implement and analyze such systems, this article develops the meta theory of probabilistic session types with an application focus on automatic expected resource analysis. Probabilistic session types describe probability distributions over messages and are a conservative extension of intuitionistic (binary) session types. To send on a probabilistic channel, processes have to utilize internal randomness from a probabilistic branching or external randomness from receiving on a probabilistic channel. The analysis for expected resource bounds is smoothly integrated with the type system and is a variant of automatic amortized resource analysis. Type inference relies on linear constraint solving to automatically derive symbolic bounds for various cost metrics. The technical contributions include the meta theory that is based on a novel nested multiverse semantics and a type-reconstruction algorithm that allows flexible mixing of different sources of randomness without burdening the programmer with complex type annotations. The type system has been implemented in the language NomosPro with linear-time type checking. Experiments demonstrate that NomosPro is applicable in different domains such as cost analysis of randomized distributed algorithms, analysis of Markov chains, probabilistic analysis of amortized data structures and digital contracts. NomosPro is also shown to be scalable by (i) implementing two broadcast and a bounded retransmission protocol where messages are dropped with a fixed probability, and (ii) verifying the limiting distribution of a Markov chain with 64 states and 420 transitions.
- Bogdan Aman and Gabriel Ciobanu. 2019. Probabilities in Session Types. Electronic Proceedings in Theoretical Computer Science, 303 (2019), Sep, 92–106. issn:2075-2180 https://doi.org/10.4204/eptcs.303.7
Google Scholar
Cross Ref
- Suzana Andova. 1999. Process Algebra with Probabilistic Choice. In Formal Methods for Real-Time and Probabilistic Systems, Joost-Pieter Katoen (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg. 111–129. isbn:978-3-540-48778-4
Google Scholar
- Martin Avanzini, Ugo Dal Lago, and Alexis Ghyselen. 2019. Type-Based Complexity Analysis of Probabilistic Functional Programs. In Logic in Computer Science (LICS’19). https://doi.org/10.1109/LICS.2019.8785725
Google Scholar
Cross Ref
- Stephanie Balzer and Frank Pfenning. 2017. Manifest Sharing with Session Types. Proc. ACM Program. Lang., 1, ICFP (2017), Article 37, Aug., 29 pages. https://doi.org/10.1145/3110281
Google Scholar
Digital Library
- J.A. Bergstra and J.W. Klop. 1984. Process algebra for synchronous communication. Information and Control, 60, 1 (1984), 109 – 137. issn:0019-9958 https://doi.org/10.1016/S0019-9958(84)80025-X
Google Scholar
Cross Ref
- Nathalie Bertrand, Igor Konnov, Marijana Lazic, and Josef Widder. 2019. Verification of Randomized Consensus Algorithms Under Round-Rigid Adversaries. In 30th International Conference on Concurrency Theory (CONCUR 2019), Wan Fokkink and Rob van Glabbeek (Eds.) (Leibniz International Proceedings in Informatics (LIPIcs), Vol. 140). Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, Dagstuhl, Germany. 33:1–33:15. isbn:978-3-95977-121-4 issn:1868-8969 https://doi.org/10.4230/LIPIcs.CONCUR.2019.33
Google Scholar
Cross Ref
- Johannes Borgström, Ugo Dal Lago, Andrew D. Gordon, and Marcin Szymczak. 2016. A Lambda-Calculus Foundation for Universal Probabilistic Programming. In Int. Conf. on Functional Programming (ICFP’16). https://doi.org/10.1145/2951913.2951942
Google Scholar
Digital Library
- Gabriel Bracha. 1987. Asynchronous Byzantine agreement protocols. Information and Computation, 75, 2 (1987), 130–143. issn:0890-5401 https://doi.org/10.1016/0890-5401(87)90054-X
Google Scholar
Digital Library
- Luís Caires and Frank Pfenning. 2010. Session Types as Intuitionistic Linear Propositions. In Proceedings of the 21st International Conference on Concurrency Theory (CONCUR 2010), P.Gastin and F.Laroussinie (Eds.). Springer LNCS 6269, Paris, France. 222–236.
Google Scholar
Digital Library
- Krishnendu Chatterjee, Hongfei Fu, and Amir Kafshdar Goharshady. 2016. Termination Analysis of Probabilistic Programs Through Positivstellensatz’s. In Computer Aided Verif. (CAV’16). https://doi.org/10.1007/978-3-319-41528-4_1
Google Scholar
Cross Ref
- David Chaum. 1988. The Dining Cryptographers Problem: Unconditional Sender and Recipient Untraceability. J. Cryptology, 1 (1988), 65–75. https://doi.org/10.1007/BF00206326
Google Scholar
Cross Ref
- Clp team. 2022. COIN-OR Linear Programming Solver. Available on. https://projects.coin-or.org/Clp
Google Scholar
- A. Das, S. Balzer, J. Hoffmann, F. Pfenning, and I. Santurkar. 2021. Resource-Aware Session Types for Digital Contracts. In 2021 IEEE 34th Computer Security Foundations Symposium (CSF). IEEE Computer Society, 111–126. issn:2374-8303
Google Scholar
- Ankush Das, Henry DeYoung, Andreia Mordido, and Frank Pfenning. 2021. Nested Session Types. In 30th European Symposium on Programming, N. Yoshida (Ed.). Springer LNCS, Luxembourg, Luxembourg. 178–206. http://www.cs.cmu.edu/~fp/papers/esop21.pdf Extended version available as arXiv:2010.06482
Google Scholar
- Ankush Das, Jan Hoffmann, and Frank Pfenning. 2018. Work Analysis with Resource-Aware Session Types. In Proceedings of the 33rd Annual ACM/IEEE Symposium on Logic in Computer Science (LICS ’18). ACM, New York, NY, USA. 305–314. isbn:978-1-4503-5583-4 https://doi.org/10.1145/3209108.3209146
Google Scholar
Digital Library
- Ankush Das and Frank Pfenning. 2020. Rast: Resource-Aware Session Types with Arithmetic Refinements (System Description). In 5th International Conference on Formal Structures for Computation and Deduction (FSCD 2020), Zena M. Ariola (Ed.) (Leibniz International Proceedings in Informatics (LIPIcs), Vol. 167). Schloss Dagstuhl–Leibniz-Zentrum für Informatik, Dagstuhl, Germany. 33:1–33:17. isbn:978-3-95977-155-9 issn:1868-8969 https://doi.org/10.4230/LIPIcs.FSCD.2020.33
Google Scholar
Cross Ref
- Ankush Das and Frank Pfenning. 2020. Session Types with Arithmetic Refinements. In 31st International Conference on Concurrency Theory (CONCUR 2020), Igor Konnov and Laura Kovács (Eds.) (Leibniz International Proceedings in Informatics (LIPIcs), Vol. 171). Schloss Dagstuhl–Leibniz-Zentrum für Informatik, Dagstuhl, Germany. 13:1–13:18. isbn:978-3-95977-160-3 issn:1868-8969 https://doi.org/10.4230/LIPIcs.CONCUR.2020.13
Google Scholar
Cross Ref
- Ankush Das and Frank Pfenning. 2020. Verified Linear Session-Typed Concurrent Programming. In Proceedings of the 22nd International Symposium on Principles and Practice of Declarative Programming (PPDP ’20). Association for Computing Machinery, New York, NY, USA. Article 7, 15 pages. isbn:9781450388214 https://doi.org/10.1145/3414080.3414087
Google Scholar
Digital Library
- Ankush Das, Di Wang, and Jan Hoffmann. 2021. Probabilistic Resource-Aware Session Types. arxiv:2011.09037
Google Scholar
- Ankush Das, Di Wang, and Jan Hoffmann. 2022. Probabilistic Resource-Aware Session Types (Artifact). https://doi.org/10.5281/zenodo.7147007
Google Scholar
Digital Library
- Christian Dehnert, Sebastian Junges, Joost-Pieter Katoen, and Matthias Volk. 2017. A Storm is Coming: A Modern Probabilistic Model Checker. In Computer Aided Verif. (CAV’17). https://doi.org/10.1007/978-3-319-63390-9_31
Google Scholar
Cross Ref
- Luis María Ferrer Fioriti and Holger Hermanns. 2015. Probabilistic Termination: Soundness, Completeness, and Compositionality. In Princ. of Prog. Lang. (POPL’15). https://doi.org/10.1145/2676726.2677001
Google Scholar
Digital Library
- Vojtěch Forejt, Marta Kwiatkowska, Gethin Norman, and David Parker. 2011. Automated Verification Techniques for Probabilistic Systems. Springer Berlin Heidelberg, Berlin, Heidelberg. 53–113. isbn:978-3-642-21455-4 https://doi.org/10.1007/978-3-642-21455-4_3
Google Scholar
Cross Ref
- Nate Foster, Dexter Kozen, Konstantinos Mamouras, Mark Reitblatt, and Alexandra Silva. 2016. Probabilistic netkat. In European Symposium on Programming. 282–309.
Google Scholar
Digital Library
- Simon Gay and Malcolm Hole. 2005. Subtyping for session types in the pi calculus. Acta Informatica, 42, 2 (2005), 01 Nov, 191–225. issn:1432-0525 https://doi.org/10.1007/s00236-005-0177-z
Google Scholar
Cross Ref
- Timon Gehr, Sasa Misailovic, Petar Tsankov, Laurent Vanbever, Pascal Wiesmann, and Martin Vechev. 2018. Bayonet: probabilistic inference for networks. ACM SIGPLAN Notices, 53, 4 (2018), 586–602.
Google Scholar
Digital Library
- J. Y. Girard and Y. Lafont. 1987. Linear logic and lazy computation. In TAPSOFT ’87, Hartmut Ehrig, Robert Kowalski, Giorgio Levi, and Ugo Montanari (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg. 52–66. isbn:978-3-540-47717-4
Google Scholar
- Hans Hansson and Bengt Jonsson. 1994. A Logic for Reasoning about Time and Reliability. Formal Aspects of Computing, 6 (1994), 102–111.
Google Scholar
Digital Library
- Hans A. Hansson and Lars-Ake Fredlund. 1994. Time and Probability in Formal Design of Distributed Systems. Elsevier Science Inc., USA. isbn:0444899405
Google Scholar
- Sergiu Hart, Micha Sharir, and Amir Pnueli. 1983. Termination of Probabilistic Concurrent Program. Trans. on Prog. Lang. and Syst., 5 (1983), July, https://doi.org/10.1145/2166.357214
Google Scholar
Digital Library
- L. Helmink, M. P. A. Sellink, and F. W. Vaandrager. 1994. Proof-checking a data link protocol. In Types for Proofs and Programs, Henk Barendregt and Tobias Nipkow (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg. 127–165. isbn:978-3-540-48440-0
Google Scholar
- Oltea Mihaela Herescu and Catuscia Palamidessi. 2000. Probabilistic Asynchronous π -Calculus. In Foundations of Software Science and Computation Structures, Jerzy Tiuryn (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg. 146–160. isbn:978-3-540-46432-7
Google Scholar
Cross Ref
- Jane Hillston. 1996. A Compositional Approach to Performance Modelling. Cambridge University Press, USA. isbn:0521571898
Google Scholar
- Jan Hoffmann, Ankush Das, and Shu-Chun Weng. 2017. Towards Automatic Resource Bound Analysis for OCaml. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL 2017). Association for Computing Machinery, New York, NY, USA. 359–373. isbn:9781450346603 https://doi.org/10.1145/3009837.3009842
Google Scholar
Digital Library
- Martin Hofmann and Steffen Jost. 2003. Static Prediction of Heap Space Usage for First-Order Functional Programs. In 30th Symposium on Principles of Programming Languages (POPL’03). 185–197.
Google Scholar
- Kohei Honda. 1993. Types for dyadic interaction. In CONCUR’93, Eike Best (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg. 509–523. isbn:978-3-540-47968-0
Google Scholar
- Kohei Honda, Nobuko Yoshida, and Marco Carbone. 2008. Multiparty Asynchronous Session Types. In Proceedings of the 35th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’08). ACM, New York, NY, USA. 273–284. isbn:978-1-59593-689-9 https://doi.org/10.1145/1328438.1328472
Google Scholar
Digital Library
- Ross Horne. 2019. The Sub-Additives: A Proof Theory for Probabilistic Choice extending Linear Logic. In Formal Struct. for Comput. and Deduction (FSCD’19). https://doi.org/10.4230/LIPIcs.FSCD.2019.23
Google Scholar
Cross Ref
- Omar Inverso, Hernán Melgratti, Luca Padovani, Catia Trubiani, and Emilio Tuosto. 2020. Probabilistic Analysis of Binary Sessions. In 31st International Conference on Concurrency Theory (CONCUR 2020), Igor Konnov and Laura Kovács (Eds.) (Leibniz International Proceedings in Informatics (LIPIcs), Vol. 171). Schloss Dagstuhl–Leibniz-Zentrum für Informatik, Dagstuhl, Germany. 14:1–14:21. isbn:978-3-95977-160-3 issn:1868-8969 https://doi.org/10.4230/LIPIcs.CONCUR.2020.14
Google Scholar
Cross Ref
- Alon Itai and Michael Rodeh. 1990. Symmetry breaking in distributed networks. Information and Computation, 88, 1 (1990), 60 – 87. issn:0890-5401 https://doi.org/10.1016/0890-5401(90)90004-2
Google Scholar
Digital Library
- Claire Jones. 1989. Probabilistic Nondeterminism. Ph. D. Dissertation. University of Edinburgh.
Google Scholar
- Benjamin Lucien Kaminski, Joost-Pieter Katoen, Christoph Matheja, and Federico Olmedo. 2016. Weakest Precondition Reasoning for Expected Run–Times of Probabilistic Programs. In European Symp. on Programming (ESOP’16). https://doi.org/10.1007/978-3-662-49498-1_15
Google Scholar
Digital Library
- Tristan Knoth, Di Wang, Nadia Polikarpova, and Jan Hoffmann. 2019. Resource-Guided Program Synthesis. In Prog. Lang. Design and Impl. (PLDI’19). https://doi.org/10.1145/3314221.3314602
Google Scholar
Digital Library
- Donald E. Knuth and Andrew Chi-Chih Yao. 1976. The complexity of nonuniform random number generation.
Google Scholar
- Dexter Kozen. 1981. Semantics of Probabilistic Programs. J. Comput. Syst. Sci., 22 (1981), June, https://doi.org/10.1016/0022-0000(81)90036-2
Google Scholar
Cross Ref
- Satoshi Kura, Natsuki Urabe, and Ichiro Hasuo. 2019. Tail Probability for Randomized Program Runtimes via Martingales for Higher Moments. In Tools and Algs. for the Construct. and Anal. of Syst. (TACAS’19). https://doi.org/10.1007/978-3-030-17465-1_8
Google Scholar
Cross Ref
- Marta Kwiatkowska, Gethin Norman, and David Parker. 2007. Stochastic Model Checking. Springer Berlin Heidelberg, Berlin, Heidelberg. 220–270. isbn:978-3-540-72522-0 https://doi.org/10.1007/978-3-540-72522-0_6
Google Scholar
Cross Ref
- Marta Kwiatkowska, Gethin Norman, and David Parker. 2011. PRISM 4.0: Verification of Probabilistic Real-Time Systems. In Computer Aided Verification, Ganesh Gopalakrishnan and Shaz Qadeer (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg. 585–591. isbn:978-3-642-22110-1
Google Scholar
- Marta Kwiatkowska, Gethin Norman, Jeremy Sproston, and Fuzhi Wang. 2007. Symbolic model checking for probabilistic timed automata. Information and Computation, 205, 7 (2007), 1027 – 1077. issn:0890-5401 https://doi.org/10.1016/j.ic.2007.01.004
Google Scholar
Digital Library
- Michael W. Mislove. 2000. Nondeterminism and Probabilistic Choice: Obeying the Laws. In Int. Conf. on Concurrency Theory (CONCUR’00). https://doi.org/10.1007/3-540-44618-4_26
Google Scholar
Cross Ref
- Michael W. Mislove, Joël Ouaknine, and James Worrell. 2004. Axioms for Probability and Nondeterminism. Electr. Notes Theor. Comp. Sci., 96 (2004), June, https://doi.org/10.1016/j.entcs.2004.04.019 Proceedings of the 10th International Workshop on Expressiveness in Concurrency
Google Scholar
Cross Ref
- Van Chan Ngo, Quentin Carbonneaux, and Jan Hoffmann. 2018. Bounded Expectations: Resource Analysis for Probabilistic Programs. In Prog. Lang. Design and Impl. (PLDI’18). https://doi.org/10.1145/3192366.3192394
Google Scholar
Digital Library
- Gethin Norman. 2004. Analysing Randomized Distributed Algorithms. Springer Berlin Heidelberg, Berlin, Heidelberg. 384–418. isbn:978-3-540-24611-4 https://doi.org/10.1007/978-3-540-24611-4_11
Google Scholar
Cross Ref
- G. Norman, C. Palamidessi, D. Parker, and P. Wu. 2007. Model checking the probabilistic pi-calculus. In Fourth International Conference on the Quantitative Evaluation of Systems (QEST 2007). 169–178.
Google Scholar
Digital Library
- Lawrence Page, Sergey Brin, Rajeev Motwani, and Terry Winograd. 1999. The PageRank Citation Ranking: Bringing Order to the Web.. Stanford InfoLab. http://ilpubs.stanford.edu:8090/422/ Previous number = SIDL-WP-1999-0120
Google Scholar
- Benjamin C. Pierce and David N. Turner. 2000. Local Type Inference. ACM Trans. Program. Lang. Syst., 22, 1 (2000), Jan., 1–44. issn:0164-0925 https://doi.org/10.1145/345099.345100
Google Scholar
Digital Library
- Steffen Smolka, Praveen Kumar, David M Kahn, Nate Foster, Justin Hsu, Dexter Kozen, and Alexandra Silva. 2019. Scalable Verification of Probabilistic Networks. In Proceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and Implementation. 190–203.
Google Scholar
Digital Library
- T. K. Srikanth and Sam Toueg. 1987. Simulating Authenticated Broadcasts to Derive Simple Fault-Tolerant Algorithms. Distributed Comput., 2, 2 (1987), 80–94. https://doi.org/10.1007/BF01667080
Google Scholar
Digital Library
- RE Tarjan. 1985. Amortized computational complexity. SIAM J. Algebraic Discrete Methods, 6, 2 (1985), 306–318.
Google Scholar
Digital Library
- Joseph Tassarotti and Robert Harper. 2018. Verified Tail Bounds for Randomized Programs. In Interactive Theorem Proving - 9th International Conference, ITP 2018, Held as Part of the Federated Logic Conference, FloC 2018, Oxford, UK, July 9-12, 2018, Proceedings, Jeremy Avigad and Assia Mahboubi (Eds.) (Lecture Notes in Computer Science, Vol. 10895). Springer, 560–578. https://doi.org/10.1007/978-3-319-94821-8_33
Google Scholar
Cross Ref
- Joseph Tassarotti and Robert Harper. 2019. A Separation Logic for Concurrent Randomized Programs. Proc. ACM Program. Lang., 3, POPL (2019), Article 64, Jan., 30 pages. https://doi.org/10.1145/3290377
Google Scholar
Digital Library
- Regina Tix, Klaus Keimel, and Gordon D. Plotkin. 2009. Semantic Domains for Combining Probability and Non-Determinism. Electr. Notes Theor. Comp. Sci., 222 (2009), February, https://doi.org/10.1016/j.entcs.2009.01.002
Google Scholar
Digital Library
- Bernardo Toninho, Luís Caires, and Frank Pfenning. 2013. Higher-Order Processes, Functions, and Sessions: A Monadic Integration. In European Symp. on Programming (ESOP’13). https://doi.org/10.1007/978-3-642-37036-6_20
Google Scholar
Digital Library
- Daniele Varacca. 2002. The Powerdomain of Indexed Valuations. In Logic in Computer Science (LICS’02). https://doi.org/10.1109/LICS.2002.1029838
Google Scholar
Cross Ref
- Daniele Varacca. 2003. Probability, Nondeterminism and Concurrency: Two Denotational Models for Probabilistic Computation. Ph. D. Dissertation. University of Aarhus.
Google Scholar
- Daniele Varacca and Glynn Winskel. 2006. Distributing Probability over Nondeterminism. Math. Struct. Comp. Sci., 16 (2006), February, https://doi.org/10.1017/S0960129505005074
Google Scholar
Digital Library
- Daniele Varacca and Nobuko Yoshida. 2007. Probabilistic π -Calculus and Event Structures. Electronic Notes in Theoretical Computer Science, 190, 3 (2007), 147 – 166. issn:1571-0661 https://doi.org/10.1016/j.entcs.2007.07.009 Proceedings of the Fifth Workshop on Quantitative Aspects of Programming Languages (QAPL 2007)
Google Scholar
Cross Ref
- Di Wang, Jan Hoffmann, and Thomas Reps. 2019. A Denotational Semantics for Low-Level Probabilistic Programs with Nondeterminism. Electr. Notes Theor. Comp. Sci., 347 (2019), November, https://doi.org/10.1016/j.entcs.2019.09.016 Proceedings of the Thirty-Fifth Conference on the Mathematical Foundations of Programming Semantics
Google Scholar
Digital Library
- Di Wang, David M. Kahn, and Jan Hoffmann. 2020. Raising Expectations: Automating Expected Cost Analysis with Types.
Google Scholar
- Peixin Wang, Hongfei Fu, Amir Kafshdar Goharshady, Krishnendu Chatterjee, Xudong Qin, and Wenjun Shi. 2019. Cost Analysis of Nondeterministic Probabilistic Programs. In Prog. Lang. Design and Impl. (PLDI’19). https://doi.org/10.1145/3314221.3314581
Google Scholar
Digital Library
Index Terms
Probabilistic Resource-Aware Session Types
Recommendations
Work Analysis with Resource-Aware Session Types
LICS '18: Proceedings of the 33rd Annual ACM/IEEE Symposium on Logic in Computer ScienceWhile there exist several successful techniques for supporting programmers in deriving static resource bounds for sequential code, analyzing the resource usage of message-passing concurrent processes poses additional challenges. To meet these challenges,...
Gradual session types
Session types are a rich type discipline, based on linear types, that lift the sort of safety claims that come with type systems to communications. However, web-based applications and micro services are often written in a mix of languages, with type ...
Type checking a multithreaded functional language with session types
We define a language whose type system, incorporating session types, allows complex protocols to be specified by types and verified by static type checking. A session type, associated with a communication channel, specifies the state transitions of a ...






Comments