Abstract
Reversible programming languages guarantee that their programs are invertible at the cost of restricting the permissible operations to those which are locally invertible. However, writing programs in a reversible style can be cumbersome, and may produce significantly different implementations than the conventional – even when the implemented algorithm is, in fact, invertible. We introduce Jeopardy, a functional programming language that guarantees global program invertibility without imposing local invertibility. In particular, Jeopardy allows the limited use of uninvertible – and even nondeterministic – operations, provided that they are used in a way that can be statically determined to be globally invertible. To this end, we outline an implicitly available arguments analysis and further approaches that can give a partial static guarantee to the (generally difficult) problem of guaranteeing invertibility.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
Often (as in Janus) local invertibility only guarantees invertibility of partial functions. This comes from the fact that control structures (like conditional and loops) require assertion of specific values.
- 2.
It will never be possible to write an invertible implementation of the Fibonacci function that does not include something extra in its output, since the first couple of outputs has to be \(\texttt {[suc [zero]]}\) for two different inputs.
- 3.
The problem of extending an invertible (or even a reversible) programming language with (real) higher order functions will be worthy of its own paper.
References
Abramov, S., Glück, R.: The universal resolving algorithm and its correctness: inverse computation in a functional language. Sci. Comput. Program. 43(2–3), 193–229 (2002)
Bennett, C.H.: Logical reversibility of computation. IBM J. Res. Dev. 17(6), 525–532 (1973)
Carette, J., Heunen, C., Kaarsgaard, R., Sabry, A.: With a few square roots, quantum computing is as easy as Pi. Proc. ACM Program. Lang. 8(POPL), 546–574 (2024)
Dijkstra, E.W.: Program Inversion, pp. 54–57. Springer, Heidelberg (1979). https://doi.org/10.1007/BFb0014657
Futamura, Y.: Partial computation of programs. In: Goto, E., Furukawa, K., Nakajima, R., Nakata, I., Yonezawa, A. (eds.) RIMS Symposia on Software Science and Engineering. LNCS, vol. 147, pp. 1–35. Springer, Heidelberg (1983). https://doi.org/10.1007/3-540-11980-9_13
Giachino, E., Lanese, I., Mezzina, C.A.: Causal-consistent reversible debugging. In: Gnesi, S., Rensink, A. (eds.) FASE 2014. LNCS, vol. 8411, pp. 370–384. Springer, Heidelberg (2014). https://doi.org/10.1007/978-3-642-54804-8_26
Girard, J.Y.: Linear logic. Theor. Comput. Sci. 50(1), 1–101 (1987)
Glück, R., Yokoyama, T.: Reversible computing from a programming language perspective. Theor. Comput. Sci. 953, 113429 (2023)
Heunen, C., Kaarsgaard, R.: Bennett and Stinespring, together at last. In: Proceedings 18th International Conference on Quantum Physics and Logic (QPL 2021). Electronic Proceedings in Theoretical Computer Science, vol. 343, pp. 102–118. OPA (2021)
Heunen, C., Kaarsgaard, R.: Quantum information effects. Proc. ACM Program. Lang. 6(POPL) (2022)
Heunen, C., Kaarsgaard, R., Karvonen, M.: Reversible effects as inverse arrows. In: Mathematical Foundations of Programming Semantics XXXIV, Proceedings. Electronic Notes in Theoretical Computer Science, vol. 341, pp. 179–199. Elsevier (2018)
Huffman, D.A.: Canonical forms for information-lossless finite-state logical machines. IRE Trans. Inf. Theory 5(5), 41–59 (1959)
Jacobsen, P.A.H., Kaarsgaard, R., Thomsen, M.K.: \(\sf 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
James, R.P., Sabry, A.: Theseus: a high level language for reversible computing (2014). Work in progress paper at RC 2014. www.cs.indiana.edu/~sabry/papers/theseus.pdf
Kristensen, J.T., Kaarsgaard, R., Thomsen, M.K.: Branching execution symmetry in jeopardy by available implicit arguments analysis. In: Norwegian Informatics Conference, NIK, vol. 1. 34th Norwegian ICT Conference for Research and Education, NIKT 2022 (2022, to appear)
Kristensen, J.T., Kaarsgaard, R., Thomsen, M.K.: Tail recursion transformation for invertible functions. In: Kutrib, M., Meyer, U. (eds.) RC 2023. LNCS, vol. 13960, pp. 73–88. Springer, Cham (2023). https://doi.org/10.1007/978-3-031-38100-3_6
Landauer, R.: Irreversibility and heat generation in the computing process. IBM J. Res. Dev. 5(3), 261–269 (1961)
Lanese, I., Nishida, N., Palacios, A., Vidal, G.: CauDEr: a causal-consistent reversible debugger for erlang. In: Gallagher, J.P., Sulzmann, M. (eds.) FLOPS 2018. LNCS, vol. 10818, pp. 247–263. Springer, Cham (2018). https://doi.org/10.1007/978-3-319-90686-7_16
Laursen, J.S., Schultz, U.P., Ellekilde, L.P.: Automatic error recovery in robot assembly operations using reverse execution. In: 2015 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), pp. 1785–1792. IEEE (2015)
Lee, C.S., Jones, N.D., Ben-Amram, A.M.: The size-change principle for program termination. In: Symposium on Principles of Programming Languages, POPL 2001, pp. 81–92. ACM (2001)
Lutz, C., Derby, H.: Janus: a time-reversible language. A letter to R. Landauer (1986). http://tetsuo.jp/ref/janus.pdf
Matsuda, K., Wang, M.: SPARCL: a language for partially invertible computation. J. Funct. Program. 34, e2 (2024). https://doi.org/10.1017/S0956796823000126
McCarthy, J.: The inversion of functions defined by turing machines. In: Shannon, C.E., McCarthy, J. (eds.) Automata Studies. Princeton University Press (1956)
Nielson, F., Nielson, H.R., Hankin, C.: Principles of Program Analysis. Springer, Heidelberg (2015)
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
Schordan, M., Oppelstrup, T., Thomsen, M.K., Glück, R.: Reversible languages and incremental state saving in optimistic parallel discrete event simulation. In: Ulidowski, I., Lanese, I., Schultz, U.P., Ferreira, C. (eds.) RC 2020. LNCS, vol. 12070, pp. 187–207. Springer, Cham (2020). https://doi.org/10.1007/978-3-030-47361-7_9
Schultz, U., Bordignon, M., Stoy, K.: Robust and reversible execution of self-reconfiguration sequences. Robotica 29(1), 35–57 (2011)
Thomsen, M.K., Axelsen, H.B.: Interpretation and programming of the reversible functional language. In: Symposium on the Implementation and Application of Functional Programming Languages, IFL 2015, pp. 8:1–8:13. ACM (2016)
Thomsen, M.K., Kaarsgaard, R., Soeken, M.: Ricercar: a language for describing and rewriting reversible circuits with ancillae and its permutation semantics. In: Krivine, J., Stefani, J.-B. (eds.) RC 2015. LNCS, vol. 9138, pp. 200–215. Springer, Cham (2015). https://doi.org/10.1007/978-3-319-20860-2_13
Voichick, F., Li, L., Rand, R., Hicks, M.: Qunity: a unified language for quantum and classical computing. Proc. ACM Program. Lang. 7(POPL), 921–951 (2023)
Wadler, P.: Linear types can change the world! In: IFIP TC 2 Working Conference on Programming Concepts and Methods, pp. 347–359. North Holland (1990)
Yokoyama, T., Axelsen, H.B., Glück, R.: Towards a reversible functional language. In: De Vos, A., Wille, R. (eds.) RC 2011. LNCS, vol. 7165, pp. 14–29. Springer, Heidelberg (2012). https://doi.org/10.1007/978-3-642-29517-1_2
Yokoyama, T., Glück, R.: A reversible programming language and its invertible self-interpreter. In: Partial Evaluation and Program Manipulation, PEPM 2007, pp. 144–153. ACM (2007)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2024 The Author(s), under exclusive license to Springer Nature Switzerland AG
About this paper
Cite this paper
Kristensen, J.T., Kaarsgaard, R., Thomsen, M.K. (2024). Jeopardy: An Invertible Functional Programming Language. In: Mogensen, T.Æ., Mikulski, Ł. (eds) Reversible Computation. RC 2024. Lecture Notes in Computer Science, vol 14680. Springer, Cham. https://doi.org/10.1007/978-3-031-62076-8_9
Download citation
DOI: https://doi.org/10.1007/978-3-031-62076-8_9
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-031-62075-1
Online ISBN: 978-3-031-62076-8
eBook Packages: Computer ScienceComputer Science (R0)