Abstract
Randomized higher-order computation can be seen as being captured by a λ-calculus endowed with a single algebraic operation, namely a construct for binary probabilistic choice. What matters about such computations is the probability of obtaining any given result, rather than the possibility or the necessity of obtaining it, like in (non)deterministic computation. Termination, arguably the simplest kind of reachability problem, can be spelled out in at least two ways, depending on whether it talks about the probability of convergence or about the expected evaluation time, the second one providing a stronger guarantee. In this paper, we show that intersection types are capable of precisely characterizing both notions of termination inside a single system of types: the probability of convergence of any λ-term can be underapproximated by its type, while the underlying derivation’s weight gives a lower bound to the term’s expected number of steps to normal form. Noticeably, both approximations are tight—not only soundness but also completeness holds. The crucial ingredient is non-idempotency, without which it would be impossible to reason on the expected number of reduction steps which are necessary to completely evaluate any term. Besides, the kind of approximation we obtain is proved to be optimal recursion theoretically: no recursively enumerable formal system can do better than that.
- Beniamino Accattoli, Stéphane Graham-Lengrand, and Delia Kesner. 2018. Tight typings and split bounds. Proc. of ICFP 2018 2, ICFP ( 2018 ), 94 : 1-94 : 30. https://doi.org/10.1145/3236789 Google Scholar
Digital Library
- Beniamino Accattoli, Giulio Guerrieri, and Maico Leberle. 2019. Types by Need. In Proc. of ESOP 2019 (LNCS), Vol. 11423. 410-439. https://doi.org/10.1007/978-3-030-17184-1_15 Google Scholar
Cross Ref
- Martin Avanzini, Ugo Dal Lago, and Alexis Ghyselen. 2019. Type-Based Complexity Analysis of Probabilistic Functional Programs. In Proc. of LICS 2019. 1-13. https://doi.org/10.1109/LICS. 2019.8785725 Google Scholar
Cross Ref
- Martin Avanzini, Ugo Dal Lago, and Akihisa Yamada. 2020. On probabilistic term rewriting. Sci. Comput. Program. 185 ( 2020 ). https://doi.org/10.1016/j.scico. 2019.102338 Google Scholar
Cross Ref
- Henk Barendregt, Mario Coppo, and Mariangiola Dezani-Ciancaglini. 1983. A Filter Lambda Model and the Completeness of Type Assignment. Journal of Symbolic Logic 48, 4 ( 1983 ), 931-940. https://doi.org/10.2307/2273659 Google Scholar
Cross Ref
- Alexis Bernadet and Stéphane Lengrand. 2013. Non-idempotent intersection types and strong normalisation. Log. Methods Comput. Sci. 9, 4 ( 2013 ). https://doi.org/10.2168/LMCS-9( 4 :3) 2013 Google Scholar
Cross Ref
- Patrick Billingsley. 1979. Probability and measure. John Wiley and Sons, New York.Google Scholar
- Ales Bizjak and Lars Birkedal. 2015. Step-Indexed Logical Relations for Probability. In Proc. of FoSSaCS. 279-294. https: //doi.org/10.1007/978-3-662-46678-0_18 Google Scholar
Cross Ref
- Olivier Bournez and Florent Garnier. 2006. Proving Positive Almost Sure Termination Under Strategies. In Rewriting Techniques and Applications, RTA. 357-371. https://doi.org/10.1007/11805618_27 Google Scholar
Digital Library
- Pierre Brémaud. 2017. Discrete Probability Models and Methods. Springer. https://doi.org/10.1007/978-3-319-43476-6 Google Scholar
Cross Ref
- Flavien Breuvart and Ugo Dal Lago. 2018. On Intersection Types and Probabilistic Lambda Calculi. In Proc. of PPDP 2018. 8 : 1-8 : 13. https://doi.org/10.1145/3236950.3236968 Google Scholar
Digital Library
- Sébastien Carlier, Jef Polakow, J. B. Wells, and A. J. Kfoury. 2004. System E: Expansion Variables for Flexible Typing with Linear and Non-linear Types and Intersection Types. In Proc. of ESOP 2004 (LNCS), Vol. 2986. Springer, 294-309. https://doi.org/10.1007/978-3-540-24725-8_21 Google Scholar
Cross Ref
- Aleksandar Chakarov and Sriram Sankaranarayanan. 2013. Probabilistic Program Analysis with Martingales. In Proc. of CAV 2013 (LNCS), Vol. 8044. Springer, 511-526. https://doi.org/10.1007/978-3-643-39799-8_34 Google Scholar
Cross Ref
- Mario Coppo and Mariangiola Dezani-Ciancaglini. 1978. A new type assignment for lambda-terms. Archiv für mathematische Logik und Grundlagenforschung 19, 1 ( 1978 ), 139-156. https://doi.org/10.1007/BF02011875 Google Scholar
Cross Ref
- Mario Coppo and Mariangiola Dezani-Ciancaglini. 1980. An extension of the basic functionality theory for the λ-calculus. Notre Dame J. Formal Logic 21, 4 ( 10 1980 ), 685-693. https://doi.org/10.1305/ndjfl/1093883253 Google Scholar
Cross Ref
- Mario Coppo, Mariangiola Dezani-Ciancaglini, and Betti Venneri. 1980. Principal type schemes and lambda-calculus semantics. In To H.B. Curry: Essays on Combinatory Logic, Lambda Calculus and Formalism. Academic Press, 535-560.Google Scholar
- Mario Coppo, Mariangiola Dezani-Ciancaglini, and Betti Venneri. 1981. Functional Characters of Solvable Terms. Math. Log. Q. 27, 2-6 ( 1981 ), 45-58. https://doi.org/10.1002/malq.19810270205 Google Scholar
- Mario Coppo, Mariangiola Dezani-Ciancaglini, and Maddalena Zacchi. 1987. Type Theories, Normal Forms and D ∞-LambdaModels. Inf. Comput. 72, 2 ( 1987 ), 85-116. https://doi.org/10.1016/ 0890-5401 ( 87 ) 90042-3 Google Scholar
Digital Library
- Patrick Cousot. 1997. Types as Abstract Interpretations. In Proc. of POPL 1997. 316-331. https://doi.org/10.1145/263699.263744 Google Scholar
Digital Library
- Ugo Dal Lago and Beniamino Accattoli. 2017. Encoding Turing Machines into the Deterministic Lambda-Calculus. CoRR abs/1711.10078 ( 2017 ). http://arxiv.org/abs/1711.10078Google Scholar
- Ugo Dal Lago, Claudia Faggian, and Simona Ronchi Della Rocca. 2020. Intersection Types and (Positive) Almost-Sure Termination (Extended version). CoRR 2010. 12689 ( 2020 ). http://arxiv.org/abs/ 2010.12689Google Scholar
- Ugo Dal Lago and Marco Gaboardi. 2011. Linear Dependent Types and Relative Completeness. Log. Methods Comput. Sci. 8, 4 ( 2011 ). https://doi.org/10.2168/LMCS-8( 4 :11) 2012 Google Scholar
Cross Ref
- Ugo Dal Lago and Charles Grellois. 2019. Probabilistic Termination by Monadic Afine Sized Typing. ACM Trans. Program. Lang. Syst. 41, 2 ( 2019 ), 10 : 1-10 : 65. https://doi.org/10.1145/3293605 Google Scholar
Digital Library
- Ugo Dal Lago, Davide Sangiorgi, and Michele Alberti. 2014. On coinductive equivalences for higher-order probabilistic functional programs. In Proc. of POPL 2014. 297-308. https://doi.org/10.1145/2535838.2535872 Google Scholar
Digital Library
- Ugo Dal Lago and Margherita Zorzi. 2012. Probabilistic operational semantics for the lambda calculus. RAIRO-Theor. Inf. and Applic. 46, 3 ( 2012 ), 413-450. https://doi.org/10.1051/ita/2012012 Google Scholar
Cross Ref
- Daniel de Carvalho. 2018. Execution time of λ-terms via denotational semantics and intersection types. Math. Struct. Comput. Sci. 28, 7 ( 2018 ), 1169-1203. https://doi.org/10.1017/S0960129516000396 Availabel in preprint form from 2009 https://arxiv.org/abs/0905.4251.Google Scholar
- Karel De Leeuw, Edward F Moore, Claude E Shannon, and Norman Shapiro. 1956. Computability by probabilistic machines. Automata studies 34 ( 1956 ), 183-198.Google Scholar
- Ugo de'Liguoro. 2001. Characterizing Convergent Terms in Object Calculi via Intersection Types. In Proc. of TLCA 2001 (LNCS), Vol. 2044. Springer, 315-328. https://doi.org/10.1007/3-540-45413-6_25 Google Scholar
Cross Ref
- Ugo de'Liguoro and Adolfo Piperno. 1995. Non Deterministic Extensions of Untyped Lambda-Calculus. Inf. Comput. 122, 2 ( 1995 ), 149-177. https://doi.org/10.1006/inco. 1995.1145 Google Scholar
Digital Library
- Mariangiola Dezani-Ciancaglini, Ugo de'Liguoro, and Adolfo Piperno. 1993. Filter Models for a Parallel and Non Deterministic Lambda-Calculus. In Proc. of MFCS 1993. 403-412. https://doi.org/10.1007/3-540-57182-5_32 Google Scholar
Cross Ref
- Thomas Ehrhard, Christine Tasson, and Michele Pagani. 2014. Probabilistic coherence spaces are fully abstract for probabilistic PCF. In Proc. of POPL 2014. ACM, 309-320. https://doi.org/10.1145/2535838.2535865 Google Scholar
Digital Library
- Kousha Etessami and Mihalis Yannakakis. 2009. Recursive Markov chains, stochastic grammars, and monotone systems of nonlinear equations. J. ACM 56, 1 ( 2009 ), 1 : 1-1 : 66. https://doi.org/10.1145/1462153.1462154 Google Scholar
Digital Library
- Luis María Ferrer Fioriti and Holger Hermanns. 2015. Probabilistic Termination: Soundness, Completeness, and Compositionality. In Proc. of POPL 2015. 489-501. https://doi.org/10.1145/2676726.2677001 Google Scholar
Digital Library
- Philippa Gardner. 1994. Discovering Needed Reductions Using Type Theory. In Proc. of TACS '94, ( LNCS ), Vol. 789. Springer, 555-574. https://doi.org/10.1007/3-540-57887-0_155 Google Scholar
Cross Ref
- John Gill. 1977. Computational complexity of probabilistic Turing machines. SIAM J. Comput. 6, 4 ( 1977 ), 675-695. https://doi.org/10.1137/0206049 Google Scholar
Cross Ref
- Jean-Yves Girard. 1971. Une Extension De l'Interpretation De Gödel a l'Analyse, Et Son Application a l' Elimination Des Coupures Dans l'Analyse Et La Theorie Des Types. In Proceedings of the Second Scandinavian Logic Symposium. Studies in Logic and the Foundations of Mathematics, Vol. 63. Elsevier, 63-92. https://doi.org/10.1016/ S0049-237X( 08 ) 70843-7 Google Scholar
Cross Ref
- Shafi Goldwasser and Silvio Micali. 1984. Probabilistic encryption. Journal of computer and system sciences 28, 2 ( 1984 ), 270-299. https://doi.org/10.1016/ 0022-0000 ( 84 ) 90070-9 Google Scholar
Cross Ref
- Noah D. Goodman, Vikash K. Mansinghka, Daniel M. Roy, Keith Bonawitz, and Joshua B. Tenenbaum. 2008. Church: a language for generative models. In UAI. 220-229.Google Scholar
- Jean Goubault-Larrecq. 2015. Full Abstraction for Non-Deterministic and Probabilistic Extensions of PCF I: the Angelic Cases. Journal of Logic and Algebraic Methods in Programming 84 ( 2015 ), 155-184. https://doi.org/10.1016/j.jlamp. 2014. 09.003 Google Scholar
Cross Ref
- John Hughes, Lars Pareto, and Amr Sabry. 1996. Proving the Correctness of Reactive Systems Using Sized Types. In Proc. of POPL 1996. ACM Press, 410-423. https://doi.org/10.1145/237721.240882 Google Scholar
Digital Library
- Claire Jones and Gordon D. Plotkin. 1989. A Probabilistic Powerdomain of Evaluations. In Proc. of LICS 1989. 186-195. https://doi.org/10.1109/LICS. 1989.39173 Google Scholar
Cross Ref
- Achim Jung and Regina Tix. 1998. The troublesome probabilistic powerdomain. Electr. Notes Theor. Comput. Sci. 13 ( 1998 ), 70-91. https://doi.org/10.1016/S1571-0661 ( 05 ) 80216-6 Google Scholar
Cross Ref
- Benjamin Lucien Kaminski, Joost-Pieter Katoen, and Christoph Matheja. 2019. On the hardness of analyzing probabilistic programs. Acta Informatica 56, 3 ( 2019 ), 255-285. https://doi.org/10.1007/s00236-018-0321-1 Google Scholar
Digital Library
- Benjamin Lucien Kaminski, Joost-Pieter Katoen, Christoph Matheja, and Federico Olmedo. 2018. Weakest Precondition Reasoning for Expected Runtimes of Randomized Algorithms. J. ACM 65, 5 ( 2018 ), 30 : 1-30 : 68. https://doi.org/10.1145/ 3208102 Google Scholar
Digital Library
- Assaf J. Kfoury. 2000. A linearization of the Lambda-calculus and consequences. J. Log. Comput. 10, 3 ( 2000 ), 411-436. https://doi.org/10.1093/logcom/10.3. 411 Google Scholar
Cross Ref
- A. J. Kfoury and J. B. Wells. 1999. Principality and Decidable Type Inference for Finite-Rank Intersection Types. In POPL '99, Proceedings of the 26th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, San Antonio, TX, USA, January 20-22, 1999, Andrew W. Appel and Alex Aiken (Eds.). ACM, 161-174. https://doi.org/10.1145/292540.292556 Google Scholar
Digital Library
- Naoki Kobayashi. 2009. Types and higher-order recursion schemes for verification of higher-order programs. In Proceedings of the 36th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2009, Savannah, GA, USA, January 21-23, 2009. 416-428. https://doi.org/10.1145/1480881.1480933 Google Scholar
Digital Library
- Naoki Kobayashi, Ugo Dal Lago, and Charles Grellois. 2019. On the Termination Problem for Probabilistic Higher-Order Recursive Programs. In Proc. of LICS 2019. 1-14. https://doi.org/10.1109/LICS. 2019.8785679 Google Scholar
Cross Ref
- Naoki Kobayashi and C.-H. Luke Ong. 2009. A Type System Equivalent to the Modal Mu-Calculus Model Checking of Higher-Order Recursion Schemes. In Proc. of LICS 2009. 179-188. https://doi.org/10.1109/LICS. 2009.29 Google Scholar
Digital Library
- Dexter Kozen. 1981. Semantics of Probabilistic Programs. J. Comput. Syst. Sci. 22, 3 ( 1981 ), 328-350. https://doi.org/10.1016/ 0022-0000 ( 81 ) 90036-2 Google Scholar
Cross Ref
- Annabelle McIver and Carroll Morgan. 2005. Abstraction, Refinement and Proof for Probabilistic Systems. Springer. https: //doi.org/10.1007/b138392 Google Scholar
Cross Ref
- David Monniaux. 2001. An Abstract Analysis of the Probabilistic Termination of Programs. In Proc. of SAS 2001. 111-126. https://doi.org/10.1145/360204.360211 Google Scholar
Digital Library
- Rajeev Motwani and Prabhakar Raghavan. 1995. Randomized Algorithms. Cambridge University Press. https://doi.org/10. 1017/cbo9780511814075 Google Scholar
Cross Ref
- Peter Møller Neergaard and Harry G. Mairson. 2004. Types, potency, and idempotency: why nonlinearity and amnesia make a type system work. In Proc. of ICFP 2004. 138-149. https://doi.org/10.1145/1016850.1016871 Google Scholar
Digital Library
- Van Chan Ngo, Quentin Carbonneaux, and Jan Hofmann. 2018. Bounded expectations: resource analysis for probabilistic programs. In Proc. of PLDI 2018. 496-512. https://doi.org/10.1145/3192366.3192394 Google Scholar
Digital Library
- Piergiorgio Odifreddi. 1989. Classical Recursion Theory. Elsevier.Google Scholar
- C.-H. Luke Ong. 2006. On Model-Checking Trees Generated by Higher-Order Recursion Schemes. In Proc. of LICS 2006. 81-90. https://doi.org/10.1109/LICS. 2006.38 Google Scholar
Digital Library
- Benjamin C. Pierce. 2002. Types and programming languages. MIT Press.Google Scholar
Digital Library
- Gordon D. Plotkin. 1975. Call-by-Name, Call-by-Value and the lambda-Calculus. Theor. Comput. Sci. 1, 2 ( 1975 ), 125-159. https://doi.org/10.1016/ 0304-3975 ( 75 ) 90017-1 Google Scholar
Cross Ref
- Garrell Pottinger. 1980. A type assignment for the strongly normalizable lambda-terms. In To H.B. Curry: Essays on Combinatory Logic, Lambda Caclulus and Formalism. Academic Press, 561-577.Google Scholar
- Martin L. Puterman. 1994. Markov Decision Processes: Discrete Stochastic Dynamic Programming (1st ed.). John Wiley & Sons, Inc., New York, NY, USA. https://doi.org/10.1002/9780470316887 Google Scholar
Cross Ref
- Michael O Rabin. 1963. Probabilistic automata. Information and control 6, 3 ( 1963 ), 230-245. https://doi.org/10.1016/S0019-9958 ( 63 ) 90290-0 Google Scholar
Cross Ref
- N. Saheb-Djahromi. 1978. Probabilistic LCF. In Proc. of MFCS 1978 (LNCS), Vol. 64. 442-451. https://doi.org/10.1007/3-504-08921-7_92 Google Scholar
Cross Ref
- Eugene S. Santos. 1969. Probabilistic Turing machines and computability. Proc. Amer. Math. Soc. 22, 3 ( 1969 ), 704-710.Google Scholar
Cross Ref
- Morten Heine Sørensen and Pawel Urzyczyn. 1989. Lectures on the Curry-Howard Isomorphism. Elsevier. https://doi.org/10. 1016/ S0049-237X( 06 ) 80005-4 Google Scholar
Cross Ref
- David Tolpin, Jan-Willem van de Meent, and Frank D. Wood. 2015. Probabilistic Programming in Anglican. In Proc. of ECML PKDD 2015 (LNCS), Vol. 9286. Springer, 308-311. https://doi.org/10.1007/978-3-319-23461-8_36 Google Scholar
Digital Library
- Takeshi Tsukada and Naoki Kobayashi. 2012. An Intersection Type System for Deterministic Pushdown Automata. In Proc. of TCS 2012. 357-371. https://doi.org/10.1007/978-3-642-33475-7_25 Google Scholar
Digital Library
- Stefen van Bakel, Franco Barbanera, and Ugo de'Liguoro. 2012. Characterisation of Strongly Normalising lambda-mu-Terms. In Proc. of, ITRS 2012 (EPTCS), Vol. 121. 1-17. https://doi.org/10.4204/EPTCS.121.1 Google Scholar
Cross Ref
- Christopher Wadsworth. 1980. Some unusual λ-calculus numeral systems. In To H.B. Curry: Essays on Combinatory Logic, Lambda Calculus and Formalism, J.P. Seldin and J.R. Hindley (Eds.). Academic Press.Google Scholar
Index Terms
Intersection types and (positive) almost-sure termination
Recommendations
Gradual typing with union and intersection types
We propose a type system for functional languages with gradual types and set-theoretic type connectives and prove its soundness. In particular, we show how to lift the definition of the domain and result type of an application from non-gradual types to ...
Disjoint intersection types
ICFP 2016: Proceedings of the 21st ACM SIGPLAN International Conference on Functional ProgrammingDunfield showed that a simply typed core calculus with intersection types and a merge operator is able to capture various programming language features. While his calculus is type-safe, it is not coherent: different derivations for the same expression ...
A Typed Lambda Calculus with Gradual Intersection Types
PPDP '22: Proceedings of the 24th International Symposium on Principles and Practice of Declarative ProgrammingIntersection types have the power to type expressions which are all of many different types. Gradual types combine type checking at both compile-time and run-time. Here we combine these two approaches in a new typed calculus that harness both of their ...






Comments