Decidability and undecidability of equivalence for linear Datalog, with applications to normal-form optimizations

  • Tomás Feder
  • Yatin Saraiya
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 646)


A variety of optimizations in logic databases [20] involve the transformation of safe, function-free (Datalog) logic programs to simpler, more efficiently évaluable programs. The essence of these transformations is the detection of program equivalence. Equivalence has been shown to be undecidable in [1, 17, 18, 19], but those results are unsatisfactory in that they involve highly nonlinear rules, or an unbounded number of linear recursive rules, and hence yield no insight into the behaviour of small, linear recursive programs. In this paper, we consider programs that consist of one nonrecursive linear rule, one linear recursive rule and one initialization rule. We provide a tight characterization of the decidability of program equivalence, proving it undecidable for such programs, and proving it decidable for a subclass that includes binary chain programs and programs with no repeated predicates in the rule body. We then apply these results to various normal-form optimizations [12, 18], including the detection of serializability, cornmutativity, basis-linearizability and rule redundancy.


Logic Program Basis Rule Conjunctive Query Counter Machine Recursive Rule 
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.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Abiteboul, S. Boundedness is undecidable for Datalog programs with a single recursive rule. Information Processing Letters 32, 281–287, 1989.Google Scholar
  2. 2.
    Chandra, A.K. and P.M. Merlin. Optimal implementation of conjunctive queries in relational databases. Proc. Ninth Annual ACM Symposium on the Theory of Computing, 77–90, 1977.Google Scholar
  3. 3.
    Feder, T. and Y. Saraiya. Undecidable normal forms for logic databases, Tech. report TM-ARH-019576, Bellcore, June 1991.Google Scholar
  4. 4.
    Feder, T. and Y. Saraiya. Detecting commutativity, Tech. report TM-ARH-019716, Bellcore, June 1991.Google Scholar
  5. 5.
    Hopcroft, J.E. and J. D. Ullman. Introduction to automata theory, languages and computation, Addison-Wesley, 1979.Google Scholar
  6. 6.
    Ioannidis, Y. E. Commutativity and its role in the processing of linear recursion. Tech. Report 804, University of Wisconsin-Madison, 1989.Google Scholar
  7. 7.
    Ioannidis, Y. E. and E. Wong. Towards an algebraic theory of recursion. JACM, to appear.Google Scholar
  8. 8.
    Ioannidis, Y.E. and E. Wong. Transforming nonlinear recursion to linear recursion. J. Logic Programming, to appear.Google Scholar
  9. 9.
    Jagadish, H. V., R. Agrawal and L. Ness. A study of transitive closure as a recursion mechanism. ACM SIGMOD International conference on Management of data, 1987.Google Scholar
  10. 10.
    Kannan, R. Solution of the Frobenius problem and its generalization. Combinatorica, to appear.Google Scholar
  11. 11.
    Naughton, J. F. Compiling separable recursions. ACM SIGMOD Intl. Conf. on the Management of Data, 312–319, 1988.Google Scholar
  12. 12.
    Ramakrishnan, R., Y. Sagiv, J.D. Ullman and M.Y. Vardi. Proof-tree transformation theorems and their applications. Proc. Eighth ACM Symposium on Principles of Database Systems, 172–181, 1989.Google Scholar
  13. 13.
    Sagiv, Y. Optimizing Datalog programs. Proc. Sixth ACM Symposium on Principles of Database Systems, 349–362, 1987.Google Scholar
  14. 14.
    Sagiv, Y. and M. Yannakakis. Equivalence among relational expressions with the union and difference operators. J. ACM 27, 633–655, 1981.Google Scholar
  15. 15.
    Saraiya, Y. Linearizing nonlinear recursions in polynomial time. Proc. Eighth ACM Symposium on Principles of Database Systems, 182–189, 1989.Google Scholar
  16. 16.
    Saraiya, Y. Polynomial-time program transformations in deductive databases. Proc. Ninth ACM Symposium on Principles of Database Systems, 1990.Google Scholar
  17. 17.
    Saraiya, Y. Hard problems for simple logic programs. Proc. ACM SIGMOD International Conference on Management of Data, 64–73, 1990.Google Scholar
  18. 18.
    Saraiya, Y. Subtree-elimination algorithms in deductive databases, Ph.D. Thesis, Stanford University, 1991.Google Scholar
  19. 19.
    Shmueli, O. Decidability and expressiveness aspects of logic queries. Proc. Sixth ACM Symposium on Principles of Database Systems, 237–249, 1987.Google Scholar
  20. 20.
    Ullman, J. D. Principles of Database and Knowledge-base Systems. 2 volumes. Computer Science Press, Rockville, Md., 1989.Google Scholar
  21. 21.
    Ullman, J. D. and A. van Gelder. The parallel complexity of logical query languages. Proc. IEEE Symposium on Foundations of Computer Science, 1986.Google Scholar
  22. 22.
    Zhang, W., C.T. Yu and D. Troy. Necessary and sufficient conditions to linearize doubly recursive programs in logic databases. ACM Transactions on Database Systems 15:3, 459–482, 1990.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1992

Authors and Affiliations

  • Tomás Feder
    • 1
    • 2
  • Yatin Saraiya
    • 1
    • 2
  1. 1.IBM Almaden Research LaboratoryUSA
  2. 2.Bellcore

Personalised recommendations