A Grammar-Based Approach to Invertible Programs

  • Kazutaka Matsuda
  • Shin-Cheng Mu
  • Zhenjiang Hu
  • Masato Takeichi
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6012)


Program inversion has many applications such as in the implementation of serialization/deserialization and in providing support for redo/undo, and has been studied by many researchers. However, little attention has been paid to two problems: how to characterize programs that are easy or hard to invert and whether, for each class of programs, efficient inverses can be obtained. In this paper, we propose an inversion framework that we call grammar-based inversion, where a program is associated with an unambiguous grammar describing the range of the program. The complexity of the grammar indicates how hard it is to invert the program, while the complexity is related to how efficient an inverse can be obtained.


Evaluation Tree Production Rule Production Tree Tree Automaton Left Inverse 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


  1. 1.
    Abramov, S.M., Glück, R.: Principles of Inverse Computation and the Universal Resolving Algorithm. In: The Essence of Computation, pp. 269–295 (2002)Google Scholar
  2. 2.
    Aho, A.V., Ullman, J.D.: The Theory of Parsing, Translation, and Compiling. Prentice-Hall, Inc., Upper Saddle River (1972)Google Scholar
  3. 3.
    Asveld, P.R.J.: Time and Space Complexity of Inside-Out Macro Languages. Int. J. Comput. Math. 10(1), 3–14 (1981)zbMATHCrossRefMathSciNetGoogle Scholar
  4. 4.
    Biehl, M., Klarlund, N., Rauhe, T.: Algorithms for Guided Tree Automata. In: Raymond, D.R., Yu, S., Wood, D. (eds.) WIA 1996. LNCS, vol. 1260, pp. 6–25. Springer, Heidelberg (1997)Google Scholar
  5. 5.
    Boullier, P.: Range Concatenation Grammars. In: New Developments in Parsing Technology, pp. 269–289. Kluwer Academic Publishers, Norwell (2004)Google Scholar
  6. 6.
    Comon, H., Dauchet, M., Gilleron, R., Jacquemard, F., Lugiez, D., Tison, S., Tommasi, M.: Tree Automata Techniques and Applications,
  7. 7.
    Dershowitz, N., Mitra, S.: Jeopardy. In: Narendran, P., Rusinowitch, M. (eds.) RTA 1999. LNCS, vol. 1631, pp. 16–29. Springer, Heidelberg (1999)Google Scholar
  8. 8.
    Dijkstra, E.W.: Program Inversion. In: Gerhart, S.L., Pair, C., Pepper, P.A., Wössner, H., Dijkstra, E.W., Guttag, J.V., Owicki, S.S., Partsch, H., Bauer, F.L., Gries, D., Griffiths, M., Horning, J.J., Wirsing, M. (eds.) Program Construction. LNCS, vol. 69, pp. 54–57. Springer, Heidelberg (1979)CrossRefGoogle Scholar
  9. 9.
    Engelfriet, J., Schmidt, E.M.: IO and OI. I. J. Comput. Syst. Sci. 15(3), 328–353 (1977)zbMATHCrossRefMathSciNetGoogle Scholar
  10. 10.
    Engelfriet, J., Vogler, H.: Macro Tree Transducers. J. Comput. Syst. Sci. 31(1), 71–146 (1985)zbMATHCrossRefMathSciNetGoogle Scholar
  11. 11.
    Eppstein, D.: A Heuristic Approach to Program Inversion. In: International Joint Conference on Artificial Intelligence (IJCAI 1985), pp. 219–221 (1985)Google Scholar
  12. 12.
    Foster, J.N., Greenwald, M.B., Moore, J.T., Pierce, B.C., Schmitt, A.: Combinators for Bidirectional Tree Transformations: A Linguistic Approach to the View-Update Problem. ACM Trans. Program. Lang. Syst. 29(3) (2007)Google Scholar
  13. 13.
    Frisch, A.: Regular Tree Language Recognition with Static Information. In: Lévy, J.J., Mayr, E.W., Mitchell, J.C. (eds.) Exploring New Frontiers of Theoretical Informatics, IFIP 18th World Computer Congress, TC1 3rd International Conference on Theoretical Computer Science (TCS 2004), pp. 661–674. Kluwer, Dordrecht (2004)Google Scholar
  14. 14.
    Fülöp, Z., Vogler, H.: Syntax-Directed Semantics: Formal Models Based on Tree Transducers. Springer, New York (1998)zbMATHGoogle Scholar
  15. 15.
    Glück, R., Kawabe, M.: A Method for Automatic Program Inversion Based on LR(0) Parsing. Fundam. Inform. 66(4), 367–395 (2005)zbMATHGoogle Scholar
  16. 16.
    Glück, R., Kawabe, M.: Revisiting an Automatic Program Inverter for Lisp. SIGPLAN Notices 40(5), 8–17 (2005)CrossRefGoogle Scholar
  17. 17.
    Gries, D.: 21 Inverting Programs. In: The Science of Programming. Springer, Heidelberg (1981)Google Scholar
  18. 18.
    Hopcroft, J.E., Motwani, R., Ullman, J.D.: 7 Properties of Context-Free Languages. In: Introduction to Automata Theory, Languages, and Computation, 3rd edn. Addison-Wesley Longman Publishing Co., Inc., Amsterdam (2006)Google Scholar
  19. 19.
    Hosoya, H., Pierce, B.C.: XDuce: A Statically Typed XML Processing Language. ACM Trans. Internet Techn. 3(2), 117–148 (2003)CrossRefGoogle Scholar
  20. 20.
    Hu, Z., Iwasaki, H., Takeichi, M., Takano, A.: Tupling Calculation Eliminates Multiple Data Traversals. In: ICFP 1997: Proceedings of the second ACM SIGPLAN International Conference on Functional Programming, pp. 164–175. ACM Press, New York (1997)CrossRefGoogle Scholar
  21. 21.
    Matsuda, K., Hu, Z., Nakano, K., Hamana, M., Takeichi, M.: Bidirectionalization Transformation based on Automatic Derivation of View Complement Functions. In: ICFP 2007: Proceedings of the 12th ACM SIGPLAN International Conference on Functional Programming, pp. 47–58. ACM, New York (2007)CrossRefGoogle Scholar
  22. 22.
    Morihata, A., Kakehi, K., Hu, Z., Takeichi, M.: Swapping Arguments and Results of Recursive Functions. In: Uustalu, T. (ed.) MPC 2006. LNCS, vol. 4014, pp. 379–396. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  23. 23.
    Mu, S.C., Hu, Z., Takeichi, M.: An Injective Language for Reversible Computation. In: Kozen, D. (ed.) MPC 2004. LNCS, vol. 3125, pp. 289–313. Springer, Heidelberg (2004)Google Scholar
  24. 24.
    Neumann, A., Seidl, H.: Locating Matches of Tree Patterns in Forests. In: Arvind, V., Sarukkai, S. (eds.) FST TCS 1998. LNCS, vol. 1530, pp. 134–146. Springer, Heidelberg (1998)Google Scholar
  25. 25.
    Nishida, N., Sakai, M.: Completion after Program Inversion of Injective Functions. Electr. Notes Theor. Comput. Sci. 237, 39–56 (2009)CrossRefGoogle Scholar
  26. 26.
    Nishida, N., Sakai, M.: Proving Injectivity of Functions via Program Inversion in Term Rewriting. Accepted for FLOPS 2010. LNCS, vol. 6009. Springer, Heidelberg (2010)Google Scholar
  27. 27.
    Nishida, N., Sakai, M., Sakabe, T.: Partial Inversion of Constructor Term Rewriting Systems. In: Giesl, J. (ed.) RTA 2005. LNCS, vol. 3467, pp. 264–278. Springer, Heidelberg (2005)Google Scholar
  28. 28.
    Schimpf, K.M., Gallier, J.H.: Tree Pushdown Automata. J. Comput. Syst. Sci. 30(1), 25–40 (1985)zbMATHCrossRefMathSciNetGoogle Scholar
  29. 29.
    Wadler, P.: Deforestation: Transforming Programs to Eliminate Trees. Theor. Comput. Sci. 73(2), 231–248 (1990)zbMATHCrossRefMathSciNetGoogle Scholar
  30. 30.
    Yellin, D.M.: Attribute Grammar Inversion and Source-to-source Translation. LNCS, vol. 302. Springer, Heidelberg (1988)zbMATHGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2010

Authors and Affiliations

  • Kazutaka Matsuda
    • 1
    • 2
  • Shin-Cheng Mu
    • 1
    • 3
  • Zhenjiang Hu
    • 4
  • Masato Takeichi
    • 1
  1. 1.University of TokyoJapan
  2. 2.JSPS Research Fellow 
  3. 3.Academia SinicaTaiwan
  4. 4.National Institute of InformaticsJapan

Personalised recommendations