# Logic programming and parallel complexity

## Abstract

This paper is a survey of the many applications of the theory of parallel algorithms and complexity to logic programming problems. The mathematical tools relevant to the analysis of parallel logic programs include: the concept of alternation, the complexity class NC, and parallel algorithms using randomization and/or achieving optimal speed-ups. The logic programming problems addressed are related to query optimization for deductive databases and to fast parallel execution of primitive operations in logic programming languages, such as, fixpoint operators, term unification, and term matching. The formal language we use to illustrate the addition of recursion to database queries is the language of *logical query programs* (or programs), whose evaluation has been the object of much recent research. Our presentation highlights the fact that all of these results can be stated using the *stage function* s_{H}(n) of a program H, where n is the size of the database queried. In this context we also present two new observations. (1) Given a linear single rule program H, it is NP-hard to decide whether s_{H}(n)=O(1); this extends the bounded recursion analysis of[57, 42]. (2) There is a program that can be evaluated in s(n)=O(log n) stages, but whose derivation trees (of width 1) are of size exponential in n. An extension of derivation trees from width 1 to constant width properly strengthens the fast evaluation method of [76].

## Keywords

Parallel Algorithm Logic Programming Transitive Closure Derivation Tree Deductive Database## Preview

Unable to display preview. Download preview PDF.

## References

- 1.Aho, A.V. and Ullman, J.D. Universality of Data Retrieval Languages. Proceedings of the 6
^{th}POPL, ACM, 1979.Google Scholar - 2.Afrati, F. Papadimitriou, C.H. The Polynomial Stack Theorem and its Applications. Tech. Rep., National Technical Univ. of Athens, May 1986.Google Scholar
- 3.Atallah, M.J., Hambrusch, S.E. Solving Tree Problems on a Mesh-connected Processor Array. Proceedings of the 26th FOCS, IEEE, 1985.Google Scholar
- 4.Apt, K.R., van Emden, M.H. "Contributions to the Theory of Logic Programming".
*JACM 29*, 4 (1982), 841–862.Google Scholar - 5.Barwise, J. Moschovakis, Y.N. "Global Inductive Definability".
*Journal of Symbolic Logic 43*, 3 (1978), 521–534.Google Scholar - 6.Bancilhon, F., Maier, D., Sagiv, Y., Ullman, J.D. Magic Sets and Other Strange Ways to Implement Logic Programs. Proceedings of the 5th PODS, ACM, 1986.Google Scholar
- 7.Bancilhon, F., Ramakrishnan, R. An Amateur's Introduction to Recursive Query Processing Strategies. Proceedings of the 86 SIGMOD, ACM, 1986.Google Scholar
- 8.Chandra, A.K., Harel, D. "Structure and Complexity of Relational Queries".
*JCSS 25*, 1 (1982), 99–128.Google Scholar - 9.Chandra, A.K., Harel, D. "Horn Clause Programs and Generalizations".
*J. Logic Programming 2*(1985), 1–15.Google Scholar - 10.Chandra, A.K. Maximal Parallelism in Matrix Multiplication. RC 6193, IBM, 1976.Google Scholar
- 11.Cosmadakis, S.S., Kanellakis, P.C. Parallel Evaluation of Recursive Rule Queries. Proceedings of the 5th PODS, ACM, 1986.Google Scholar
- 12.Chandra, A.K., Kozen, D.C., Stockmeyer, L.J. "Alternation".
*JACM 28*, 1 (1981), 114–133.Google Scholar - 13.Clark, K.L., Gregory, S. A Relational Language for Parallel Programming. Proceedings of the ACM Conference on Functional Programming Languages and Computer Architecture, ACM, 1981.Google Scholar
- 14.Clark, K.L. Negation as Failure. In
*Logic and Databases*, Gallaire, H. and Minker, J., Eds., Plenum Press, 1978, pp. 293–324.Google Scholar - 15.Clocksin, W.F., Mellish, C.S.,
*Programming in Prolog*. Springer Verlag, 1981.Google Scholar - 16.Codd, E.F. "A Relational Model for Large Shared Data Banks".
*CACM 13*, 6 (June 1970), 377–387.Google Scholar - 17.Cook, S.A. "An Observation on a Time-Storage Trade-off".
*JCSS 9*, 3 (1974), 308–316.Google Scholar - 18.Cook, S.A. "A Taxonomy of Problems with Fast Parallel Algorithms".
*Information and Control 64*(1985), 2–22.Google Scholar - 19.Cole, R., Vishkin, U. Deterministic Coin Tossing and Accelerating Cascades: Micro and Macro Techniques for Designing Parallel Algorithms. Proceedings of the 17th STOC, ACM, 1986.Google Scholar
- 20.Coppersmith, D., Winograd, S. "On the Asymptotic Complexity of Matrix Multiplication".
*SIAM J. of Computing 11*, (1982), 472–492.Google Scholar - 21.deRougemont, M. Uniform Definability of Finite Structures with Successor. Proceedings of the 16th STOC, ACM, 1984.Google Scholar
- 22.Dwork, C., Kanellakis, P.C., and Mitchell, J.C. "On the Sequential Nature of Unification".
*J. Logic Programming 1*, 1 (1984), 35–50.Google Scholar - 23.Dwork, C., Kanellakis, P.C., Stockmeyer, L.J. Parallel Algorithms for Term Matching. Proceedings of the 8th International Conference on Automated Deduction, Springer Verlag LNCS, 1986.Google Scholar
- 24.Downey, P.J., Sethi, R. and Tarjan, R.E. "Variations on the Common Subexpression Problem".
*JACM 27*, 4 (1980), 758–771.Google Scholar - 25.Fagin, R. "Monadic Generalized Spectra".
*Zeitschr. f. math. logik 21*, (1975), 89–96.Google Scholar - 26.Fagin, R. "Generalized First-Order Spectra and Polynomial-Time Recognizable Sets".
*SIAM-AMS Proc. 7*, 1 (1974), 43–73.Google Scholar - 27.Fortune, S., Wyllie, J. Parallelism in Random access Machines. Proceedings of the 10th STOC, ACM, 1978.Google Scholar
- 28.Gaifman, H. January 1986. NAIL Seminar.Google Scholar
- 29.Gaifman, H., Vardi, M.Y. "A Simple Proof that Connectivity of Finite Graphs is Not First-Order Definable".
*Bulletin of the EATCS 26*, June (1985), 44–45.Google Scholar - 30.Gallaire, H., Minker, C., Nicolas, J.M. "Logic and Databases: A Deductive Approach".
*Computing Surveys 16*, (1984), 153–185.Google Scholar - 31.Goldschlager, L.M. "The Monotone and Planar Circuit Value Problems are Logspace-complete forP".
*SIGACT News 9*, 2 (1977), 25–29.Google Scholar - 32.Gurevich, Y., Shelah S. Fixed-Point Extensions of First-Order Logic. Proceedings of the 26th FOCS, IEEE, 1985.Google Scholar
- 33.Gurevich, Y. Algebra of Feasible Functions. Proceedings of the 24th FOCS, IEEE, 1983.Google Scholar
- 34.Gurevich, Y., Lewis, H.R. "A Logic for Constant Depth Circuits".
*Information and Control 61*, (1984), 65–74.Google Scholar - 35.Harel, D., Kozen, D.C. "A Programming Language for the Inductive Sets, and Applications".
*Information and Control 63*, (1984), 118–139.Google Scholar - 36.Henschen, L.J., Naqvi, S.A. "On Compiling Queries in Recursive First-Order Databases".
*JACM 31*, 1 (1984), 47–85.Google Scholar - 37.Hopcroft, J.E. and Ullman, J.D..
*Introduction to Automata Theory, Languages, and Computation*. Addison-Wesley, 1979.Google Scholar - 38.Huet, G. and Oppen, D. Equations and Rewrite Rules: a Survey. In
*Formal Languages: Perspectives and Open Problems*, Book, R., Ed., Academic Press, 1980, pp. 349–403.Google Scholar - 39.Immerman, N. "Number of Quantifiers is Better than Number of Tape Cells".
*JCSS 22*, 3 (1981), 65–72.Google Scholar - 40.Immerman, N. Relational Queries Computable in Polynomial Time. Proceedings of the 14th STOC, ACM, 1982.Google Scholar
- 41.Immerman, N. Languages which Capture complexity Classes. Proceedings of the 15th STOC, ACM, 1983.Google Scholar
- 42.Ioannidis, Y.E. A Time Bound on the Materialization of Some Recursively Defined Views. Proceedings of the 85 VLDB, Stockholm, 1985.Google Scholar
- 43.Ioannidis, Y.E. On the Computation of the Transitive Closure of Relational Operators. Proceedings of the 86 VLDB, Tokyo, 1986.Google Scholar
- 44.Jones, N.D., Laaser, W.T. "Complete Problems for Deterministic Polynomial Time".
*TCS 3*, 2 (1977), 105–117.Google Scholar - 45.Knuth, D.E. and Bendix, P.B. Simple Word Problems in Universal Algebras. In
*Computational Problems in Abstract Algebra*, Leech, J., Ed., Pergamon, Oxford, 1970, pp. 263–297.Google Scholar - 46.Kowalski, R.A..
*Logic for Problem-Solving*. North Holland, 1979.Google Scholar - 47.Kozen, D. Complexity of Finitely Presented Algebras. Proceedings of the 9
^{th}STOC, ACM,, 1977.Google Scholar - 48.Kanellakis, P.C., Papadimitriou, C.H. February 1986. Notes on Monadic Sirups-unpublished.Google Scholar
- 49.Karp, R.M., Upfal, E., Wigderson, A. Constructing a Perfect Matching is in Random NC. Proceedings of the 17th STOC, ACM, 1985.Google Scholar
- 50.Kowalski, R. Predicate Logic as a Programming Language. Proceedings IFIP 74, Amsterdam, 1974, pp. 569–574.Google Scholar
- 51.Mairson, H., Sagiv, Y. February 1986. Personal Communication.Google Scholar
- 52.Maluszynski, J., Komorowski, H.J. Unification-free Execution of Horn-clause Programs. Proceedings of the 2nd Logic Programming Symposium, IEEE, 1985.Google Scholar
- 53.Martelli, A., Montanari, U. "An efficient Unification Algorithm".
*ACM Trans. on Programming Languages and Systems 4*, 2 (1982).Google Scholar - 54.Miller, G.L., Reif, J.H. Parallel Tree Contraction and its Applications. Proceedings of the 26th FOCS, IEEE, 1985.Google Scholar
- 55.Minker, J., Nicolas, J.M. "On Recursive Axioms in Relational Databases".
*Information Systems 8*(1982), 1–13.Google Scholar - 56.Moschovakis, Y.N..
*Elementary Induction on Abstract Structures*. North Holland, 1974.Google Scholar - 57.Naughton, J. Data Independent Recursion in Deductive Databases. Proceedings of the 5th PODS, ACM, 1986.Google Scholar
- 58.Papadimitriou, C.H. "A Note on the Expressive Power of PROLOG".
*Bulletin of the EATCS 26*, June (1985), 21–23.Google Scholar - 59.Pippenger, N. On Simultaneous Resource Bounds. Proceedings of the 20th FOCS, IEEE, 1979.Google Scholar
- 60.Paterson, M.S., Wegman, M.N. "Linear Unification".
*JCSS 16*, (1978), 158–167.Google Scholar - 61.Rabin, M.O. "Probabilistic Algorithm for Testing Primality".
*J. Number Theory 12*(1980), 128–138.Google Scholar - 62.Reif, J. Optimal Parallel Algorithms for Integer Sorting and Graph Connectivity. Proceedings of the 26th FOCS, IEEE, 1985.Google Scholar
- 63.Robinson, J.A. "A Machine Oriented Logic Based on the Resolution Principle",
*JACM 12*, (January 1965), 23–41.Google Scholar - 64.Roussel, P. PROLOG: Manuel de Reference et d' Utilisation, Groupe de IA, UER Luminy. Univ. d' Aix-Marseille, France, 1975.Google Scholar
- 65.Ruzzo, W.L. "Tree-size Bounded Alternation".
*JCSS 21*, 2 (1980), 218–235.Google Scholar - 66.Ruzzo, W.L. "On Uniform Circuit Complexity",
*JCSS 22*, 3 (1981), 365–383.Google Scholar - 67.Sagiv, Y. On Computing Restricted Projections of Representative Instances. Proceedings of the 4th PODS, ACM, 1985.Google Scholar
- 68.Sacca, D., Zaniolo, C. On the Implementation of a Simple Class of Logic Queries for Databases. Proceedings of the 5th PODS, ACM, 1986.Google Scholar
- 69.Sagiv, Y. February 1986. Notes on Uniform Equivalence-unpublished.Google Scholar
- 70.Sazonov. A Logical Approach to the Problem P=NP. Proceedings of the MFCS, Springer LNCS 88, 1980.Google Scholar
- 71.Schwartz, J.T. "Fast Probabilistic Algorithms for the Verification of Polynomial Identities".
*JACM 27*, 4 (1980), 701–717.Google Scholar - 72.Shapiro, E.Y. A Subset of Concurrent PROLOG and its Interpreter. No. 3, ICOT, Tokyo, 1983.Google Scholar
- 73.Tarjan R.E., Vishkin, U. Finding Biconnected Components and Computing Tree Functions in Logarithmic Parallel Time. Proceedings of the 25th FOCS, IEEE, 1984.Google Scholar
- 74.Ullman, J.D..
*Principles of Database Systems*. Computer Science Press, 1983.Google Scholar - 75.Ullman, J.D. "Implementation of Logical query Languages for Databases".
*ACM Trans. on Database Systems 10*(1985), 289–321.Google Scholar - 76.Ullman, J.D., Van Gelder, A. Parallel Complexity of Logical Query Programs. Proceedings of the 27th FOCS, 1986, to appear.Google Scholar
- 77.Vardi, M.Y. Complexity of Relational Query Languages. Proceedings of the 14th STOC, ACM, 1982.Google Scholar
- 78.Valduriez, P., Boral, H. Evaluation of Recursive Queries Using Join Indices. Proceedings of the 1rst International Conference on Expert Database Systems, Charleston, South Carolina, 1986.Google Scholar
- 79.Vardi, M.Y. May 1985. Personal Communication.Google Scholar
- 80.Vardi, M.Y. February 1986. Personal Communication.Google Scholar
- 81.van Emden, M.H., Kowalski, R.A. "The Semantics of Predicate Logic as a Programming Language".
*JACM 23*, 4 (1976), 733–742.Google Scholar - 82.Vishkin, U. Randomized Speed-ups in Parallel Computation. Proceedings of the 16th STOC, ACM, 1984.Google Scholar
- 83.Verma, R.M., Krishnaprasad, T., Ramakrishnan, I.V. An Efficient Parallel algorithm for Term Matching. Tech. Rep., SUNY Stony Brook, June 1986.Google Scholar
- 84.Vitter, J.S., Simons, R. "New Classes for Parallel Complexity: a Study of Unification and Other Complete Problems for P".
*IEEE Trans. on Computers*(1986).Google Scholar - 85.Valiant, L.G., Skyum, S., Berkowitz, S., Rackoff, C. "Fast Parallel Computation on Polynomials Using Few Processors".
*SIAM J. of Computing 12*, 4 (November 1983), 641–644.Google Scholar - 86.Yasuura, H. On the Parallel Computational Complexity of Unification. ER 83-01, Yajima Lab., October 1983.Google Scholar
- 87.Yannakakis, M. March 1986. Personal Communication.Google Scholar