skip to main content
research-article
Open Access

Intersection types and (positive) almost-sure termination

Published:04 January 2021Publication History
Skip Abstract Section

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.

References

  1. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  2. 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 ScholarGoogle ScholarCross RefCross Ref
  3. 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 ScholarGoogle ScholarCross RefCross Ref
  4. 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 ScholarGoogle ScholarCross RefCross Ref
  5. 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 ScholarGoogle ScholarCross RefCross Ref
  6. 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 ScholarGoogle ScholarCross RefCross Ref
  7. Patrick Billingsley. 1979. Probability and measure. John Wiley and Sons, New York.Google ScholarGoogle Scholar
  8. 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 ScholarGoogle ScholarCross RefCross Ref
  9. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  10. Pierre Brémaud. 2017. Discrete Probability Models and Methods. Springer. https://doi.org/10.1007/978-3-319-43476-6 Google ScholarGoogle ScholarCross RefCross Ref
  11. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  12. 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 ScholarGoogle ScholarCross RefCross Ref
  13. 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 ScholarGoogle ScholarCross RefCross Ref
  14. 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 ScholarGoogle ScholarCross RefCross Ref
  15. 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 ScholarGoogle ScholarCross RefCross Ref
  16. 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 ScholarGoogle Scholar
  17. 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 ScholarGoogle Scholar
  18. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  19. Patrick Cousot. 1997. Types as Abstract Interpretations. In Proc. of POPL 1997. 316-331. https://doi.org/10.1145/263699.263744 Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. 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 ScholarGoogle Scholar
  21. 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 ScholarGoogle Scholar
  22. 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 ScholarGoogle ScholarCross RefCross Ref
  23. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  24. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  25. 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 ScholarGoogle ScholarCross RefCross Ref
  26. 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 ScholarGoogle Scholar
  27. Karel De Leeuw, Edward F Moore, Claude E Shannon, and Norman Shapiro. 1956. Computability by probabilistic machines. Automata studies 34 ( 1956 ), 183-198.Google ScholarGoogle Scholar
  28. 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 ScholarGoogle ScholarCross RefCross Ref
  29. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  30. 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 ScholarGoogle ScholarCross RefCross Ref
  31. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  32. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  33. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  34. 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 ScholarGoogle ScholarCross RefCross Ref
  35. John Gill. 1977. Computational complexity of probabilistic Turing machines. SIAM J. Comput. 6, 4 ( 1977 ), 675-695. https://doi.org/10.1137/0206049 Google ScholarGoogle ScholarCross RefCross Ref
  36. 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 ScholarGoogle ScholarCross RefCross Ref
  37. 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 ScholarGoogle ScholarCross RefCross Ref
  38. 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 ScholarGoogle Scholar
  39. 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 ScholarGoogle ScholarCross RefCross Ref
  40. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  41. 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 ScholarGoogle ScholarCross RefCross Ref
  42. 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 ScholarGoogle ScholarCross RefCross Ref
  43. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  44. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  45. 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 ScholarGoogle ScholarCross RefCross Ref
  46. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  47. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  48. 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 ScholarGoogle ScholarCross RefCross Ref
  49. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  50. 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 ScholarGoogle ScholarCross RefCross Ref
  51. Annabelle McIver and Carroll Morgan. 2005. Abstraction, Refinement and Proof for Probabilistic Systems. Springer. https: //doi.org/10.1007/b138392 Google ScholarGoogle ScholarCross RefCross Ref
  52. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  53. Rajeev Motwani and Prabhakar Raghavan. 1995. Randomized Algorithms. Cambridge University Press. https://doi.org/10. 1017/cbo9780511814075 Google ScholarGoogle ScholarCross RefCross Ref
  54. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  55. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  56. Piergiorgio Odifreddi. 1989. Classical Recursion Theory. Elsevier.Google ScholarGoogle Scholar
  57. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  58. Benjamin C. Pierce. 2002. Types and programming languages. MIT Press.Google ScholarGoogle ScholarDigital LibraryDigital Library
  59. 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 ScholarGoogle ScholarCross RefCross Ref
  60. 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 ScholarGoogle Scholar
  61. 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 ScholarGoogle ScholarCross RefCross Ref
  62. 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 ScholarGoogle ScholarCross RefCross Ref
  63. 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 ScholarGoogle ScholarCross RefCross Ref
  64. Eugene S. Santos. 1969. Probabilistic Turing machines and computability. Proc. Amer. Math. Soc. 22, 3 ( 1969 ), 704-710.Google ScholarGoogle ScholarCross RefCross Ref
  65. 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 ScholarGoogle ScholarCross RefCross Ref
  66. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  67. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  68. 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 ScholarGoogle ScholarCross RefCross Ref
  69. 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 ScholarGoogle Scholar

Index Terms

  1. Intersection types and (positive) almost-sure termination

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!