Clean Reversible Simulations of Ranking Binary Trees

  • Chapter
  • First Online:
Reversibility and Universality

Part of the book series: Emergence, Complexity and Computation ((ECC,volume 30))

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.

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

Access this chapter

Subscribe and save

Springer+ Basic
EUR 32.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or Ebook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
EUR 29.95
Price includes VAT (Germany)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
EUR 85.59
Price includes VAT (Germany)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
EUR 106.99
Price includes VAT (Germany)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free ship** worldwide - see info
Hardcover Book
EUR 106.99
Price includes VAT (Germany)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free ship** worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

Notes

  1. 1.

    A video compression standard.

  2. 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. 3.

    In this paper, reversible procedures generated by embedding have the suffix E, e.g., catalanE.

  4. 4.

    The indices of the tree permutations (see Sect.Ā 4.4) in [21] lie in the range one or above, but in this paper, they lie in the range zero or above for simplicity.

  5. 5.

    \(\# X\) is the number of elements in the set X.

  6. 6.

    The suffix A indicates that the procedures are implemented in Algol.

References

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

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

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

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

  5. Bennett, C.H.: Logical reversibility of computation. IBM J. Res. Dev. 17(6), 525ā€“532 (1973). https://doi.org/10.1147/rd.176.0525

  6. Bennett, C.H.: Time/space trade-offs for reversible computation. SIAM J. Comput. 18(4), 766ā€“776 (1989). https://doi.org/10.1137/0218053

  7. Bennett, C.H., Landauer, R.: The fundamental physical limits of computation. Sci. Am. 253(1), 48ā€“56 (1985)

    ArticleĀ  Google ScholarĀ 

  8. 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)

    Google ScholarĀ 

  9. Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C.: Introduction to Algorithms, 3rd edn. The MIT Press, Cambridge (2009)

    MATHĀ  Google ScholarĀ 

  10. De Vos, A.: Reversible Computing: Fundamentals, Quantum Computing, and Applications. Wiley-VCH, New York (2010)

    BookĀ  MATHĀ  Google ScholarĀ 

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

  12. Er, M.C.: Enumerating ordered trees lexicographically. The Comput. J. 28(5), 538ā€“542 (1985)

    ArticleĀ  MATHĀ  Google ScholarĀ 

  13. 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)

    Google ScholarĀ 

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

  15. Frank, M.P.: Reversibility for efficient computing. Ph.D. thesis, Massachusetts Institute of Technology (1999)

    Google ScholarĀ 

  16. Fredkin, E., Toffoli, T.: Conservative logic. Int. J. Theor. Phys. 21, 219ā€“253 (1982). https://doi.org/10.1007/BF01857727

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

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

  19. Gries, D.: Inverting programs. The Science of Programming. Texts and Monographs in Computer Science, pp. 265ā€“274. Springer, Berlin (1981)

    Google ScholarĀ 

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

  21. Knott, G.D.: A numbering system for binary trees. Commun. ACM 20(2), 113ā€“115 (1977). https://doi.org/10.1145/359423.359434

  22. Knuth, D.E.: The Art of Computer Programming, Volume 1: Fundamental Algorithms, vol. 1, 3rd edn. Addison-Wesley Professional, Reading (1997)

    Google ScholarĀ 

  23. Landauer, R.: Information is physical. Phys. Today 44(5), 23ā€“29 (1991)

    ArticleĀ  Google ScholarĀ 

  24. Lutz, C.: Janus: A time-reversible language. Letter to R, Landauer (1986)

    Google ScholarĀ 

  25. Mogensen, T.Ɔ.: Garbage-free reversible multipliers for arbitrary constants. ACM J. Emerg. Technol. Comput. Syst. 11(2), 1ā€“18 (2014)

    ArticleĀ  Google ScholarĀ 

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

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

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

  29. 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)

    Google ScholarĀ 

  30. Perumalla, K.S.: Introduction to Reversible Computing. CRC Press, Boca Raton (2013)

    Google ScholarĀ 

  31. Pesu, T., Phillips, I.: Real-Time Methods in Reversible Computation, pp. 45ā€“59. Springer International Publishing, Berlin (2015)

    Google ScholarĀ 

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

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

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

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

  36. Wille, R., Drechsler, R.: Towards a Design Flow for Reversible Logic. Springer, Berlin (2010)

    BookĀ  MATHĀ  Google ScholarĀ 

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

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

  39. 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)

    MATHĀ  Google ScholarĀ 

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

Download references

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

Authors

Corresponding author

Correspondence to Tetsuo Yokoyama .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

Ā© 2018 Springer International Publishing AG

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

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)

Publish with us

Policies and ethics

Navigation