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)


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.


Reversible computation Iteration Delay monad 


  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). 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). Scholar
  3. 3.
    Barthe, G., Capretta, V., Pons, O.: Setoids in type theory. J. Funct. Program. 13(2), 261–293 (2003). 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). Scholar
  6. 6.
    Capretta, V.: General recursion via coinductive types. Logical Methods Comput. Sci. 1(2) (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). 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). 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). 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).
  12. 12.
    Danielsson, N.A.: Up-to techniques using sized types. PACMPL 2(POPL), 43:1–43:28 (2018). 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).
  14. 14.
    Ésik, Z., Goncharov, S.: Some remarks on conway and iteration theories. CoRR abs/1603.00838 (2016).
  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). Scholar
  17. 17.
    Goncharov, S., Schröder, L., Rauch, C., Jakob, J.: Unguarded recursion on coinductive resumptions. Logical Methods Comput. Sci. 14(3) (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). Scholar
  19. 19.
    Hofmann, M.: Extensional Constructs in Intensional Type Theory. CPHC/BCS Distinguished Dissertations. Springer, London (1997). 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). 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).
  22. 22.
    James, R.P., Sabry, A.: Theseus: A high level language for reversible computing (2014). 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). 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). 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). 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). 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). 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). Scholar
  36. 36.
    Univalent Foundations Program: Homotopy Type Theory: Univalent Foundations of Mathematics, Institute for Advanced Study (2013).
  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). 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). Scholar
  39. 39.
    Veltri, N.: A Type-Theoretical Study of Nontermination. Ph.D. thesis, Tallinn University of Technology (2017).
  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