Advertisement

En Garde! Unguarded Iteration for Reversible Computation in the Delay Monad

  • Robin Kaarsgaard
  • Niccolò VeltriEmail author
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 11825)

Abstract

Reversible computation studies computations which exhibit both forward and backward determinism. Among others, it has been studied for half a century for its applications in low-power computing, and forms the basis for quantum computing.

Though certified program equivalence is useful for a number of applications (e.g., certified compilation and optimization), little work on this topic has been carried out for reversible programming languages. As a notable exception, Carette and Sabry have studied the equivalences of the finitary fragment of \(\mathsf {\Pi }^{\mathsf {o}}\), a reversible combinator calculus, yielding a two-level calculus of type isomorphisms and equivalences between them. In this paper, we extend the two-level calculus of finitary \(\mathsf {\Pi }^{\mathsf {o}}\) to one for full \(\mathsf {\Pi }^{\mathsf {o}}\) (i.e., with both recursive types and iteration by means of a trace combinator) using the delay monad, which can be regarded as a “computability-aware” analogue of the usual maybe monad for partiality. This yields a calculus of iterative (and possibly non-terminating) reversible programs acting on user-defined dynamic data structures together with a calculus of certified program equivalences between these programs.

Keywords

Reversible computation Iteration Delay monad 

References

  1. 1.
    Abel, A., Chapman, J.: Normalization by evaluation in the delay monad: a case study for coinduction via copatterns and sized types. In: Proceedings 5th Workshop on Mathematically Structured Functional Programming, MSFP@ETAPS 2014, Grenoble, France, 12 April 2014, pp. 51–67 (2014).  https://doi.org/10.4204/EPTCS.153.4MathSciNetCrossRefGoogle Scholar
  2. 2.
    Altenkirch, T., Danielsson, N.A., Kraus, N.: Partiality, revisited. In: Esparza, J., Murawski, A.S. (eds.) FoSSaCS 2017. LNCS, vol. 10203, pp. 534–549. Springer, Heidelberg (2017).  https://doi.org/10.1007/978-3-662-54458-7_31CrossRefGoogle Scholar
  3. 3.
    Barthe, G., Capretta, V., Pons, O.: Setoids in type theory. J. Funct. Program. 13(2), 261–293 (2003).  https://doi.org/10.1017/S0956796802004501MathSciNetCrossRefzbMATHGoogle Scholar
  4. 4.
    Bennett, C.H.: Logical reversibility of computation. IBM J. Res. Dev. 17(6), 525–532 (1973)MathSciNetCrossRefGoogle Scholar
  5. 5.
    Benton, N., Kennedy, A., Varming, C.: Some domain theory and denotational semantics in Coq. In: Berghofer, S., Nipkow, T., Urban, C., Wenzel, M. (eds.) TPHOLs 2009. LNCS, vol. 5674, pp. 115–130. Springer, Heidelberg (2009).  https://doi.org/10.1007/978-3-642-03359-9_10CrossRefzbMATHGoogle Scholar
  6. 6.
    Capretta, V.: General recursion via coinductive types. Logical Methods Comput. Sci. 1(2) (2005).  https://doi.org/10.2168/LMCS-1(2:1)2005
  7. 7.
    Carette, J., Sabry, A.: Computing with semirings and weak rig groupoids. In: Thiemann, P. (ed.) ESOP 2016. LNCS, vol. 9632, pp. 123–148. Springer, Heidelberg (2016).  https://doi.org/10.1007/978-3-662-49498-1_6CrossRefzbMATHGoogle Scholar
  8. 8.
    Chapman, J., Uustalu, T., Veltri, N.: Quotienting the delay monad by weak bisimilarity. Math. Struct. Comput. Sci. 29(1), 67–92 (2019).  https://doi.org/10.1017/S0960129517000184MathSciNetCrossRefzbMATHGoogle Scholar
  9. 9.
    Cockett, J.R.B., Lack, S.: Restriction categories I: categories of partial maps. Theoret. Comput. Sci. 270(1–2), 223–259 (2002)MathSciNetCrossRefGoogle Scholar
  10. 10.
    Cockett, J.R.B., Lack, S.: Restriction categories III: colimits, partial limits and extensivity. Math. Struct. Comput. Sci. 17(4), 775–817 (2007).  https://doi.org/10.1017/S0960129507006056MathSciNetCrossRefzbMATHGoogle Scholar
  11. 11.
    Danielsson, N.A.: Operational semantics using the partiality monad. In: ACM SIGPLAN International Conference on Functional Programming, ICFP 2012, Copenhagen, Denmark, 9–15 September 2012, pp. 127–138 (2012).  https://doi.org/10.1145/2364527.2364546
  12. 12.
    Danielsson, N.A.: Up-to techniques using sized types. PACMPL 2(POPL), 43:1–43:28 (2018).  https://doi.org/10.1145/3158131CrossRefGoogle Scholar
  13. 13.
    Escardó, M.H., Knapp, C.M.: Partial elements and recursion via dominances in univalent type theory. In: 26th EACSL Annual Conference on Computer Science Logic, CSL 2017, 20–24 August 2017, Stockholm, Sweden, pp. 21:1–21:16 (2017).  https://doi.org/10.4230/LIPIcs.CSL.2017.21
  14. 14.
    Ésik, Z., Goncharov, S.: Some remarks on conway and iteration theories. CoRR abs/1603.00838 (2016). http://arxiv.org/abs/1603.00838
  15. 15.
    Giles, B.: An investigation of some theoretical aspects of reversible computing. Ph.D. thesis, University of Calgary (2014)Google Scholar
  16. 16.
    Goncharov, S., Milius, S., Rauch, C.: Complete elgot monads and coalgebraic resumptions. Electr. Notes Theor. Comput. Sci. 325, 147–168 (2016).  https://doi.org/10.1016/j.entcs.2016.09.036MathSciNetCrossRefzbMATHGoogle Scholar
  17. 17.
    Goncharov, S., Schröder, L., Rauch, C., Jakob, J.: Unguarded recursion on coinductive resumptions. Logical Methods Comput. Sci. 14(3) (2018).  https://doi.org/10.23638/LMCS-14(3:10)2018
  18. 18.
    Hasegawa, M.: Recursion from cyclic sharing: traced monoidal categories and models of cyclic lambda calculi. In: de Groote, P., Roger Hindley, J. (eds.) TLCA 1997. LNCS, vol. 1210, pp. 196–213. Springer, Heidelberg (1997).  https://doi.org/10.1007/3-540-62688-3_37CrossRefzbMATHGoogle Scholar
  19. 19.
    Hofmann, M.: Extensional Constructs in Intensional Type Theory. CPHC/BCS Distinguished Dissertations. Springer, London (1997).  https://doi.org/10.1007/978-1-4471-0963-1CrossRefGoogle Scholar
  20. 20.
    Jacobsen, P.A.H., Kaarsgaard, R., Thomsen, M.K.: CoreFun: a typed functional reversible core language. In: Kari, J., Ulidowski, I. (eds.) RC 2018. LNCS, vol. 11106, pp. 304–321. Springer, Cham (2018).  https://doi.org/10.1007/978-3-319-99498-7_21CrossRefzbMATHGoogle Scholar
  21. 21.
    James, R.P., Sabry, A.: Information effects. In: Proceedings of the 39th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2012, Philadelphia, Pennsylvania, USA, 22–28 January 2012, pp. 73–84 (2012).  https://doi.org/10.1145/2103656.2103667
  22. 22.
    James, R.P., Sabry, A.: Theseus: A high level language for reversible computing (2014). https://www.cs.indiana.edu/~sabry/papers/theseus.pdf. Work-in-progress report at RC 2014
  23. 23.
    Joyal, A., Street, R., Verity, D.: Traced monoidal categories. Math. Proc. Camb. Philos. Soc. 119(3), 447–468 (1996).  https://doi.org/10.1017/S0305004100074338MathSciNetCrossRefzbMATHGoogle Scholar
  24. 24.
    Kaarsgaard, R., Glück, R.: A categorical foundation for structured reversible flowchart languages: soundness and adequacy. Logical Methods Comput. Sci. 14(3), 1–38 (2018)MathSciNetzbMATHGoogle Scholar
  25. 25.
    Kaarsgaard, R., Axelsen, H.B., Glück, R.: Join inverse categories and reversible recursion. J. Logic Algebra Methods Program. 87, 33–50 (2017).  https://doi.org/10.1016/j.jlamp.2016.08.003MathSciNetCrossRefzbMATHGoogle Scholar
  26. 26.
    Karvonen, M.: The Way of the Dagger. Ph.D. thesis, School of Informatics, University of Edinburgh (2019)Google Scholar
  27. 27.
    Kastl, J.: Inverse categories. In: Hoehnke, H.J. (ed.) Algebraische Modelle, Kategorien und Gruppoide, Studien zur Algebra und ihre Anwendungen, vol. 7, pp. 51–60. Akademie-Verlag, Berlin (1979)Google Scholar
  28. 28.
    Landauer, R.: Irreversibility and heat generation in the computing process. IBM J. Res. Dev. 5(3), 261–269 (1961)MathSciNetCrossRefGoogle Scholar
  29. 29.
    Laplaza, M.L.: Coherence for distributivity. In: Kelly, G.M., Laplaza, M., Lewis, G., Mac Lane, S. (eds.) Coherence in Categories. LNM, vol. 281, pp. 29–65. Springer, Heidelberg (1972).  https://doi.org/10.1007/BFb0059555CrossRefGoogle Scholar
  30. 30.
    Laursen, J.S., Ellekilde, L.P., Schultz, U.P.: Modelling reversible execution of robotic assembly. Robotica 36(5), 625–654 (2018)CrossRefGoogle Scholar
  31. 31.
    Norell, U.: Dependently Typed Programming in Agda. In: Proceedings of TLDI 2009: 2009 ACM SIGPLAN International Workshop on Types in Languages Design and Implementation, Savannah, GA, USA, 24 January 2009, pp. 1–2 (2009)Google Scholar
  32. 32.
    Rendel, T., Ostermann, K.: Invertible syntax descriptions: unifying parsing and pretty printing. ACM SIGPLAN Not. 45(11), 1–12 (2010)CrossRefGoogle Scholar
  33. 33.
    Schordan, M., Jefferson, D., Barnes, P., Oppelstrup, T., Quinlan, D.: Reverse code generation for parallel discrete event simulation. In: Krivine, J., Stefani, J.-B. (eds.) RC 2015. LNCS, vol. 9138, pp. 95–110. Springer, Cham (2015).  https://doi.org/10.1007/978-3-319-20860-2_6CrossRefGoogle Scholar
  34. 34.
    Schultz, U.P.: Reversible object-oriented programming with region-based memory management. In: Kari, J., Ulidowski, I. (eds.) RC 2018. LNCS, vol. 11106, pp. 322–328. Springer, Cham (2018).  https://doi.org/10.1007/978-3-319-99498-7_22CrossRefzbMATHGoogle Scholar
  35. 35.
    Thomsen, M.K., Axelsen, H.B., Glück, R.: A reversible processor architecture and its reversible logic design. In: De Vos, A., Wille, R. (eds.) RC 2011. LNCS, vol. 7165, pp. 30–42. Springer, Heidelberg (2012).  https://doi.org/10.1007/978-3-642-29517-1_3CrossRefGoogle Scholar
  36. 36.
    Univalent Foundations Program: Homotopy Type Theory: Univalent Foundations of Mathematics, Institute for Advanced Study (2013). https://homotopytypetheory.org/book
  37. 37.
    Uustalu, T., Veltri, N.: The delay monad and restriction categories. In: Hung, D., Kapur, D. (eds.) Theoretical Aspects of Computing - ICTAC 2017. LNCS, vol. 10580, pp. 32–50. Springer, Cham (2017).  https://doi.org/10.1007/978-3-319-67729-3_3CrossRefGoogle Scholar
  38. 38.
    Uustalu, T., Veltri, N.: Partiality and container monads. In: Chang, B.-Y.E. (ed.) APLAS 2017. LNCS, vol. 10695, pp. 406–425. Springer, Cham (2017).  https://doi.org/10.1007/978-3-319-71237-6_20CrossRefzbMATHGoogle Scholar
  39. 39.
    Veltri, N.: A Type-Theoretical Study of Nontermination. Ph.D. thesis, Tallinn University of Technology (2017). https://digi.lib.ttu.ee/i/?7631
  40. 40.
    de Vos, A.: Reversible Computing: Fundamentals, Quantum Computing, and Applications. Wiley, Weinheim (2010)Google Scholar
  41. 41.
    Yokoyama, T., Glück, R.: A reversible programming language and its invertible self-interpreter. In: Proceedings of Partial Evaluation and Program Manipulation, pp. 144–153. ACM (2007)Google Scholar

Copyright information

© Springer Nature Switzerland AG 2019

Authors and Affiliations

  1. 1.DIKU, Department of Computer ScienceUniversity of CopenhagenCopenhagenDenmark
  2. 2.Department of Computer ScienceIT University of CopenhagenCopenhagenDenmark

Personalised recommendations