Skip to main content

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

  • Conference paper
  • First Online:
Mathematics of Program Construction (MPC 2019)

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.

Niccolò Veltri was supported by a research grant (13156) from VILLUM FONDEN.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    Here we give the definition of complete Elgot monad on \(\mathsf {Set}\), but the definition of complete Elgot monad makes sense in any category with finite coproducts.

References

  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.4

    Article  MathSciNet  Google Scholar 

  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_31

    Chapter  Google Scholar 

  3. Barthe, G., Capretta, V., Pons, O.: Setoids in type theory. J. Funct. Program. 13(2), 261–293 (2003). https://doi.org/10.1017/S0956796802004501

    Article  MathSciNet  MATH  Google Scholar 

  4. Bennett, C.H.: Logical reversibility of computation. IBM J. Res. Dev. 17(6), 525–532 (1973)

    Article  MathSciNet  Google Scholar 

  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_10

    Chapter  MATH  Google Scholar 

  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. 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_6

    Chapter  MATH  Google Scholar 

  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/S0960129517000184

    Article  MathSciNet  MATH  Google Scholar 

  9. Cockett, J.R.B., Lack, S.: Restriction categories I: categories of partial maps. Theoret. Comput. Sci. 270(1–2), 223–259 (2002)

    Article  MathSciNet  Google Scholar 

  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/S0960129507006056

    Article  MathSciNet  MATH  Google Scholar 

  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. Danielsson, N.A.: Up-to techniques using sized types. PACMPL 2(POPL), 43:1–43:28 (2018). https://doi.org/10.1145/3158131

    Article  Google Scholar 

  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. Ésik, Z., Goncharov, S.: Some remarks on conway and iteration theories. CoRR abs/1603.00838 (2016). http://arxiv.org/abs/1603.00838

  15. Giles, B.: An investigation of some theoretical aspects of reversible computing. Ph.D. thesis, University of Calgary (2014)

    Google Scholar 

  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.036

    Article  MathSciNet  MATH  Google Scholar 

  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. 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_37

    Chapter  MATH  Google Scholar 

  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-1

    Book  Google Scholar 

  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_21

    Chapter  MATH  Google Scholar 

  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. 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. Joyal, A., Street, R., Verity, D.: Traced monoidal categories. Math. Proc. Camb. Philos. Soc. 119(3), 447–468 (1996). https://doi.org/10.1017/S0305004100074338

    Article  MathSciNet  MATH  Google Scholar 

  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)

    MathSciNet  MATH  Google Scholar 

  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.003

    Article  MathSciNet  MATH  Google Scholar 

  26. Karvonen, M.: The Way of the Dagger. Ph.D. thesis, School of Informatics, University of Edinburgh (2019)

    Google Scholar 

  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. Landauer, R.: Irreversibility and heat generation in the computing process. IBM J. Res. Dev. 5(3), 261–269 (1961)

    Article  MathSciNet  Google Scholar 

  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/BFb0059555

    Chapter  Google Scholar 

  30. Laursen, J.S., Ellekilde, L.P., Schultz, U.P.: Modelling reversible execution of robotic assembly. Robotica 36(5), 625–654 (2018)

    Article  Google Scholar 

  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. Rendel, T., Ostermann, K.: Invertible syntax descriptions: unifying parsing and pretty printing. ACM SIGPLAN Not. 45(11), 1–12 (2010)

    Article  Google Scholar 

  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_6

    Chapter  Google Scholar 

  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_22

    Chapter  MATH  Google Scholar 

  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_3

    Chapter  Google Scholar 

  36. Univalent Foundations Program: Homotopy Type Theory: Univalent Foundations of Mathematics, Institute for Advanced Study (2013). https://homotopytypetheory.org/book

  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_3

    Chapter  Google Scholar 

  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_20

    Chapter  MATH  Google Scholar 

  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. de Vos, A.: Reversible Computing: Fundamentals, Quantum Computing, and Applications. Wiley, Weinheim (2010)

    Google Scholar 

  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 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Niccolò Veltri .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2019 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Kaarsgaard, R., Veltri, N. (2019). En Garde! Unguarded Iteration for Reversible Computation in the Delay Monad. In: Hutton, G. (eds) Mathematics of Program Construction. MPC 2019. Lecture Notes in Computer Science(), vol 11825. Springer, Cham. https://doi.org/10.1007/978-3-030-33636-3_13

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-33636-3_13

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-33635-6

  • Online ISBN: 978-3-030-33636-3

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics