=Paper=
{{Paper
|id=Vol-1517/JOWO-15_ontolp_paper_7
|storemode=property
|title=Extending NoHR for OWL 2 QL
|pdfUrl=https://ceur-ws.org/Vol-1517/JOWO-15_ontolp_paper_7.pdf
|volume=Vol-1517
|dblpUrl=https://dblp.org/rec/conf/ijcai/CostaKL15
}}
==Extending NoHR for OWL 2 QL==
Extending NoHR for OWL 2 QL∗ Nuno Costa, Matthias Knorr and João Leite NOVA LINCS Departamento de Informática Universidade NOVA de Lisboa 2829-516 Caparica, Portugal Abstract et al., 2010] are not suitable to model defaults and exceptions with a closed-world view, a frequently requested feature, e.g., The Protégé plug-in NoHR allows the user to com- when matching patient records to clinical trial criteria [Patel bine an OWL 2 EL ontology with a set of non- et al., 2007]. monotonic (logic programming) rules – suitable, Among the plethora of approaches for extending DLs with e.g., to express defaults and exceptions – and non-monotonic features and deal with this problem (c.f. re- query the combined knowledge base (KB). The lated work in [Eiter et al., 2008; Motik and Rosati, 2010]), formal approach realized in NoHR is polynomial NoHR builds on Hybrid MKNF [Motik and Rosati, 2010], (w.r.t. data complexity) and it has been shown that which is based on the logic of minimal knowledge and nega- even very large health care ontologies, such as tion as failure (MKNF) [Lifschitz, 1991], under the well- SNOMED CT, can be handled. As each of the founded semantics [Knorr et al., 2011], a formalism that com- tractable OWL profiles is motivated by different ap- bines DLs and non-monotonic rules as known from Logic plication cases, extending the tool to the other pro- Programming (see also [Alberti et al., 2012] for further moti- files is of particular interest, also because these pre- vation in its favor). serve the polynomial data complexity of the com- This choice is motivated, on the one hand, by the fact that bined formalism. Yet, a straightforward adaptation non-monotonic logic programming rules are one of the most of the existing approach to OWL 2 QL turns out to well-studied formalisms that admit expressing defaults, ex- not be viable. In this paper, we provide the non- ceptions, and also integrity constraints in a declarative way, trivial solution for the extension of NoHR to OWL and are part of RIF [Boley and Kifer, 2013], the other expres- 2 QL by directly translating the ontology into rules sive language for the Semantic Web whose standardization without any prior pre-processing or classification. is driven by the W3C.4 On the other hand, Hybrid MKNF We have implemented our approach and our evalu- provides a very general and flexible framework for combin- ation shows encouraging results. ing DL ontologies and non-monotonic rules (see [Motik and Rosati, 2010]). In addition, [Knorr et al., 2011], which is 1 Introduction a variant of [Motik and Rosati, 2010] based on the well- founded semantics [Gelder et al., 1991] for logic programs, NoHR1 is a plug-in for the ontology editor Protégé2 that al- has a (lower) polynomial data complexity and is amenable lows its users to query combinations of EL+ ⊥ ontologies and for applying top-down query procedures, such as SLG(O) non-monotonic rules in a top-down manner. [Alferes et al., 2013], to answer queries based only on the in- Its motivation stems from the fact that many current ontolo- formation relevant for the query, and without computing the gies, such as the very large health care ontologies widely used entire model. in the area of medicine, e.g., SNOMED CT,3 are expressed in NoHR is thus applicable to combinations of non- OWL 2 EL, one of the OWL 2 profiles [Motik et al., 2013], monotonic rules and OWL 2 EL ontologies. However, other and its underlying description logic (DL) EL++ [Baader et applications (see, e.g., [Calvanese et al., 2011; Savo et al., al., 2005]. Yet, due to their monotonic semantics, i.e., pre- 2010]) require ontologies using DL constructors which are viously drawn conclusions persist when new additional in- not covered by OWL 2 EL, such as concept and role negation formation is adopted, DL-based ontology languages [Baader or role inverses, as admitting these would raise its polynomial ∗ complexity [Baader et al., 2005]. Partially supported by Fundação para a Ciência e a Tecnologia under project PTDC/EIA-CCO/121823/2010 and strategic project OWL 2 QL and the DL-Lite family [Calvanese et al., PEst/UID/CEC/04516/2013. M. Knorr was also supported by grant 2007; Artale et al., 2009] to which the DL underneath OWL 2 SFRH/BPD/86970/2012. QL belongs, DL-LiteR , is suitable in these cases and has re- 1 cently drawn a lot of attention in research and in applications. http://centria.di.fct.unl.pt/nohr/ 2 http://protege.stanford.edu 3 4 http://www.ihtsdo.org/snomed-ct/ http://www.w3.org Even though a simple language at first glance, it is expres- 2 Preliminaries sive enough to capture basic ontology languages, conceptual data models, e.g., Entity-Relationship, and object-oriented 2.1 DL-LiteR formalisms, e.g., basic UML class diagrams. Reasoning fo- The description logic underlying OWL QL is DL-LiteR , cuses on answering queries by rewriting the initial query, with one language of the DL-Lite family [Calvanese et al., 2007; the help of the ontology, into a set of queries that can be an- Artale et al., 2009], which we recall following the presenta- swered using an industry-strength SQL engine over the data. tion in [Knorr and Alferes, 2011]. This provides the very low data complexity of LOGSPACE for The syntax of DL-LiteR is based on three disjoint sets of query answering, but also links directly to applications in individual names NI , concept names NC , and role names NR . ontology-based data access (OBDA) [Calvanese et al., 2011; Complex concepts and roles can be formed according to the Kontchakov et al., 2011]. Altogether, OWL 2 QL is naturally following grammar tailored towards huge datasets. B → A | ∃Q C → B | ¬B Q → P | P− R → Q | ¬Q In order to provide also such applications based on OWL 2 QL with the additional expressive power obtained from com- where A ∈ NC is a concept name, P ∈ NR a role name, and bining DL ontologies with non-monotonic rules, in this paper, P − its inverse. We also call B a basic concept, Q a basic we extend NoHR to OWL 2 QL. Whereas, at first sight, this relation, C a general concept and R a general role. could seem like a routine exercise, the fact that, to the best of A DL-LiteR knowledge base O = (T , A) consists of a our knowledge, no dedicated open-source OWL 2 QL clas- TBox T and an ABox A. The TBox contains general inclu- sifier with OWL API is available, and applying the EL rea- sion axioms (GCI) of the form B v C and role inclusion soner ELK [Kazakov et al., 2013], currently used in NoHR, axioms (RI) of the form Q v R, with B, C, Q, and R de- to classify a DL-LiteR ontology is obviously not possible, fined as above. We term positive inclusion axioms all GCIs we have to follow a different path here, namely translate the and RIs in O such that C is a basic concept and R is a basic ontology directly into rules. This introduces some non-trivial relation, respectively, and all other GCIs and RIs negative in- problems, in particular, the need to capture unsatisfiable con- clusion axioms. We also assume that Q− denotes the role P cepts and roles and irreflexive roles, for which in [Calvanese if Q = P − , and P − if Q = P . The ABox contains assertions et al., 2007] a closure of so-called negative axioms is com- of the form A(a) and P (a, b) where A ∈ NC , P ∈ NR , and puted, potentially introducing a huge number of additional a, b ∈ NI . Assertions C(a) for general concepts C can be axioms. We solve this problem by introducing an extension included by A v C and A(a) for a new concept name A. of the graph, used, e.g., in [Lembo et al., 2013] for classifica- The semantics of DL-LiteR is based on interpretations tion in OWL QL, to negative axioms. The resulting transla- I = (∆I , ·I ) consisting of a nonempty interpretation domain tion is implemented as a module of the NoHR translator, and ∆I and an interpretation function ·I that assigns to each indi- its performance evaluated. Our main contributions are: vidual a a distinct6 element aI of ∆I , to each concept name A a subset AI , and to each role name P a binary relation P I • A procedure for translating DL-LiteR ontologies into over I. This can be extended as usual: rules which allows answering queries over hybrid KBs (P − )I = {(i2 , i1 ) | (i1 , i2 ) ∈ P I } (¬B)I = ∆I \ B I combining such ontologies and non-monotonic rules; • An substantial extension of the Protégé plug-in NoHR to (∃Q)I = {i | (i, i0 ) ∈ QI } (¬Q)I = ∆I × ∆I \ QI include OWL 2 QL ontologies, beyond DL-LiteR via An interpretation I is a model of GCI B v C and of RI normalizations, including optimizations on the number Q v R if B I ⊆ C I and QI ⊆ RI respectively. I is also a of created rules and the use of tabling in the top-down model of an assertion A(a) (P (a, b)) if aI ∈ AI ((aI , bI ) ∈ query engine XSB Prolog;5 P I ). Given an axiom/assertion α we denote by I |= α that • An evaluation of our extension that shows that NoHR I is a model of α. A model of a DL-LiteR KB O = (T , A) for OWL 2 QL maintains all positive evaluation results is an interpretation I such that I |= α holds for all α ∈ of the OWL 2 EL version [Ivanov et al., 2013], and is T ∪ A, and O is satisfiable if it has at least one model, and even faster during pre-processing, as no classification is unsatifiable otherwise. Also, O entails axiom α, written O |= necessary, in exchange for an on average slightly longer α, if every model of O satisfies α. response time during querying. 2.2 MKNF Knowledge Bases The remainder of the paper is structured as follows. In Sect. 2, we briefly recall DL-LiteR and MKNF knowl- MKNF knowledge bases (KBs) build on the logic of minimal edge bases as a tight combination of the former DL and knowledge and negation as failure (MKNF) [Lifschitz, 1991]. non-monotonic rules. Then, we present the translation of Two main different semantics have been defined [Motik and DL-LiteR ontologies which allows us to query such MKNF Rosati, 2010; Knorr et al., 2011], and we focus on the well- knowledge bases in Sect. 3. In Sect. 4, we discuss the changes founded version [Knorr et al., 2011], due to its lower com- made in the implementation for OWL 2 QL including opti- putational complexity and amenability to top-down querying mizations, and evaluate it in Sect. 5, before we conclude in without computing the entire model. Here, we only point out Sect. 6. 6 Hence, the unique name assumption is applied and, as shown in Artale et al., 2009], dropping it would increase significantly the [ 5 http://xsb.sourceforge.net computational complexity of DL-LiteR . important notions following [Ivanov et al., 2013], and refer to commonly achieved using a partition of modal atoms, i.e., [Knorr et al., 2011] and [Alferes et al., 2013] for the details. all expressions of the form Kϕ for each Kϕ or notϕ oc- We start by recalling MKNF knowledge bases as presented curring in π(K). For [Knorr et al., 2011], such a partition in [Alferes et al., 2013] to combine an ontology and a set of assigns true, false, or undefined to (modal) atoms, and can non-monotonic rules (similar to a normal logic program). be effectively computed in polynomial time. If K is MKNF- Definition 1. Let O be an ontology. A function-free first- consistent, then this partition does correspond to the unique order atom P (t1 , . . . , tn ) s.t. P occurs in O is called DL- model of K [Knorr et al., 2011], and, like in [Alferes et al., atom; otherwise non-DL-atom. A rule r is of the form 2013], we call the partition the well-founded MKNF model Mwf (K). Here, K may indeed not be MKNF-consistent if the H ← A1 , . . . , An , notB1 , . . . , notBm (1) ontology alone is unsatisfiable, or by the combination of ap- where the head of r, H, and all Ai with 1 ≤ i ≤ n and Bj propriate axioms in O and rules in P, e.g., A v ¬B, and with 1 ≤ j ≤ m in the body of r are atoms. A program P A(a) ← and B(a) ←. Strictly speaking, unlike [Ivanov et is a finite set of rules, and an MKNF knowledge base K is a al., 2013], we do not have to make assumptions on the satisfi- pair (O, P). A rule r is DL-safe if all its variables occur in at ability of O as we are not going to use a classifier when pro- least one non-DL-atom Ai with 1 ≤ i ≤ n, and K is DL-safe cessing DL-LiteR ontologies. Still, for the technical results if all its rules are DL-safe. established in Sec. 3, we will rely on satisfiability, since we DL-safety ensures decidability of reasoning with MKNF are able to entail everything from an unsatisfiable O, whereas knowledge bases and can be achieved by introducing a new the translation into rules defined in Sec. 3 would not permit predicate o, adding o(i) to P for all constants i appearing in that. This is why in the following, we assume that O oc- K and, for each rule r ∈ P, adding o(X) for each variable X curring in K is satisfiable, which does not truly constitute a appearing in r to the body of r. Therefore, we only consider restriction as we can always turn the ABox into rules with- DL-safe MKNF knowledge bases. out any effect on Mwf (K). An alternative approach would be to use one of the paraconsistent semantics for MKNF knowl- Example 1. Consider an MKNF knowledge base K as given edge bases [Kaminski et al., 2015], but this is outside the below for recommending CDs adapted from [Knorr et al., scope of this paper, and an issue for future work as currently 2011] (with some modifications). We denote DL-atoms and no paraconsistent correspondence to the querying procedure constants with upper-case names and non-DL-atoms and SLG(O) used here exists. variables with lower-case names.7 ∃HasArtist − v Artist Piece v ∃HasArtist 2.3 Querying in MKNF Knowledge Bases In [Alferes et al., 2013], a procedure, called SLG(O), is de- ∃HasComposed − v Piece Artist v ¬Piece fined for querying MKNF knowledge bases under the well- HasComposed − v HasArtist founded MKNF semantics. This procedure extends SLG res- recommend (x ) ← Piece(x ), notowns(x ), notlowEval (x ), olution with tabling [Chen and Warren, 1996] with an ora- cle to O that handles ground queries to the DL-part of K by interesting(x ) returning (possibly empty) sets of atoms that, together with interesting(x ) ← Piece(x ), notowns(x ), Piece(y), owns(y), O and information already proven true, allows us to derive Artist(z ), HasArtist(y, z ), HasArtist(x , z ) the queried atom. We refer to [Alferes et al., 2013] for the full account of SLG(O), and only recall a few crucial notions owns(Summertime) ← Piece(Summertime) ← necessary in the following. HasArtist(Summertime, Gershwin) ← SLG(O) is based on creating top-down derivation trees HasComposed (Gershwin, RhapsodyInBlue) ← with the aim of answering (DL-safe) conjunctive queries Q = q(X) ~ ← A1 , . . . , An , notB1 , . . . , notBm where each This example shows that we can seamlessly express defaults and exceptions, such as recommending pieces as long as they variable in Q occurs in at least one non-DL atom in Q, and where X ~ is the (possibly empty) set of requested variables are not owned or having a low evaluation, and at the same time taxonomic/ontological knowledge including information appearing in the body. over unknown individuals, such as every piece having at least In general, the computation of Mwf (K) uses two different one artist without having to specify whom, but also features of versions of K in parallel to guarantee that a) coherence is en- DL-LiteR , such as domain and range restrictions (of roles). sured, i.e., if ¬P (a) is derivable, then notP (a) has to be true as well (cf. also [Knorr et al., 2011]), and b) MKNF- The semantics of MKNF knowledge bases K is usually consistency of K can be verified. For a top-down approach given by a translation π into an MKNF formula π(K), i.e., a this is impractical, so, instead, a doubled MKNF knowledge formula over first-order logic extended with two modal oper- base Kd = (O, Od , P d ) is defined in which a copy of O with ators K and not. Namely, every rule of the form (1) is trans- new doubled predicates is added, and two rules occur in P d lated into KH ← KA1 , . . . , KAn , notB1 , . . . , notBm , for each rule in P, intertwining original and doubled predi- π(P) is the conjunction of the translations of its rules, and cates (see Def. 3.1 in [Alferes et al., 2013]). It is shown that π(K) = Kπ(O) ∧ π(P) where π(O) is the first-order trans- an atom A is true in Mwf (K) iff A is true in Mwf (Kd ) and A lation of O. Reasoning with such MKNF formulas is then is false in Mwf (K) iff Ad is false in Mwf (Kd ). Note that Kd 7 To ease readability, we omit the auxiliary atoms that ensure DL- is necessary in general, but we can use K here if it contains safety and leave them implicit. no negative inclusion axioms. In [Alferes et al., 2013], the notion of oracle is defined to cannot be translated straightforwardly into rules, nor do they handle ground queries to the ontology, but before we recall directly contribute to the result when querying for ground in- that notion, we use an example to illustrate the idea. stances, e.g., of HasArtist(x , y). Still, such axioms may con- Example 2. Recall K in Ex. 1. Here, we omit Kd and restrict tribute to derivations within O, which is why, in [Ivanov et al., ourselves to K, which suffices our purposes. Consider query 2013], a classification using the dedicated and highly efficient q = recommend (Summertime). By instantiating the body EL reasoner ELK [Kazakov et al., 2013] is first applied to de- of the matching rule head in K with x = Summertime, we rive implicit consequences. These, together with all axioms obtain two new queries. The first one, Piece(Summertime), in O, are then translated into rules, now discarding certain can be answered by means of the rule with matching head. axioms with ∃ on the right-hand side. The second, notowns(Summertime), is handled by query- ing for owns(Summertime), for which a corresponding rule exists, so notowns(Summertime) fails, hence q is false. Here, since to the best of our knowledge no dedicated, open-source OWL 2 QL classifier with OWL API is avail- Consider q1 = recommend (RhapsodyInBlue). Us- able, we opt to follow a different path, namely translate the ing the same rule with matching rule head we obtain ontology directly into rules. This also simplifies and short- four new instantiated queries from the rule body. Now, ens the preprocessing phase and avoids a priori-classification, Piece(RhapsodyInBlue) cannot be derived from the rules, but requires some non-trivial considerations to ensure that no but we can query the ontology and the oracle will return, derivations are lost in the process, which we will explain next. e.g., a query HasComposed (x1 , RhapsodyInBlue) that if proven true can be added to O, which would allow us to derive the queried goal. This query succeeds because Essentially, axioms, such as Piece v ∃HasArtist, cannot of HasComposed (Gershwin, RhapsodyInBlue) ←, and so be translated into a rule HasArtist(x , y) ← Piece(x ) us- does Piece(RhapsodyInBlue). Then, we cannot prove ing a universal variable y, as this would allow us to derive owns(RhapsodyInBlue) nor lowEval (RhapsodyInBlue), HasArtist(x , y) for any Piece(x ) and y, which is clearly not so both fail, succeeding their (default) negated queries. For what the axiom expresses. Using a new constant c instead of y the remaining new query interesting(RhapsodyInBlue), the would not be correct either, as querying for HasArtist(x , y) second rule head matches, creating further subgoals. The would return HasArtist(x , c) for any Piece(x ) for the same first two were just answered, as the next two with y = c. Therefore, we proceed differently by introducing new Summertime for q. The remaining also follow from the in- auxiliary predicates that intuitively represent the domain and terplay of O and P in K, so q1 succeeds. range of roles. For our example, this will yield the rule We recall the notions of a complete and a (correct) partial DHasArtist(x ) ← Piece(x ) where DHasArtist stands for oracle from [Alferes et al., 2013]. the domain of HasArtist (and RHasArtist its range). Us- Definition 2. Let Kd = (O, Od , P d ) be a doubled MKNF ing such auxiliary predicates also means that we have to KB, I a set of ground atoms (already proven to be true), make sure that, e.g., HasArtist(Summertime, Gershwin) S a ground query, and L a set of ground atoms such that allows us to derive DHasArtist(Summertime), which can each L ∈ L is unifiable with at least one rule head in P d . be achieved via an additional rule DHasArtist(x ) ← The complete oracle for O, denoted compTO , is defined by HasArtist(x , y). Moreover, for HasComposed − v compTO (I, S, L) iff O ∪ I ∪ L |= S or Od ∪ I ∪ L |= S. A HasArtist, it does not suffice to translate the ax- partial oracle for O, denoted pTO , is a relation pTO (I, S, L) iom to HasArtist(x , y) ← HasComposed (y, x ), but such that if pTO (I, S, L), then O∪I∪L |= S or Od ∪I∪L |= also link the new auxiliary predicates for both roles, S for consistent O ∪ I ∪ L and Od ∪ I ∪ L, respectively. by adding, DHasArtist(x ) ← RHasComposed (x ) and A partial oracle pTO is correct w.r.t. compTO iff, for all RHasArtist(x ) ← DHasComposed (x ). MKNF-consistent Kd , replacing compTO in SLG(O) with pTO succeeds for exactly the same set of queries. We now formalize this translation, and we start by intro- Partial oracles may avoid returning unnecessary answers L, ducing notation on how to translate general concepts and such as non-minimal answers or those that try to derive an roles. For that purpose, we formally introduce for each role MKNF-inconsistency even though Kd is MKNF-consistent. P ∈ NR auxiliary predicates DP and RP with the intuition Also, correctness of partial oracles is only defined w.r.t of representing the domain and range of P . Also, similar to MKNF-consistent K. The rationale is that, when querying previous work in [Alferes et al., 2013; Ivanov et al., 2013], top-down, we want to avoid checking whether the entire KB we use special atoms N H(t~i ) in SLG(O) that represent a Kd is MKNF-consistent. This leads to para-consistent deriva- query ¬H(t~i ) to the oracle. These are, of course, only rele- tions if Kd is not MKNF-consistent, e.g., some atom P is true, vant if O contains negative inclusion axioms. yet P d is false, while other independent atoms are evaluated as if Kd was MKNF-consistent (see [Alferes et al., 2013]). 3 Translating the Ontology into Rules As argued for the case of EL+ [ ] ⊥ Ivanov et al., 2013 , axioms Definition 3. Let C be a concept, R a role, x and y variables, with ∃ on the right-hand side, e.g., Piece v ∃HasArtist, and v a new (anonymous) variable (disjoint from x and y). ∃HasComposed We define tr(C, x) and tr(R, x, y) as follows: ∃HasComposed− ∃HasArtist− A(x) if C = A DP (x) if C = ∃P P iece ¬∃HasArtist Artist tr(C, x) = RP (x) if C = ∃P − ∃HasArtist ¬Artist ¬P iece if C = ¬A N A(x) tr(¬Q, x, v) if C = ¬∃Q ¬∃HasArtist− ¬∃HasComposed− P (x, y) if R = P ¬∃HasComposed if R = P − P (y, x) HasComposed− ¬HasArtist HasComposed ¬HasArtist− tr(R, x, y) = N P (x, y) if C = ¬P HasArtist ¬HasComposed− HasArtist− ¬HasComposed N P (y, x) if C = ¬P − We obtain trd (C, x) and trd (Q, x, y) from tr(C, x) and Figure 1: The digraph GT for Example 1 tr(Q, x, y) by substituting all predicates P in tr(C, x) and tr(Q, x, y) with P d , respectively. is irreflexive. Even though this does not entail any assertion, tr(C, x) and tr(R, x, y) handle both positive and negative knowing that ∀x.¬HasComposed (x , x ) does hold should be inclusions and no additional case distinction is necessary. captured in the translation. We introduce Ψ(T ), the set of Before we present the actual translation, we need to in- irreflexive roles in T , to be able to ensure exactly that. troduce one central notion, namely a graph to represent the Definition 5. Let T be a DL-LiteR TBox and GT its di- axioms in a given TBox T as well as the implicitly derivable graph. W e define Ψ(T ) as the smallest set of all P ∈ NR axioms, which will be necessary for defining the translation that satisfy at least one of the following conditions: itself, but also turn out useful when establishing the correct- ness of the translation. Graphs have been used for classifi- 1. For some B1 v ¬B2 ∈ T , there exist paths from ∃P to cation in OWL QL (of positive inclusion axioms) [Lembo et B1 and from ∃P − to B2 ; al., 2013], and we extend the notion here to also take negative 2. For some B1 v ¬B2 ∈ T , there exist paths from ∃P − inclusion axioms into account. We thus introduce the digraph to B1 and from ∃P to B2 ; (directed graph) of T as follows. 3. For some Q1 v ¬Q2 ∈ T , there exist paths from P to Q1 and from P − to Q2 ; Definition 4. Let T be a DL-LiteR TBox. The digraph of 4. For some Q1 v ¬Q2 ∈ T , there exist paths from P − to T , GT = hV, Ei, is constructively defined as follows. Q1 and from P to Q2 . 1. If A ∈ NC , then A and ¬A are in V; This notion builds on GT , which is also required for detect- 2. If R ∈ NR , then P , ∃P , ∃P − , ¬P , ¬∃P , and ¬P − are ing a further set of derivations. Imagine we would (wrong- in V; fully) add Artist v ∃HasComposed − to O in Example 1. 3. If B1 v B2 ∈ T , then the edges (B1 , B2 ) and Then there would be a path from Artist to both Piece and (¬B2 , ¬B1 ) are in E; ¬Piece, i.e., the concept Artist would be unsatisfiable. Note 4. If Q1 v Q2 ∈ T , then the edges (Q1 , Q2 ), (Q− − 1 , Q2 ), that independently of whether the hybrid KB is MKNF- (∃Q1 , ∃Q2 ), (∃Q1 , ∃Q2 ), (¬Q2 , ¬Q1 ),(¬Q2 , ¬Q− − − − 1 ), inconsistent or not, we need to make sure that all unsatisfiable (¬∃Q2 , ¬∃Q1 ) e (¬∃Q− 2 , ¬∃Q − 1 ) are in E; concepts and roles are determined, so we introduce Ω(T ), 5. If B1 v ¬B2 ∈ T , then the edges (B1 , ¬B2 ) and quite similar in spirit to Ψ(T ). (B2 , ¬B1 ) are in E; Definition 6. Let T be a DL-LiteR TBox and GT its di- 6. If Q1 v ¬Q2 ∈ T , then the edges (Q1 , ¬Q2 ), graph. We define Ω(T ) as the smallest set of all A ∈ NC (Q− − 2 , ¬Q1 ), (∃Q1 , ¬∃Q2 ), (∃Q2 , ¬∃Q1 ), such that, for some B1 v ¬B2 ∈ T , there exist paths from A (∃Q1 , ¬∃Q− − − − 2 ) and (∃Q2 , ¬∃Q1 ) are in E. to both B1 and B2 , and all P ∈ NR that satisfy at least one of Basically, each possible general concept and general role the following conditions: over NC and NR is a node in GT , and the directed edges 1. For some B1 v ¬B2 ∈ T , there exist paths from ∃P to represent logical implications that follow from the axioms. both B1 and B2 ; Namely, for items 3. and 5., the subset inclusion itself and its 2. For some B1 v ¬B2 ∈ T , there exist paths from ∃P − contrapositive are in E, and this is similar for items 4. and 6., to both B1 and B2 ; only that the additional combinations due to inverses, ∃, and 3. For some Q1 v ¬Q2 ∈ T , there exist paths from P to ¬ have to be taken into account. In this sense, the graph can both Q1 and Q2 ; be understood as capturing all subset inclusions (explicit and 4. For some Q1 v ¬Q2 ∈ T , there exist paths from P − to implicit) in O, i.e., whenever there is a path from concept C1 both Q1 and Q2 . to concept C2 and from role R1 to role R2 , then C1 v C2 and R1 v R2 hold respectively. An Example of such a digraph is With all pieces in place, we can finally introduce the defi- given in Fig. 1 for the TBox T from Example 1. nition of the translation of a DL-LiteR ontology into rules. One observation to be made in Fig. 1, is that Definition 7. Let O be a DL-LiteR ontology. We define d ∃HasComposed v ¬∃HasComposed , i.e., HasComposed PO from O, where B1 , B2 are basic concepts, Q1 , Q2 basic roles, x, y variables, and a, b individuals, as the smallest set Lemma 1. Let O be a DL-LiteR ontology, A a unary and containing: R a binary predicate: d d (e) for every P ∈ NR : • O |= A(a) iff PO |= A(a) and O |= R(a, b) iff PO |= DP (x) ← P (x, y) DP d (x) ← P d (x, y) R(a, b). RP (y) ← P (x, y) RP d (y) ← P d (x, y) A similar property holds for (classically) atoms. (a1) for every A(a) ∈ O: A(a) ← Ad (a) ← notN A(a) Lemma 2. Let O be a DL-LiteR ontology, A a unary and (a2) for every P (a, b) ∈ O: R a binary predicate: P (a, b) ← P d (a, b) ← notN P (a, b) • O |= ¬A(a) iff POd |= N A(a) and O |= ¬R(a, b) iff (s1) for every B1 v B2 ∈ O: d PO |= N R(a, b). tr(B2 , x) ← tr(B1 , x) trd (B2 , x) ← trd (B1 , x), nottr(¬B2 , x) We can also show the correspondent to Lemma 1 for the tr(¬B1 , x) ← tr(¬B2 , x) doubled predicates. (s2) for every Q1 v Q2 ∈ O: Lemma 3. Let O be a DL-LiteR ontology, A a unary and tr(Q2 , x, y) ← tr(Q1 , x, y) R a binary predicate: trd (Q2 , x, y) ← trd (Q1 , x, y), nottr(¬Q2 , x, y) tr(∃Q2 , x) ← tr(∃Q1 , x) • Od |= Ad (a) iff PO d |= Ad (a) and Od |= Rd (a, b) iff d d trd (∃Q2 , x) ← trd (∃Q1 , x), nottr(¬∃Q2 , x) PO |= R (a, b). tr(∃Q− − 2 , x) ← tr(∃Q1 , x) d Thus, we can define a correct partial oracle based on PO . tr (∃Q2 , x) ← tr (∃Q− d − d − 1 , x), nottr(¬∃Q2 , x) tr(¬Q1 , x, y) ← tr(¬Q2 , x, y) Theorem 4. Let Kd = (O, Od , P d ) be a doubled MKNF KB (n1) for every B1 v ¬B2 ∈ O: and pTOQL a partial QL oracle such that pTOQL (I, S, L) iff tr(¬B1 , x) ← tr(B2 , x) tr(¬B2 , x) ← tr(B1 , x) POd ∪ I ∪ L |= S. Then pTOQL is a correct partial oracle w.r.t. (n2) for every Q1 v ¬Q2 ∈ O: compTO . tr(¬Q2 , x, y) ← tr(Q1 , x, y) tr(¬Q1 , x, y) ← tr(Q2 , x, y) Instead of coupling two rule reasoners that interact with (i1) for every A ∈ Ω(T ): N A(x) ← each other using an oracle, we can simplify the process alto- (i2) for every P ∈ Ω(T ): N P (x, y) ← gether and integrate both into one rule reasoner. The resulting (ir) for every P ∈ Ψ(T ): N P (x, x) ← approach is decidable with polynomial data complexity. Item (e) ensures that the domain and range of roles is cor- Theorem 5. Let K = (O, P) be an MKNF KB with O in rectly encoded, items (a1) and (a2) translate the ABox, items DL-LiteR . An SLG(O) evaluation of a query in KQL = (s1) and (s2) the positive inclusions, items (n1) and (n2) the (∅, (P d ∪ PO d )) is decidable with data complexity in PTIME. negative inclusions, and items (i1), (i2), and (ir) introduce the rules representing unsatisfiable concepts and unsatisfiable 4 System Description d and irreflexive roles. Note, that PO contains the rule repre- d sentation for both O and O , which is why items (e)–(s2) In this section, we briefly describe the changes to the archi- contain doubled rules. Of course, if O does not contain neg- tecture of our plug-in and discuss some optimizations imple- ative inclusion axioms, then we can skip all these, as well as mented w.r.t. the translation described in Sec. 3. items (n1)–(ir) which will not contribute anything anyway in To allow the usage of OWL QL ontologies, changes were this case. The additional default atoms are added to the dou- essentially made in the translator. First, since now two bled rules to be in line with the idea of the doubling of rules OWL profiles are supported we have introduced a switch that in [Alferes et al., 2013]: whenever, e.g., A(x) is “classically checks the profile of the loaded/edited ontology. If it is in false” for some x, i.e., N A(x) holds, then we make sure that OWL EL, then NoHR behaves as described in [Ivanov et al., Ad (x) is derivable as false for that same x from the rules, 2013], i.e., the reasoner ELK is used to classify the ontology but not necessarily A(x), thus allowing to detect potential and return the inferred axioms to translator, which are then MKNF-inconsistencies. That is also the reason why neither translated. Otherwise, we treat O of the hybrid KB based on (n1)–(ir) nor the contrapositives in (s1) and (s2) do produce the translation described in Sec. 3 for OWL QL. the doubled counterparts: atoms based on predicates of the Notably, in Sec. 3, we only considered DL-LiteR while forms N C d or N Rd are not used anywhere. Finally, the dou- OWL QL includes a number of additional constructs which bled rules in (e) do not contain the default negated atom as often can be expressed in DL-LiteR . To account for that, this case only associates domain and range to a role assertion, we first normalize such expressions to axioms in DL-LiteR . either present in the ABox or derived elsewhere. Addition- This includes ignoring certain expressions, most of which do ally, predicates N DP or N RP are not used anywhere, so not contribute anything to derivations, e.g., SubClassOf(B such default negated atoms would be of no impact. owl:Thing), while others make the ontology unsatisfi- We can establish three correspondences between entail- able, such as ClassAssertion(owl:Nothing a), al- ment from satisfiable O and the program resulting from the though, as mentioned before, with no effect when querying translation POd . First, we consider positive atoms. the translated rules. The details on the normalization can be found in the appendix of the extended paper. Figure 2: Preprocessing time for LUBM for the two transla- Figure 3: Query time for three LUBM queries tion modes from roughly 100,000 to over 1,300,000 and performed pre- Subsequently, the graph is constructed, for determining un- processing from loading the ontology to loading the transla- satisfiable concepts and unsatisfiable and irreflexive roles, af- tion result in XSB. The results for both translators EL and ter which the translation is performed, which includes a num- QL can be found in Fig. 2. Note that the segment “Initializa- ber of optimizations. First, whenever there are no negative in- tion” is the time for preparing the translation, which for EL clusions, the doubled rules are omitted in the cases (e)–(s2) of includes classifying the ontology, while the larger part of the Def. 7. Additionally, case (e) is limited to those rules whose segment “Other” corresponds to loading the ontology. heads appear in the body of another rule. Both steps reduce We can observe that QL is considerably faster, indeed up the overall number of rules created during the translation. to 40s for LUBM10, to a considerable extent due to avoiding The second group of optimizations is related to tabling in classification. Besides that, the preprocessing time increases XSB, which contributes to help answering queries very effi- linearly, and the overall time for preprocessing is acceptable ciently in a top-down manner, and avoid infinite loops while in our opinion as this is only done once before querying. querying. However, simply declaring all predicates to be Next, we also queried the resulting ten rule sets in XSB for tabled is very memory-consuming, so we reduced the num- both EL and QL using queries from the LUBM benchmark, ber of tabled predicates without affecting loop detection. For that were manually transformed from SPARQL to queries us- example, only predicates that appear in any rule head and in able in XSB. Among the fourteen provided queries, we chose any rule body need to be tabled. In addition, rules with an seven, because the others were either no longer meaningful empty body (facts) can be ignored in the previous criterion, due to removal of certain axioms/DL constructors during the as these will not cause an infinite loop. initial simplifications we applied to LUBM, or because ini- tial tests revealed that XSB would run out of memory for a 5 Evaluation query, simply because, for our test system with 4GB mem- ory, too much data was being gathered in the tables to answer In this section, we evaluate our system and show that a) pre- the query. In more detail, we used the queries 1, 2, 3, 4, 5, processing is even faster when compared to NoHRs EL ver- 7, 10 from the LUBM benchmark. The results are shown for sion, which was already capable of preprocessing large on- some representatives in Fig. 3. Basically, for queries 1, 3, 4, tologies in a short period of time, b) querying scales well, and 10, no real difference between EL and QL exists and the even for over a million facts/assertions in the ABox, despite response time is strictly below 1s. For query 7, there exists a being slightly slower on average in comparison to EL, and c) slight difference in favor of EL with 2.5s vs. 1s for LUBM10, adding rules scales linearly for pre-processing and querying, whereas for queries 2 and 5 the difference increases. In all even for an ontology with many negative inclusions. cases, the response time grows linearly w.r.t. the increasing Tests were performed on a Notebook running Linux size of LUBM, and we can conclude that on average query- 3.17.6-1-ARCH (x86 64) with 1.8 GHz 4x Intel Core i3 pro- ing in QL is slightly slower. Here, EL compensates for the cessor and 4 GB of RAM. We used XSB 3.4.0 for querying, longer preprocessing, and this effect becomes more visible, ran all tests in a terminal version and Java with “-XX:+Ag- the more complex the query is and the more data needs to gressiveHeap” option, and report averages over 5 runs. gathered to answer it. Intuitively, this can be explained by First, we considered LUBM8 [Guo et al., 2005], a standard looking at a simple example with two axioms A v ∃R and benchmark for evaluating queries over a large data set. The ∃R v B For EL, classification, yields A v B and only one ontology itself is already rather simple and we reduced it even axiom is translated and only one derivation step is required in a bit further by removing all axioms that are not common to XSB to obtain, say B(a) from A(a). For QL, both axioms both OWL 2 QL and EL. The resulting ontology has only are translated directly without classification, using DR, but ninety logical axioms, but this way we can use it with both now, two derivation steps would be required in XSB to ob- translators included in NoHR and compare their performance. tain B(a) from A(a). It thus seems that deciding which of We created instances of LUBM 1–10 with assertions ranging the two forms of translations performs better depends on the kind (and number) of queries we pose. 8 http://swat.cse.lehigh.edu/projects/lubm/ Finally, with the aim of also testing a more expressive Alferes, 2011] both build on the well-founded MKNF seman- tics [Knorr et al., 2011]. While [Gomes et al., 2010] uses the non-standard CDF framework integrated in XSB, which complicates compatibility to standard OWL tools based on the OWL API, [Knorr and Alferes, 2011] presents an OWL 2 QL oracle based on common rewritings in the underlying DL DL-LiteR [Artale et al., 2009], but would require constant interaction between a rule reasoner and a DL reasoner, which is why we believe it to be less efficient than our approach. Two related tools are DReW [Xiao et al., 2013] and HD Rules [Drabent et al., 2007], although based on different un- Figure 4: Query time for LIPID derlying formalisms to combine ontologies and rules (c.f. [Eiter et al., 2008; Motik and Rosati, 2010] for a compari- son), which, again, considerably complicates comparison. OWL 2 QL ontology, we used the LIPID ontology,9 which Future work includes the extension to OWL 2 RL, but has, besides 749 subclass axioms, 1,486 class disjointness developing an alternative for OWL 2 QL using the classi- axioms and 20 inverse object properties in combination with fier integrated in ontop [Kontchakov et al., 2014] once its non-monotonic rules. The latter were created by means of OWL API becomes available, or even the general reasoner the rule generator already used in [Ivanov et al., 2013] with Konclude [Steigmiller et al., 2014], could shed more light a ratio 1:10 between rules and facts, also introducing some on whether classification or direct translation fares better for new predicates not present in the ontology itself. We per- proper OWL 2 QL ontologies. The efficiency of the latter rea- formed the preprocessing step and observed only slight ef- soner also motivates looking into non-polynomial DLs, with fects due to the increasing amount of rules. The time for possible influences from recent work on rewriting disjunctive processing the ontology was naturally stable for all steps, datalog programs [Kaminski et al., 2014]. Finally, we may and overall processing time was between 2 and 3s. Notably, extend NoHR for OWL 2 QL (and EL) to the paraconsistent the considerable amount of negative inclusions had no sig- semantics [Kaminski et al., 2015] that would provide true nificant impact on time, e.g., when constructing the graph. support to the already occasionally observed paraconsistent Then, we posed three simple queries (Query1–3), namely behavior, or alternatively, to either generalizations of hybrid Acyl Ester Chain(X), Lipid(X), and Entity(X) to the result- KBs [Gonçalves and Alferes, 2010; Knorr et al., 2014; 2012; ing rule sets in XSB. The results are shown in Fig. 4. As Knorr, 2015] or dynamics in hybrid KBs [Slota et al., 2011; we can see, the response time is still very reasonable, from Slota and Leite, 2012], or even both [Gonçalves et al., 2014]. clearly below 1s to up to 8s. Still, the results in our opinion already show the effect of the arbitrary rules that tend to intro- References duce links between predicates that increase the search space. [Alberti et al., 2012] M. Alberti, M. Knorr, A. S. Gomes, J. Leite, This can be noted in particular for Query1, where in one case R. Gonçalves, and M. Slota. Normative systems require hybrid a smaller set of rules results in a higher response time, simply knowledge bases. In Procs. of AAMAS. IFAAMAS, 2012. because no generated rule set is a subset of another. We note [Alferes et al., 2013] J. J. Alferes, M. Knorr, and T. Swift. Query- that performance tests of querying (non-monotonic) rules and driven procedures for hybrid MKNF knowledge bases. ACM ontologies would considerably benefit from real datasets but Trans. Comput. Log., 14(2):1–43, 2013. to the best of our knowledge currently none are available. [Artale et al., 2009] A. Artale, D. Calvanese, R. Kontchakov, and M. Zakharyaschev. The DL-Lite family and relations. J. Artif. 6 Conclusions Intell. Res. (JAIR), 36:1–69, 2009. We have extended NoHR, the Protégé plug-in that allows to [Baader et al., 2005] F. Baader, S. Brandt, and C. Lutz. Pushing query non-monotonic rules and ontologies in OWL 2 EL, the EL envelope. In Procs. of IJCAI. Professional Book Center, to also admit ontologies in OWL 2 QL. While the principal 2005. architecture of the tool remains the same, the crucial mod- [Baader et al., 2010] F. Baader, D. Calvanese, D. L. McGuinness, ule that translates the ontology into rules with the help of a D. Nardi, and P. F. Patel-Schneider, editors. The Description classifier simply cannot be re-used, which is why we intro- Logic Handbook. Cambridge University Press, 2010. duced a novel direct translation for OWL 2 QL ontologies to [Boley and Kifer, 2013] H. Boley and M. Kifer, editors. RIF cover this profile. We have implemented this translation and Overview. W3C Recommendation, 5 February, 2013. Available discussed optimizations. The evaluation shows that it main- at http://www.w3.org/TR/rif-overview/. tains all positive evaluation results of the OWL 2 EL version [Calvanese et al., 2007] D. Calvanese, G. de Giacomo, D. Lembo, [Ivanov et al., 2013], and is even faster during pre-processing, M. Lenzerini, and R. Rosati. Tractable reasoning and efficient as no classification is necessary, in exchange for an on aver- query answering in description logics: The DL-Lite family. age slightly longer response time during querying. Journal of Automated Reasoning, 39(3):385–429, 2007. Besides the OWL 2 EL profile supported by NoHR, and [Calvanese et al., 2011] D. Calvanese, G. De Giacomo, D. Lembo, compared to in Sect. 5, also [Gomes et al., 2010; Knorr and M. Lenzerini, A. Poggi, M. Rodriguez-Muro, R. Rosati, M. Ruzzi, and D. F. Savo. The MASTRO system for ontology- 9 http://bioonto.dcs.aber.ac.uk/ql-ont/ based data access. Semantic Web, 2(1):43–53, 2011. [Chen and Warren, 1996] W. Chen and D. S. Warren. Tabled Eval- [Kontchakov et al., 2014] R. Kontchakov, M. Rezk, M. Rodriguez- uation with Delaying for General Logic Programs. Journal of the Muro, G. Xiao, and M. Zakharyaschev. Answering SPARQL ACM, 43(1):20–74, 1996. queries over databases under OWL 2 QL entailment regime. In [Drabent et al., 2007] W. Drabent, J. Henriksson, and J. Maluszyn- Procs. of ISWC. Springer, 2014. ski. Hd-rules: A hybrid system interfacing prolog with dl- [Lembo et al., 2013] D. Lembo, V. Santarelli, and D. F. Savo. reasoners. In Procs. of ALPSWS. CEUR-WS.org, 2007. Graph-based ontology classification in OWL 2 QL. In Procs. of ESWC. Springer, 2013. [Eiter et al., 2008] T. Eiter, G. Ianni, T. Lukasiewicz, R. Schind- lauer, and H. Tompits. Combining answer set programming [Lifschitz, 1991] V. Lifschitz. Nonmonotonic databases and epis- with description logics for the semantic web. Artif. Intell., temic queries. In Procs. of IJCAI. Morgan Kaufmann, 1991. 172(12-13):1495–1539, 2008. [Motik and Rosati, 2010] B. Motik and R. Rosati. Reconciling de- [Gelder et al., 1991] A. Van Gelder, K. A. Ross, and J. S. Schlipf. scription logics and rules. J. ACM, 57(5):93–154, 2010. The well-founded semantics for general logic programs. J. ACM, [Motik et al., 2013] B. Motik, B. Cuenca Grau, I. Horrocks, Z. Wu, 38(3):620–650, 1991. A. Fokoue, and C. Lutz, editors. OWL 2 Web Ontology Language: [Gomes et al., 2010] A. Sofia Gomes, J. J. Alferes, and T. Swift. Profiles. W3C Recommendation, 5 February, 2013. Available at Implementing query answering for hybrid MKNF knowledge http://www.w3.org/TR/owl2-profiles/. bases. In Procs. of PADL. Springer, 2010. [Patel et al., 2007] C. Patel, J. J. Cimino, J. Dolby, A. Fokoue, [Gonçalves et al., 2014] R. Gonçalves, M. Knorr, and J. Leite. A. Kalyanpur, A. Kershenbaum, L. Ma, E. Schonberg, and Evolving multi-context systems. In Procs. of ECAI. IOS Press, K. Srinivas. Matching patient records to clinical trials using on- 2014. tologies. In Procs. of ISWC/ASWC. Springer, 2007. [Gonçalves and Alferes, 2010] R. Gonçalves and J. Alferes. [Savo et al., 2010] D. F. Savo, D. Lembo, M. Lenzerini, A. Poggi, Parametrized logic programming. In Procs. of JELIA. Springer, M. Rodriguez-Muro, V. Romagnoli, M. Ruzzi, and G. Stella. 2010. Mastro at work: Experiences on ontology-based data access. In Procs. of DL. CEUR-WS.org, 2010. [Guo et al., 2005] Y. Guo, Z. Pan, and J. Heflin. LUBM: A [Slota and Leite, 2012] M. Slota and J. Leite. A unifying perspec- benchmark for OWL knowledge base systems. J. Web Sem., tive on knowledge updates. In Procs. of JELIA. Springer, 2012. 3(2-3):158–182, 2005. [Slota et al., 2011] M. Slota, J. Leite, and T. Swift. Splitting and up- [Ivanov et al., 2013] V. Ivanov, M. Knorr, and J. Leite. A query tool dating hybrid knowledge bases. TPLP, 11(4-5):801–819, 2011. for EL with non-monotonic rules. In Procs. of ISWC. Springer, 2013. [Steigmiller et al., 2014] A. Steigmiller, T. Liebig, and B. Glimm. Konclude: System description. J. Web Sem., 27:78–85, 2014. [Kaminski et al., 2014] M. Kaminski, Y. Nenov, and B. Cuenca Grau. Datalog rewritability of disjunctive datalog programs and [Xiao et al., 2013] G. Xiao, T. Eiter, and S. Heymans. The DReW its applications to ontology reasoning. In Procs. of AAAI. AAAI system for nonmonotonic dl-programs. In Procs. of SWWS. Press, 2014. Springer, 2013. [Kaminski et al., 2015] T. Kaminski, M. Knorr, and J. Leite. Ef- ficient paraconsistent reasoning with ontologies and rules. In Procs. of IJCAI, 2015. [Kazakov et al., 2013] Y. Kazakov, M. Krötzsch, and F. Simančı́k. The incredible ELK: From polynomial procedures to efficient reasoning with EL ontologies. Journal of Automated Reasoning, 53:1–61, 2013. [Knorr and Alferes, 2011] M. Knorr and J. J. Alferes. Querying OWL 2 QL and non-monotonic rules. In Procs. of ISWC. Springer, 2011. [Knorr et al., 2011] M. Knorr, J. J. Alferes, and P. Hitzler. Local closed world reasoning with description logics under the well- founded semantics. Artif. Intell., 175(9–10):1528–1554, 2011. [Knorr et al., 2012] M. Knorr, P. Hitzler, and F. Maier. Reconciling OWL and non-monotonic rules for the semantic web. In Procs. of ECAI. IOS Press, 2012. [Knorr et al., 2014] M. Knorr, M. Slota, J. Leite, and M. Homola. What if no hybrid reasoner is available? hybrid MKNF in multi- context systems. J. Log. Comput., 24(6):1279–1311, 2014. [Knorr, 2015] Matthias Knorr. Nonmonotonic nominal schemas re- visited. In Procs. of DL. CEUR-WS.org, 2015. [Kontchakov et al., 2011] R. Kontchakov, C. Lutz, D. Toman, F. Wolter, and M. Zakharyaschev. The combined approach to ontology-based data access. In Procs. of IJCAI. IJCAI/AAAI, 2011.