This Article 
 Bibliographic References 
 Add to: 
SYGRAF: Implementing Logic Programs in a Database Style
July 1988 (vol. 14 no. 7)
pp. 922-935

It is shown how Horn logic programs can be implemented using database techniques, namely, mostly bottom-up in combination with certain top-down elements (as opposed to the top-down implementations of logic programs prevailing so far). The proposed method is sound and complete. It easily lends itself to a parallel implementation and is free of nonlogical features like backtracking. As an extension to the common approach to deductive databases, function symbols are allowed to appear in programs, and it is shown that much of database query optimization can be applied to optimize logic programs. An important advantage of present approach is its ability to evaluate successfully many programs that terminate under neither pure top-down nor bottom-up evaluation strategies.

[1] R. Agrawal and P. Devanbu, "Moving selections into linear least fixpoint queries," inProc. IEEE 4th Int. Conf. Data Eng., Los Angeles, CA, Feb. 1988.
[2] A. Aho and J. Ullman, "Universality of data retrieval languages," inProc. 6th ACM Symp: Principles of Programming Languages, San Antonio, TX, Jan. 1979.
[3] F. Bancilhon, "Naive evaluation of recursively defined relations," MCC, Tech. Rep. DB-004-85, 1985.
[4] F. Bancilhon and R. Ramakrishnan, "Performance evaluation of data intensive logic programs," inProc. Workshop Foundation of Deductive Databases and Logic Programming, Washington, DC, Aug. 1986.
[5] F. Bancilhon, D. Maier, Y. Sagiv, and J. D. Ullman, "Magic sets and other strange ways to implement logic programs," inProc. 5th ACM Symp. Principles of Database Syst.(Cambridge, MA), Mar. 1986, pp. 1-15.
[6] C. Beeri and R. Ramakrishnan, "On the power of magic," inProc. 6th ACM Symp. Principles of Database Syst.(San Diego, CA), Mar. 1987, pp. 269-283.
[7] J. A. Campbell, Ed.,Implementations of Prolog. Chichester, England: Ellis Horwood, 1984.
[8] C. L. Chang and R. C. T. Lee,Symbolic Logic and Mechanical Theorem Proving. New York: Academic, 1973.
[9] W. F. Clocksin and C. S. Mellish,Programming in Prolog. New York: Springer-Verlag, 1984.
[10] S. Dietrich-Wagner and D. S. Warren, "Extension tables: Memo relations in logic programming," inProc. Symp. Logic Programming, San Francisco, CA, Sept. 1987, pp. 264-273.
[11] G. Gardarin, C. Maindreville, and E. Simon, "Extending a relational DBMS towards a rule-based system: An approach using predicate transition nets," INRIA, Sabre Project Rep., 1985.
[12] G. Gardarin, "Magic functions: A technique to optimize extended datalog recursive programs," inProc. ACM Int. Conf. Very Large Data Bases, 1987, pp. 21-30.
[13] U. Guntzer and W. K. A. R. Bayer, "On evaluation of recursion in deductive database systems by efficient differential fixpoint iteration," inProc. 3rd Int. Conf. Data Engineering, 1987, pp. 120-129.
[14] J. Kerisit, "A relational approach to logic programming: The extended Alexander method," BULL Research Center, Louveciennes, France, Tech. Rep. 87004, Feb. 1987.
[15] M. Kifer and E. L. Lozinskii, "Query optimization in deductive databases," Dep. Comput. Sci., SUNY at Stony Brook, NY, Tech. Rep. 85/16, June 1985.
[16] M. Kifer and E. L. Lozinskii, "Filtering data flow in deductive databases," inProc. Int. Conf. Database Theory, Rome, Italy, Sept. 1986, pp. 186-202.
[17] M. Kifer and E. L. Lozinskii, "Can we implement logic as a database system?" Dep. Comput. Sci., SUNY at Stony Brook, NY, Tech. Rep. 86/16, Mar. 1986.
[18] M. Kifer and E. L. Lozinskii, "A framework for an efficient implementation of deductive database systems," inProc. 6th Advanced Database Symp., Tokyo, Japan, Aug. 1986.
[19] M. Kifer and E. L. Lozinskii, "On compile-time query optimization in deductive databases by means of static filtering," submitted, 1986.
[20] M. Kifer and E. L. Lozinskii, "Implementing logic programs as a database system," inProc. IEEE 3rd Int. Conf. Data Engineering, Feb. 1987, pp. 375-385.
[21] M. Kifer and E. L. Lozinskii, "On the safety of queries in deductive databases with function symbols," in preparation, 1988.
[22] D. Kuehner, "Some special purpose resolution systems," inMachine Intelligence, E. Meltzer and D. Michie, Eds. London: Edinburgh University Press, 1972.
[23] J. W. Lloyd,Foundations of Logic Programming, New York: Springer, 1984.
[24] J. W. Lloyd and R. W. Topor, "A basis for deductive database systems,"J. Logic Programming, pp. 93-109, 1985.
[25] J. W. Lloyd and R. W. Topor, "A basis for deductive database systems II,"J. Logic Programming, 1986, pp. 55-67.
[26] E. L. Lozinskii, "A remark on distributed termination," inProc. 5th IEEE Int. Conf. Distributed Computing, Denver, CO, May 1985.
[27] E. L. Lozinskii, "Evaluating queries in deductive databases by generating," inProc. IJCAI, 1985, pp. 173-177.
[28] E. L. Lozinskii, "A problem-oriented inferential database system,"ACM Trans. Database Syst., vol. 11, pp. 323-356, 1986.
[29] D. Maier,The Theory of Relational Databases. Potomac, MD: Computer Science Press, 1983.
[30] A. Martelli and U. Montanari, "An efficient unification algorithm,"ACM Trans. Program. Lang. Syst., vol. 4, no. 2, pp. 258-282, 1982.
[31] J. Minker and J. M. Nicolas, "On recursive axioms in deductive databases,"Inform. Syst., vol. 8, no. 1, pp. 1-13, 1983.
[32] R. C. Moore, "The role of logic in knowledge representation and commonsense reasoning," inProc. AAAI, Pittsburgh, PA, 1982, pp. 428-433.
[33] Y. Morita, H. Yokota, K. Nishida, and H. Itoh, "Retrieval-by-unification operation on a relational knowledge base," inProc. ACM Int. Conf. Very Large Data Bases, 1986, pp. 52-59.
[34] S. A. Naqvi, "Interfacing Prolog and relational databases: The problem of recursive queries," inProc. 1st Int. Workshop Expert Data-base Systems, Kiawah Island, SC, Oct. 1984, pp. 740-746.
[35] N. Nilsson,Principles of Artificial Intelligence. Palo Alto, CA: Tioga, 1980.
[36] R. Ramakrishnan, F. Bancilhon, and A. Silberschatz, "Safety of recursive Horn clauses with infinite relations," inProc. ACM SIGACT-SIGMOD Symp. Principles of Database Systems, 1987, pp. 328-339.
[37] R. Reiter, "Towards a logical reconstruction of relational database theory," inOn Conceptual Modelling: Perspectives from Artificial Intelligence, Databases and Programming Languages, M. L. Brodie, J. Mylopoulos, and J. Schmidt, Eds. New York: Springer-Verlag, 1984.
[38] J. Rohmer and R. Lescoeur, "The Alexander's method: A technique for the processing of recursive axioms in deductive databases," Res. Rep. DRAL/IA/45.01, Mar. 1985.
[39] D. J. Rosenkrantz and H. B. Hunt, "Processing conjunctive predicates and queries," inProc. ACM Int. Conf. Very Large Data Bases, 1980, pp. 64-72.
[40] D. Sacca and C. Zaniolo, "Implementation of recursive queries for a data language based on pure Horn logic," MCC, Rep. DB-092-86, Mar. 1986.
[41] D. Sacca and C. Zaniolo, "Implementation recursive logic queries with function symbols," MCC, Austin, TX, Tech. Rep. DB-065-86, Feb. 1986.
[42] E. Sciore and D. S. Warren, "Towards an integrated database prolog system," Dep. Comput. Sci., SUNY at Stony Brook, Tech. Rep. 84- 079, June 1984.
[43] S. Shapiro, J. Martins, and D. McKay, "Bi-directional inference," inProc. 4th Annu. Conf. Cognitive Science Soc., Arlington, MI, Aug. 1982, pp. 90-93.
[44] O. Shmueli, "Decidability and expressiveness aspects of logic queries," inProc. ACM SIGACT-SIGMOD Symp. Principles Database Systems, 1987, pp. 237-249.
[45] J. D. Ullman,Principles of Databases Systems. Rockville, MD: Computer Science Press, 1982.
[46] J. D. Ullman and A. V. Gelder, "Testing applicability of top-down capture rules," STAN-CS-85-1046, Dep. Comput. Sci., Stanford Univ. Rep. STAN-CS-85-1046, 1985.
[47] J. D. Ullman, "Implementation of logical query languages for databases,"ACM TODS, vol. 10, no. 3, pp. 289-321, 1985.
[48] T. Vasak and J. Potter, "Characterization of terminating logic programs," inProc. IEEE Symp. Logic Programming, 1986, pp. 140- 147.
[49] L. Vieille, "Recursion in deductive databases: A DB-complete proof procedure based on SLD-resolution," ECRC Tech. Rep. KB-15, Nov. 1986.
[50] L. Vieille, "Recursive axioms in deductive databases: The query-subquery approach," inProc. 1st Conf. Expert Database System, Charleston, SC, 1986, pp. 179-196.
[51] H. Yokotaet al., "An enhanced inference mechanism for generating relational algebra queries," inProc. 3rd Symp. Principles of Database Syst., 1984, pp. 229-238.
[52] C. Zaniolo, "The representation and deductive retrieval of complex objects," MCC, Austin, TX, Tech. Rep., 1985.

Index Terms:
logic programming; parallel programming; SYGRAF; Horn logic programs; deductive databases; function symbols; query optimization; bottom-up evaluation; database theory; formal logic; logic programming; programming theory
M. Kifer, E.L. Lozinskii, "SYGRAF: Implementing Logic Programs in a Database Style," IEEE Transactions on Software Engineering, vol. 14, no. 7, pp. 922-935, July 1988, doi:10.1109/32.42735
Usage of this product signifies your acceptance of the Terms of Use.