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.
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Cross Ref
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Cross Ref
- 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 Scholar
- 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 Scholar
Digital Library
- Frederic Benton Fitch. 1952. Symbolic logic, an introduction. Ronald Press Co., New York, NY, USA. https://doi.org/10.2307/ 2266614 Google Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- The Univalent Foundations Program. 2013. Homotopy Type Theory: Univalent Foundations of Mathematics. https: //homotopytypetheory.org/book, Institute for Advanced Study.Google Scholar
- 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 Scholar
Digital Library
Index Terms
Diamonds are not forever: liveness in reactive programming with guarded recursion
Recommendations
Simply RaTT: a fitch-style modal calculus for reactive programming without space leaks
Functional reactive programming (FRP) is a paradigm for programming with signals and events, allowing the user to describe reactive programs on a high level of abstraction. For this to make sense, an FRP language must ensure that all programs are causal,...
Fair reactive programming
POPL '14: Proceedings of the 41st ACM SIGPLAN-SIGACT Symposium on Principles of Programming LanguagesFunctional Reactive Programming (FRP) models reactive systems with events and signals, which have previously been observed to correspond to the "eventually" and "always" modalities of linear temporal logic (LTL). In this paper, we define a constructive ...
Fair reactive programming
POPL '14Functional Reactive Programming (FRP) models reactive systems with events and signals, which have previously been observed to correspond to the "eventually" and "always" modalities of linear temporal logic (LTL). In this paper, we define a constructive ...






Comments