# Optimization of linear logic programs using counting methods

## Abstract

*We present a general solution to the problem of optimized execution of logic programs containing linear recursive rules. Our solution is based on extensions of the classical counting method, which is known to be efficient but of limited applicability. In fact, the range of applicability of the counting method, and its variants proposed by previous researchers, suffer from one or more of the following limitations: the method can be applied only when (1) the adorned program contains one recursive rule, (2) the ‘left part’ and the ‘right part’ of the recursive rule do not have any common variable and (3) the relation associated with the left part of the recursive rule is ‘acyclic’. In this paper, a simple and unified framework is presented, where those limitations are removed, and the counting method thus become applicable to all programs with linear rules. This framework also allows a simple treatment of programs factorizable into segments, which can be computed separately yielding a much faster execution. A simple factorization technique based on argument reduction is presented that produces optimizations similar to those defined in the literature for RLC-linear programs (i.e., programs with right- linear rules, left-linear rules and a combination of the two)*.

## Preview

Unable to display preview. Download preview PDF.

## References

- [1]A.V. Aho, Hopcroft J.E., and Ullman J.D.
*The Design and Analysis of Computer Algorithms*. Addison-Wesley, 1974.Google Scholar - [2]H. Aly and Z.M. Ozsoyoglu. Synchronized counting method. In
*Proceedings of the Fifth Intern. Conference on Data Engineering*, pages 366–373, 1989.Google Scholar - [3]F. Bancilhon, D. Maier, Y. Sagiv, and J. Ullman. Magic sets and other strange ways to implement logic programs. In
*Proceedings of the Fifth ACM Symposium on Principles of Database Systems*, pages 1–15, 1986.Google Scholar - [4]F. Bancilhon and R. Ramakrishnan. Performance evaluation of data intensive logic programs. In J. Minker, editor,
*Foundations of Deductive Databases and Logic Programming*, pages 439–518, Morgan-Kaufman, Los Altos, CA, 1988.Google Scholar - [5]C. Beeri, S. Naqvi, R. Ramakrishnan, O. Shmueli, and S. Tsur. Sets and negation in a logic database language (LDL1). In
*Proceedings of the Sixth ACM Symposium on Principles of Database Systems*, pages 21–37, 1987.Google Scholar - [6]C. Beeri and R. Ramakrishnan. On the power of magic.
*Journal of Logic Programming*, 10(3 & 4):333–361, 1991.Google Scholar - [7]D. Chimenti, R. Gamboa, R. Krishnamurthy, S. Naqvi, T. Shalom, and C. Zaniolo. The LDL system prototype. In
*IEEE Transaction on Knowledge and Data Engineering*, pages 76–90, 1990.Google Scholar - [8]S. Greco and C. Zaniolo.
*Optimization of Linear Logic Programs Using Counting Methods*. Research Report, MCC, 1991.Google Scholar - [9]R. Haddad and J. Naughton. A counting algorithm for a cyclic binary query.
*Journal of Computer and System Science*, 43(1):145–169, 1991.Google Scholar - [10]J. Lloyd.
*Foundations of Logic Programming*. Springer-Verlag, New York, 2nd edition, 1987.Google Scholar - [11]A. Marchetti-Spaccamela, A. Pelaggi, and D. Saccà. Comparison of methods for logic query implementation.
*Journal of Logic Programming*, 10(3 & 4):333–361, 1991.Google Scholar - [12]S. Naqvi and S Tsur.
*A Logic Language for Data and Knowledge Bases*. Computer Science Press, New York, 1989.Google Scholar - [13]J.F. Naughton, R. Ramakrisnhan, Y. Sagiv, and J.D. Ullman. Argument reduction by factoring. In
*Proceedings of the 15th Conference on Very Large Data Bases*, pages 173–182, 1989.Google Scholar - [14]J.F. Naughton, R. Ramakrisnhan, Y. Sagiv, and J.D. Ullman. Efficient evaluation of right-, left-, and multi-linear rules. In
*Proceedings of the 1988 ACM SIGMOD Int. Conf. on Management of Data*, pages 235–242, 1989.Google Scholar - [15]D. Saccà and C. Zaniolo. The generalized counting method of recursive logic queries for databases.
*Theoretical Computer Science*, 187–220, 1988.Google Scholar - [16]D. Saccà and C. Zaniolo. Magic counting methods. In
*Proceedings of the 1987 ACM SIGMOD Int. Conf. on Management of Data*, pages 49–59, 1987.Google Scholar - [17]D. Saccà and C. Zaniolo. On the implementation of a simple class of logic queries for databases. In
*Proceedings of the Fifth ACM Symposium on Principles of Database Systems*, pages 16–23, 1986.Google Scholar - [18]R Tarjan. Depth first search of linear graphs algorithms.
*SIAM J. Computing*, 1(2):146–160, 1972.Google Scholar - [19]J. Ullman.
*Principles of Data and Knowledge-Base Systems*. Volume 2, Computer Science Press, New York, 1989.Google Scholar - [20]J. Ullman.
*Principles of Data and Knowledge-Base Systems*. Volume 1, Computer Science Press, New York, 1988.Google Scholar - [21]C. Zaniolo. Design and implementation of a logic based language for data intensive applications. In
*Proc. of the Intern. Conf. on Logic Programming*, 1988.Google Scholar - [22]C. Zaniolo. Óbject identity and inheritance in deductive databases: an evolotionary approach. In
*Proc. 1st Int. Conf. on Deductive and Object-Oriented Databases*, 1989.Google Scholar