Abstract
We propose clean reversible simulations of ranking binary trees and unranking as reversible algorithms for reversible computing systems, which are useful for enumerating and randomly generating binary trees. Algorithms for ranking binary trees and their inverses have been studied since the 1970s. Each of these algorithms can be converted into a reversible simulation by saving all data and control information otherwise lost, and each pair of ranking and unranking reversible programs can be combined to realize a clean reversible simulation by using the Bennett method. However, such a clean reversible simulation requires multiple traversal of the given data and/or intermediate data as well as additional storage proportional to the length of the computation. We show that for Knottās ranking and unranking algorithms, additional storage usage can be reduced by using the proper assertions of reversible loops in embedded reversible simulations. We also show a clean reversible simulation that involves only one traversal. The running time and memory usage of the proposed clean reversible simulations are asymptotically equivalent to those of the original programs by Knott with intermediate garbage of constant size. In general, the derivation strategy of efficient reversible programs from irreversible ones has not yet been established, and this study can be seen as one of the case studies. All the reversible programs presented in this paper can be run on an interpreter of the reversible programming language Janus.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
A video compression standard.
- 2.
A variable is zero-cleared if it is set to zero, and an array is zero-cleared if all its elements set to zero.
- 3.
In this paper, reversible procedures generated by embedding have the suffix E, e.g., catalanE.
- 4.
- 5.
\(\# X\) is the number of elements in the set X.
- 6.
The suffix A indicates that the procedures are implemented in Algol.
References
Axelsen, H.B., GlĆ¼ck, R.: A simple and efficient universal reversible Turing machine. In: Dediu, A.H., Inenaga, S., MartĆn-Vide, C. (eds.) Language and Automata Theory and Applications. Lecture Notes in Computer Science, vol. 6638, pp. 117ā128. Springer, Berlin (2011). https://doi.org/10.1007/978-3-642-21254-3_8
Axelsen, H.B., GlĆ¼ck, R.: What do reversible programs compute? In: Hofmann, M. (ed.) Foundations of Software Science and Computation Structures. Proceedings. Lecture Notes in Computer Science, vol. 6604, pp. 42ā56. Springer, Berlin (2011). https://doi.org/10.1007/978-3-642-19805-2_4
Axelsen, H.B., Yokoyama, T.: Programming techniques for reversible comparison sorts. In: Feng, X., Park, S. (eds.) Programming Languages and Systems. Lecture Notes in Computer Science, vol. 9458, pp. 407ā426. Springer, Berlin (2015). https://doi.org/10.1007/978-3-319-26529-2_22
Baker, H.G.: NREVERSAL of fortune ā the thermodynamics of garbage collection. In: Bekkers, Y., Cohen, J. (eds.) International Workshop on Memory Management. Proceedings. Lecture Notes in Computer Science, vol. 637, pp. 507ā524. Springer, Berlin (1992). https://doi.org/10.1007/BFb0017210
Bennett, C.H.: Logical reversibility of computation. IBM J. Res. Dev. 17(6), 525ā532 (1973). https://doi.org/10.1147/rd.176.0525
Bennett, C.H.: Time/space trade-offs for reversible computation. SIAM J. Comput. 18(4), 766ā776 (1989). https://doi.org/10.1137/0218053
Bennett, C.H., Landauer, R.: The fundamental physical limits of computation. Sci. Am. 253(1), 48ā56 (1985)
Burignat, S., Vermeirsch, K., De Vos, A., Thomsen, M.K.: Garbageless reversible implementation of integer linear transformations. In: GlĆ¼ck, R., Yokoyama, T. (eds.) Reversible Computation. Proceedings. Lecture Notes in Computer Science, vol. 7581. Springer, Berlin (2013)
Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C.: Introduction to Algorithms, 3rd edn. The MIT Press, Cambridge (2009)
De Vos, A.: Reversible Computing: Fundamentals, Quantum Computing, and Applications. Wiley-VCH, New York (2010)
Early, D., Gao, A., Schellekens, M.: Frugal encoding in reversible \(\cal MOQA\it \): A case study for quicksort. In: GlĆ¼ck, R., Yokoyama, T. (eds.) Reversible Computation. Proceedings. Lecture Notes in Computer Science, vol. 7581, pp. 85ā96. Springer, Berlin (2013). https://doi.org/10.1007/978-3-642-36315-3_7
Er, M.C.: Enumerating ordered trees lexicographically. The Comput. J. 28(5), 538ā542 (1985)
Feynman, R.P.: Reversible computation and the thermodynamics of computing (Chapter 5). In: Hey, A.J.G., Allen, R.W. (eds.) Feynman Lectures on Computation, pp. 137ā184. Addison-Wesley, Reading (1996)
Foster, J.N., Greenwald, M.B., Moore, J.T., Pierce, B.C., Schmitt, A.: Combinators for bi-directional tree transformations: a linguistic approach to the view update problem. ACM Trans. Program. Lang. Syst. 29(3), 1ā65 (2007). https://doi.org/10.1145/1232420.1232424
Frank, M.P.: Reversibility for efficient computing. Ph.D. thesis, Massachusetts Institute of Technology (1999)
Fredkin, E., Toffoli, T.: Conservative logic. Int. J. Theor. Phys. 21, 219ā253 (1982). https://doi.org/10.1007/BF01857727
GlĆ¼ck, R., Kawabe, M.: Derivation of deterministic inverse programs based on LR parsing. In: Kameyama, Y., Stuckey, P.J. (eds.) Functional and Logic Programming. Proceedings. Lecture Notes in Computer Science, vol. 2998, pp. 291ā306. Springer, Berlin (2004). https://doi.org/10.1007/978-3-540-24754-8_21
GlĆ¼ck, R., Yokoyama, T.: A linear-time self-interpreter of a reversible imperative language. Comput. Softw. 33(3), 108ā128 (2016). https://doi.org/10.11309/jssst.33.3_108
Gries, D.: Inverting programs. The Science of Programming. Texts and Monographs in Computer Science, pp. 265ā274. Springer, Berlin (1981)
James, R.P., Sabry, A.: Information effects. Principles of Programming Languages. Proceedings, pp. 73ā84. ACM Press (2012). https://doi.org/10.1145/2103656.2103667
Knott, G.D.: A numbering system for binary trees. Commun. ACM 20(2), 113ā115 (1977). https://doi.org/10.1145/359423.359434
Knuth, D.E.: The Art of Computer Programming, Volume 1: Fundamental Algorithms, vol. 1, 3rd edn. Addison-Wesley Professional, Reading (1997)
Landauer, R.: Information is physical. Phys. Today 44(5), 23ā29 (1991)
Lutz, C.: Janus: A time-reversible language. Letter to R, Landauer (1986)
Mogensen, T.Ć.: Garbage-free reversible multipliers for arbitrary constants. ACM J. Emerg. Technol. Comput. Syst. 11(2), 1ā18 (2014)
Morita, K.: A simple universal logic element and cellular automata for reversible computing. In: Margenstern, M., Rogozhin, Y. (eds.) Machines, Computations, and Universality. Lecture Notes in Computer Science, vol. 2055, pp. 102ā113. Springer, Berlin (2001). https://doi.org/10.1007/3-540-45132-3_6
Morita, K.: Reversible computing and cellular automata ā a survey. Theor. Comput. Sci. 395(1), 101ā131 (2008). https://doi.org/10.1016/j.tcs.2008.01.041
Morita, K.: Simulating reversible Turing machines and cyclic tag systems by one-dimensional reversible cellular automata. Theor. Comput. Sci. 412(30), 3856ā3865 (2011). https://doi.org/10.1016/j.tcs.2011.02.022
Nishida, N., Sakai, M., Sakabe, T.: Partial inversion of constructor term rewriting systems. In: Giesl, J. (ed.) Term Rewriting and Applications. Proceedings. Lecture Notes in Computer Science, vol. 3467, pp. 264ā278. Springer, Berlin (2005)
Perumalla, K.S.: Introduction to Reversible Computing. CRC Press, Boca Raton (2013)
Pesu, T., Phillips, I.: Real-Time Methods in Reversible Computation, pp. 45ā59. Springer International Publishing, Berlin (2015)
Saeedi, M., Markov, I.L.: Synthesis and optimization of reversible circuits ā a survey. ACM Comput. Surv. 45(2), 21:1ā21:34 (2013). https://doi.org/10.1145/2431211.2431220
Sprugnoli, R.: The generation of binary trees as a numerical problem. J. ACM 39(2), 317ā327 (1992). https://doi.org/10.1145/128749.128753
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.) Reversible Computation. Proceedings. Lecture Notes in Computer Science, vol. 7165, pp. 30ā42. Springer, Berlin (2012). https://doi.org/10.1007/978-3-642-29517-1_3
VitĆ”nyi, P.: Time, space, and energy in reversible computing. Computing Frontiers. Proceedings, pp. 435ā444. ACM Press (2005). https://doi.org/10.1145/1062261.1062335
Wille, R., Drechsler, R.: Towards a Design Flow for Reversible Logic. Springer, Berlin (2010)
Yokoyama, T., GlĆ¼ck, R.: A reversible programming language and its invertible self-interpreter. Partial Evaluation and Semantics-Based Program Manipulation. Proceedings, pp. 144ā153. ACM Press (2007). https://doi.org/10.1145/1244381.1244404
Yokoyama, T., Axelsen, H.B., GlĆ¼ck, R.: Principles of a reversible programming language. Computing Frontiers. Proceedings, pp. 43ā54. ACM Press (2008). https://doi.org/10.1145/1366230.1366239
Yokoyama, T., Axelsen, H.B., GlĆ¼ck, R.: Optimizing clean reversible simulation of injective functions. J. Multi. Valued Log. Soft Comput. 18(1), 5ā24 (2012)
Yokoyama, T., Axelsen, H.B., GlĆ¼ck, R.: Towards a reversible functional language. In: De Vos, A., Wille, R. (eds.) Reversible Computation. Proceedings. Lecture Notes in Computer Science, vol. 7165, pp. 14ā29. Springer, Berlin (2012). https://doi.org/10.1007/978-3-642-29517-1_2
Acknowledgements
The authors would like to thank Kota Kimura for insightful comments on an early draft of this paper, and the anonymous reviewers for their helpful and constructive comments. Preliminary versions of this paper were presented at the 33rd Workshop of the Japan Society for Software Science and Technology and the 19th JSSST Workshop on Programming and Programming Languages. This work was supported by JSPS KAKENHI Grant Number JP25730049 and Nanzan University Pache Research Subsidy I-A-2 for the 2017 academic year.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
Ā© 2018 Springer International Publishing AG
About this chapter
Cite this chapter
Ohkubo, Y., Yokoyama, T., Kanayama, C. (2018). Clean Reversible Simulations of Ranking Binary Trees. In: Adamatzky, A. (eds) Reversibility and Universality. Emergence, Complexity and Computation, vol 30. Springer, Cham. https://doi.org/10.1007/978-3-319-73216-9_11
Download citation
DOI: https://doi.org/10.1007/978-3-319-73216-9_11
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-73215-2
Online ISBN: 978-3-319-73216-9
eBook Packages: EngineeringEngineering (R0)