Towards a Reversible Functional Language
We identify concepts of reversibility for a functional language by means of a set of semantic rules with specific properties. These properties include injectivity along with local backward determinism, an important operational property for an efficient reversible language. We define a concise reversible first-order functional language in which access to the backward semantics is provided to the programmer by inverse function calls. Reversibility guarantees that in this language a backward run (inverse interpretation) is as fast as the corresponding forward run itself. By adopting a symmetric first-match policy for case expressions, we can write overlapping patterns in case branches, as is customary in ordinary functional languages, and also in leaf expressions, unlike existing inverse interpreter methods, which enables concise programs. In patterns, the use of a duplication/equality operator also simplifies inverse computation and program inversion. We discuss the advantages of a reversible functional language using example programs, including run-length encoding. Program inversion is seen to be as lightweight as for imperative reversible languages and realized by recursive descent. Finally, we show that the proposed language is r-Turing complete.
Unable to display preview. Download preview PDF.
- 6.Bowman, W.J., James, R.P., Sabry, A.: Dagger traced symmetric monoidal categories and reversible programming. In: De Vos, A., Wille, R. (eds.) 3rd Workshop on Reversible Computation, pp. 51–56. University of Gent. (2011)Google Scholar
- 7.De Vos, A.: Reversible Computing: Fundamentals, Quantum Computing, and Applications. Wiley-VCH (2010)Google Scholar
- 8.Frank, M.P.: Reversibility for efficient computing. Ph.D. thesis, EECS Dept. MIT, Cambridge, Massachusetts (1999)Google Scholar
- 11.Gries, D.: Inverting Programs. In: The Science of Programming. Texts and Monographs in Computer Science, ch. 21, pp. 265–274. Springer, Heidelberg (1981)Google Scholar
- 12.Lutz, C.: Janus: a time-reversible language. Letter to R. Landauer (1986), http://www.tetsuo.jp/ref/janus.html
- 13.McCarthy, J.: The inversion of functions defined by Turing machines. In: Shannon, C.E., McCarthy, J. (eds.) Automata Studies, pp. 177–181. Princeton University Press (1956)Google Scholar
- 14.Mogensen, T.Æ.: Partial evaluation of the reversible language Janus. In: Proceedings of Partial Evaluation and Program Manipulation, pp. 23–32. ACM Press (2011)Google Scholar
- 18.Yokoyama, T., Axelsen, H., Glück, R.: Principles of a reversible programming language. In: Proceedings of Computing Frontiers, pp. 43–54. ACM Press (2008)Google Scholar
- 20.Yokoyama, T., Glück, R.: A reversible programming language and its invertible self-interpreter. In: Proceedings of Partial Evaluation and Semantics-Based Program Manipulation, pp. 144–153. ACM Press (2007)Google Scholar