DBQUERY Chris Mellish September 1983 A DATABASE QUERY LANGUAGE ------------------------- The Prolog library package DBQUERY provides an alternative language for querying a Prolog database. This language is a suitable target for natural language understanding programs dealing with database queries. Expressions in the query language are POPLOG lists representing propositions in a manner similar to Predicate Logic. When a query is presented for evaluation, the system attempts to verify that the complex proposition it represents is true. As a side effect of verifying the truth of the main proposition, it may have to verify the truth of various subsidiary propositions. Some special propositions are always true and cause things (ANSWERS) to be printed out when they are encountered. Here are the kinds of expressions that can appear in this language. In the language, variables are represented by words consisting of the letter "X" followed by a number (NB The POP-11 notation for lists is used here): [all VARIABLE CONDITION GOAL] To check that this is true involves finding all the values of the VARIABLE which make the CONDITION true and then checking that for each of these values the GOAL is also true. [exists VARIABLE CONDITION GOAL] To check that this is true involves checking that there is a value of the VARIABLE that makes both the CONDITION and the GOAL true. [the VARIABLE CONDITION GOAL] The checking for this is as in the last case, except that, if the check does not succeed it is considered that there is an error in the question. [and CONDITION1 CONDITION2] To check this, check that both CONDITION1 and CONDITION2 are true. [not CONDITION] This checks out as true if the CONDITION checks out as false, and vice versa. [printout VARIABLE] This always checks out as true, but whenever it is encountered the current value of the VARIABLE is printed out. [PREDICATE ...ARGUMENTS...] This represents a proposition that can be verified by directly looking at the database (and possibly using Prolog inference rules). PREDICATE is a word specifying the relation involved and ARGUMENTS specify the objects involved in that relation. What predicates you can sensibly use and what arguments you can sensibly provide depend on what is in your database. Here are some examples of queries in this language, together with natural language questions that they might correspond to: [all X1 [man X1] [printout X1] ] "what men are there?" [all X1 [and [person X1] [exists X2 [monarch X2] [bore X1 X2] ] ] [printout X1] ] "who bore a monarch?" [all X1 [and [person X1] [exists X2 [bore X1 X2]]] [printout X1]] "which people have children?" You may notice a similarity between these forms and certain constructions in POP-11 and the Predicate Calculus. Using the System ---------------- The library file does not provide any special facilities for CONSTRUCTING database queries - that is up to other programs (eg natural language understanders) to provide. What it provides is the ability to answer a query that has already been constructed. The POP-11 procedure QUERY takes a list as argument and answers the query. A Prolog predicate, 'query' with 1 argument, provides the same capability. Shortcomings ------------ The way in which the system prints out answers to complex questions leaves a lot to be desired. Its error messages are also unhelpful - ideally some natural language generation is called for here (see "Cooperative Responses from a Portable Natural Language Database Query System" by J. Kaplan in "Computational Models of Discourse, edited by Brady and Berwick, MIT Press, 1983). References ---------- There are great similarities between this query language and that used by Woods in the LUNAR system. The following references cover some work on the use of similar languages for natural language querying of databases: Colmerauer, A., "An interesting subset of Natural Language", in Clark, K.L. and Taernlund, S. A., (Eds) LOGIC PROGRAMMING, Academic Press, 1982. Woods, W. A., "Semantics for Question Answering System", especially Chapter 9. Woods, W. A. paper in Zampolli, A. "Linguistic Structures Processing", North Holland. Woods, W. A. paper in "Advances in Computers", Vol 17, Ed. M. C. Yovits. Warren, D. and Pereira, F., "An Efficient Easily Adaptable System for Interpreting Natural Language Queries", AJCL Vol 8, Number 3-4, 1982. --- File: local/plog/help/dbquery --- Distribution: all --- University of Sussex Poplog LOCAL File ------------------------------