# Functional queries in Datalog

- 29 Downloads

## Abstract

A ‘functional’ query is a query whose answer is always defined and unique i.e. it is either true or false in all models. It has been shown that the expressive powers of the various types of stable models, when restricted to the class of DATALOG^{¬} functional queries, do not in practice go beyond those of well-founded semantics, except for the least undefined stable models which, instead, capture the whole boolean hierarchyBH.

In this paper we present a ‘functional’ language which, by means of a disciplined use of negation, achieves the desired level of expressiveness up toBH. Although the semantics of the new language is partial, all atoms in the source program are defined and possibly undefined atoms are introduced in a rewriting phase to increase the expressive power. We show that the language satisfies ‘desirable’ properties better than classical languages with (unstratified) negation and stable model semantics. We present an algorithm for the evaluation of functional queries and we show that exponential time resolution is required for hard problems only. Finally we present the architecture of a prototype of the language which has been developed.

## Keywords

Logic Programming Datalog Stable Models Functional Queries Expressive Power Data Complexity## Preview

Unable to display preview. Download preview PDF.

## References

- 1).Abiteboul, S., Hull, R. and Vianu, V.,
*Foundations of Databases*, Addison-Wesley, 1994.Google Scholar - 2).Abiteboul, S., Simon, E. and Vianu, V., “Non-deterministic Languages to Express Deterministic Transformations,” in
*Proc. of ACM PODS Symp.*, pp. 218–229, 1990.Google Scholar - 3).Abiteboul, S. and Vianu, V., “Datalog Extensions for Databases Queries and Updates,”
*Journal of Computer and System Science, 43*, pp. 62–124, 1991.MathSciNetCrossRefGoogle Scholar - 4).Apt, K., Blair, H. and Walker, A., “Towards a Theory of Declarative Knowledge,” in
*Foundations of Deductive Databases and Logic Programming*, pp. 89–142, 1988.CrossRefGoogle Scholar - 5).Baral, V. and Subrahmanian, V., “Stable and Extension Class Theory for Logic Programs and Default Logic,”
*Journal of Automated Reasoning*, pp. 345–366, 1992.MathSciNetCrossRefGoogle Scholar - 6).Basta, S., “A System Prototype for the Evaluation of Functional Datalog Queries,”
*Degree thesis*(in Italian), 1997.Google Scholar - 7).Chandra, A. and Harel, D., “Computable Queries for Relational Databases,”
*Journal of Computer and System Sciences, 21*, pp. 156–178, 1980.MathSciNetCrossRefGoogle Scholar - 8).Chandra, A. and Harel, D., “Structure and Complexity of Relational Queries,”
*Journal of Computer and System Sciences, 25*, pp. 99–128, 1982.CrossRefGoogle Scholar - 9).Dix, J., “Classifying Semantics of Logic Programs,” in
*Int. Workshop, on Logic Programming and Non-Monotonic Reasoning*, pp. 166–180, 1991.Google Scholar - 10).Fagin, R., “Generalized First-Order Spectra and Polynomial-Time Recognizable Sets,” in
*SIAM-AMS Proc., 7*, pp. 43–73, 1974.Google Scholar - 11).Flum, J., Kubierschky, M. and Ludascher, B., “Total and Partial Well-founded DATALOG Coincide,” in
*Proc. of the Int. Conf. on Database Theory*, Springer-Verlag, pp. 113–124, 1997.Google Scholar - 12).Gelfond, M. and Lifschitz, V., “The Stable Model Semantics for Logic Programming,” in
*Proc. of 5th Int. Conf. and Symp. on Logic Programming*, MIT Press, Cambridge, pp. 1070–1080, 1988.Google Scholar - 13).Giannotti, F., Pedreschi, D., Saccà, D. and Zaniolo, C., “Non-determinism in Deductive Databases,” in
*Proc. of 2nd Conf. on Deductive and Object-Oriented Databases*, 1991.CrossRefGoogle Scholar - 14).Greco, S., Saccà, D. and Zaniolo C., “DATALOG Queries with Stratified Negation and Choice: fromP toD
_{p},” in*Proc. of the Fifth Int. Conf. on Database Theory*, 1995.Google Scholar - 15).Greco, S. and Saccà, D., “Possible-is-certain, is Desiderable and Can Be Expressive,”
*Annals of Mathematics and Artificial Intelligence*(preliminary version in ASIAN'97), 1997.Google Scholar - 16).Greco, S., “Non-determinism and Weak Constraints in Datalog,”
*New Generation Computing*(preliminary version in AGP Conf., 1996)*16, 4*, 1998.CrossRefGoogle Scholar - 17).Greco, S., “Dynamic Programming in Datalog with Aggregates,”
*IEEE Transactions on Knowledge and Data Engineering*, pp. 265–283, 1999.CrossRefGoogle Scholar - 18).Gurevich, Y., “Logic and the Challenge of Computer Science,” in
*Trends in Theoretical Computer Science*, Computer Science Press, 1988.Google Scholar - 19).Immerman, N., “Languages Which Capture Complexity Classes,”
*SIAM Journal on Computing, 16*, pp. 760–778, 1987.MathSciNetCrossRefGoogle Scholar - 20).Johnson, D. S., “A Catalog of Complexity Classes,”
*Handbook of Theoretical Computer Science, 1*, North-Holland, 1990.Google Scholar - 21).Kanellakis, P. C., “Elements of Relational Database Theory,”
*Handbook of Theoretical Computer Science, 2*, North-Holland, 1991.Google Scholar - 22).Kolaitis, P., “The Expressive Power of Stratified Logic Programs,”
*Information an Computation*, 90, pp. 50–66, 1990.MathSciNetCrossRefGoogle Scholar - 23).Kolaitis, P. G. and Papadimitriou, C. H., “Why not Negation by Fixpoint?,”
*Journal of Computer and System Sciences, 43*, pp. 125–144, 1991.MathSciNetCrossRefGoogle Scholar - 24).Krishnamurthy, R. and Naqvi, S. A., “Non-deterministic Choice in Datalog,” in
*Proc. of 3rd Int. Conf. on Data and Knowledge Bases*, pp. 416–424, 1988.CrossRefGoogle Scholar - 25).Lloyd, J. W.,
*Foundations of Logic Programming*, Springer Verlag, Berlin, 1987.CrossRefGoogle Scholar - 26).Makinson, D., “General Pattern in Nonmonotonic Reasoning,”
*Handbook of Logic in Artificial Intelligence and Logic Programming*, (D. M. Gabbay, C. J. Hogger and J. A. Robinson eds.),*2*, Oxford University Press, 1993.Google Scholar - 27).Marek, W. and Truszcynski, M., “Autoepistemic Logic,”
*Journal of the ACM*, 38, pp. 588–619, 1991.MathSciNetCrossRefGoogle Scholar - 28).Papadimitriou, C. H.,
*Computational Complexity*, Addison Wesley, 1994.Google Scholar - 29).Papadimitriou, C. H. and Yannakakis, M., “Tie-Breaking Semantics and Structural Totality,”
*JCSS, 54, 1*, pp. 48–60, 1997.MathSciNetMATHGoogle Scholar - 30).Przymusinski, T. C., “Well-founded Semantics Coincides with Three-valued Stable Semantics,”
*Foundamenta Informaticae, 13*, pp. 445–463, 1990.MathSciNetMATHGoogle Scholar - 31).Ross, K. A., “Structural Totality and Constraint Stratification,” in
*PODS*, pp. 184–195.Google Scholar - 32).Ross, K. A., “A Syntactic Stratification Condition Using Constraints,” in
*SLP*, 76–90, 1994.Google Scholar - 33).Ross, K. A., “Modular Stratification and Magic Sets for Datalog Programs with Negation,”
*JACM, 41, 6*, pp. 1216–1266, 1994.MathSciNetCrossRefGoogle Scholar - 34).Saccà, D., “The Expressive Powers of Stable Models for Bound and Unbound DATALOG Queries,”
*Journal of Computer and System Science*, 1997.Google Scholar - 35).Saccà, D. and Zaniolo, C., “Stable Models and Non-Determinism in Logic Programs with Negation,” in
*Proc. ACM PODS Symp.*, pp. 205–218, 1990.Google Scholar - 36).Saccà, D. and Zaniolo, C., “Deterministic and Non-deterministic Stable Models,” Journal of Logic and Computation, 1997.Google Scholar
- 37).Schlipf, J. S., “The Expressive Powers of the Logic Programming Semantics,” in
*Proc. of ACM PODS Symp.*, pp. 196–204, 1990.Google Scholar - 38).Ullman, J. D., “Principles of Database and Knowledge Base Systems,”
*1–2*, Computer Science Press, 1989.Google Scholar - 39).Vardi, M. Y., “The Complexity of Relational Query Languages,” in
*Proc. of ACM Symp. on Theory of Computing*, pp. 137–146, 1982.Google Scholar - 40).Van Gelder, A., Ross, K. and Schlipf, J. S., “The Well-Founded Semantics for General Logic Programs,”
*Journal of the ACM, 38, 3*, pp. 620–650, 1991.MathSciNetMATHGoogle Scholar - 41).Vielle, L., “Recursive Query Processing: The Power of Logic,”
*Theoretical Computer Science, 69*, pp. 1–53, 1989.MathSciNetCrossRefGoogle Scholar - 42).You, J., and Yuan, L. Y., “On the Equivalence of Semantics for Normal Logic Programs,”
*Journal of Logic Programming*, pp. 211–222, 1995.MathSciNetCrossRefGoogle Scholar