A deductive environment for dealing with objects and nonmonotonic reasoning

20
IEEE TRANSACTIONS ON KNOWLEDGE AND DATA ENGINEERING, VOL. 9, NO. 4, JULY/AUGUST 1997 539 A Deductive Environment for Dealing with Objects and Nonmonotonic Reasoning Nicola Leone, Pasquale Rullo, Antonella Mecchia, and Giuseppe Rossi, Member, IEEE Abstract—The BQM—an acronym that stands for Bottom-up Query machine, the role played by our system in the framework of the KIWIS system [2]—system extends deductive database technology with knowledge structuring capabilities to provide an advanced environment for the development of data and knowledge-based applications. The system relies on a knowledge representation language that combines the declarativeness of logic programming with the notions of object, inheritance with exceptions, and message passing. Exceptions are supported by allowing rules with negated heads. The use of exceptions inside the inheritance mechanism makes the language inherently nonmonotonic. The paper contains a comprehensive description of both the language and the implementation principles of the BQM system. It begins by providing a model-theoretic semantics of the language based on the notion of least model. A fixpoint semantics, providing a constructive definition of the least model, is given as well. Then, a number of implementation techniques for efficient query evaluation are described. Such techniques significantly extend “traditional” deductive database query evaluation strategies to deal with monotonic reasoning. A description of the architecture of the current prototype of the BQM system is also given. Index Terms—Deductive databases, object-oriented programming, nonmonotonic reasoning, logic programming, bottom-up evaluation, optimization techniques. ———————————————————— 1 INTRODUCTION ANY current research works are devoted to the exten- sion of database technology to deal with new sophis- ticated applications, such as expert systems, engineering applications, and advanced scientific applications. The two most fruitful approaches so far pursued are object- orientation [6], [24], [40] and logic query languages [1], [37], [38]. The former tends to abandon relational databases in favor of object-oriented ones, whereas the latter relies on the logic paradigm to extend relational domain calculus- based languages. Nonetheless, a third promising direction is emerging from the integration of the two above men- tioned approaches [3], [4], [15], [19]. Such a research line takes the viewpoint that combining the declarativity of logic programming with the abstraction mechanisms of the object-oriented paradigm allows to achieve high-level knowledge representation capabilities. Significant theoreti- cal advances in such a direction have been made in the last few years, and a number of systems, such as LDL [14], CORAL [33], Glue-NAIL! [29], LOGRES [12], and COMPLEX [17] have been developed. Finally, we mention the HERMES project in which an advanced system integrating various da- tabases with the commercial object-oriented system Ob- jectStore has been developed. This system uses annotated logic for amalgamating knowledge coming from multiple heterogeneous sources [35]. This paper presents the BQM system (often simply BQM), an advanced environment for data and knowledge-based applications that seeks to efficiently combine techniques of deductive database systems, such as inference capabilities and efficient treatment of large relations, with more powerful modeling capabilities and nonmonotonic reasoning. The main aspects of the system are summarized below. First, it supports a logic-based language including structuring constructs like object identity, (multiple) in- heritance with exceptions and message passing. Exceptions are fully integrated in the logic paradigm by allowing rules with negated heads along with preference criteria among such rules. Clearly, the capability to provide constructs for specifying exceptions in the context of an inheritance hier- archy makes the language intrinsically nonmonotonic. In essence, the BQM language (note that BQM is also used to name the language of the BQM system) is an an extension of Ordered Logic [22], [25], [26], [27] to deal with objects and cooperation among objects. We shall show that the BQM language has a semantics based on the notion of least model that provides a unique and intuitive meaning to any BQM program. A closer observation of this semantics re- veals that it is a generalization of the well-founded seman- tics of traditional logic programs [38]. Second, it is a sound and complete inference system (with respect to the least model semantics) that fully sup- ports the declarative semantics of the BQM language. It relies on a bottom-up model of computation based on a fixpoint semantics that, despite the nonmonotonicity of the language, allows us to monotonically build up the least model of any BQM program. Third, the BQM implementation principles feature tech- nology advances to efficiently support the characteristics of the language. We shall describe a number of evaluation 1041-4347/97/10.00 © 1997 IEEE ¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥ N. Leone is with the Information System Department, Technical Univer- sity of Vienna, A-1040 Vienna, Austria. E-mail: [email protected]. P. Rullo is with DIMET, Universita’ di Reggio Calabria, I-89100 Reggio Calabria, Italy. E-mail: [email protected]. A. Mecchia and G. Rossi are with CRAI, Loc. S. Stefano, I-87036 Rende, Italy. E-mail: {antonia, jred}@crai.it. Manuscript received 6 Sept., 1994; revised 26 May 1995. For information on obtaining reprints of this article, please send e-mail to: [email protected], and reference IEEECS Log Number 104405. M

Transcript of A deductive environment for dealing with objects and nonmonotonic reasoning

IEEE TRANSACTIONS ON KNOWLEDGE AND DATA ENGINEERING, VOL. 9, NO. 4, JULY/AUGUST 1997 539

A Deductive Environment for Dealingwith Objects and Nonmonotonic Reasoning

Nicola Leone, Pasquale Rullo, Antonella Mecchia, and Giuseppe Rossi, Member, IEEE

Abstract —The BQM—an acronym that stands for Bottom-up Query machine, the role played by our system in the framework of theKIWIS system [2]—system extends deductive database technology with knowledge structuring capabilities to provide an advancedenvironment for the development of data and knowledge-based applications. The system relies on a knowledge representationlanguage that combines the declarativeness of logic programming with the notions of object, inheritance with exceptions, andmessage passing. Exceptions are supported by allowing rules with negated heads. The use of exceptions inside the inheritancemechanism makes the language inherently nonmonotonic. The paper contains a comprehensive description of both the languageand the implementation principles of the BQM system. It begins by providing a model-theoretic semantics of the language based onthe notion of least model. A fixpoint semantics, providing a constructive definition of the least model, is given as well. Then, anumber of implementation techniques for efficient query evaluation are described. Such techniques significantly extend “traditional”deductive database query evaluation strategies to deal with monotonic reasoning. A description of the architecture of the currentprototype of the BQM system is also given.

Index Terms —Deductive databases, object-oriented programming, nonmonotonic reasoning, logic programming, bottom-upevaluation, optimization techniques.

——————————✦——————————

1 INTRODUCTION

ANY current research works are devoted to the exten-sion of database technology to deal with new sophis-

ticated applications, such as expert systems, engineeringapplications, and advanced scientific applications. The twomost fruitful approaches so far pursued are object-orientation [6], [24], [40] and logic query languages [1], [37],[38]. The former tends to abandon relational databases infavor of object-oriented ones, whereas the latter relies onthe logic paradigm to extend relational domain calculus-based languages. Nonetheless, a third promising directionis emerging from the integration of the two above men-tioned approaches [3], [4], [15], [19]. Such a research linetakes the viewpoint that combining the declarativity oflogic programming with the abstraction mechanisms of theobject-oriented paradigm allows to achieve high-levelknowledge representation capabilities. Significant theoreti-cal advances in such a direction have been made in the lastfew years, and a number of systems, such as LDL [14],CORAL [33], Glue-NAIL! [29], LOGRES [12], and COMPLEX[17] have been developed. Finally, we mention the HERMESproject in which an advanced system integrating various da-tabases with the commercial object-oriented system Ob-jectStore has been developed. This system uses annotatedlogic for amalgamating knowledge coming from multipleheterogeneous sources [35].

This paper presents the BQM system (often simply BQM),an advanced environment for data and knowledge-basedapplications that seeks to efficiently combine techniques ofdeductive database systems, such as inference capabilitiesand efficient treatment of large relations, with more powerfulmodeling capabilities and nonmonotonic reasoning. Themain aspects of the system are summarized below.

First, it supports a logic-based language includingstructuring constructs like object identity, (multiple) in-heritance with exceptions and message passing. Exceptionsare fully integrated in the logic paradigm by allowing ruleswith negated heads along with preference criteria amongsuch rules. Clearly, the capability to provide constructs forspecifying exceptions in the context of an inheritance hier-archy makes the language intrinsically nonmonotonic. Inessence, the BQM language (note that BQM is also used toname the language of the BQM system) is an an extensionof Ordered Logic [22], [25], [26], [27] to deal with objectsand cooperation among objects. We shall show that theBQM language has a semantics based on the notion of leastmodel that provides a unique and intuitive meaning to anyBQM program. A closer observation of this semantics re-veals that it is a generalization of the well-founded seman-tics of traditional logic programs [38].

Second, it is a sound and complete inference system(with respect to the least model semantics) that fully sup-ports the declarative semantics of the BQM language. Itrelies on a bottom-up model of computation based on afixpoint semantics that, despite the nonmonotonicity of thelanguage, allows us to monotonically build up the leastmodel of any BQM program.

Third, the BQM implementation principles feature tech-nology advances to efficiently support the characteristics ofthe language. We shall describe a number of evaluation

1041-4347/97/10.00 © 1997 IEEE

¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥

• N. Leone is with the Information System Department, Technical Univer-sity of Vienna, A-1040 Vienna, Austria. E-mail: [email protected].

• P. Rullo is with DIMET, Universita’ di Reggio Calabria, I-89100 ReggioCalabria, Italy. E-mail: [email protected].

• A. Mecchia and G. Rossi are with CRAI, Loc. S. Stefano, I-87036 Rende,Italy. E-mail: {antonia, jred}@crai.it.

Manuscript received 6 Sept., 1994; revised 26 May 1995.For information on obtaining reprints of this article, please send e-mail to:[email protected], and reference IEEECS Log Number 104405.

M

540 IEEE TRANSACTIONS ON KNOWLEDGE AND DATA ENGINEERING, VOL. 9, NO. 4, JULY/AUGUST 1997

techniques that significantly extend the query evaluationstrategies in deductive databases to efficiently deal withnonmonotonic reasoning. In particular,we shall define aclass of BQM programs, called stratified programs, for whichthe computation of the least model can be carried out in avery simple and efficient fashion. The evaluation of suchprograms is further improved by extending to them well-known optimization techniques developed for deductivedatabases. In particular, we shall show how the General-ized Magic Set method [8], despite the novelties of the lan-guage, can be easily adapted to such programs.

Compared to the above mentioned systems (LDL,CORAL, etc.), the main novelty of BQM is the support ofnonmonotonic reasoning by true negation which, stemmingfrom a rather natural combination of objects and inheri-tance with exceptions into logic programming, significantlyextends the knowledge modeling capabilities of other de-ductive systems (e.g., NAIL!, COMPLEX, LDL). However,being originally conceived as a subsystem of KIWIS [2], theBQM language was designed as a declarative query lan-guage rather than a database programming language and,as such, it does not include all functionalities of a full-fledged programming language (e.g., updates and I/O)supported by systems like Glue-NAIL! and CORAL. Fromthe implementation point of view, BQM shares, with alldeductive database systems, the common objective of effi-cient manipulation of large amounts of data. In particular,some basic optimization techniques, such as rewriting pro-gram methods, widely used by many such systems (NAIL!,LDL, COMPLEX) are opportunely extended to cope withnonmonotonic reasoning.

The BQM system has been developed in the context ofKIWIS, an advanced environment for large database sys-tems, which supports knowledge-based applications andprovides a seamless integration of information comingfrom different external sources [2]. Inside KIWIS, BQM is incharge of performing the bottom-up evaluation of queries.

A prototypical version of BQM, both as a standalonesystem as well as a layer of the KIWIS system, has beenimplemented and is available on Sun Workstations.

The rest of the paper concentrates on the language(Section 2), the implementation principles (Section 3) andthe architecture of BQM (Section 4).

For lack of space, we have suppressed the proofs of the results.The complete proofs as well as additional details on the BQM canbe found in the technical report [21], which is available via e-mail-request to the authors.

2 THE LANGUAGE OF BQMThe BQM language integrates the notions of object and in-heritance with exceptions in the context of the logic para-digm. Further, it supports cooperation among objects. Fol-lowing some recent proposals [16], [20], [25], exceptions areexpressed by allowing negative rules (i.e., rules with ne-gated heads). Negation is treated as true negation, althoughClosed World Assumption can easily be modeled (see Section2.5). The presence of exceptions in an inheritance hierarchymakes the language nonmonotonic. A desirable property ofthe language is that of maintaining, from the deductive ap-

proach, a clearly defined semantics along with a declarativestyle of programming.

In this section, we start with an overview of the lan-guage, and then we provide a formal presentation of boththe syntax and the declarative semantics. A fixpoint se-mantics is also given. Then, we show that the BQM lan-guage generalizes the well-founded semantics of traditionallogic programs, and give a discussion on the complexityand the expressibility of the language.

2.1 OverviewNext, we provide a number of examples to give the flavorof the BQM language.

As a very basic starting point, a knowledge base (KB, forshort) consists of a number of objects, each one distin-guished by a (unique) identifier and composed of a set offacts and rules.

EXAMPLE 2.1 (Objects). Let us consider a KB consisting of thefollowing object:

fred = {name(“Fred”) ←; married ← wife(X); wife(sally ) ←}

where fred is the object identifier. The meaning of thisobject is rather clear: fred has name “Fred,” has wifesally and, hence, is married (notice that sally is theidentifier of an object, while ”Fred” is a string). Thus,the meaning of fred could equivalently be representedby facts name(fred, “Fred”), wife(fred, sally), and mar-ried(fred).

Thus, an object can be seen as a logical theory (with aunique identifier) whose meaning is the set of properties(literals) that are derivable from its rules. From an object-oriented perspective, one can regard facts and rules as dataand methods, respectively. A theory is the natural analogueof the notion of encapsulation in the object-oriented model.We notice that constants appearing in an object are objectidentifiers (also strings, such as “fred” in the above example,and integers are regarded in our model as identifiers ofobjects with an empty theory, as shown in the next section).That is, the universe of the language is made of object iden-tifiers. Thus, each fact is actually an aggregate of objectidentifiers, so that it can be regarded as a relationshipamong objects. As an example, the fact wife(sally) aboveexpresses a relationship between the objects fred and sally.This points out the object-based nature of the language.

However, as programs normally consist of several re-lated objects, the meaning of a single object generally doesnot depend only on its own facts and rules. Indeed, objectsare organized into an inheritance hierarchy, which is thelogical equivalent of the specialization relation of the object-oriented paradigm.Intuitively speaking, when we say thatan object o is a specialization (or subobject) of another objecto’ (which, in turn, is a superobject of o), we are stating thatwhatever is true for o’ is also true for o (unless explicitlycontradicted).

EXAMPLE 2.2 (Inheritance). Consider the following KB, wherefred is now a subobject of person. (Note: each object ispreceded by the list of its immediate superobjects).

person = {married ← wife(Y)}(person) fred = {wife(sally) ←; name(”Fred”) ←}

LEONE ET AL.: A DEDUCTIVE ENVIRONMENT FOR DEALING WITH OBJECTS AND NONMONOTONIC REASONING 541

It should be intuitively clear that the properties of fredhave not changed from the previous example. Therule for married is inherited from person so that marriedcan be inferred for fred.

Thus, each object has its own perception of the knowl-edge base, given by its local rules plus some inherited rules,that is, those coming from the “upper” objects in the in-heritance hierarchy. The meaning of an object is now de-fined as the set of literals derivable from its completed logicaltheory (i.e., the union of its own rules plus those inheritedfrom its super objects). Thus, inheritance yields a modularrepresentation of information, allowing different objects toshare common pieces of knowledge. Referring to the aboveexample, the rule married ← wife(Y) automatically holds forall instances of person (which might be thousands) withoutthe need of being replicated for each of them.

We note that the language so far described supports asort of implicit cooperation mechanism among objects. In-deed, a property of a given object can be defined in terms ofother properties defined in any of its superobjects. How-ever, this approach still lacks generality, as cooperationamong incomparable (in the inheritance hierarchy) objectsis often required. In order to allow such a cooperation, weextend the language by allowing prefixed body literals,called referential literals (a similar approach has been pro-posed in [28]).

EXAMPLE 2.3 (Message Passing). Consider the BQM knowledgebase IKfred consisting of the following two objects:

fred = {is_father ← X.has_father(fred)} john = {has_father(fred) ←}

The rule in the object fred says that fred is father ifthere exists an object X for which the propertyhas_father(fred) holds.

Thus, in general, from an object-oriented point of view, areferential literal can be seen as an (explicit) request to someobject to execute one of its methods. In logic programming,a referential literal, say o.p, should be read as “p is true inthe object o.”

Let us now return our attention to the inheritance hierar-chy. As already mentioned, a key feature of our language isits exception mechanism, i.e., the mechanism whereby asubobject inherits all properties but those it explicitly con-tradicts. Following the approach of ordered logic pro-gramming [22], [25], [27], exceptions are handled by al-lowing negative rules, i.e., rules with negative heads, alongwith preference criteria among such rules. Thus, a certainliteral is true for an object if it is derivable from some ruleand, further, it is not contradicted by a more specific rule.We notice that, unlike traditional logic programming, ne-gation is treated as true negation, i.e., a negative literal istrue only if it is derivable from some rule of the program. Inother words, negative information is considered as valuableas positive information (true negation).

EXAMPLE 2.4 (Exceptions). Consider the following BQMknowledge base IKtom :

person = {taxPayer ←}

(person) unemployed = {¬taxPa er ← ¬rich} (unemployed) tom = {¬rich ←} (unemployed) john = { }

The property taxPayer acts as a “default”: It is visiblefrom all person’s subobjects, and it holds unless ex-plicitly contradicted. Thus, john is a taxPayer (as noexceptions are specified for him), while tom is not. In-deed, tom is not rich and, further, the rule r: ¬taxPayer¬rich holds (as inherited from unemployed). This ruleis considered a sort of refinement to the default ruler’: taxPayer ←, as the inheritance hierarchy explicitlystates the specificity of the former (we say that r over-rules r’). Thus, although both taxPayer and ¬taxPayerare derivable for tom, the latter prevails on the former.We point out that ¬taxPayer is derivable for tom as¬rich is explicitly stated (true negation).

Unlike the situation above, where the ordering betweenthe involved objects suggests an intuitive solution to con-tradictions, there are many real-world situations that areintrinsically ambiguous. The well known Nixon Diamondexample, shown next, illustrates a case of ambiguity deter-mined by multiple inheritance.

EXAMPLE 2.5 (Defeating). The Nixon Diamond BQM knowl-edge base IKnix is shown below:

quaker = {pacifist ← } republican = {Øpacifist ← } (quaker republican) nixon = { }

This KB states: quakers are pacifist, republicans arenot pacifist, nixon is both a quaker and a republican.Now, what is the meaning of the object nixon or, putanother way, is nixon a pacifist or not? The point hereis that there is no correlation between republican andquaker and, hence, no indication of which point ofview should be trusted: The network is perfectly am-biguous and both conclusions are rejected or, as wesay, defeated.

We conclude this overview of the BQM language pre-senting a final more involved example. In [20], it has beenshown that a logic program can conveniently be used toexpress the sentences of a legal act, including the manynegative statements representing exceptions. In the fol-lowing example, we exploit this idea and describe a knowl-edge base representing a (small) part of the knowledge of ajudicial office.

EXAMPLE 2.6. In what follows we envisage a KB, that we callKBjudge, made of two hierarchies of objects: one de-scribes a hierarchy of persons, whereas the other clas-sifies crimes. These two hierarchies are related byrules describing how the law applies to differentcases. To make the example easier, we do not refer toany real legislation, although rather realistic assump-tions are made.

In the crime hierarchy (see Fig. 1), each crime is ei-ther heavy or light.Thus, crime is the highest object inthe hierarchy, heavy-fault and light-fault are its subob-jects, while the objects representing actual crimes are-subobjects of either heavy-fault or light-fault. Heavy

542 IEEE TRANSACTIONS ON KNOWLEDGE AND DATA ENGINEERING, VOL. 9, NO. 4, JULY/AUGUST 1997

crimes are punished by detention, while light crimesare those for which a fine is provided by law. Thus,each heavy crime is characterized by the property de-tention(X), where X is the penalty in terms of years ofjail, whereas each light crime shows the propertyfine(X), where X is the amount of money (in thou-sands of italian liras) to be paid. The part of KBjudgeconsisting of the objects in the crime hierarchy is re-ported next.

crime = { } (crime) heavy -fault = { } (crime) light-fault = { } (heavy-fault) car-theft = {detention(1) ←} (heavy-fault) bribery = {detention(6) ←} (heavy-fault) murder = {detention(20) ←} (light-fault) bag-snatching = {fine(2,000) ←} (light-fault) house-breaking = {fine(12,000) ←}

Here, car-theft, bribery, and murder are heavy faults,for which a detention of 1, 6, and 20 years is pre-scribed, respectively; while bag-snatching and house-breaking are light faults, for which a fine of 2 and 12million of liras is provided by law, respectively.

Fig. 1. The crime hierarchy.

Let us now consider the person hierarchy, which is-represented in Fig. 2. Here, persons are classified intoprejudged and nonprejudged, where a prejudged is aperson who committed some heavy crime in the past.A subobject of nonprejudged is member-of-parliamentwhich, in turn, has the subobject unprivileged. Thelatter collects the member of the parliament who weredeprived of the parliamentary immunity. Each of theobjects prejudged, nonprejudged, member-of-parliament,and unprivileged has also a number of subobjects rep-resenting single instances of persons.

Fig. 2. The person hierarchy.

We notice that the person hierarchy has beenstructured in such a way to meet the juridical point ofview, as the legislation provides specific laws for eachof the abovementioned classes of people. Thus, eachof the objects above some rules defining the lawswhich apply on its subobjects.

There are two general laws, holding for all persons,stating that who is guilty of a crime is punished bylaw. In particular, a person either

1) is jailed for X years, if he is guilty of a crime forwhich a detention of X years is required, or

2) is obliged to pay a fine of X thousands of liras, if heis guilty of a crime for which a fine of X thousandsof liras is provided.

Hence, the object person is defined as follows:

person = {jailed(X) ¬ guilty(X), Y.detention(X) pay-fine(X) ¬ guilty(X), Y.fine(X)}

No exception to the general laws is provided forprejudged people; thus, the theory of the object pre-judged is empty:

(person) prejudged = { }.

Our legislation allows a nonprejudged that is con-demned to avoid the jail provided that the detentionis less than two years. Then, we define in the objectnonprejudged a rule for Øjailed that contradicts thegeneral one:

(person) nonprejudged = {Øjailed(X) ¬ guilty(Y), Y.detention(X), X £ 2}

Members of the parliament enjoy a stronger privi-lege, as there is a law stating they cannot go into jail,independently of the fault possibly made. Hence:

(nonprejudged) member-of-parliament = {Øjailed(X) ¬}

However, it is possible that a special commissionof the parliament decides for the admissibility of theprison, provided that the fault does not depend onsome political tamperings. In the sample KB, themembers of the parliament for which the commisiondecided for the admissibilty are the subobjects of un-privileged. Thus, the general law about the jail, definedfor common people, also applies to “unprivileged”members of the parliament:

(member_of_parliament) unprivileged = {jailed(X) ¬ guilty(Y), Y.detention(X)}

So far we have described laws and their range ofapplicability, i.e., the knowledge allowing the judge tomake decisions. Next, we represent the personsscheduled in the judicial office (as guilty of somecrime):

(prejudged) mary = {guilty(bag-snatching) ¬} (nonprejudged) joseph = {guilty(murder) ¬} (nonprejudged) john = {guilty(car-theft) ¬} (unprivileged) mark = {guilty(bribery) ¬} (member-of-parliament) peter = {guilty(bribery) ¬}

LEONE ET AL.: A DEDUCTIVE ENVIRONMENT FOR DEALING WITH OBJECTS AND NONMONOTONIC REASONING 543

Now that the description of KBjudge is completed, itis worth noting the role played by referential literalsin relating pieces of knowledge defined on differenthierarchies, namely, the crime and the person hierar-chies. For an instance, in the rule jailed(X) ¬ guilty(Y),Y.detention(X) of the object person, the variable Y al-lows us to associate with a person who is guilty acrime Y the corresponding detention, which isa prop-erty of some object of the crime hierarchy. Thus, refer-ential literals can be regarded as a mechanismwhereby to access, from a given object, the knowledgeof other unrelated objects (i.e., objects that are not“visible” in the inheritance hierarchy).

Finally, we can see what happens to joseph, john, pe-ter and mark, i.e., how the laws apply to their situations.

A first possible question is: “who goes into jail andfor how long will he be jailed?” In the BQM languagethe question corresponds to the query X.jail(Y). The an-swer to this query is given by the following set of facts:

{joseph.jailed(20), mark.jailed(6)}

Indeed, joseph is condemned according to the generalrule (defined in the theory of person), as he committed acrime (murder) for which 20 years of jail are providedby law. In turn, mark is a member of the parliament forwhich the commission has given the admissibility (he isa subobject of unprivileged). Hence, even as member ofthe parliament, he is condemned to six years of jail. Infact, the rule jailed(X) ¬ guilty(Y), Y.detention(X), de-fined on its direct superobject unprivileged, overrulesthe fact Øjailed(X) ¬ defining the immunity for themember of the parliament. Notice that john, who stole acar, does not go into jail, enjoying the privilege definedfor nonprejudged, since the detention provided for car-theft is less than two years. Moreover, the parliamentarpeter, who is guilty of bribery, differently from thebriber mark, does not go into jail, as he holds the par-liamentary immunity.

Now we pose the following questions: “whoshould pay a fine, and what is the amount of the fineto be paid?” In the BQM language, this is expressedby the query X.pay-fine(Y). It is easily seen that the an-swer to such a query is {mary.pay-fine(2000)}, as thegeneral law pay-fine(X) ¬ guilty(Y), Y.fine(X) does notadmit any exception and applies on every people.

The above example points out the suitability of the BQMlanguage to represent real situations. As already pointedout, the example has been inspired by one from [20], wherethe authors prove that negative logic programs (i.e., logicprograms with negation allowed also in the head of therules) are well suited to represent legislation, as negativerules permit to express exceptions to general laws (veryfrequent in any legislation). Actually, the BQM languageappears even more adapt to represent such a situation, as itallows us to naturally describe multilevel exceptions (i.e.,exceptions, exceptions to exceptions, etc.).

2.2 Syntax

Let ObjU, ObjI, and ObjS be disjoint finite sets of strings fromthe English alphabet, integer numbers, and quoted strings

from the English alphabet, respectively. Let (Obj, £) be afinite partially ordered set of object identifiers (or simply“identifiers”), where Obj = ObjU È ObjI È ObjS. The elementsfrom ObjI È ObjS are called built-in identifiers; while elementsfrom ObjU are called user-defined identifiers. Each built-inobject identifier o is incomparable with any other element ofObj, i.e., there does not exist o’ ¹ o such that o £ o’ or o’ £ o.Intuitively, the relation £ represents the object/subobjecthierarchy. In particular, if o < o’, where < represents thereflexive reduction1 of £, we say that o is a subobject of o‘and o‘ is a superobject of o. (Note that, being < a subset of thepartial order £, it is acyclic; thus, if o is a subobject of o‘,then o’ cannot be a subobject of o.) Let Pred be a finite set ofpredicates and Var a finite set of variables. With each elementof Pred is associated a nonnegative integer, its arity. A termis either a constant in Obj or a variable in Var. An atom isp(t1, ..., tn), where p is a predicate of arity n in Pred, and t1, ...,tn are terms, called arguments. We shall often denote anatom as p X( ), where X stands for its arguments. A simpleliteral is either a positive literal P or a negative literal ØP,where P is an atom. A referential literal is t.L, where t is aterm (which is called the referential term of t.L) and L is asimple literal. A literal is either a simple literal or a referen-tial literal. Two simple (referential) literals are complemen-tary if they are of the form P (t.P) and ØP (t.ØP), for someatom P. Given a literal L, Ø.L denotes its complementaryliteral, i.e., if L is a positive literal P (resp. o.P), then Ø.L =ØP (resp. ØL = o.ØP), if L is a negative literal ØP (resp.o.ØP), then Ø.L = P (resp. Ø.L= o.P). Accordingly, given aset X of literals, Ø.X denotes the set {Ø.L|L Î X}. A rule r is astatement of the form H ¬ B, where H, the head of r, is aliteral and B, the body of r, is a (possibly empty) set of liter-als. We shall often denote the head of r by Head(r) and itsbody by Body(r). We point out that the head of a rule maybe a negative literal. An object is a pair (o, T(o)), where o ÎObj and T(o), the theory of o, is a finite set of rules.We as-sume that referential literals only appear in the body of therules of T(o). If o is a user-defined (built-in, resp.) identifierthen (o, T(o)) is a user-defined (built-in, resp.) object. Thetheory of a built-in object is empty.2

DEFINITION 2.1 (Knowledge Base). A knowledge base (or simplyKB) is a pair ( IK , £) where: IK is a set of objects such thatthere is one object (o, T(o)) in IK for each o Î Obj, and £ isthe binary relation induced on IK by the relation £ on Obj.

In the following, we shall often denote a KB simply byIK . A query is a referential literal t.L.

We remark that the syntax informally adopted in Section2.1 can be straightforwardly mapped onto the above defini-tions. Syntactically, a user-defined object (o, T(o)), where:

1) T(o) consists of the rules r rm1 � , and2) o1 ... on are the direct superobjects of o in IK ,

is represented by (o1 ... on ) o = {r1 ... rm}.

1. Recall that the reflexive reduction of a binary relation R is the relationR’ = {(a, b) Î R|a ¹ b}.

2. In the following examples, we shall obviously omit the representationof built-in objects.

544 IEEE TRANSACTIONS ON KNOWLEDGE AND DATA ENGINEERING, VOL. 9, NO. 4, JULY/AUGUST 1997

2.3 Declarative SemanticsIn the following we give a model-theoretic semantics de-fining the meaning of a KB as the smallest model for it.Throughout this section, we assume that a knowledge baseIK has been fixed.

We start by defining the notion of BQM program (simply“program,” whenever no confusion arises). As it will beclear later in this paper, this notion can be convenientlyused as a suitable representation of a knowledge base forgiving both semantics and implementation principles.

DEFINITION 2.2 (Program). A (generic) program of IK is a pair( IP, obj-of) where

1) IP is a finite multiset of rules of the form o.L ¬ t1.L1, ...,tn.Ln where o ÎObj and ti.Li, 1 £ i £ n, is a referentialliteral, and

2) obj-of is a function from IP to Obj such that, for eachrule r Î IP with head, say, o.L, the condition o £obj-of(r) holds.

The notion of (generic) program indicates the constraintsthat a set of rules must satisfy in order to be a program ofIK . We next specialize the above definition to give the morespecific notion of the program of the knowledge base IK . Tothis end, we need some preliminary definitions.

As informally pointed out in Section 2.1, the knowledge“perceived” by an object, besides the rules in its theory,includes the rules contained in the theories of its superob-jects. This reflects the semantics of inheritance in the object-oriented paradigm. Thus, with each object we associate acompleted theory consisting of all rules that are either definedfor it or inherited from its superobjects.

DEFINITION 2.3 (Completed Theory). Let (o, T(o)) be an object inIK . The completed theory of (o, T(o)) is the pair (T*(o), obj-ofo), where

1) T*(o) is the multiset ∪ ′≤

+o o

T o'

( ) , where È+ denotes the

operator of union with duplicates, and2) obj-ofo: T*(o) ® Obj; r ® o’, where o’ is the object iden-

tifier such that r Î T(o’).

We observe that if a rule occurs, say, in two differenttheories “visible” from o, then it appears twice in T*(o).Thus, obj-ofo is actually a function associating with each rulein T*(o) the object it comes from, i.e., given a rule r Î T*(o),obj-ofo(r) is the (unique) object identifier of the theory wherer is defined.

EXAMPLE 2.7. The completed theory T*(tom) for the objecttom of IKtom (see Example 2.4) consists of the follow-

ing rules: r1: taxPayer ¬, r2: ØtaxPayer ¬ Ørich, and r3:

Ørich ¬. The function obj-oftom for T*(tom) is {(r1, per-

son), (r2, unemployed), (r3, tom)}.

We point out that, due to the presence of referential lit-erals in rule bodies, the semantics of an object cannot, ingeneral, be completely defined by the rules in its completedtheory, as it might be affected by the semantics of the ob-jects that are referred (through referential literals). That is,objects cannot be considered independently of each other,but rather as interacting entities. Thus, in general, the entire

knowledge base has to be considered in order to assign a“meaning” to an object. To this end, it is convenient to de-fine the notion of flat version of the knowledge base IK ,that we call (BQM) program of IK . Informally, this is an un-structured representation of IK , where features like objectsand inheritance are not explicitly represented. The infor-mation on the structure of IK is mantained through a re-writing of rules that explicitly associates with each rule inT*(o) the object identifier o. We do this simply by prefixingeach simple literal L by the label o (in fact, L in T*(o) is actu-ally a shorthand for o.L, with the prefix o being implicit).Let us denote by go the syntactic transformation functionthat performs the above rewriting of a rule r ÎT*(o), that is,go(r) is the rule obtained from r by replacing each simple

literal L by o.L. We denote by go (T*(o)) the multiset whose

elements are the rules go(r) such that r Î T*(o). Moreover,

we denote by go-1 the inverse of function go (note that go

-1

exists, as go is a bijection from T*(o) onto go (T*(o))).

DEFINITION 2.4 (The Program of a KB). The program of IK is thepair ( IP , obj-of), where IP g T o

o Obj o= È+

Î

( * ( )) and

obj-of: IP ® Obj, obj of obj of go Obj o oo- -= ÈÎ

-1.

Note that, given a rule r Î IP coming from T*(o) (i.e.,such that g r T oo

1( ) * ( )), obj-of(r) = o’ iff o’ = obj-ofo ( ( )g ro-1 )

(that is, g ro−1( ) comes from the superobject o’ of o). Hence,

obj-of extends the functions obj-ofo , associating to each rule rin IP the object from which r comes from.

It is easy to see that the program of IK is a (generic) pro-gram (according to Definition 2.2). For simplicity of nota-tion, in the following we shall often denote ( IP , obj-of) sim-ply by IP . Note that, having fixed IK , the program IP is alsofixed.

EXAMPLE 2.8. Reconsider IK nix defined in Example 2.5. Theassociated program is ( , )IP obj ofnix - , where IPnix con-sists of the following rules

r1: quaker.pacifist ¬

r2: republican. Øpacifist ¬

r3: nixon.pacifist ¬

r4: nixon. Øpacifist ¬

and obj-of is the following set of pairs: {(r1, quaker), (r2,

republican), (r3, quaker), (r4, republican)}. From( , )IP obj ofnix - we can easily see that, for instance, rule

r4 belongs to the completed theory of nixon (as the

head literal of r4 is prefixed by nixon) and is inherited(by nixon) from the object of IKnixon with identifier re-

publican (as the pair (r4, republican) is in obj-of).For another example, for the KB IKfred (defined in

Example 2.3) we have IPfred consisting of the rules

r5: fred.is-father ¬ X.has-father(fred)

r6: john.has-father (fred)

and obj-of = {(r5, fred), (r6, john)}.

LEONE ET AL.: A DEDUCTIVE ENVIRONMENT FOR DEALING WITH OBJECTS AND NONMONOTONIC REASONING 545

Now that we have defined the flat version IP of IK , weprovide a semantics for IK in terms of IP . IK .

The Base of IP , denoted by BIP , is the set of all groundreferential literals constructible from the elements of Objand the predicates appearing in IP (clearly, BIP is finite).Note that BIP also contains negative literals. This reflectsthe fact that, due to the presence of negative rule heads,negative literals are considered to be as valuable as positiveones in our language.

A substitution is a mapping s from the set Var to Obj. (Bya little abuse of notation, given a substitution s, we shalloften write s(E), even if E is not a variable, to denote thesyntactic expression obtained from E by replacing everyvariable X in E by s(X). For instance, if E is a rule, s(E) de-notes the ground rule where each variable X appearing in Eis replaced by s(X).) Let r be a rule occurring in IP . Aground instance of r is any ground rule s(r) obtained by ap-plying a substitution s to r. We define the instantiation of IPto be the pair (ground( IP ), obj-of), where ground( IP ) is themultiset consisting of all possible ground instances of therules in IP (notice that if a rule occurs more than once in IPthen we require that the respective ground instances aredistinct) and obj-of is the natural extension to ground( IP ) ofthe function obj-of defined on IP , associating with each rulein ground( IP ) an object identifier. In particular, if �r is aground instance of r, then obj-of ( �r ) = o iff o = obj-of(r).

Given a set X BIP⊆ , a ground literal Q is true (resp., false)w.r.t. X if Q Î X (resp., Q ÎØ.X). The set of literals, whichare neither true nor false w.r.t. X is denoted X (i.e.,X B X XIP= - È Ø( . )). The elements of X are undefined lit-erals. X is consistent if X XÇØ = /. O . An interpretation for IPis any consistent subset I of BIP . An interpretation I is total ifI is the empty set; otherwise it is partial. (Notice that a lit-eral cannot be true and false at the same time w.r.t. an in-terpretation I.) For instance, let B a a b b c cIP = Ø Ø Ø{ , , , , , }and X = {a, Øa, b}; then, literals a, Øa and b are true, a, Øaand Øb are false, and c and Øc are undefined w.r.t. X (notethat a is both true and false w.r.t. X; this can happen be-cause X is not an interpretation).

Let I be an interpretation for IP and r be a (ground) rulein ground( IP ). The body of r is true w.r.t. I if it is containedin I (i.e., every body literal is true w.r.t. I); it is false w.r.t. I ifit contains some literal which is false w.r.t. I. Then, r is truew.r.t. I if either the head of r is true w.r.t. I or its body is nottrue w.r.t. I.

Next, we introduce the concept of model for IP . Unfor-tunately, unlike traditional logic programming, the notionof truth of a rule is not sufficient for our purposes, as it doesnot take into account the presence of explicit contradictions.Indeed, in our case, negation in the head is allowed andpossible inconsistencies must be resolved. Hence, somepreliminary definitions are needed.

DEFINITION 2.5 (Overruling). Let X be any subset of the Base BIP .A rule r Î ground(IP ) is overruled in X if there exists r’ Îground(IP ) such that all of the following conditions hold:

1) obj-of(r’) < obj-of(r) (i.e., the object of r‘ is a subobject ofthe object of r),

2) Head(r) =Ø.Head(r’) (i.e., the heads of r and r‘ are com-plementary literals),

3) Body(r’)Í X (i.e., each literal in the body of r’ is truew.r.t. X).

EXAMPLE 2.9. The rules of ground( IPtom ) (the KB IKtom is re-ported in Example 2.4) are shown below (note that,since the predicates appearing in IPtom are all of arityzero, then ground( IPtom ) coincides with IPtom ):

r1 : person.taxPayer ¬r2 : unemployed. ØtaxPayer ¬ unemployed. Ørichr3 : unemployed.taxPayer ¬r4 : tom. ØtaxPayer ¬ tom.Ørichr5 : tom.taxPayer ¬r6 : tom. Ørich ¬r7 : john.taxPayer ¬r8 : john. ØtaxPayer ¬ john. Ørich

The function obj-of is made up of the following set ofpairs: {(r1, person), (r2, unemployed), (r3, person), (r4, un-employed), (r5, person), (r6, tom), (r7, person), (r8, unem-ployed)}.

Let X = {tom. Ørich} be given. It is clear that rule r5is overruled in X. Indeed, rule r4 has a complementaryhead, its body is in X and, further, obj-of(r4) = unem-ployed, obj-of(r5) = person and unemployed < person. In-formally, this corresponds to the intuition that r4 ispreferable to r5 because coming from a more specificobject in the inheritance hierarchy. In other words,rule r4 is considered as a sort of refinement of themore general rule r5.

DEFINITION 2.6 (Unfounded Set). Let I and X be two sets ofground literals. We say that X is an unfounded set for IPwith respect to I if each literal Q Î X satisfies the followingcondition. For each rule r Î ground( IP) with head Q, (atleast) one of the following holds:

1) Body(r) ÇØ ¹ /. OI (i.e., some literal in Body(r) is falsew.r.t. I),

2) Body(r) Ç ¹ /X O , or

3) r is overruled in I.

Note that the above conditions 1 and 2 are the adaptationof the conditions of unfoundness given for traditional logicprograms [38], while condition 3 is needed because of thepresence of complementary head literals. Intuitively, thepeculiarity of an unfounded set is that there is no way toinfer its elements from a program, so that we shall never becontradicted by assuming the truth of the complement ofany literal in an unfounded set. Clearly, the union of twounfounded sets w.r.t. I is an unfounded set w.r.t. I as well.We denote by GUS IIP ( ) the greatest unfounded set for IPw.r.t. I, i.e., the union of all unfounded sets for IP w.r.t. I.

EXAMPLE 2.10. Given the program IPtom and the interpreta-tion I = {tom. Ørich}, the set X = {john. Ørich, john.ØtaxPayer, tom.taxPayer} is an unfounded set (for IPtomw.r.t. I). Indeed, referring to ground( IPtom ) shown inExample 2.9,

1) the ground rule r8 with head john. ØtaxPayer veri-fies condition 2 of Definition 2.6 as its body literaljohn. Ørich is in X,

546 IEEE TRANSACTIONS ON KNOWLEDGE AND DATA ENGINEERING, VOL. 9, NO. 4, JULY/AUGUST 1997

2) the ground rule r5 with head tom.taxPayer is over-ruled in I (see the previous example) thus verifyingcondition 3, and

3) no ground rule exists for john. Ørich (thus, no con-dition has to be verified for it).

For another example, let us consider the programIPnix . It is easy to realize that {quaker. Øpacifist, republi-can.pacifist} is the greatest unfounded set for IPnixw.r.t. the empty interpretation.

PROPOSITION 2.1. GUSIP is a monotonic transformation in( , )2BIP Í .3

We are finally ready to provide the definition of model.We have already stated that a model M of a BQM programIP cannot be simply defined as an interpretation making allrules in ground( IP ) true. Indeed, we may allow a rule r to befalse in M (i.e., its body is true in M while its head is false inM) provided that it is contradictable. More precisely, givenan interpretation I, we say that a rule r Î ground( IP ) is con-tradictable w.r.t. I if Ø.Head(r) Ï GUS IIP ( ).

DEFINITION 2.7 (Model). Let M be an interpretation for IP . Wesay that M satisfies a rule r Î ground( IP) (or r is satisfiedin M) if either

1) r is true w.r.t. M or2) r is contradictable w.r.t. M. A model for IP is an inter-

pretation that satisfies every rule in ground( IP ).

REMARK. It is worth noting that if r is not true in M (hence, itis contradictable w.r.t. M) then there exists another ruler’ with complementary head, such that r is not morespecific than r’ (i.e., not obj-of(r) < obj-of(r’)), r’ is notoverruled in M and, further, the body of r’ does notcontain any literal which is either false or unfoundedw.r.t. M. In proof, r not true implies Ø.Head(r) ÏGUSIP (M). Hence, there exists (at least) one rule inground( IP ), with head Ø.Head(r), for which none of theunfoundness conditions of Definition 2.6 is satisfied.Let R be the set of such rules. Now, it can be easilyseen that r cannot be more specific than all rules in R,i.e., obj-of(r) < obj-of(r’) cannot hold for each r’ Î R. Toshow this, assume the contrary holds, i.e., obj-of(r) < obj-of(r’), for every rule r’ Î R. Then, since Body(r) is truew.r.t. M, every r’ Î R is overruled in M. Hence a con-tradiction arises, as we assumed that no unfoundnesscondition holds for the rules in R.

EXAMPLE 2.11.

M = {person.taxPayer, unemployed.taxPayer, tom. Ørich, tom. ØtaxPayer, john.taxPayer}

is a model for IPtom . Indeed, let us consider the rules r1to r8 in ground( IPtom ) shown in Example 2.9. Given thatthe greatest unfounded set of IPtom w.r.t. M is

GUS MIP ( ) = {person. ØtaxPayer, person.rich, person. Ørich, unemployed. Ørich, unemployed.rich, unemployed. ØtaxPayer, tom.rich, tom.taxPayer, john. Ørich, john.rich, john. ØtaxPayer}

it is easy to see that:

3. Recall that a transformation T is monotonic in a domain (D, Í) if," Î ÍI J D I J, , implies T(I) Í T(J).

1) rules r1, r3, r4, r6, r7, r8 are satisfied in M becausethey are true w.r.t. M, while

2) r2 and r5 are satisfied in M because they are contra-dictable w.r.t. M (indeed, Ø.Head(r2) = unem-ployed.taxPayer Ï GUSIP (M), and Ø.Head(r5 ) = tom.Ø.taxPayer Ï GUSIP (M)).

Consider now the program IPnix , which has thefollowing models: M1 = {quaker.pacifist, republican.Øpacifist}, M2 = M1 È {nixon.pacifist}, and M3 = M1 È{nixon. Øpacifist}

It should be noted that since the greatest un-founded set for IPnix w.r.t. M1 is

GUS M quaker pacifist republican pacifistIPnix( ) { . , . }1 = Ø

the ground rules nixon.pacifist ¬ and nixon. Øpacifist

¬ are both satisfied by M1, as neither nixon.pacifistnor nixon. Øpacifist are in GUS MIPnix

( )1 .

A key property of BQM programs is that the intersectionof any number of models is a model.

PROPOSITION 2.2. Let P be a nonempty set of models of IP . Then,ÇÎM

ii

MP

is a model for IP as well.

PROPOSITION 2.3. Every program has a model.

COROLLARY 2.1. Let P be the set of the models of IP . Then,M MIP

M

ii

= ÇÎP

is the least model of IP .

We consider the least model of IP as the intended meaningof the knowledge base IK (thus, IP and IK are actually al-ternative syntactic representations of each other). By a littleabuse of language, in the following we may refer to theleast model of IK .

EXAMPLE 2.12. Clearly, M1 (reported in Example 2.11) is theleast model of IPnix and represents the natural mean-ing of IKnix . Note that no true fact holds for nixon, ac-cording to the intuition that conflicting pieces of in-formation, none of them is preferable, defeat eachother. For another example, the model M of Example2.11 is the least model of IPtom , as no subset of it is amodel. Intuitively, every literal in M must be in eachmodel of IPtom , since it is the head of a rule with a truebody, which is not contradictable (because no lowerrule with complementary head has a true body).

Next we give a deeper characterization of the leastmodel MIP . The following proposition shows that the liter-als in MIP are precisely those that can be “derived” fromthe rules of IP provided that their complements are un-founded. We point out that such a “pessimistic” approach(in the sense that a literal belongs to the least model only ifit is truly certain that it is uncontradictable) is reminiscentof the well-founded semantics [38] of traditional logic pro-grams of which, as we shall show in Section 2.5, our for-mulation is a generalization.

PROPOSITION 2.4. Let MIP be the least model of IP . Then L ÎMIP if and only if there exists r Î ground( IP ) such thatHead(r) = L, Body(r) Í MIP , and Ø.L ÎGUS MIP IP( ) .

LEONE ET AL.: A DEDUCTIVE ENVIRONMENT FOR DEALING WITH OBJECTS AND NONMONOTONIC REASONING 547

Observe that the least model semantics of BQM is“syntax sensitive,” that is a ¬ Øb is not fully equivalent tob ¬Øa (even if both rules are equivalent to a or b in classicallogics). The reason for this is that, like for the main seman-tics for logic programs with negation [1], [16], [38], BQMrules are to be seen as “inference rules” rather than as logi-cal clauses.

COROLLARY 2.2. Let MIP be the least model of IP . Then, Ø. MIPÍ GUSIP( MIP ).

We point out that the converse of Corollary 2.2 does nothold, i.e., an unfounded literal is not necessarily false; thusunfounded literals are either false or undefined. This is aconsequence of true negation, according to which in order aliteral L be false, Ø.L is to be derived from the rules of IP .Moreover, we observe that undefined literals are not neces-sarily unfounded. It is the case of nixon.pacifist and nixon.Øpacifist, which are both undefined and not unfoundedw.r.t. MIPnix

(see Examples 2.11 and 2.12 again).

DEFINITION 2.8 (Answer Set). Let MIP be the least model of IPand G a query onIK . We define the answer set of G, de-noted Ans(G), to be the set: {A Î MIP | there exists a sub-stitution s s.t. A = s(G)}.

We conclude this section by observing that each objectcan be assigned a set of facts that we regard as its intended“meaning.” Indeed, it is rather intuitive to define the se-mantics of an object o of IK as the set of facts in the leastmodel MIP of IP that are prefixed by o.

DEFINITION 2.9 (Least Model in an Object). Let MIP be the leastmodel of the program IP . The least model of IP in o ÎObjis M Q o Q MIP o IP= Î{ . }.

Observe that the prefix o would be redundant for the lit-erals in MIP o (as it is implicitly understood). It is worth

noting that MIP o does not coincide in general with the least

model of T*(o) (i.e., the completed theory of o) unless noreferential literal appears in it. (Formally, T*(o) is not a pro-gram; however, it is quite natural to see T*(o) as represent-ing the program (go (T*(o)), obj-ofo¢ ), where obj-ofo¢ is the ex-

tension to go (T*(o)) of the function obj-ofo defined on T*(o).)

EXAMPLE 2.13. The least model of IKfred of Example 2.3 is

{fred.is-father, john.has-father}. Then, the least model ofIKfred in fred is {is-father}, which we regard as the in-

tended meaning of the object fred. Notice that this setdoes not coincide with the least model of T*(fred) ={fred.is-father ¬ X.has-father(fred)} (which is the emptyset).

The least model of IKnix in nixon is the empty set,as no fact prefixed by nixon is in the least model ofIPnix (denoted by M1 in Example 2.11). It is immediateto see that the empty set is also the least model of theprogram T*(nixon). The reason is that no referentialliteral appears in T* (nixon).

2.4 Fixpoint SemanticsThe aim of this section is to present a constructive definitionof the least model of a BQM program IP . Such a goal is ob-

tained by defining a suitable operator WIP whose least fix-point coincides with the least model of the program IP of IK .

Before giving the definition of WIP , we need to provide asuitable reformulation of the immediate consequence operatoras follows:

T

T I Q B r ground IP s t Head r Q Body r IIP

B B

IP IP

IP IP:

( ) { ( ) . . ( ) ( ) }

2 2®

= Î $ Î = Ù Í

Note that T IIP ( ) contains a (possibly negative) literal Q ifand only if it is the head of a rule such that every body lit-eral, even if negative, is in I (i.e., negation is treated as truenegation). Clearly, the operator TIP is monotonic.

DEFINITION 2.10 (WIP operator).

W

W I T I GUS IIP

B B

IP IP IP

IP IP:

( ) ( ) . ( )

2 2→= ∩ ¬

Informally, for an interpretation I, L ÎW IIP ( ) if it is deriv-able from IP by TIP provided that its complement is un-founded (that is, Ø.L ÎGUS IIP ( )). Intuitively, this preventsfrom the possibility of deriving contradictions.

PROPOSITION 2.5. The WIP operator admits a least fixpoint Win (2BIP ,Í). W is the least model MIP of IP .

Notice that the second part of the proof above( M WIP = ) justifies the statement of Proposition 2.3 (aboutthe existence of models), as it proves that the least fixpointof the WIP operator is a model for IP .

In order to give an effective method for the evaluation ofthe least model, a constructive definition of the greatestunfounded set is needed. Following [22], [38], we next pro-vide a method that computes the set of literals which arenot unfounded and then redefine WIP in terms of such a set.

DEFINITION 2.11. Let I be an interpretation for IP , and X be a setof ground literals. We define

Γ

ΓI

B B

I

IP IP

X Q r ground IP s t Head r Q Body r X

Body r I O r is not overruled in I

:

( ) { ( ) . . ( ) ( )

( ) . }

2 2→

= ∃ ∈ = ∧ ⊆∧ ∩ ¬ = / ∧

PROPOSITION 2.6. Let I be an interpretation for IP . Then:

1) GI operator admits a least fixpoint GI¥ /(O) in ( , )2BIP Í ,

and2) GUS I BIP IP I( ) (O)= - /

¥G .

COROLLARY 2.3. Let I be an interpretation for IP . Then,W I T I OIP IP I( ) ( ) . ( ( ))= - Ø /

¥G .

2.5 Relation to Logic ProgrammingIn this section, we show that the least model semantics ofBQM programs is a generalization of the well-founded se-mantics of (traditional) logic programming [38].

In [22], [25], it is shown that any Datalog program (i.e., afunction-free logic program) can be represented by an or-dered logic program. Since “multiple inheritance,” as wellas referential literals, do not occur in such an ordered logicprogram, its (OL) well-founded semantics is equivalent tothe (BQM) least model [21]. In other words, given a Datalogprogram D, we can build a knowledge base KB(D) whose(BQM) semantics is equivalent to the well-founded seman-

548 IEEE TRANSACTIONS ON KNOWLEDGE AND DATA ENGINEERING, VOL. 9, NO. 4, JULY/AUGUST 1997

tics of D. KB(D) is a two-level knowledge base consisting oftwo objects with identifiers program and CWA (ClosedWorld Assumption) such that program < CWA. The theoryof program consists of the rules of D, while the theory ofCWA contains a rule of the form Øq(X1, ..., Xn) ¬ for eachn-ary predicate q appearing in D, where X1, ..., Xn are dis-tinct variables. The intuition behind such a representation isthat the higher object CWA corresponds to an explicit worlddeclaration stating that a fact is false unless explicitly con-tradicted.

Given a datalog program D, we call the program ofKB(D) the BQM version of D, and denote it by BQM(D).

PROPOSITION 2.7. Let D be a Datalog program and BQM(D) theassociated BQM program. Then, the well-founded model ofD coincides with the least model of BQM(D) in the object“program.”

This interesting result provides solidity to our formula-tion, as it proves that the least model semantics of a BQMprogram is a sound generalization of the well-founded se-mantics of Datalog programs. Since CWA can be easily rep-resented, the BQM language is in a sense more flexiblecompared to traditional logic programming, as the user isfree of choosing the predicates for which the Closed WorldAssumption must hold (unlike traditional logic program-ming where the CWA is applied to all predicates by de-fault). Note that the introduction of the CWA does notcause inconsistencies since the semantics of BQM solvespossible conflicts arising from the program rules (as statedin Proposition 2.3, every BQM program has a model).

Concerning the translatability of BQM into Datalog, it iseasy to see that every negation-free BQM program is se-mantically equivalent to the Datalog program consisting ofthe same set of rules where referential terms are consideredas part of the predicate symbols. Indeed, in absence of ne-gation, the rule ordering defined by the inheritance hierar-chy is immaterial since there is no conflict to be solved. Forgeneral BQM programs (where negation may appear), weconjecture that the translatability from BQM to Datalog isfeasible although not trivial.

2.6 On Complexity and Expressibility of BQMWe conclude the section with some considerations on thecomplexity and the expressibility of the BQM language.

As usual in the deductive database framework, we shallstudy data complexity [39]. The BQM program is thought ofas consisting of two parts, a database of facts (extensionaldatabase, EDB for short) and a set of rules for inferring ad-ditional information (intensional database, IDB for short).Thus, data complexity is defined as follows: for a fixed IDB,measure the complexity as a function of the size of the EDB.

PROPOSITION 2.8. Under data complexity, the least model of aBQM program IP is computed in polynomial time.

Concerning the expressive power of BQM, we observethat, from the result of the previous section, the BQM lan-guage can express all properties expressed by thetraditionalwell-founded semantics (of Datalog programs). On theother hand, it is rather clear that, like the well-founded se-mantics, it expresses only a strict subset of the polynomialtime computable properties (e.g., no BQM query is able to

decide if the universe of the input database is even). Thus,BQM does not add real expressive power to the well-founded semantics of Datalog. Nevertheless, it is certainlyacknowledgeable that the inclusion of objects, true negationand other mechanisms for the direct description of excep-tion and defeasible reasoning yields a remarkable im-provement in usability, clarity and modeling capabilities ofthe BQM language (w.r.t. Datalog). Moreover, these im-provements do not cause a computational overhead, sincethe BQM semantics is polynomial time computable (asproven in Proposition 2.8).

Compared to classical monotonic formalisms such as De-fault Logic [31], clearly BQM is strictly less expressive, sinceDefault Logic captures the complexity class S2

IP [13]. Exten-sions of the BQM language representing wider ranges ofproblems are described in [11], [10], where the NP andS2

IP complexity classes are proven to be captured, respec-tively. The reason why we adopted the least model seman-tics in this paper (rather than a more expressive semantics)for BQM is that the language is implemented in a real sys-tem where polynomiality of query computation is a fun-damental issue. In other words, we decided to pay a cost interms of expressibility in order to guarantee tractability.

3 IMPLEMENTATION PRINCIPLES

So far, we have concentrated on the language of the BQMsystem. In this section, we discuss its implementation prin-ciples. In particular, we address the problem of the efficientquery evaluation.

We already mentioned that BQM is a sound and com-plete system which fully supports the declarative semanticsof its language—i.e., it is capable of correctly evaluating anypossible query.

In the general case, the evaluation of queries in the BQMsystem is based, according to the results of Section 2.4, onan implementation of the WIP operator, which relies on therelational algebra primitives. This general method is simplyan extension of the classical bottom-up evaluation of de-ductive databases. Unfortunately, a closer observation ofthis approach reveals that, in the general case, the compu-tation of the least model is a very demanding task. Indeed,for each interpretation I generated during the evaluation ofthe least fixpoint of WIP I, G¥ is to be computed.

It is possible, however, to specialize the general methodand make it inherently more efficient for a large class ofqueries, called stratified queries. Such queries present a nicecomputational property: Their evaluation is based on theuse of the TIP operator only, without the need for comput-ing the greatest unfounded set. In particular, the answer setis computed simply by applying the TIP operator to strata inthe usual bottom-up fashion. This clearly represents a greatbenefit in terms of amount of computation to be performed.A further advantage of stratification comes from the possi-bility of applying to stratified queries optimization tech-niques for the propagation of possible query bindings. In-deed, as in traditional logic programming, a plain bottom-up evaluation of a stratified query would still suffer from agreat amount of redundant computation: The point is that

LEONE ET AL.: A DEDUCTIVE ENVIRONMENT FOR DEALING WITH OBJECTS AND NONMONOTONIC REASONING 549

all facts in the model would be blindly derived, even ifsome of them are definitely not relevant for the answer to agiven query. This problem has been widely studied in thefield of deductive databases [7], [8], [34] and the basic re-sults, as we shall see later in this section, can be adapted toour language in a natural way. This is the case, in particu-lar, with the Generalized Magic Set rewriting method [8].

Efficiency of evaluation is of course paid for in terms ofexpressivity of the language, as only a limited form of con-tradictions is allowed by stratified queries. However, thereis another class of (query) programs the BQM system iscapable of dealing with efficiently. These are called admissi-ble queries, a generalization of stratified queries, that can behandled with a small computational overhead w.r.t. thelatter. For reasons of space we omit here the presentation ofsuch queries; the interested reader is referred to [21].

In the rest of this section, we shall concentrate on stratifiedquery evaluation. In particular, in Section 3.1 we give thenotion of query program; in Section 3.2 we define the class ofstratified queries and provide an algorithm for their efficientevaluation. A comparison with classical stratification is alsogiven. In Section 3.3, we extend the Generalized Magic SetMethod for the rewriting of BQM programs and give amethod for the evaluation of rewritten BQM programs.

From now on, we shall make use the following basicnotations and definitions.

Some Basic Notations and Definitions

• We denote a literal with predicate p of the form, say,t.p(X ) or t. Øp(X ), as t.P(X ) (thus, P may representeither the predicate p or its negation Øp). We call t.Pthe name of t.P(X ).

• The set of all possible (literal) names constructiblefrom the predicates appearing in IP and the set of theuser-defined identifiers in Obj is denoted by N.

• Given a (literal) name o.P, o P. �� denotes the name ob-tained from o.P by negating P, i.e., o P. �� = o. Øp if P = p,and o P. �� = o.p if P = Øp. The names o.P and o P. �� aresaid complementary.

• Two literals with complementary names, i.e., of theform o.P(X ) and o P. ��(Y ), are said to be conflicting.Accordingly, two rules with conflicting heads arecalled conflicting rules. We shall often denote two con-flicting literals simply as L and ��L .

• A rule r is said to be overrulable by r‘ if r and r‘ areconflicting rules and, further, obj-of(r’) < obj-of(r).

REMARK. As already mentioned, for implementation pur-poses it is convenient to use the flat representation IPrather than the knowledge base IK . The reason is two-fold: first, in IP object identifiers are directly repre-sented within rules, thus allowing a natural treatmentof the referential literals appearing in IK . Second, inIP the inheritance hierarchy is captured by duplica-tion of rules, thus explicitly associating with each ob-ject, the rules in its completed theory. Thus, in thefollowing parts of this section, we shall normally re-fer to IP .

Throughout this section, we assume a knowledge baseIK has been fixed.

3.1 The Query ProgramAs in traditional logic programming, the whole program IPis not, in general, needed for answering a query G. In thefollowing we show how to single out a subset of IP in orderto answer G.

As usual, the rules that are needed for this purpose areidentified by the predicates from which the query predicatedepends on. However, the classical depends-on relation [37]is not sufficient for our purposes, as we have to deal withcontradictions. The starting point in the definition of ourdepends-on relation is the observation that a predicate maybe defined in several objects and negation may appear inthe rules’ heads. Thus, unlike traditional logic program-ming, the depends-on relation cannot simply be defined onthe set Pred of predicate symbols, but it is to be defined onthe set N of the literal names.

Now, the “form” of depends-on is essentially an extensionof that defined for traditional logic programs. Indeed, be-sides the (explicit) dependency of the head of a rule on eachof its body literals, we have to also take into account the(implicit) dependency between the head literals of con-flicting rules.

As for the former type of dependency (explicit depend-ency) we are required to be more precise, since we aredealing with rules using referential literals. To this end, letus consider a rule r ÎIP of the form, say, o.p(X, Y) ¬ X.q(Y).Here, we should notice that the body literal indicates thatthe predicate p on o depends on the predicate q for eachinstantiation o‘ of X such that there is a rule in IP with headname o’.q. We denote by range(X) the set of all such objectidentifiers. More formally, given a referential literal t.P(X ),we have that range(t) = {t}, if t ÎObj or range(t) = {o Î Obj | $r ÎIP s.t. Head(r) = o.P( Z )} if t is a variable.

Concerning the second type of dependencies (implicitdependencies), we note that the presence of two rules r1and r2 with conflicting heads of the form o.P(X ) ando P Y. ��( ), respectively, implies a dependency of o.P on o P. �� ,and conversely. This is because we are interested in a con-tradiction-free semantics, so that we cannot state both factso P a. ( ) and o P a. ��( ) true at the same time. However, if rule r1is more reliable than rule r2 —i.e., r2 is overrulable by r1—then o.P will not depend on o P. �� .

DEFINITION 3.1. Let IP be a program. We define relations R1, R2,and depends-on N on as follows.

• o1.P1 R1o2.P2 if there exists a rule r Î IP with heado1.P1(X ) s.t. the body of r contains either o2.P2(Y ) orZ. P2 (Y ) such that o2 Î range(Z).

• o1.P1 R2 o2.P2 if there exist rules r1 and r2 in IP , with

heads o1.P1(X ) and r2.P2(Y ), respectively, such that o1

= o2 and P1 = ��P2 (i.e., r1 and r2 are conflicting rules)

and, further, obj (r1) is not a subobject of obj (r2).• depends-on = R1 È R2.

We notice that R1 corresponds to the classical depends-onrelation defined for traditional logic programs, while R2expresses the implicit dependency between any two con-flicting literals.

550 IEEE TRANSACTIONS ON KNOWLEDGE AND DATA ENGINEERING, VOL. 9, NO. 4, JULY/AUGUST 1997

EXAMPLE 3.1. The depends-on relation for IPtom (see Example2.9) is the following:

R1 = {(john. ØtaxPayer, john.Ørich), (tom. ØtaxPayer, tom. Ørich), (unemployed. ØtaxPayer, unemployed. Ørich)}

R2 = {(john. taxPayer, john. ØtaxPayer), (tom.taxPayer, tom.ØtaxPayer), (unemployed.taxPayer, unemployed. ØtaxPayer)}

depends-on = R1 È R2.

For an instance, the pair (tom.taxPayer, tom. ØtaxPayer)is in R2 since the program IPtom (see Example 2.9)contains the rules r1: tom. ØtaxPayer ¬ tom.Ørich andr2: tom. taxPayer ¬ such that obj-of(r1) = unemployed,obj-of(r2) = person, and person is not a subobject of un-employed). Informally speaking, such a dependencyexpresses the intuition that we cannot statetom.taxPayer as a true fact independently on the pos-sibility of deriving its negation by rule r1, this beingmore specific than rule r2.

Once the depends-on relation is defined, we are ready tosingle out the program of a query. Let depends-on* denotethe reflexive-transitive closure4 of depends-on.

DEFINITION 3.2. Given a query G of the form t.Q(Z ), the pro-gram of G is ( IP (G), obj-of), where

IP G r IP Head r o Q Y o Q

depends on o Q

o range t( ) = È Î = Ù

Î

-

( ){ ( ) �. � ( ) .

* �. � }

obj-of is the restriction of the function obj-of of IP to itssubset IP(G).

As usual, we shall often omit the explicit specification ofthe obj-of function, denoting a query program simply byIP (G).

Given a query G, it is easy to see that the set of theground instances of G in the least model of the query pro-gram IP (G) coincides with the set of the ground instancesof G in the least model of IP .

PROPOSITION 3.1. Given a query G on IP , its answer set coincideswith the answer set of G on IP(G).

Using the depends-on relation we next define the notionof base literal.

DEFINITION 3.3. Let IP be a program and L = o.P (X ) be a literalappearing in IP . We say that L is a base literal in IP if noliteral o’.Q(Y ) appearing in IPis such that o.P depends-ono’. Q. Otherwise, L is said nonbase literal.

Thus, like in traditional logic programming, a literal L isof base type if it does not depend on any other literal ap-pearing in IP . This implies that, in order L be of base type, itis to be defined by rules with empty bodies (as intraditionallogic programming) and, further, no rule with head Ø.L is

4. Recall that the reflexive-transitive closure of a binary relation R on K is

{(a, b) Î K × K ½ a = b or $ t1, ¼ tn Î K (n ³ 2) s.t. t1 = a, tn = b, (t1-1,t1), Î R, ∀ i

s.t. 2 £ i £ n}.

more reliable than any with head L (otherwise L depends-onØ.L would hold). We note that a literal of the form o.P(X )may be, say, of base type, whereas a literal o’.P ( )Y is non-base. Thus, it makes no sense to classify a literal of the formX.P (Y ), where X is a variable, as either base or nonbase.Finally, we observe that a literal which is nonbase in IPmay be of base type in IP (G), for some query G.

EXAMPLE 3.2. The program IPtom (tom.taxPayer) of the querytom.taxPayer consists of the following rules: r1:tom.taxPayer ¬, r2 : tom. ØtaxPayer ¬ tom. Ørich and r

3 : tom. Ørich ¬, while IPtom (tom.ØtaxPayer) consists ofrules r2 and r3.

The program IPnix (nixon.pacifist) of the querynixon.pacifist consists of the following rules:nixon.pacifist ¬ and nixon. Øpacifist ¬. Note thatIPnix (nixon. Øpacifist) coincides with IPnix (nixon.pacifist).

Concerning base literals, we have that:

1) in the program IPnix (nixon.pacifist), bothnixon.pacifist and nixon. Øpacifist are nonbase liter-als, and

2) in the program IPtom (tom. ØPayer)), tom. Ørich is abase literal.

The reason is that, in the former case, both literalsdepend on each other, while in the latter case tom.Ørich does not depend on any other literal (thus, it canbe considered in the same way as a fact in logicprogramming).

3.2 StratificationWe shall define here a class of queries whose evaluationcan be carried out very efficiently. The notion we introduceis that of stratification, which restricts us to define contra-dictions in a limited fashion. However, a stratified (query)program presents the desirable property that its least modelcan be efficiently evaluated without having to compute thegreatest unfounded set (or its complement). This is donesimply by ordinately applying to strata the TIP operator (seeSection 2.4). This approach clearly results in a great gain interms of efficiency.

3.2.1 Stratified QueriesTypically, a stratified (query) program shows a “polarized”structure: The definition of a property belongs to a certainobject, while the exceptions (i.e. contradicting rules) belongonly to its subobjects. In a sense, the notion of stratificationcan be intended as a way to detect when a program has asimple structure w.r.t. the treatment of contradictions. Weillustrate the basic intuition by an example.

EXAMPLE 3.3. Consider the query G = tom.taxPayer whoseassociated program has been shown in Example 3.2.Following the ordering stated by the depends-on rela-tion (see Example 3.1), we proceed to the evaluationof G as follows. We start by deriving tom. Ørich, whichis actually a base literal. Then, using this literal, we in-fer tom. ØtaxPayer (from the rule tom.ØtaxPayer ¬ tom.Ørich) and, finally, we derive tom.taxPayer; but, sinceits complement tom. ØtaxPayer has already been in-ferred (from a more “specific” rule in the inheritancehierarchy of IPtom ), tom.taxPayer is discarded. Actually,

LEONE ET AL.: A DEDUCTIVE ENVIRONMENT FOR DEALING WITH OBJECTS AND NONMONOTONIC REASONING 551

tom. ØtaxPayer and tom. Ørich are the only facts fortom in the least model of IPtom (see Examples 2.11 and2.12). The reason this approach works correctly in thiscase is that the program IPtom has a syntactic structureensuring the existence of a bottom-up rule evaluationordering that preserves the “precedence” (in the in-heritance hierarchy) of more specific over more generalrules (e.g., the precedence of the rule tom. ØtaxPayer ¬tom. Ørich. w.r.t. tom.taxPayer ¬).

Given a program IP , we associate with it a dependencygraph DGIP = (N, E) representing the depends-on relation.DGIP is a directed graph such that:

1) the set of nodes is the set N of the names, and2) there is an edge in E from node n to m iff m depends-

on n in IP .

As in traditional logic programming, the notion of depend-ency graph can be used to detect the desirable property ofstratification.

DEFINITION 3.4. A program IP is stratified if no cycle of the de-pendency graph contains complementary nodes. A query Gon IP is stratified if its programIP(G) is stratified.

It is worth noting that a query G on IP may be stratifiedeven if IP is not.

EXAMPLE 3.4. For the query tom.taxPayer on IPtom , the de-pendency graph of IPtom (tom.taxPayer) is depicted inFig. 3a. It is easy to see that this program is stratified.

For another example, consider the following KB.

¢ = ¬

¢ = Ø ¬

o p

o o p p

{ }( ) { }

whose corresponding program IP is {o’.p ¬, o.p ¬,o.Øp ¬ o.p}.

The dependency graph of IP (see Fig. 3b) has a cy-cle containing two complementary nodes, namely, o.pand o. Øp, hence the above program is not stratified.Intuitively, the reason is that, on one hand, o.p isneeded to derive o. Øp but, on the other hand, o.p im-plicitly depends on o. Øp. However, it is easily seenthat the query o’.p is stratified.

Fig. 3. Dependency graphs for (a) IP (tom.taxpayer) and (b) IP (o.p).

The next proposition formalizes what we intuitively re-ferred to as the “polarized structure” of a stratified pro-gram. In particular, it proves that conflicting rules are dis-tributed over the objects of a knowledge base in such a waythat those that are positive (i.e., with positive head) are alleither upper or lower in the inheritance hierarchy with re-spect to negative ones.

PROPOSITION 3.2. Let IP be a stratified program. Then,

1) for each pair r1 and r2 of conflicting rules in IP , eitherobj-of(r1) < obj-of(r2) or obj-of(r2) < obj-of(r1).

2) there do not exist three conflicting rules r1, r2 r3 ÎIPwith head o.P(X ), o P. ��(Y ), and o P. ��(Z ), respectively,such that obj-of (r2) < obj-of(r1), and obj-of(r1)< obj-of(r3).

It is easily seen that stratification can be detected inpolynomial time in the size IK of IK (in particular, in time

O IK( ))2 .We are now ready to introduce the notion of stratifica-

tion. Let DGIP be the dependency graph of the program IP

and C1, ..., Cn the maximal strongly connected components

of DGIP . Further, let DG N AIP^

( , )= be the directed graphobtained by collapsing the maximal strongly connectedcomponents of DGIP . More precisely, the set of nodes of

DGIP^

is N= {C1, ..., Cn} and the set of edges is A = {(Ci, Cj)

|(n, m) is an arc of DGIP , n Î Ci, m Î Cj, and i ¹ j} (clearly,

DGIP^

is acyclic).

DEFINITION 3.5. A stratification for IP is a totally ordered parti-tion ({S1, ..., Sn}, < ) of IP , where:

• Si (1 £ i £ n) is the set of all rules of IP with head of theform o.Q(X ) such that o.Q Î Ci;

• the binary relation < is a total ordering on {S1, ..., Sn}

such that if there exists an arc (Ci, Cj) in DGIP^

then

Si < Sj.

Each element of a stratification({S1, ..., Sn}, <) is called stra-tum of IP .

We notice that the notion of stratification is well definedas a total ordering on {S1, ..., Sn} there always exist, being

induced by a topological sort of the nodes of DGIP^

(whichis an acyclic graph). Observe that < is one of the total or-derings “compatible” with the partial order represented by

the graph DGIP^

.

EXAMPLE 3.5. Reconsider the program for the querytom.taxPayer given in Example 3.2. A stratification forthis program is: {S1, S2, S3}, where S1= {Ørich ¬},S2 ={ØtaxPayer ¬ Ørich}, S3 ={taxPayer ¬} and S1 < S2< S3.

From the above definition, it is immediately realized thatall rules of IP with the same head name belong to the samestratum of IP . Another property of a stratification is givenby the following proposition.

PROPOSITION 3.3. Let S = <S1, ..., Sn> be a stratification for IP

and L1, L2 be two literals appearing in IP , with names o1.P1

and o2 .P 2, respectively, such that o1.P1 depends-on o2.P2.

Further, let Si and Sj be the strata of S containing the rules

of IP with names o1.P1 and o2.P2, respectively. Then, either

Sj < Si or Sj = Si.

552 IEEE TRANSACTIONS ON KNOWLEDGE AND DATA ENGINEERING, VOL. 9, NO. 4, JULY/AUGUST 1997

We observe that in the definition of stratification for aprogram ( IP , obj-of) the function obj-of is not needed any-more. Roughly speaking, as for as conflicting rules are con-cerned, this function is “built-in” the ordering of the strata,as the following proposition shows.

COROLLARY 3.1. Let S = <S1, ..., Sn> be a stratification for IP .

Further, let r ÎSi and r’ Î Sj be two conflicting rules such

that obj-of(r) < obj-of(r’). Then Si < Sj.

The above statements point out a fundamental charac-teristic of a stratification: it preserves the rule orderingstated by the depends-on relation of IP . As we shall see, thisis the basis of the (bottom-up) evaluation method of strati-fied programs.

A semantic property of a stratified program is that all lit-erals that are not in a model belong to the greatest un-founded set. Intuitively speaking, it is because the syntacticstructure of a stratified program imposes a preference orderamong conflicting pieces of information (see Proposition3.2), so that one of them (the more “reliable”) prevails overthe others, which remain unfounded. It is easy to realizethat this property does not hold, in general, for any BQMprogram (see program IPnix , Example 2.11).

PROPOSITION 3.4. Let IP be a stratified program and M a modelfor it. Then, B M GUS MIP IP- Í ( ) .

COROLLARY 3.2. Let IP be a stratified program and M a modelfor IP . If M GUS MIPÇ = /( ) O then M MIP= .

3.2.2 Evaluating Stratified QueriesWe have seen that, when a program is stratified, there is astratification of its rules, i.e., an ordered partition of theprogram into strata, such that:

1) if a literal L1 depends on a literal L2 (according toDefinition 3.1), then the rules defining L2 are in astratum “lower” than those defining L1 (see Proposi-tion 3.3) and

2) if a rule r is more specific in IP than a conflicting ruler’, then the stratum of r is “lower” than that of r’ (seeCorollary 3.1).

Hence, a stratification provides a rule ordering suitable fora bottom-up evaluation (because of point 1 above) which iscompatible with the rule specificity determined by the in-heritance relationship (because of point 2 above).

Thus, the notion of stratification gives us an ordering inwhich to evaluate rules. As in traditional logic program-ming, the process proceeds (bottom-up) from the “lower”strata to the “upper” ones. The facts that are derived for astratum Si are used as input data for any “upper” stratum

Sj. Contradictions can be easily solved taking into accountthat: given a fact o P a. ( ) derived from a rule r, if its com-plement o P a. ��( ) is not in the current interpretation, theno P. ��( a ) is definitely unfounded. In such a case, o P a. ( ) canbe stated true. Otherwise (i.e., o P a. ��( ) is in the current inter-pretation), o P a. ( ) is to be discarded. Hence, contradictionscan be solved by simple set difference. Intuitively, the rea-son is that the set of not unfounded literals in a stratifiedcomputation coincides with the current interpretation

(while, for general programs, this set is to be computed asGI¥ /(O)). In essence, this is the great advantage of stratifica-

tion. i.e., no additional sets are to be computed for solvingcontradictions. This is basically a consequence of the factthat any two contradicting pieces of information are solv-able in favor of either one on the basis of the rule orderingstated by the program.

We next formalize the above intuitions.

DEFINITION 3.6. Let IP be a stratified program and S be a stratifi-cation for IP . Given a stratum Si Î S and a set I of groundliterals, we define:

Z I I T I IS Si i( ) ( ( ) . )= È - Ø

where

T I Q r ground S s t

Head r Q Body r IS ii

( ) { ( ) . .

( ) ( ) }

= $ Î

= Ù Í.

Given a stratum Si and a set I of literals, let { }Jn n INÎ bethe sequence whose nth term is the n-fold application of ZSi

on I (i.e., J Z I J Z JS n S ni i1 1= = −( ), ( ) ). It is easily seen that the

sequence { }Jn n INÎ is monotonically increasing. Therefore,

there exists the first finite l such that Jl = J

l–1 (recall that the

Base of IP is a finite upper bound for the sequence). Jl is a

fixpoint for the ZSi operator that we denote by Z ISi

¥( ) .

DEFINITION 3.7. Let IP be a stratified program and S = <S1, ...,

Sn> a stratification for IP . The sequence of fixpoints for IP

is the list <M0, M1, ..., Mn>, where M0 = /O , M1 =

Z MS1 0∞ ( ), � , ( )M Z Mn S nn

-1 .

Clearly, the sequence of fixpoints for IP is monotonicallyincreasing. We next show that the interpretation Mn coin-cides with the least model MIP of IP .

PROPOSITION 3.5. Let IP be a stratified program and S = <M0, ...,Mn> its sequence of fixpoints. Then, Mn coincides with theleast model MIP of IP .

Thus, the above proposition states that the nth term ofthe sequence of fixpoints S coincides with the least modelof IP . Since the computation of S essentially relies on theimmediate consequence operator TSi

, the sequence S de-

fines an effective evaluation method of IP , that we call theStratified Evaluation Strategy.

3.2.3 BQM Stratification vs. Traditional StratificationAn interesting aspect of our notion of stratification is that itis a sound generalization of that given for traditional logicprograms [1]. To prove this statement, we show that a logicprogram LP is stratified (in a traditional sense) if and only ifits BQM version BQM(LP) (see Section 2.5) is stratified(according to Definition 3.4). That is, the BQM notion ofstratification reduces to the traditional one on traditionallogic programs.

PROPOSITION 3.6. Let LP be a traditional logic program andBQM(LP) be the BQM version of LP. Then, LP is stratified(according to [1]) iff BQM(LP) is stratified (according toDefinition 3.4).

LEONE ET AL.: A DEDUCTIVE ENVIRONMENT FOR DEALING WITH OBJECTS AND NONMONOTONIC REASONING 553

As a further remark, we note that the notion of BQMstratification (as well as that of traditional stratification)is“data independent,” i.e., it depends only on the structureof the program at hand rather than on the constants ap-pearing in it. The advantage of this approach is that stratifi-cation can be statically (and efficiently) checked looking atthe intensional database only. Clearly, if we restrict our-selves to traditional logic programs, this kind of definitionappears weaker than other “data-dependent” definitionslike local stratification [30], and modular stratification [32]. Thereason for our choice is that, while defining stratification,our motivation was mainly that of finding techniques tooptimize a query system (the BQM system) working underthe usual assumption of deductive databases (large exten-sional database, small intensional one). Thus, even ifadopting a “data-dependent” approach would enlarge theclass of programs, it could compromise the overall effi-ciency of the BQM system.

3.3 Optimizing Stratified QueriesOne of the consolidated results of the deductive databaseresearch is the definition of a number of methods for recur-sive query optimization. Next, we show how, despite thenovelties of our language, a method such as the General-ized Magic Set [8] can be extended to our framework in arather natural way.

3.3.1 Preliminaries on Magic Sets for DatalogThe Generalized Magic Set (GMS) method is a rewritingtechnique that simulates the sideways binding passingmechanism of the top-down execution model by introduc-ing additional predicates (the magic predicates) in order toconstrain variables to take values from a restricted range.For an instance, consider the Datalog program LP shownbelow, where m and n are base predicate symbols (i.e., mand n are defined by ground facts only).

r1: s(X, Y) ¬ m(X, Y)

r2 : s(X, Y) ¬ n(X, Z), s(Z, Y)

For the query goal s(a, X), where a is a constant, the re-written version LP

gmsof LP is shown below.

¢r1 : magic_sbf

(a)

¢r2 : magic_sbf

(Z) ¬ m (X, Z), magic_sbf

(X)

¢r3 : sbf

(X, Y) ¬magic_sbf

(X), n(X, Y)

¢r4 : sbf

(X, Y) ¬magic_sbf

(X), m (X, Z), sbf

(Z, Y)

Rules ¢r1 and ¢r2 are the magic rules for s, i.e., the rules de-fining the (magic) set of all constants that are relevant forthe given query. In particular, ¢r1 defines the initial bindinga as belonging to the magic set of s. Rule ¢r2 , in turn, simu-lates the sideways binding passing mechanism of the top-down model of execution. In particular, it expresses that if aconstant c is “assigned” (during a top-down execution) to thevariable X of the head of r2 Î LP, then the subquery s(Z, Y) isran for all Z-values such that m(c, Z) is true. Consequently, ifc is in the magic set of s then such Z-values are in the magicset of s as well. The kind of information passing patternabove described (bound values are always assigned to thefirst argument of the recursive literals of r2) is made explicit

by the adornment bf used for the magic predicates, express-ing that the first and the second argument of s are boundand free, respectively.

Rules ¢r3 and ¢r4 are the rewritten versions of the rules r1and r2 of LP (we call such rules transformed rules). Again, anadorned predicate such as s

bf (X, Y) expresses that X is a

bound argument while Y is free. The magic predicate for s,in the body of both rules, is used to select, from the rela-tions for m and n, only those tuples of potential relevancefor the given query. We point out that the bodies of both ¢r3and ¢r4 are ordered in such a way to propagate bindingsfrom left to right. A detailed description of the GMS tech-nique can be found in [8].

3.3.2 Rewriting Stratified QueriesNext, we describe the extension of the Generalized MagicSet method to stratified BQM query programs. The key ideais that, besides the “classical” binding propagation, there isa sort of (implicit) binding passing between conflictingrules coming from the implicit dependency between therespective heads. To be more precise, let r and r‘ be tworules such that r is overrulable by r‘. Let H o P X= . ( ) and�� . ��( )H o P Y= be the respective heads. Let us denote by SH

and SH��

the strata of IP containing r and r‘, respectively.

Clearly, by Corollary 3.1, SH��

< SH. Now, bindings arepassed from r to r‘ in two distinct ways:

1) If a literal with name o P. �� appears in the body of r,then bindings are propagated from r to r‘ just as forany other literal. Thus, the magic set technique is notmodified in this respect.

2) In any case, because of the implicit dependency of Hfrom ��H , a fact derived for o P X. ( ), say o P a. ( ), gener-ates the transfer of the binding a from r to r‘ to checkwhether o P a. ��( ) is derivable from r‘ (in such a caseo P a. ( ) cannot be asserted as r is overruled by r‘). Inthis way, we limit the derivation of facts for o P Y. ��( ) tojust those that are necessary to validate the truthnessof each derived fact for o P X. ( ).

EXAMPLE 3.6. Let us consider the following program:

� { ( , ) ( , )

( , ) ( , ), ( , ), ( )

( ) ( , )

( ) ( , ), ( )}

( �) { ( , ) ( , )}

o p x Y a X Y

p X Y b X Y p Z T q T

q X a X Y

q X b X Y q Y

o o p X Y d X Y

= ←←

←←

= ¬ ←

where a, b, and d are base predicates defined by anumber of ground facts.

The query program for the query o.p(const, Y) isshown below:

r1 : p(X, Y) ¬ a(X, Y) r2 : p(X, Y) ¬ b(X, Z), p(Z, T), q(T) r3 : q(X) ¬ a(X, Y) r4 : q(X) ¬ b(X, Y), q(Y) r5 : Øp(X, Y) ¬ d(X, Y)

(here, for notational simplicity, we omitted the speci-fication of the prefix o, this being shared by all literals

554 IEEE TRANSACTIONS ON KNOWLEDGE AND DATA ENGINEERING, VOL. 9, NO. 4, JULY/AUGUST 1997

appearing in the program). Notice that both r1 and r2are overrulable by r5 . This program is stratified andthe following is a stratification:

Sp(X,Y) = {r1, r2}, Sq(X) = {r3, r4}and

SØp(X,Y) = {r5},

where SØp(X,Y) < Sp(X,Y) < Sq(X). We now start by rewriting

Sp(X,Y) and Sq(X) on the basis of the given query, by usingthe “classical” magic set rewriting technique. Hence, weobtain the following rewritten rules:

¢r1 : magicpbf

(const) ¬

¢r2 : magicpbf

(Z) ¬ magicpbf

(X), b(X, Z).

¢r3 : pbf

(X, Y) ¬ magicpbf

(X), a(X, Y).

¢r4 : pbf

(X, Y) ¬ magicpbf

(X), b (X, Z), pbf

(Z, T), qb(T).

¢r5 : magicqb(T) ¬ magicp

bf(X), b (X, Z), p

bf(Z, T).

¢r6 : magicqb(Y) ¬ magicq

b(X), b(X, Y).

¢r7 : qb(X) ¬ magicq

b(X), a(X, Y).

¢r8 : qb(X) ¬ magicq

bf(X), b(X, Y), q

b(Y).

We point out that ′r5 is the rule whereby bindings are

passed from r2 to both r3 and r4 . We call such a ruletransfer rule. At this point, to complete the rewriting of

our program, we have still to transform SØp(X,Y) insuch a way as to restrict the computation only to factsof the form Øp(a, b) such that p(a, b) is derived from

the rules in Sp(X,Y). To this end, we rewrite SØp(X,Y) asfor fully bound queries, that is

¢r9 : magicØpbb

(X, Y) ¬ magicpbf

(X), a(X, Y).

¢r10 : magicØpbb

(X, Y) ¬ magicpbf

(X), b(X, Z), pbf

(Z, T), qb(T).

′r11: Øpbb

(X, Y) ¬ magicØpbb

(X, Y), d(X, Y).

Here, ¢r9 and ¢r10 are transfer rules, as they are used topropagate bindings from r1 and r2 to r5. In particular,having the same bodies as r’3 and ¢r4 , they express thatall facts for p are ‘magic’ (i.e., relevant) for Øp.

In essence, the rewriting of a stratified program is an ex-tension of the rewriting technique of a traditional logic pro-gram to handle contradictions in an efficient way. Clearly,the transformation process so far described in an informalway, can be systematically applied to any stratified program.

The algorithm for rewriting a query program IP (G) isshown in Fig. 4. Informally, the transformation of IP (G) iscarried out by the recursive function Rewrite. This function,given an adorned5 name Rb and the associated program IP ,begins with the rewriting of the Horn version of IP (whereeach literal o P X. ( ) is considered as a positive literal withname o.P), performed according to the generalized magicset method. To this end, the external function GMS is in-voked. (We consider the Horn version because, as a conse-

5. An adornment is a string specifying the binding status (i.e., free orbound) of the arguments of a literal [8].

quence of the true negation, each literal is treated as a posi-tive one.) Then, for each overrulable rule r with head H =o.P(Y ) appearing in IP , the function Rewrite is recursivelyfired for the transformation of the program IP ( ��H ) (clearly,if no conflicting rules occur in IP (G) then the rewriting ofIP (G) coincides with the rewriting of its Horn version). Topropagate bindings from r to its conflicting rules in ��H , thefollowing transfer rule is added: magic magicP Xbound�� ( ) ¬Body(t(r)), where Body(t(r)) denotes the body of the trans-formed version t(r) of r.6 Note that the transfer rule has ex-

actly the same body as t(r). In this way, for each fact o.P( k )derived from r, the magic fact magicP kbound�� ( ) is created(obviously, some optimization technique, such as supple-mentary magic [8], can be used to avoid redoing joins). Weconclude by noticing that the algorithm of Fig. 4 uses theimplicit assumption that no literal of the form X.P(Y )where X is a variable, appears in the query program IP (G).However, this does not result in a loss of generality. Indeed,if such a literal appears in a rule r of IP (G), this rule cansimply be replaced by a number of rules, one for each objectidentifier �o in range(X), each one obtained from r by re-placing X.P(Y ) by �. ( )o P Y .

The Extended_GMS Algorithm

INPUT: A query G of the form t.Q(X ) and its program IP (G).OUTPUT. The rewritten query program W( IP (G)).NOTATION. Horn( IP (G)) denotes the (traditional) logic pro-gram obtained from IP (G) by considering each literal o. P(X )as a positive literal with symbol o.P. a is the adornment associ-ated with the input query, and bound is the adornment of aliteral whose arguments are all bound. a denotes the list ofconstants appearing among the arguments of the query G.

Function rewrite( Rb, IP )

IP^

:= GMS(Rb, Horn( IP (G)));

for each overrulable rule r in IP (G) do /* Let the head of r be H = o.P(Y ) */

IP^

:= IP^

È Rewrite (o Pbound. �� , IP ( ��H ));

Let t(r) Î IP^

be the transformed rule of r.

Then add to IP^

the following transfer rule: magicP X Body t rbound�� ( ) ( ( ))¬ ; that is,

IP IP magicP X Body t rbound

^ ^

: { �� ( ) ( ( ))}= ∪ ← end_for;

return IP^

; /* end function rewrite */begin {main} W( IP (G) ) := È

Îo range tRewrite o Q IP G

( )( . , ( ))a

W( IP (G)) := W IP G magic o Q ao range t

( ( )) { _ . ( ) })( )

∪∈

α

end.

Fig. 4. The Extended_GMS algorithm.

6. For simplicity, we assume only one transformed rule is associated withr (i.e., each literal gets bindings in just one way).

LEONE ET AL.: A DEDUCTIVE ENVIRONMENT FOR DEALING WITH OBJECTS AND NONMONOTONIC REASONING 555

3.3.3 Evaluating Rewritten QueriesUnfortunately, after a program has been rewritten by thealgorithm of Fig. 4, the stratified evaluation strategy, de-scribed in Section 3.2.2, is not helpful anymore for itsevaluation. Indeed, the computation of a rewritten programcannot proceed following a “pure” bottom-up strategy (i.e.,from lower to upper strata), as bindings are to be propa-gated in a top-down fashion. That is, we need an evaluationstrategy where the bottom-up generation of facts is com-bined with a top-down generation of goals. We remark thatthe same problem arises in traditional logic programmingwhen stratified programs (here “stratified” is to be in-tended in the traditional sense) are rewritten in such a wayto push bindings from upper to lower strata. This problemhas been addressed in [9], [23].

Next we propose an evaluation method which is an ad-aptation to BQM programs of that given in [23] for traditionallogic programs. We outline this method by an example, theformal description of the method being reported in [21].

EXAMPLE 3.6 (continued). Informally, the computation ofthe rewritten query program can be carried out asfollows. The query literal p(const, Y) triggers the bot-tom-up evaluation of the set of rules Wp(X,Y) = { ¢r1 , ¢r2 ,¢r3 , ¢r4 }. Iteratively, by using the available relations for

the body literals, the relations for the head literals areconstructed. However, there is a problem with ¢r4 , as

the relation for qb(T) is not yet available (thus, we say

that qb(T) is an external literal). Hence, whenever ¢r4 is

to be evaluated, the current computation of Wp(X,Y) is

suspended, and the (sub)query qb

(T) is fired. The an-swer to such a query results from the evaluation ofthe set of rules Wq(T) = { ¢r5 , ¢r6 , ¢r7 , ¢r8 }. We point outthat, during this evaluation, no subquery is to befired. In particular, the execution of rules ¢r5 and

¢r6 (whereby bindings are transferred to qb

(T)) is to be

carried out by considering magicpbf

(X) and pbf

(Z, T) asalready evaluated literals, since the values we are in-terested in, are those currently available. Once the re-lation for q

b(T) is ready, the previously interrupted

evaluation of ¢r4 (in Wp(X,Y)) is resumed and the cur-rent relation for the head of ¢r4 is eventually com-

puted. However, after all rules in Wp(X,Y) have beenevaluated for the current iteration, there is a furtherstep to be performed, in order to rule out possiblecontradictions: for each computed fact for p, say p(a,b), we have to check whether Øp(a, b) is derivable (infact, in such a case p(a, b) is to be discarded since itsrule gets overruled). To this end, the subquery Øp

bb

(X, Y)7 is run and the evaluation of WØp(X,Y) =

{ ′ ′ ′r r r9 10 11, , } is carried out. Notice that, as for Wq(T), no

subquery is to be fired while evaluating WØp(X,Y)..

7. The adornment of the subquery is bb since both the arguments of Øp(a, b)are bound.

4 ARCHITECTURE OF BQMThe original design of BQM has been conceived in the con-text of KIWIS, where BQM is in charge of the efficient bot-tom-up execution of stratified queries (a description ofBQM in the context of KIWIS is reported in [21]). As astandalone system, BQM fully supports the querying capa-bilities on a static, unchangeable KB. In fact, updates andI/O features, as well as other extralogical predicates, aremanaged by other layers of KIWIS.

The architecture of BQM, shown in Fig. 5, is composed oftwo main distinct blocks: the Static Compiler, supporting theprecompilation phase of the KB, and the Run-Time Environ-ment, for querying capabilities. These modules are inter-faced through BQM KB.

Fig. 5. Architecture of BQM.

The aim of the Static Compiler is to generate the internalrepresentation of the KB along with additional (meta) in-formation to support fast retrieval of query programs. Inparticular, the Static Compiler:

1) parses the KB program to check a number of (bothsyntactic and semantic) conditions, such as referentialintegrity;

2) builds an in-memory image of the whole KB: objects,rules, and hierarchies are stored into BQM KB;

3) for each object/predicate pair (literal name)

• collects the associated query program;• builds the dependency graph and recognizes

whether the program is possibly stratified or ad-missible [21]; in such cases, a stratification is de-termined;

• generates a compact internal representation of thequery program (or of a possible stratification) andstores it into BQM KB.

The general strategy of the Static Compiler follows atopological order enforced by the objects hierarchy. That is,no object is compiled before its immediate super-objects arecompiled. This allows an incremental costruction of eachdependency graph, re-using dependency graphs associatedto other objects. Such a strategy can be suspended by thereferential predicates, which may cause the processing ofpossibly another portion of the objects hierarchy, and thecreation of links between dependency graphs.

BQM KB is the natural interface between the Static Com-piler and the Run-Time Environment: It is the depository of theinformation collected by the Static Compiler, and is consultedby the Run-Time Environment. It consists of two components:

556 IEEE TRANSACTIONS ON KNOWLEDGE AND DATA ENGINEERING, VOL. 9, NO. 4, JULY/AUGUST 1997

1) the KB schema, which contains the plain description ofthe objects, their hierarchies, and their rules and

2) the KB metaschema, which summarizes the processingmade by the Static Compiler.

Both components are represented in terms of relations,whose mplementation makes use of threated AVL trees forindexing single arguments. In particular, we build an indexon each argument of the relations representing facts, whichwill turn useful during query execution, and on some ar-gument of the other relations, in order to speed up theq-uery program retrieval.

A query on the KB activates the Run-Time Environment,composed by three main blocks (see Fig. 6): the Rewriter, theOptimizer, and the Executor. The overall working of suchmodules is managed by BQM Manager, which is also re-sponsible of accessing BQM KB and the query archive—aprivate archive of the Run-Time Environment containing acompiled form of all query programs that have been exe-cuted in the current working section.

Fig. 6. Architecture of the run-time environment

In particular, the first task of BQM Manager is to verify,by accessing the query archive, whether a similar8 query hasbeen previously issued in the same working session. If nosimilar query is found, the following steps areperformed byBQM Manager:

1) the query program (or its stratification, if it is eitherstratified or admissible [21]) is retrieved by accessingto both the KB metaschema, to single out the set ofneeded rules, and the KB schema for the actual ruleretrieval;

2) if the query program is stratified, the Rewriter is in-voked to generate its rewritten version;

3) the (possibly rewritten) query program is then sup-plied to the Optimizer for a further processing;

4) the resulting program is stored into the query archive(to be possibly reused during the same working ses-sion) and, finally,

5) the control is left to the Executor for the programevaluation. On the contrary (i.e., a similar query hasbeen executed in the same working session), the op-timized (and possibly rewritten) program of the queryis retrieved from the query archive and it is directlysubmitted to the Executor for its evaluation.

8. Two nonstratified queries are considered similar if they have the samename, while two stratified queries are similar if they have the same nameand the same binding pattern. In fact, in such a case, the associated rewrit-ten program is exactly the same.

The main goal of the Rewriter is to rewrite the query pro-gram according to the Extended_GMS method discussed inSection 3.3.1. As already pointed out, such a technique al-lows us to reduce the amount of derived facts to those thatare relevant to the given query.

The optimization performed by the Optimizer is con-cerned with the efficient execution of the join operationsamong body literals. The problem here is that of finding an“optimal” ordering for body literals according to the con-straints imposed by the binding propagation. To this end,the tree query optimization technique [18] is implemented.Similar techniques have been successfully employed in theprevious ESPRIT project 1117 KIWI, as well as in the LDLsystem [14]. Obviously, in order that the optimization tech-nique be applied, statistical data (i.e., relation cardinalitiesand attribute cardinalities) are to be provided during theBQM start-up.

BQM Executor evaluates queries. As already remarked, itis capable of executing any query, either stratified or not.Stratified queries are computed by the NQS algorithm de-scribed in this paper (actually, an enhancement of it, basedon the generalized semi-naive evaluation strategy). We re-call that the NQS algorithm permits the exploitation of pos-sible query bindings. Admissible queries, in turn, areevaluated by the Extended Semi-Naive (ESN) algorithm[21], which is an extension of theStratified Evaluation Strat-egy (see Section 3.2.2) to deal with more complicated formsof contradictions. Finally, general queries are implementedby the Naive Bottom-Up algorithm (NBU), which evaluatesthe least fixpoint of WIP in terms of the GI i operator definedin Section 2.4. Both the ESN and the NBU algorithms relyon the relational algebra primitives and are based on thegeneralized semi-naive evaluation strategy [5]. A simplerelational machine, whose main operation is then-ary nestedloop join, is used as the basic rule evaluation engine. Thismachine implements a main-memory data manager, asBQM relies on the assumption of large main memory avail-ability. A detailed description of the ESN as well as theNBU algorithms is reported in [21].

The current implementation of BQM runs on Sun-SPARC workstations. The whole prototype is written in Cand is about 13,800 lines of code.

ACKNOWLEDGMENTS

This work has been partially supported by the ChristianDoppler Expert Systems Laboratory, and by ISI-CNR,Rende (CS), Italy.

REFERENCES

[1] K. Apt, H. Blair, and A. Walker, “Towards a Theory of Declara-tive Knowledge,” Foundations of Deductive Databases and Logic Pro-gramming, J. Minker, ed., pp. 89-148. Los Altos, Calif.: MorganKaufman, 1987.

[2] Ahlsen et al., “The KIWIS Knowledge Base Management System,”Proc. Third Int’l Conf. CAiSE’91, Trondheim, Norway, May 1991.

[3] S. Abiteboul and P.C. Kanellakis, ”Object Identity as a QueryLanguage Primitive,” Proc. ACM SIGMOD Int’l Conf. Managementof Data, Portland, Ore., pp. 159-173, 1989.

[4] H. Ait-Kaci and R. Nasr, “LOGIN: A Logic Programming Lan-guage with Built-In Inheritance,” The J. of Logic Programming, vol.3, no. 3, pp. 185-215, Oct. 1986.

LEONE ET AL.: A DEDUCTIVE ENVIRONMENT FOR DEALING WITH OBJECTS AND NONMONOTONIC REASONING 557

[5] I. Balbin and K. Ramamohanarao,” A Generalization of the Dif-ferential Approach to Recursive Query Evaluation,” The J. of LogicProgramming, vol. 4, no. 3, pp. 259-262, 1987.

[6] F. Bancilhon, “Object-Oriented Database Systems,” Proc. SeventhACM SIGART-SIGMOD-SIGACT Symp. Principles of Database Sys-tems, Austin, Tex., pp. 152-162, 1988.

[7] F. Bancilhon, D. Maier, Y. Sagiv, and J.D. Ullman, ”Magic Sets andOther Strange Ways to Implement Logic Programs,” Proc. FifthACM SIGMOD-SIGACT Symp. Principles of Database Systems, 1986.

[8] C. Beeri and R. Ramakrishnan, “On the Power of Magic,” Proc.Sixth ACM SIGMOD-SIGACT Symp. Principles of Databases Sys-tems, pp. 269-283, 1987.

[9] I. Balbin, G.S. Port, K. Ramamohanarao, and K. Meenakshi,“Efficient Bottom-Up Computation of Queries on Stratified Data-bases,” The J. of Logic Programming, North-Holland, vol. 11, nos.3/4, pp. 295-344, 1991.

[10] F. Buccafurri, N. Leone, L. Palopoli, and P. Rullo, “DisjunctiveOrdered Logic,” Proc. DEXA ‘95, London, pp. 303-312, Sept., 1995.

[11] Buccafurri, F., N. Leone, and P. Rullo, “Stable Models and TheirComputation for Logic Programming with Inheritance and TrueNegation,” The J. of Logic Programming. North-Holland, 1996.

[12] F. Cacace, S. Ceri, S. Crespi-Reghizzi, L. Tanca, and R. Zicari,“Integrating Object-Oriented Data Modeling with a Rule-BasedProgramming Paradigm.,” Proc. ACM-SIGMOD Int’l Conf., Atlan-tic City, N.J., pp. 225-236, May, 23-25, 1990.

[13] M. Cadoli, T. Eiter, and G. Gottlob, “Default Logic as a QueryLanguage,” Proc. Fourth Int’l Conf., Principles of Knowledge Repre-sentation and Reasoning (KR-94), pp. 99-108, 1994.

[14] D. Chimenti, R. Gamboa, R. Krishnamurthy, S. Naqvi, S. Tsur,and C. Zaniolo, “The LDL System Prototype,” IEEE Trans. Knowl-edge and Data Eng., vol. 2, no. 1, Mar. 1990.

[15] W. Chen and D.S. Warren, “C-Logic for Complex Objects,” Proc.ACM SIGACT-SIGMOD-SIGART Symp. Principles of Database Sys-tems, Philadelphia, pp. 369-378, Mar. 1989.

[16] M. Gelfond and V. Lifschitz, “Logic Programs with Classical Ne-gation,” Proc. Seventh ICLP, Jerusalem, pp. 579-597, 1990.

[17] S. Greco, N. Leone, and P. Rullo, “COMPLEX: An Object-OrientedLogic Programming System,” IEEE Trans. Knowledge and Data Eng,vol. 4, no. 4, pp. 344-359, Aug. 1992.

[18] R. Krishnamurty, H. Boral, and C. Zaniolo, “Optimization ofNonrecursive Queries,” Proc. VLDB’86, Kyoto, Japan, pp. 128-137,Aug. 1986.

[19] M. Kifer and G. Lausen, “F-Logic: A Higher-Order Language forReasoning about Objects, Inheritance, and Scheme,” Proc. ACMSIGMOD Int’l Conf. Management of Data, Portland, Ore., pp. 134-146, 1989.

[20] R.A. Kowalski and F. Sadri, “Logic Programs with Exceptions,”Proc. Seventh ICLP, pp. 598-616, 1990.

[21] N. Leone, A. Mecchia, G. Rossi, and P. Rullo, “A Deductive Envi-ronment for Dealing with Objects and Non-Monotonic Reason-ing,” CRAI Technical Report RI 94-06., Rende, Italy, 1994.

[22] N. Leone and G. Rossi, “Well-Founded Semantics and Stratifica-tion for Ordered Logic Programs,” New Generation Computing, vol.12, no. 1, pp. 91-121. Springer-Verlag, Nov. 1993.

[23] N. Leone and P. Rullo, “An Efficient Strategy for the Bottom-UpEvaluation of Datalog Queries,” The Computer J., vol. 35, no. 6, pp.519-527, 1992.

[24] C. Lecluse, P. Richard, and F. Velez, “O2, An Object-OrientedData Model,” Proc. ACM-SIGMOD, 1988.

[25] E. Laenens, D. Saccà, and D. Vermeir, “Extending Logic Pro-gramming,” Proc. ACM SIGMOD, May 1990.

[26] E. Laenens, and D. Vermeir,“ A Fixpoint Semantics for OrderedLogic,” J. Logic and Computation, vol. 1, no. 2, pp. 159-185, Dec.,1990.

[27] E. Laenens and D. Vermeir, “Assumption-Free Semantics forOrdered Logic Programs: On the Relationships between Well-Founded and Stable Partial Models,” J. of Logic and Computation,vol. 2, no. 2, pp. 133-172, May 1992.

[28] F.G. McCabe, “Logic and Objects,” PhD thesis, Univ. of London,1988.

[29] G. Phipps, M.A. Derr, and K.A. Ross, “Glue-NAIL!: A DeductiveDatabase System,” Proc. ACM-SIGMOD Conf. Management of Data,pp. 308-317, 1991.

[30] T.C. Przymusinski, “On the Declarative Semantics of DeductiveDatabases and Logic Programs,” Foundation of Deductive Databasesand Logic Programming, J. Minker, ed., pp. 193-216. Los Altos,Calif.: Morgan Kaufmann, 1988.

[31] R. Reiter, “A Logic for Default Reasoning,” Artificial Intelligence,vol. 13, pp. 81-132, 1980.

[32] K.A. Ross, “Modular Stratification and Magic Sets for Datalog-Programs with Negation,” ACM PODS, 1990.

[33] R. Ramakrishnan, D. Srivastava, and S. Sudarshan, “CORAL—Control, Relations and Logic,” Proc. 18th VLDB Conf., Vancouver,B.C., Canada, 1992.

[34] D. Sacca and C. Zaniolo, “The Generalized Counting Method ofRecursive Logic Queries for Databases,” Theoretical Computer Sci-ence, no. 62, pp. 187-220, Nov. 1989.

[35] V.S. Subrahmanian, ”Amalgamating Knowledge Bases,” ACM-TODS, vol. 19, no. 2, pp. 291-331, 1994.

[36] A. Tarski, “A Lattice Theoretical Fixpoint Theorem and Its Appli-cation,” Pacific J. of Math., no. 5, pp. 285-309, 1955.

[37] J.D. Ullman, Principles of Database and Knowledge-Base ManagementSystem. Academic Press, 1988.

[38] A. van Gelder, K. Ross, and J.S. Schlipf, “Unfounded Sets andWell-Founded Semantics for General Logic Programs,” Proc.ACM-PODS, pp. 221-230, Mar. 1988.

[39] M.Y. Vardi, “The Complexity of Relational Query Languages,”Proc. ACM Symp. Theory of Computing, pp. 137-146, 1982.

[40] P. Wegner, “Dimensions of Object-Based Language Design,” L.Power and Z. Weiss, eds., Proc. Int’l Conf. Object-Oriented Pro-gramming: Systems, Languages, and Applications, pp. 168-182, 1987.

Nicola Leone received the doctoral degree inmathematics from the University of Calabria, Italy.In June 1986, he joined CRAI (an industrial con-sortium for computer science research and ap-plication at Rende, Italy), where he worked untilDecember 1991. From January 1992 to September1995, he was with the ISI institute of CNR (theItalian National Research Council). Since Octo-ber 1995, he has been an associate professorfor database systems in the Information SystemsDepartment of the Technical University of Vienna.

Leone has participated in several national and International projects,mainly on the development of advanced data and knowledge bases,including the ESPRIT projects “KIWIS” and “EDS” (where he acted asthe leader of the CRAI team). He has taught computer science forthree years at the University of Calabria, Italy. His main research inter-ests are in the areas of database theory, nonmonotonic reasoning, com-plexity theory, and deductive databases. He is author of over 50 paperspublished in scientific journals, books, and conference procedures.

Pasquale Rullo received the doctoral degree inengineering from the University of Calabria, Italy,in 1979. In 1980, he joined CRAI, a research andapplication center in computer science at Rende,Italy, where he was the manager of the Re-search Division. From 1992 to 1996, he was anassociate professor at the University of Calabria.In 1996, he joined the Faculty of Engineering ofthe University of Reggio Calabria as a full pro-fessor. He has worked on database design formany years, and his current research interests

include deductive databases, their integration with the object-orientedparadigm, and nonmonotonic reasoning. He has been involved in vari-ous international research projects. In particular, he has been theleader of the CRAI team in a large project on advanced logic-basedsystems supported by the Commission of the European Communitiesunder the ESPRIT program. He has published in several journals andConference Proceedings, including IEEE Transaction on Knowledgeand Data Engineering.

558 IEEE TRANSACTIONS ON KNOWLEDGE AND DATA ENGINEERING, VOL. 9, NO. 4, JULY/AUGUST 1997

Antonella Mecchia received the doctoral degreein mathematics from the University of Calabria,Italy, in 1981. After receiving a grant for youngcomputer scientists in 1982, she joined CRAI, aresearch and application center in Informaticslocated at Rende, Italy, where she is currently asenior researcher. Her fmain interests have beendatabase design and logic programming. Shehas also been involved in two large ESPRITprojects, she approached the areas of deductivedatabases and knowledge bases, and the ex-

ploitation of the object-oriented paradigm combined with logic pro-gramming. Recently, her interests have included issues related to real-time database systems for telecommunications. She is the author ofseveral articles published in conference proceedings and refereedjournals in the above areas.

Giuseppe Rossi received the doctoral degreein computer science from the University of Bari,Italy. In 1985, after receiving a three-year grantfor young computer scientists, he joined CRAI,a research and application center in Informa-tics located at Rende, Italy, where presently heis a senior researcher. He has been mainly ac-tive in the area of data and knowledge basedesign and implementation. In particular, he wasinvolved in two large ESPRIT projects (namely,KIWI and KIWIS) for the exploitation of the

logic and object-oriented paradigms within a novel knowledge-basedsystem. In addition, he has worked on some knowledge modeling is-sues within the CRAI speech recognition group. Recently, he has beenproject leader of a large educational project. He is a member of theIEEE.