skip to main content
research-article
Free Access

Diamonds are not forever: liveness in reactive programming with guarded recursion

Published:04 January 2021Publication History
Skip Abstract Section

Abstract

When designing languages for functional reactive programming (FRP) the main challenge is to provide the user with a simple, flexible interface for writing programs on a high level of abstraction while ensuring that all programs can be implemented efficiently in a low-level language. To meet this challenge, a new family of modal FRP languages has been proposed, in which variants of Nakano's guarded fixed point operator are used for writing recursive programs guaranteeing properties such as causality and productivity. As an apparent extension to this it has also been suggested to use Linear Temporal Logic (LTL) as a language for reactive programming through the Curry-Howard isomorphism, allowing properties such as termination, liveness and fairness to be encoded in types. However, these two ideas are in conflict with each other, since the fixed point operator introduces non-termination into the inductive types that are supposed to provide termination guarantees.

In this paper we show that by regarding the modal time step operator of LTL a submodality of the one used for guarded recursion (rather than equating them), one can obtain a modal type system capable of expressing liveness properties while retaining the power of the guarded fixed point operator. We introduce the language Lively RaTT, a modal FRP language with a guarded fixed point operator and an `until' type constructor as in LTL, and show how to program with events and fair streams. Using a step-indexed Kripke logical relation we prove operational properties of Lively RaTT including productivity and causality as well as the termination and liveness properties expected of types from LTL. Finally, we prove that the type system of Lively RaTT guarantees the absence of implicit space leaks.

References

  1. Andreas Abel and Brigitte Pientka. 2013. Wellfounded Recursion with Copatterns: A Unified Approach to Termination and Productivity. In Proceedings ICFP 2013. ACM, New York, NY, USA, 185-196. https://doi.org/10.1145/2500365.2500591 Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Andreas Abel, Andrea Vezzosi, and Théo Winterhalter. 2017. Normalization by evaluation for sized dependent types. PACMPL 1, ICFP ( 2017 ), 33 : 1-33 : 30. https://doi.org/10.1145/3110277 Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Andrew W. Appel and David McAllester. 2001. An Indexed Model of Recursive Types for Foundational Proof-carrying Code. ACM Trans. Program. Lang. Syst. 23, 5 (Sept. 2001 ), 657-683. https://doi.org/10.1145/504709.504712 00283. Google ScholarGoogle ScholarCross RefCross Ref
  4. Andrew W Appel, Paul-André Mellies, Christopher D Richards, and Jérôme Vouillon. 2007. A very modal model of a modern, major, general type system. In Proceedings of the 34th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages. ACM, New York, NY, USA, 109-122. https://doi.org/10.1145/1190215.1190235 Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Robert Atkey and Conor McBride. 2013. Productive coprogramming with guarded recursion. ACM SIGPLAN Notices 48, 9 ( 2013 ), 197-208. https://doi.org/10.1145/2500365.2500597 Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Patrick Bahr, Hans Bugge Grathwohl, and Rasmus Ejlers Møgelberg. 2017. The clocks are ticking: No more delays!. In 32nd Annual ACM/IEEE Symposium on Logic in Computer Science, LICS 2017, Reykjavik, Iceland, June 20-23, 2017. IEEE Computer Society, Washington, DC, USA, 1-12. https://doi.org/10.1109/LICS. 2017.8005097 Google ScholarGoogle ScholarCross RefCross Ref
  7. Patrick Bahr, Christian Uldal Graulund, and Rasmus Ejlers Møgelberg. 2019. Simply RaTT: a fitch-style modal calculus for reactive programming without space leaks. Proceedings of the ACM on Programming Languages 3, ICFP ( 2019 ), 1-27. https://doi.org/10.1145/3341713 Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Lars Birkedal, Aleš Bizjak, Ranald Clouston, Hans Bugge Grathwohl, Bas Spitters, and Andrea Vezzosi. 2019. Guarded Cubical Type Theory. Journal of Automated Reasoning 63, 2 ( 01 Aug 2019 ), 211-253. https://doi.org/10.1007/s10817-018-9471-7 Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Lars Birkedal, Rasmus Ejlers Møgelberg, Jan Schwinghammer, and Kristian Støvring. 2011. First steps in synthetic guarded domain theory: Step-indexing in the topos of trees. In In Proc. of LICS. IEEE Computer Society, Washington, DC, USA, 55-64. https://doi.org/10.2168/LMCS-8( 4 :1) 2012 Google ScholarGoogle ScholarCross RefCross Ref
  10. Aleš Bizjak, Lars Birkedal, and Marino Miculan. 2014. A Model of Countable Nondeterminism in Guarded Type Theory. In Rewriting and Typed Lambda Calculi, Gilles Dowek (Ed.). Springer International Publishing, Cham, 108-123. https: //doi.org/10.1007/978-3-319-08918-8_8 Google ScholarGoogle ScholarCross RefCross Ref
  11. Aleš Bizjak, Hans Bugge Grathwohl, Ranald Clouston, Rasmus E. Møgelberg, and Lars Birkedal. 2016. Guarded Dependent Type Theory with Coinductive Types. In Foundations of Software Science and Computation Structures, Bart Jacobs and Christof Löding (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 20-35. https://doi.org/10.1007/978-3-662-49630-5_2 Google ScholarGoogle ScholarCross RefCross Ref
  12. Andrew Cave, Francisco Ferreira, Prakash Panangaden, and Brigitte Pientka. 2014. Fair Reactive Programming. In Proceedings of the 41st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL '14). ACM, San Diego, California, USA, 361-372. https://doi.org/10.1145/2535838.2535881 Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Ranald Clouston. 2018. Fitch-Style Modal Lambda Calculi. In Foundations of Software Science and Computation Structures, Christel Baier and Ugo Dal Lago (Eds.). Springer International Publishing, Cham, 258-275. https://doi.org/10.1007/978-3-319-89366-2_14 Google ScholarGoogle ScholarCross RefCross Ref
  14. Ranald Clouston, Aleš Bizjak, Hans Bugge Grathwohl, and Lars Birkedal. 2015. Programming and Reasoning with Guarded Recursion for Coinductive Types. In Foundations of Software Science and Computation Structures, Andrew Pitts (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg, 407-421. https://doi.org/10.1007/978-3-662-46678-0_26 Google ScholarGoogle ScholarCross RefCross Ref
  15. Ranald Clouston, Bassel Mannaa, Rasmus Ejlers Møgelberg, Andrew M. Pitts, and Bas Spitters. 2018. Modal Dependent Type Theory and Dependent Right Adjoints. CoRR abs/ 1804.05236 ( 2018 ), 1-21. arXiv: 1804.05236 http://arxiv.org/abs/ 1804.05236Google ScholarGoogle Scholar
  16. Conal Elliott and Paul Hudak. 1997. Functional Reactive Animation. In Proceedings of the Second ACM SIGPLAN International Conference on Functional Programming (ICFP '97). ACM, New York, NY, USA, 263-273. https://doi.org/10.1145/258948. 258973 Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Frederic Benton Fitch. 1952. Symbolic logic, an introduction. Ronald Press Co., New York, NY, USA. https://doi.org/10.2307/ 2266614 Google ScholarGoogle ScholarCross RefCross Ref
  18. Adrien Guatto. 2018. A Generalized Modality for Recursion. In Proceedings of the 33rd Annual ACM/IEEE Symposium on Logic in Computer Science (LICS '18). Association for Computing Machinery, New York, NY, USA, 482-491. https: //doi.org/10.1145/3209108.3209148 Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. John Hughes, Lars Pareto, and Amr Sabry. 1996. Proving the Correctness of Reactive Systems Using Sized Types. In Proceedings of the 23rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL '96). Association for Computing Machinery, New York, NY, USA, 410-423. https://doi.org/10.1145/237721.240882 Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Alan Jefrey. 2012. LTL types FRP: linear-time temporal logic propositions as types, proofs as functional reactive programs. In Proceedings of the sixth workshop on Programming Languages meets Program Verification, PLPV 2012, Philadelphia, PA, USA, January 24, 2012, Koen Claessen and Nikhil Swamy (Eds.). ACM, Philadelphia, PA, USA, 49-60. https: //doi.org/10.1145/2103776.2103783 Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Alan Jefrey. 2014. Functional Reactive Types. In Proceedings of the Joint Meeting of the Twenty-Third EACSL Annual Conference on Computer Science Logic ( CSL) and the Twenty-Ninth Annual ACM/IEEE Symposium on Logic in Computer Science (LICS) (CSL-LICS '14). ACM, New York, NY, USA, Article 54, 9 pages. https://doi.org/10.1145/2603088.2603106 Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Wolfgang Jeltsch. 2012. Towards a common categorical semantics for linear-time temporal logic and functional reactive programming. Electronic Notes in Theoretical Computer Science 286 ( 2012 ), 229-242. https://doi.org/10.1016/j.entcs. 2012. 08.015 Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Wolfgang Jeltsch. 2013. Temporal Logic with "Until", Functional Reactive Programming with Processes, and Concrete Process Categories. In Proceedings of the 7th Workshop on Programming Languages Meets Program Verification (PLPV '13). ACM, New York, NY, USA, 69-78. https://doi.org/10.1145/2428116.2428128 Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Ralf Jung, David Swasey, Filip Sieczkowski, Kasper Svendsen, Aaron Turon, Lars Birkedal, and Derek Dreyer. 2015. Iris: Monoids and invariants as an orthogonal basis for concurrent reasoning. ACM SIGPLAN Notices 50, 1 ( 2015 ), 637-650. https://doi.org/10.1145/2775051.2676980 Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Neelakantan R. Krishnaswami. 2013. Higher-order Functional Reactive Programming Without Spacetime Leaks. In Proceedings of the 18th ACM SIGPLAN International Conference on Functional Programming (ICFP '13). ACM, Boston, Massachusetts, USA, 221-232. https://doi.org/10.1145/2500365.2500588 Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Neelakantan R. Krishnaswami and Nick Benton. 2011. Ultrametric Semantics of Reactive Programs. In 2011 IEEE 26th Annual Symposium on Logic in Computer Science. IEEE Computer Society, Washington, DC, USA, 257-266. https: //doi.org/10.1109/LICS. 2011.38 Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Neelakantan R. Krishnaswami, Nick Benton, and Jan Hofmann. 2012. Higher-order functional reactive programming in bounded space. In Proceedings of the 39th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2012, Philadelphia, Pennsylvania, USA, January 22-28, 2012, John Field and Michael Hicks (Eds.). ACM, Philadelphia, PA, USA, 45-58. https://doi.org/10.1145/2103656.2103665 Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Saunders MacLane and Ieke Moerdijk. 2012. Sheaves in geometry and logic: A first introduction to topos theory. Springer Science & Business Media, New York, NY, USA. https://doi.org/10.1007/978-1-4612-0927-0 Google ScholarGoogle Scholar
  29. Rasmus E Møgelberg and Marco Paviotti. 2019. Denotational semantics of recursive types in synthetic guarded domain theory. Mathematical Structures in Computer Science 29, 3 ( 2019 ), 465-510. https://doi.org/10.1017/S0960129518000087 Google ScholarGoogle ScholarCross RefCross Ref
  30. Rasmus Ejlers Møgelberg and Niccolò Veltri. 2019. Bisimulation as path type for guarded recursive types. Proceedings of the ACM on Programming Languages 3, POPL ( 2019 ), 1-29. https://doi.org/10.1145/3290317 Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Hiroshi Nakano. 2000. A modality for recursion. In Proceedings Fifteenth Annual IEEE Symposium on Logic in Computer Science (Cat. No.99CB36332). IEEE Computer Society, Washington, DC, USA, 255-266. https://doi.org/10.1109/LICS. 2000.855774 Google ScholarGoogle ScholarCross RefCross Ref
  32. Henrik Nilsson, Antony Courtney, and John Peterson. 2002. Functional Reactive Programming, Continued. In Proceedings of the 2002 ACM SIGPLAN Workshop on Haskell (Haskell '02). ACM, New York, NY, USA, 51-64. https://doi.org/10.1145/ 581690.581695 Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Amir Pnueli. 1977. The Temporal Logic of Programs. In Proceedings of the 18th Annual Symposium on Foundations of Computer Science (SFCS '77). IEEE Computer Society, USA, 46-57. https://doi.org/10.1109/SFCS. 1977.32 Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Jorge Luis Sacchini. 2013. Type-Based Productivity of Stream Definitions in the Calculus of Constructions. In 28th Annual ACM/IEEE Symposium on Logic in Computer Science, LICS 2013, New Orleans, LA, USA, June 25-28, 2013. IEEE, New Orleans, LA, USA, 233-242. https://doi.org/10.1109/LICS. 2013.29 Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Kasper Svendsen, Filip Sieczkowski, and Lars Birkedal. 2016. Transfinite Step-Indexing: Decoupling Concrete and Logical Steps. In Programming Languages and Systems, Peter Thiemann (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg, 727-751. https://doi.org/10.1007/978-3-662-49498-1_28 Google ScholarGoogle ScholarCross RefCross Ref
  36. The Univalent Foundations Program. 2013. Homotopy Type Theory: Univalent Foundations of Mathematics. https: //homotopytypetheory.org/book, Institute for Advanced Study.Google ScholarGoogle Scholar
  37. Niccolò Veltri and Andrea Vezzosi. 2020. Formalizing-Calculus in Guarded Cubical Agda. In Proceedings of the 9th ACM SIGPLAN International Conference on Certified Programs and Proofs (CPP 2020 ). Association for Computing Machinery, New York, NY, USA, 270-283. https://doi.org/10.1145/3372885.3373814 Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Diamonds are not forever: liveness in reactive programming with guarded recursion

          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!