# A practical approach to hypothetical database queries

## Abstract

Hypothetical queries are queries embedding hypotheses about the database. The embedded hypothesis in a hypothetical query indicates, so to say, a state of the database intended for the rest of the query. Thus the answer to a hypothetical query *h > q*, with a hypothesis *h*, is in principle the result of evaluating *q* against the database revised with *h*. In case *h* is inconsistent with the database, query evaluation becomes a special case of counterfactual reasoning. However, the possible worlds semantics usually applied for this notion is not relevant for database applications due to reasons of inefficiency. In this paper we discuss and compare different approaches to hypothetical queries, paying special attention to potentials for efficient evaluation. As a central part of the paper we present and discuss our own approach “counterfactual exceptions”, which have the important property of, as opposed to the other approaches discussed, requiring only minor overhead in query evaluation. This approach is thus realistic for practical implementation and use in environments supporting large databases. The “price” for efficient evaluation is an altered semantics, as compared to the other approaches. However, it can be argued that this semantics is at least as appropriate for database applications as that of the other approaches mentioned.

## Keywords

Logic Program Logic Programming Integrity Constraint Query Evaluation Protected Part## Preview

Unable to display preview. Download preview PDF.

## References

- 1.Andreasen, T., Christiansen, H. Counterfactual exceptions in deductive database queries.
*Proc. ECAI'96, 12th European Conference on Artificial Intelligence*pp. 340–344, 1996.Google Scholar - 2.Andreasen, T., Christiansen, H., and Larsen, H.L., eds.
*Flexible Query-Answering Systems*, Kluwer, to appear 1997.Google Scholar - 3.Bonner, A.J. Intuitionistic Deductive Databases and the Polynomial Time Hierarchy.
*Journal of Logic Programming (JLP)*, 33(1):1–47,1997.zbMATHMathSciNetCrossRefGoogle Scholar - 4.Bonner, A.J. Hypothetical Datalog: Complexity and Expressibility.
*Theoretical Computer Science (TCS)*, 76:3–51, 1990.zbMATHMathSciNetCrossRefGoogle Scholar - 5.Christiansen, H., A complete resolution method for logical meta-programming languages.
*Lecture Notes in Computer Science*649, pp. 205–219, 1992.Google Scholar - 6.Clark, K.L., Negation as failure.
*Logic and Data Bases*, Gallaire, H., and Minker, J. (eds.), Plenum Press, pp. 293–322, 1978.Google Scholar - 7.Enderton, H.B.,
*A Mathematical Introduction to Logic*. Academic Press, 1972.Google Scholar - 8.Gabbay, D.M., Giordano, L., Martelli, A., and Olivetti, N.,. Hypothetical updates, priority and inconsistency in a logic programming language.
*Lecture Notes in Computer Science (LN in Artificial Intelligence)*928, Springer-Verlag, pp. 203–216, 1995.Google Scholar - 9.Gabbay, D.M. and Reyle, U., N-Prolog: An extension of Prolog with hypothetical implications.
*Journal of Logic Programming*2, pp. 319–355, 1984.MathSciNetCrossRefGoogle Scholar - 10.Gärdenfors, P.,
*Knowledge in the Flux: Modeling the Dynamics of Epistemic States*, MIT Press, 1988.Google Scholar - 11.Giordano, L. and Martelli, A., A modal reconstruction of blocks and modules in logic programming.
*International Logic Programming Symposium*, 1991.Google Scholar - 12.Giordano, L., Martelli, A., and Rossi, G., Extending Horn clause logic with implication goals.
*Theoretical Computer Science*, 1991.Google Scholar - 13.Ginsberg, L.M., Counterfactuals.
*Artificial Intelligence*30, pp. 35–79, 1986.zbMATHMathSciNetCrossRefGoogle Scholar - 14.Grahne, G., Mendelzon, A., Updates and subjunctive queries.
*Information and computation*116(2), pp. 241–252, 1995.zbMATHMathSciNetCrossRefGoogle Scholar - 15.Kakas, A. C., Kowalski, R., Toni,F., The Role of Abduction in Logic Programming, In:
*Handbook of Logic in Artificial Intelligence and Logic Programming*5, pages 235–324, D.M. Gabbay, C.J. Hogger and J.A. Robinson eds., Oxford University Press, 1998).Google Scholar - 16.Kowalski, R.A., Predicate logic as a programming language.
*Information Processing*74, pp. 569–574, 1974.zbMATHGoogle Scholar - 17.Kowalski, R.A., and Sadri, F., Logic programming with exceptions.
*Proc. of Eighth International Conference on Logic Programming*, MIT Press, pp. 598–613, 1991.Google Scholar - 18.Lewis, D,
*Counterfactuals*. Harward University Press, 1973.Google Scholar - 19.Lloyd, J.W.,
*Foundations of logic programming*, Second, extended edition. Springer-Verlag, 1987.Google Scholar - 20.Miller, D., Lexical scoping as universal quantification,
*Proc. of Sixth International Conference on Logic Programming*, MIT Press, pp. 268–283, 1989.Google Scholar - 21.Monteiro, L. and Porto, A., Contextual Logic Programming,
*Proc. of Sixth International Conference on Logic Programming*, MIT Press, pp. 284–302, 1989.Google Scholar - 22.Nait Abdallah, M. A., Ions and local definitions in logic programming,
*Lecture Notes in Computer Science*210, pp. 60–72, Springer-Verlag, 1986.zbMATHMathSciNetGoogle Scholar - 23.Pereira, L.M., Aparício, J.N., and Alfares, J.J., Counterfactual reasoning based on revising assumptions. Logic Programming, Proceedings of the 1991 Internal Symposium, MIT Press 1991.Google Scholar
- 24.
*SICStus Prolog user's manual*. Version 3 #6, SICS, Swedish Institute of Computer Science, 1997.Google Scholar - 25.Winslett, M., Updating Logical Databases.
*Cambridge Tracts in Theoretical Computer Science*, vol. 9, Cambridge University Press, 1990.Google Scholar