• Keine Ergebnisse gefunden

Chasing Sets: How to Use Existential Rules for Expressive Reasoning

N/A
N/A
Protected

Academic year: 2022

Aktie "Chasing Sets: How to Use Existential Rules for Expressive Reasoning"

Copied!
15
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Chasing Sets: How to Use Existential Rules for Expressive Reasoning

David Carral , Irina Dragoste , Markus Kr¨otzsch , Christian Lewe Knowledge-Based Systems Group, TU Dresden, Dresden, Germany

firstname.lastname@tu-dresden.de

Abstract

We propose that modern existential rule reason- ers can enable fully declarative implementations of rule-based inference methods in knowledge repre- sentation, in the sense that a particular calculus is captured by a fixed set of rules that can be evaluated on varying inputs (encoded as facts). We introduce Datalog(S) – Datalog with support for sets – as a surface language for such translations, and show that it can be captured in a decidable fragment of existential rules. We then implement several known inference methods in Datalog(S), and empirically show that an existing existential rule reasoner can thus be used to solve practical reasoning problems.

1 Introduction

Rules of inference are of fundamental importance in logi- cal reasoning, and the central building block of many proof systems, including tableaux-based model constructions, res- olution calculi, type-theoretic procedures [Ortizet al., 2010], and “consequence-driven” approaches in ontological reason- ing [Kazakov, 2009]. Indeed, rule-based calculi of logical deduction are as old as formal logic itself.

More recently, rules have also seen much renewed interest as a declarative computing paradigm, and many rule-based reasoning systems have been presented [Benediktet al., 2014;

Geerts et al., 2014; Aref et al., 2015; Baget et al., 2015;

Nenovet al., 2015; Urbaniet al., 2016]. At the core of these implementations is the simple rule languageDatalog, which is often extended with support for existential quantifiers or function terms in the consequences of rules. While this makes reasoning undecidable in general, there are many fast and scalable reasoners for cases where a finite model can be con- structed using some variant of thechaseprocedure [Benedikt et al., 2017; Urbaniet al., 2018]. It seems natural to exploit such systems to solve reasoning tasks in other areas of logic.

This can be achieved by translating theories of a relevant logic into sets of rules that entail equivalent consequences.

This idea has been applied, e.g., to description logics [Ortiz et al., 2010] and guarded logics [Ahmetajet al., 2018]. Many such approaches do not play to the strengths of modern rule engines, though, since they create exponentially many (i.e., millions of) rules [Carralet al., 2018] or rules with linearly

many (i.e., thousands of) variables [Ahmetajet al., 2018]. A more promising approach might be to “implement” reasoning algorithms in a fixed (small) set of logical rules that operates on instances of logical reasoning tasks encoded as (large) sets of input facts. This is closer to the typical presentation of rule-based deduction calculi, and was already proposed for rule-based implementations of some logics [Kr¨otzsch, 2011].

Unfortunately, this approach is severely limited by the low data complexityof known rule languages, which is PTIME

not just for Datalog, but for every previously proposed decid- able existential rule language that guarantees the chase to be finite [Kr¨otzschet al., 2019]. All of the aforementioned tools can only be used if the chase is finite;1 otherwise reasoning will not terminate. We seem to be faced with a big dilemma:

either to deal with large rule sets (in terms of rule number or size), or to be content with solving polynomial problems.

Surprisingly, however, the limits of decidable criteria that guarantee chase termination do not apply to the chase algo- rithm as such: Kr¨otzsch et al. recently showed that, in theory, even current rule engines can perform complex computations based on a fixed “program” of rules while still being guaran- teed to terminate with a finite chase [2019].

In this paper, we show that this theoretical insight can be turned into a practical approach for solving a wide range of logical reasoning tasks with existing rule engines. To unlock the necessary expressive power while guaranteeing termina- tion, we need rather complex existential rule sets that would be difficult to adapt for implementing further reasoning tasks.

We overcome this problem by proposing a more convenient intermediate language, Datalog(S), which extends Datalog with relationships oversets of constants (Section 3). This is inspired by the DatalogS language of Ortizet al. [2010], but differs in that the available sets are not fixed as part of the schema, but can grow with the size of the input: Dat- alog(S) achieves EXPTIME-complete data complexity. We show that every Datalog(S) program can be translated poly- nomially into a set of existential rules for which a previously proposed (and implemented) variant of the standard chase algorithm terminates in exponential time (Section 4). No- tably, the translated rule set does not fall into any known frag-

1Even though weakly (frontier) guarded rules are a decidable existential rule fragment with EXPTIME-complete data complexity [Gottlobet al., 2014], the chase does not terminate for this language, and no reasoners have been implemented for this fragment.

(2)

ment that guarantees chase termination, and we believe that it would be difficult to design an appropriate new fragment that is nearly as easy to use as Datalog(S).

We illustrate the capabilities of this new approach by im- plementing two previously proposed reasoning algorithms in Datalog(S): a consequence-based algorithm for description logics (Section 5), and a type-based algorithm for guarded Horn logic (Section 6). Moreover, we demonstrate practical applicability for the former by executing it on an existing rule engine to classify several real-world ontologies (Section 7).

Details we had to omit are found online [Carralet al., 2019].

2 Preliminaries

We consider a signature based on mutually disjoint, count- ably infinite sets ofconstantsC,variablesV,nullsN, and predicatesP. We assign somearity ar(p)≥0to allp∈P.

Atermis an element inT=C∪V∪N. We abbreviate lists of termst1, . . . , tnas~t, and treat such lists as sets. Anatom is a formulap(~t)withp∈P,~t⊆T, andar(p) =|~t|.

We writeϕ[~x]to indicate that~xis the set of all free vari- ables in the formula ϕ. An (existential) ruleis a null-free formula of the form∀~x, ~z.β[~x, ~z]→ ∃~y.η[~x, ~y]where~xand

~

yare disjoint lists of variables,β(thebody) andη(thehead) are conjunctions of atoms, andηcontains at least one atom.

Often, we omit universal quantifiers from rules. Afact is a variable-free rule with an empty body and a single atom in the head. A rule isgeneratingif it contains existential vari- ables, andnon-generating(orDatalog) otherwise.

For a formulaϕand asubstitutionσ : V → C∪N, let ϕσbe the expression obtained by replacing all unbound oc- currences of allx∈Vinϕbyσ(x)ifσis defined forx.

Definition 1. Consider a ruleρ=β[~x, ~z]→ ∃~y.η, an atom setA, and a substitutionσ. The rule and substitutionhρ, σi is applicable toAif (i) the domain ofσis~x∪~z, (ii)βσ⊆ A, and (iii)ησ0 6⊆ Afor allσ0 ⊇σ. Then,ρ(A)is the superset ofAwhich, for all tupleshρ, σiapplicable toA, contains the facts inησ0⊆ρ(A)withσ0 ⊇σa substitution mapping each y ∈ ~y to a fresh null. For a rule setRand an atom setA, letR(A) = S

ρ∈Rρ(A). LetRandRbe the sets of all non-generating and generating rules inR, respectively; and letR(A)be the superset ofAwithR(R(A)) =R(A).

Definition 2 (Datalog-First Chase). For a rule set R, let R0=∅,R1, . . .be the sequence withRi=R(R(Ri−1)) for alli≥1. ThechaseofRis the setchase(R) =S

i≥1Ri. The chase ofRterminatesifRk−1=Rkfor somek≥1.

Note that the Datalog-first chase is not a radically different chase method but simply a specific type of rule-application strategy for thestandard chase(also referred to asrestricted).

Fact 1. A factφis entailed by a rule setRiffφ∈chase(R).

This follows from the fact that the standard chase produces auniversal modelunder all strategies [Deutschet al., 2008].

3 Datalog with Sets

We now introduce the syntax and semantics of a language that extends Datalog with a set datatype that can represent collections of (non-set) elements. It is defined as a sorted

logic with built-in set-related functions and predicates of the expected semantics. This approach is close in spirit to the extension of Datalog withcomplex values[Abiteboulet al., 1994] for the special case with only two sorts (calleddom and{dom}by Abiteboul et al.), no negation, and a restricted choice of complex value operators.

We consider twosorts: a sort ofobjectsobjand a sort of setsset. A signature of Datalog(S) is based on countably in- finite sets ofobject constantsCobj,object variablesVobj, set variablesVset, andpredicate namesPincludingspecial predicates{,} ⊆P. Thesignatureof a predicate symbol pis a tuplesig(p) = hS1, . . . ,Sniof sorts, withsig() = hobj,setiandsig() =hset,seti. Anobject termis any object constant or object variable. Aset termis any set vari- able, the special constant∅, an expression{t}wheretis an object term, or, recursively, an expression(T1UT2)where T1, T2 are set terms. We consider{t1, . . . , tn}an abbrevia- tion for({t1}U({t2}U. . .U{tn}. . .))and omit parentheses forU. Unless otherwise stated, we use lower-case letters for object terms and upper-case letters for set terms.

Anatomis an expressionp(t1, . . . , tn)wherep∈Pwith sig(p) = hS1, . . . ,Sniandti is a term of sortSi. We write

(t, S)ast S, and(S1, S2)asS1 S2. ADatalog(S) ruleis an expression of the formB1∧. . .∧B`→H1∧. . .∧ Hk, with atomsB1, . . . , B`(thebody) andH1, . . . , Hk (the head), and where we require that:

• every object variable in the head occurs in a body atom,

• every set variable in the rule occurs in a body atom that uses some non-special predicatep∈P\ {,}, and

• the head does not use a special predicate.

ADatalog(S) programis a set of Datalog(S) rules. We admit rules with empty body for representing Datalog(S)facts.

Example 1. Before defining Datalog(S) semantics formally, we give an example that can be understood with an intuitive reading of Datalog(S) rules. Consider input facts forming a chainsucc(1,2),succ(2,3), . . . ,succ(`−1, `), starting at the constant1(the other constant names are immaterial). The following program entails facts for binary predicaten that form ann-chain of length2`:

full(∅) n(∅,{1}) parts({1},1,∅) (1) n(U, V)∧parts(V, x, V0)∧n(V0, W0)

→n(V,{x}UW0)∧parts({x}UW0, x, W0) (2) n(U, V)∧parts(V, x, V0)∧full(V0)∧succ(x, y)

→n(V,{y})∧parts({y}, y,∅)∧full(V) (3) Elements of then-chain are represented by sets, ordered as if each input constant in thesucc-chain defines one bit of a binary number. full(S)means that the represented number is of the form 0· · ·01· · ·1; parts(S, x, S0) means that the numberS has its most significant bit at positionxfrom the left, and thatS = {x} ∪S0. The three facts(1) start the chain, and the two other rules define the nextn-successor for when the most significant bit stays the same(2), or moves to the left(40), respectively.

(3)

Using an exponentially long chain structure, it is easy to simulate exponential time deterministic Turing machine com- putations in Datalog [Dantsinet al., 2001]. Based on Exam- ple 1, we can apply a similar construction to Datalog(S) to obtain the following result, which should be contrasted to the polynomial data complexity of regular Datalog:

Lemma 1. There is a fixed Datalog(S) program without spe- cial predicatesandfor which fact entailment checking is EXPTIME-hard with respect to the size of the input data.

The formal semantics of Datalog(S) codifies the intuitive idea of the set functions and relations. An interpretation I of Datalog(S) is defined by an object domain objI and an interpretation function ·I. Theset domainsetI of I is the powerset ofobjI. The interpretation maps non-special predicatespof signaturesig(p) = hS1, . . . ,Snito relations pI ⊆ SI1 ×. . .×SIn, and special predicates as expected:

I ={hδ,Γi |δ∈Γ ∈setI}andI ={hΓ12i |Γ1 ⊆ Γ2 ∈ setI}. Object constants c are mapped to elements cI ∈objI. Avariable assignmentZis a function mapping object variables xto elements Z(x) ∈ objI, and set vari- ablesY to setsZ(Y)∈setI. Given an arbitrary (set or ob- ject) termt, we definetI,Zrecursively as follows:cI,Z=cI forc∈Cobj,xI,Z=Z(x)forx∈Vobj∪Vset,∅I,Z =∅, {s}I,Z ={sI,Z}, and(S1US2)I,Z=S1I,Z∪SI,Z2 .

An interpretation I and variable assignment Z satisfy an atom p(t1, . . . , tn), written I,Z |= p(t1, . . . , tn), if htI,Z1 , . . . , tI,Zn i ∈ pI. I satisfies a Datalog(S) rule B1 ∧ . . .∧B`→H1∧. . .∧Hkif, for all variable assignmentsZ forI such thatI,Z |=Bifor all1 ≤i ≤ `, we also have I,Z |=Hjfor all1≤j ≤k. A program is satisfied if all of its rules are. A variable-free atomAis alogical consequence of a programPifI |=Afor allIwithI |=P.

Since we require object and set variables to occur in (non- special) body predicates, it is easy to see that rules are only applicable to variable assignments that use values that corre- spond to (sets of) constants in the given input facts. A Dat- alog(S) program is therefore equivalent to its finiteground- ing, obtained by replacing variables by variable-free terms that represent all possible constants and sets of constants, re- spectively. This grounding results in an exponentially large propositional Horn theory for which reasoning tasks can be solved polynomially. Together with Lemma 1, we obtain:

Theorem 1. Checking fact entailment for Datalog(S) is EXPTIME-complete for both data and combined complexity.

4 From Datalog(S) to Existential Rules

We now show how to polynomially translate Datalog(S) into existential rules while preserving (suitably translated) conse- quences. The heart of our approach is the following setRSU

of existential rules (4)–(6), which can represent sets by nulls:

→ ∃v.empty(v)∧set(v) (4) getSU(x, u)→ ∃v.SU(x, u, v)∧

SU(x, v, v)∧set(v) (5) SU(x, u, v)∧SU(y, u, u)→SU(y, v, v) (6)

Intuitively, set(s) means “s is a set” andempty(s) means

“s = ∅.” SU is for Singleton Union: SU(a, s, t) means

“{a} ∪s = t,” and getSU(a, s) means “{a} ∪s should be computed.” Note that all terms are object terms in this one-sorted logic. Given an atom set A and a constant or null s ∈ C∪N, we therefore define thecorresponding set [s]A ={a∈ C∪N | SU(a, s, s)∈ A}. We will combine RSU with additional non-generating rules, but some restric- tions are needed to guarantee correctness.

Definition 3. Atype assignment αis a function that maps each predicatep∈ Pto a tupleα(p) = hS1, . . . ,Sniwith n=ar(p)andSi∈ {obj,set}for1≤i≤n, and where we require thatα(empty) = hseti,α(SU) = hobj,set,seti, andα(getSU) =hobj,seti. We say positioniinpisof type Si. A non-generating ruleρisadmissibleif there is a type assignment such that:

(i) constants inρonly occur on positions of typeobj, (ii) variables inρonly occur on positions of a single type, (iii) emptyandSU do not occur in the head ofρ, and

(iv) getSU does not occur in the body ofρ.

A set of rules (or facts) is admissible if all of its elements are.

Example 2. RSU already suffices to simulate some Data- log(S) programs using further admissible rules. For example, rule(2)can be expressed with the following admissible rules, where the type assignment is as defined by the signature of the corresponding Datalog(S) predicates:

n(u, v)∧parts(v, x, v0)∧n(v0, w0)→getSU(x, w0) (7) n(u, v)∧parts(v, x, v0)∧n(v0, w0)∧SU(x, w0, w)

→n(v, w)∧parts(w, x, w0) (8) The original rule is split into two:(7)requests the creation of an element to represent the set “{x}∪w0” by rule(5), and(8) uses this new element to instantiate the original head atoms.

Example 2 illustrates how admissible rules can “call” the rules inRSU to provision “sets” as required. The following main correctness result confirms that this works as expected:

Theorem 2. For every admissible set of non-generating rules R, the chaseC=chase(R ∪ RSU)is such that

(a) empty(s)∈ Cimplies[s]C =∅, and (b) SU(a, s, t)∈ Cimplies{a} ∪[s]C = [t]C. Ifnis the size ofR, then the size ofCis inO(2nlogn).

Proof. It is clear that rule (4) is applied exactly once, irre- spective ofR, introducing some nulln forv. By admissi- bility, the only rule heads withSU inR ∪ RSUare in (5) and (6), and an easy induction shows thatn can never occur in such facts. Hence,[n]C =∅, showing claim (a).

For (b), first note that the claim follows from the definition of[t]C ifs=t. FactsSU(a, s, t)withs6=tare only derived by (5), and each nulltoccurs in at most one such fact. By the same rule, we getSU(a, t, t), showinga∈[t]C. Ifs=n, then rule (6) cannot produce further consequences, and we get[t]C = {a} as required. Ifs 6= n, then we have a fact SU(b, s, s)for eachb ∈[s]C by definition of[s]C. Rule (6)

(4)

getU(v, w)∧empty(v)→U(v, w, w) (9) getU(v, w)∧SU(x, v, v)→getSU(x, w) (10) getU(v, w)∧SU(x, v, v)∧

SU(x, w, w+)→getU(v, w+) (11) getU(v, w)∧SU(x, v, v)∧

SU(x, w, w+)∧U(v, w+, u)→U(v, w, u) (12) SU(x, u, u)→in(x, u) (13) set(v)∧set(w)→ckSub(v, v, w) (14) ckSub(u, v, w)∧

SU(x, u, u)∧in(x, w)→ckSub(u, v, w) (15) ckSub(u, v, w)∧empty(u)→sub(v, w) (16)

Figure 1: Rules for arbitrary unions, membership, and containment (subscripts+/−are part of variable names; they hint at sets with additional/fewer elements)

therefore derives SU(b, t, t), i.e., b ∈ [t]C. No other facts SU(b, t, t)can be derived, therefore[t]C ={a} ∪[s]C.

For the size of C, note that, all facts of the form SU(a, s, s) ∈ C are derived either when introducing s in (5), or immediately afterwards when closing under non- generating rule (6) (which is prioritised in the Datalog-first chase). Therefore, whenever (5) is applied with a sub- stitution σ to introduce a fresh null n = σ(v), all facts SU(b, σ(u), σ(u)) for b ∈ [σ(u)]C were already derived.

Since (5) is applicable, σ(x) ∈/ [σ(u)]C. Let CR be the finite set of constants that occur in R. By admissibility (and a simple induction), σ(x) ∈ CR, and by claim (b), [σ(u)]C ( [n]C ⊆ 2CR. With` = |CR|, there are at most

`! < `` ∈ O(2`log`)possible sequences of applications of rule (5). This bounds the number of terms in the chase, and hence the number of derived facts, as claimed.

Note that the proof relies on the prioritisation of rule (6) in the Datalog-first chase. However, by adapting a technique by Kr¨otzsch et al. [2019, Proof of Theorem 13], one can also ob- tain a (fixed) rule set that achieves the same termination and worst-case complexity properties for the standard chase. We omit this here as it makes rules more complicated and pre- sumably less efficient in practice (since it artificially prevents the parallel application of rule (6) to all set elements).

As the proof of Theorem 2 suggests, each set might be represented by several elements in the simulation via RSU. The elements generated byRSU correspond to sequences of unions of mutually distinct singleton sets, and several se- quences might result in the same set. This has to be taken into account when simulatingand when performing joins over set terms. Singleton sets and the empty set have at most one representative.

RSUcan only simulate the empty set and unions with sin- gletons. Arbitrary unions are supported by the rules (9)–(12) in Figure 1. Unions are constructed recursively by adding sin- gle elements from the first to the second input set. Rule (9) defines the base case. The other three rules split off a single

element, useRSUto construct unions with singletons, and use the output to define the overall union. The rules are admis- sible for the intuitive type assignmentα(getU) =hset,seti andα(U) =hset,set,seti.

As the last ingredient, the rules (13)–(16) in Figure 1 de- fine predicatesinandsubthat capture the built-in Datalog(S) predicates and , respectively. The complicated part is sub: facts of the form ckSub(u, v, w)(“check subset”) ex- press “v\u⊆w.” We initialise this for all pairs of sets (14), and recursively compare elements of the first argument (15) until reaching the empty set (16).

This completes the required set of auxiliary rules. Be- fore specifying the intended translation, we slightly nor- malise Datalog(S) rules. Let S1 = S2 be a shortcut for S1 S2∧S2 S1. First, we replace every set term of the formS1US2in a non-special predicate in the body with a fresh set variableS, and we add body atomsS =S1US2. Second, as long as a set variableSoccurs more than once in a non-special predicate in the body of a rule, we replace one of these occurrences by a fresh variableS0and addS=S0to the body. It is easy to see that these transformations preserve semantics. Rules of the resulting form are callednormalised.

Normalisation ensures that set equality checks are performed usingsub.

Now consider a normalised Datalog(S) rule ρ. We will translate it to a set ER(ρ) of existential rules. For every set term S, let v(S)be a fresh (non-sorted) variable. Let S1, . . . , Sk be a sequence of all set terms in ρthat are nei- ther variables nor∅, such that no sub-term of anySi occurs to its right. For each termSi, we define atomsαiandβi:

• if Si = {t} then αi = getSU(t, v(∅)) and βi = SU(t, v(∅), v(Si)),

• if Si = T1 UT2, then αi = getU(v(T1), v(T2))and βi=U(v(T1), v(T2), v(Si)).

Finally, setγ0=empty(v(∅)), andγj+1j∧βj+1for all 0≤ j < k. Now ruleρ=ϕ →ψis translated into the set ER(ρ)of the followingk+ 1rules:

(1) for each0≤i < k, a ruleϕ0∧γi→αi+1, (2) a ruleϕ0∧γk →ψ0,

whereϕ0andψ0are obtained fromϕandψ, respectively, by replacing all atomst S byin(t, S), all atomsS S0 by sub(S, S0), and all set termsSbyv(S).

Example 3. Letρ=p(a, S, T,{a}US) →q(SUT). Its normalisationρ0 has the body ϕ = p(a, S, T, R)∧(R

{a}US)∧({a}US R). A possible order of set terms isS1 ={a},S2 = {a}US,S3 = SUT. The translated body isϕ0 = p(a, v(S), v(T), v(R))∧sub(v(R), v(S2))∧ sub(v(S2), v(R)). We obtain the following rules inER(ρ0):

ϕ0∧empty(v(∅))→getSU(a, v(∅)) (17) . . .∧SU(a, v(∅), v(S1))→getU(v(S1), v(S)) (18) . . .∧U(v({a}), v(S), v(S2))→getU(v(S), v(T)) (19) . . .∧U(v(S), v(T), v(S3))→q(v(S3)) (20) where each “. . .” abbreviates the body of the previous rule.

Definition 4. For a Datalog(S) programP, letER(P)be the union of all rule setsER(ρ)forρ∈ Pand the rules(4)–(6) and(9)–(16).

(5)

The following result is immediate from this definition:

Theorem 3. For a Datalog(S) programP, the size ofER(P) is polynomial in the size ofP.

Theorem 4. For a Datalog(S) program P and Datalog(S) factα,P |=αif and only ifER(P)|=ER(α). Moreover, the Datalog-first chase decidesER(P)|=ER(α)inEXPTIME. Proof sketch. The correctness of the extended set of rules (9)–(16) can be shown with a suitable extension of Theo- rem 2. We can restrict the notion of admissibility to also avoid the misuse of auxiliary predicates in these rules while requiring the expected type signatures. The correctness of the translation is easy; especially the translated rules are admis- sible when using the Datalog(S) signatures to define type sig- natures. The size bound on the chase carries over from Theo- rem 2, which establishes the second part of the claim.

Together with Theorem 1, this correctness result implies that fact entailment is also EXPTIME-complete w.r.t. data complexity for the sets of rules obtained from our transfor- mation. Therefore, these transformed sets are not covered by any decidable fragment of existential rules of P (or lower) data complexity, including previously proposed criteria that ensure termination of the skolem chase [Cuenca Grauet al., 2013] and Datalog-first chase [Carralet al., 2017], as well as first-order rewritability [Bagetet al., 2011]. Weakly (frontier) guarded rules are one of the few fragments with similarly high data complexity [Gottlobet al., 2014], but already the rules in Figure 1 are not weakly frontier guarded.

5 Description Logics Reasoning

To demonstrate the utility of our approach, we look at de- scription logics (DLs) first. DLs are highly expressive logics with many applications, and for which numerous reasoning procedures have been proposed [Baaderet al., 2007]. Among the many DLs that give rise to EXPTIME-complete reasoning tasks, we select Horn-ALC as a comparatively simple case that allows us to focus on our main ideas.2

DL is based on mutually disjoint sets of concept names NC,role namesNR, andindividual namesNI. We define Horn-ALCusing axioms in normalised form [Kr¨otzschet al., 2013]. GivenA, B, C ∈NC,R∈ NR, anda, b∈ NI, the following are axioms of Horn-ALCin normal form:

A(a) (21) R(a, b) (22) AvC (23)

> vC (24)

∃R.AvC (25) AuBvC (26)

Av ⊥ (27)

Av ∀R.C (28) Av ∃R.C (29) Axioms (21) and (22), calledclass assertions, respectively role assertions, areABox axioms, corresponding to unary and binary facts. The others areTBox axioms, withDvErepre- senting a first-order formula∀x.[D]→[E], where we define [A] = A(x),[B] = B(x),[∃R.C] = ∃y.R(x, y)∧C(y), [∀R.C] =∀y.R(x, y)→C(y), and[AuB] =A(x)∧B(x).

>represents truth, and⊥falsity.

2Our use of Horn DLs is not related to the fact that existential rules are in Horn logic. Rule-based reasoning methods for non-Horn DLs, e.g., from [Simanˇc´ıket al., 2011], could also be implemented.

Classificationis the task of computing all axioms of form (23) that are entailed by anontology—i.e. a DL axiom set.

Kazakov [2009] proposes aconsequence-drivenclassification method for Horn-ALC. Figure 2 (left) shows the correspond- ing rules of inference in the version of Simanˇc´ıket al.[2011, Table 2]. Given a setT of TBox axioms, the rules produce inferences of the formH vBandH v ∃R.KwhereH, K are conjunctions of elements inNC∪ {⊥,>}(viewed as sets when convenient). A rule is applicable if its pre- (above the line) and side conditions (on the right) are satisfied; then it derives the conclusion (below the line). A conjunctionH is activeif it is either defined to be active initially, or occurs in some inference, and rules(RA)and(Ru)are restricted to such conjunctions. For classification, one initially sets all single- ton conjunctions (i.e., concept names) to be active.

The right of Figure 2 shows the corresponding Datalog(S) rules. It is easy to see how each rule corresponds to the inference rule to its left. We represent inferences by predi- catesSC andExwithsig(SC) =hset,objiandsig(Ex) = hset,obj,seti, respectively. Predicates axv,axuv,axv∀, ax∃v, andaxv∃encode Horn-ALCaxioms as facts. All el- ements ofNC∪NRcorrespond to object constants in Dat- alog(S), and conjunctions are represented as sets. Only rules (R+)and(R)can activate new conjunctions, as recorded by predicateAct. To initialise the computation, we need to acti- vate all singleton sets, which can be done by rules such as

ax∃v(a, r, b)→Act({a})∧Act({b}) (30) and analogous rules for all other types of axioms. It is obvi- ous that this translation is faithful and therefore leads to an EXPTIME-complete (hence worst-case optimal) chase-based classification algorithm for Horn-ALC.

We also note that the translation exhibits similar pay-as- you-go characteristics as the original approach. In particular, inEL-type description logics, which do not include axioms of type (28), only a linear number of singleton sets is needed, and the chase likewise terminates in polynomial time. It is an advantage of our approach that it can be used to make an existential rule engine perform essentially the same derivation steps as the original abstract inference-rule calculus.

6 Guarded Rules Reasoning

We now apply our approach to reasoning withguarded exis- tential rules (where all universally quantified variables ap- pear in a single body atom). Ahmetaj et al. [2018] give an entailment-preserving translation from guarded rules with bounded predicate arityˆato a polynomial Datalog program.

However, they require predicate arities in the order of2ˆa. Their translation actually simulates sets in Datalog. For maximal arityˆa, we consider the setAof all atoms that can be formed from a predicate in the guarded rules and generic variablesx1, . . . , xaˆ. Atypeis a subset ofA, represented in Datalog by vectors of|A|constants0or1. Datalog(S) rules are obtained, in essence, by replacing these vectors by sets, where we use constantscαfor eachα∈ A.

The rules frequently test for the absence of an element in a set. While not in Datalog(S), we can define this using an inequality predicate6≈(even without logical inequality, this

(6)

(RA)

HvA :His active andA∈H Act(H)∧aH →SC(H, a)

(Ru) {H vAi}ni=1

H vC :

n= 0,Hactive,> vC∈ T, or n= 1,A1vC∈ T, or

n= 2,A1uA2vC∈ T

Act(H)∧axv(c>, c)→SC(H, c) SC(H, a1)∧axv(a1, c)→SC(H, c) SC(H, a1)∧SC(H, a2)∧axuv(a1, a2, c)→SC(H, c)

(R+) H vA

Hv ∃R.B :Av ∃R.B∈ T SC(H, a)∧axv∃(a, r, b)→Ex(H, r,{b})

∧Act({b}) (R) Hv ∃R.K KvA

H vB :∃R.AvB∈ T Ex(H, r, K)∧SC(K, a)∧ax∃v(a, r, b)→SC(H, b) (R) Hv ∃R.K Kv ⊥

H v ⊥ Ex(H, r, K)∧SC(K, c)→SC(H, c)

(R) Hv ∃R.K H vA

H v ∃R.(KuB) :Av ∀R.B∈ T Ex(H, r, K)∧SC(H, a)∧axv∀(a, r, b)→Ex(H, r,{b}UK)

∧Act({b}UK) Figure 2: Horn-ALCinference rules by Simanˇc´ık et al. (left) and corresponding Datalog(S) program (right), wherec>andcare constants, lower-case letters are object variables, and upper-case letters are set variables

can be axiomatised for constants; this suffices). We can now derive ckNotin(u, a, u) whenever a rule needs to know if

“a /∈u”, and then apply the following rules:

ckNotin(u, z, w)∧

SU(x, u, u)∧x6≈z→ckNotin(u, z, w) (31) ckNotin(u, z, w)∧empty(u)→notin(z, w) (32) Confirmed non-memberships are recorded as notin(a, u).

The approach resembles our computation ofsubin Figure 1.

With this additional feature, most rules of Ahmetajet al.

have a straightforward translation to Datalog(S). Their rules are organised in groups(I)to(IX), where(II)and(VI)only matter in the disjunctive case. Even the remaining rules are too many to specify, but we explain the key steps. Rules(I) initialise non-set predicates of arity≤ˆa, and require no mod- ification. The rules in(III)define all types (vectors) and es- tablish a linear order on them. This can be achieved in Data- log(S) along the lines of Example 1. Rules(IV)mark types based on the given guarded rules. Using a simple decomposi- tion of rule bodies, we can assume that all guarded rules have the formρ = A∧B → ∃~y.H. Then, for each mappingh from rule variables to{x1, . . . , xˆa}, we define a rule:

Type(U)∧ch(A)U∧ch(B)U ∧ch(H)/U →Marked(U) If we assume that rules restrict to a common set of variables, there are only polynomially many possible mappingshdue to the bounded arity. Therefore, instead of adding many rules, we can also encode those mappings and the ruleρin Data- log(S) facts, and use a single Datalog(S) rule instead.

The rules(V)are again very close to Datalog(S). They use predicates such asMarkedOneσ,h, named using rulesσand certain mappingsh. As in (IV), we can remove the depen- dence on these input-related parts by representing rules and mappings as elements in the facts, and adding two additional parameters to MarkedOne to refer to them. Note that side conditions such as “R(~x) ∈ Awith~x ∈ h(vars(σ))” can simply be precomputed and stored as facts.

Rules(VII)highlight some elements in types using a spe- cial constant2instead of1, as in

Marked(~u,0, ~v)∧Marked(~u,1, ~v)→Marked(~u,2, ~v) We achieve thisaddinganother constantdαfor eachα∈ A:

Marked(X)∧cαi/X∧Marked(XU{cαi})

→Marked(XU({cαi}U{dαi}}) Such rules also depend on the given guarded rules that define A, but this dependence can easily be moved to the facts by encodingAthere. Rules (VIII)defineHorn typesas those missing exactly one atom. We can build such types itera- tively, so as to avoid the explicit mentioning of all elements in one rule. The remaining rules are also easy to express. Fi- nally, rules(IX)infer entailed facts from marked Horn types by removing elements from the type sets iteratively. Instead of removing elements, we can simply iterate by remembering the current position in an additional parameter.

By these transformations, we can obtain a Datalog(S) pro- gram that captures the original Datalog program in a polyno- mial number of rules that each use only a bounded number of variables and atoms (based on the aritya). If we furtherˆ encode guarded rules, atoms, and mappings in Datalog(S) facts as indicated, we obtain a fixed Datalog(S) program that can reason on arbitrary guarded existential rules (encoded as facts), depending only on the signature of relevant predicates.

Applying Theorem 4, we obtain a similarly small existential rule set for which the Datalog-first chase terminates:

Theorem 5. For any fixed finite set of predicatesPwith max- imal arityˆa, there is a set of existential rulesAOSPthat

1. consists of polynomially many rules (in the size ofP), 2. each with bounded number of atoms (independent ofP), 3. using predicates of arity bounded bymax(ˆa,3), and 4. wherechase(AOSP∪ F)is exponential for every set of

factsF, such that

every set of guarded existential rulesRoverPcan be trans- lated into a polynomial set of factsFRsuch thatAOSP∪FR andRentail the same ground facts overP.

(7)

ID #Ax. #Set #SC #Ex VLog (sec)

00040 223K 2K 1051K 334K 432

00048 142K 19 718K 171K 387

00477 318K 0 162K 167K 1

00533 159K 0 965K 351K 132

00786 152K 12K 2283K 978K 549

Figure 3: Ontologies and results for classification (A) showing: ax- iom count; number of non-singleton “set terms” introduced (#Set);

number ofSCandExfacts derived; reasoning time in VLog

sec

1.7M 3.1M 4.4M

100 101 102 103

Number of assertions

Reactome sec

1.9M 4M 5.9M

100 101 102 103

Number of assertions

UOBM

Figure 4: Experimental results for class retrieval (B) in VLog (pink/grey) and Konclude (black); note the log scale

7 Evaluation

We conducted two experiments: (A) compute all conse- quences of the calculus in Figure 2, and (B) compute all en- tailed axioms of type (21) (class retrieval). All experiments where run on a MacBookPro (2.4GHz Intel Core i5, 8GB RAM). The rule engine VLog was used as an implementa- tion for the Datalog-first chase [Urbaniet al., 2018]. Further evaluation details can be found in [Carralet al., 2019].

For (A), we created a simplified rule setRClfrom the rules in Figure 2, exploiting the fact that they do not need nor- malisation or all Datalog(S) features [Carral et al., 2019].

We classified five large and diverse ontologies from the Ox- ford Ontology Repository:3 00040 (GO x-anatomy), 00048 (GO x-taxon), 00477 (Gazetteer), 00533 (ChEBI mol. func- tion), and 00786 (NCI). The ontology statistics and results are shown in Figure 3. We measured pure reasoning time without the time needed to read the input file from disk.

Columns #Set, #SC, and #Ex confirm that the ontologies require significant reasoning effort, which is also reflected in most VLog reasoning times. We observed that our rules for simulating sets made only small contributions to these times, although they dominate theoretical worst-case com- plexity. Most time instead was taken up by the computation of a small number of particularly slow joins – used to find rule matches in VLog –, especially for rule(R).

While our results show practicality, optimised DL rea- soners are significantly faster: the DL reasoner Konclude [Steigmilleret al., 2014] needed between 2sec (00533) and 14sec (00786) for the tasks. This is not surprising, since Kon- clude is the leading implementation after decades of research on how to optimise this very computation, whereas VLog has never before been applied for such a task. Indeed, our ap-

3https://www.cs.ox.ac.uk/isg/ontologies/

proach leads to rules that are very different from the ones used in benchmarking rule engines today, and can therefore guide further optimisations of existing implementations.

For experiment (B) we extendRClwith the following rules:

CA(a, c)∧SU(a, E, H)∧

empty(E)∧SC(H, b)→CA(b, c) (33) RA(r, c, d)∧ax∃v(a, r, b)∧CA(a, d)→CA(b, c) (34) RA(r, c, d)∧axv∀(a, r, b)∧CA(a, c)→CA(b, d) (35) PredicatesCAandRAencode assertions:CA(A, c)encodes A(c); and RA(R, a, b) encodes R(a, b). We used several benchmark datasets that Zhouet al.[2015] created by sam- pling data for two large ontologies: the real-world knowledge base Reactome, and the synthetic benchmark UOBM.

Figure 4 shows the total times (precomputing and reason- ing) for VLog and Konclude. No times are shown in cases where Konclude exceeded a one-hour timeout. We observe that our approach leads to competitive performance in (B), which might have been expected since rule engines optimise for large datasets. In particular, VLog might benefit from its compact in-memory presentation of large predicates, which also helps to find rule matches more quickly if many facts can be processed together [Urbaniet al., 2016].

8 Conclusions

We introduced Datalog(S) as a convenient high-level lan- guage for encoding complex reasoning algorithms, which can be “compiled” into existential rules that can be successfully executed on rule engines available today. This outlines an ap- pealing new method for prototyping reasoning algorithms in an elegant and declarative way, potentially even resulting in highly scalable systems. It also indicates a promising new re- search direction for the development of modern rule engines.

Acknowledgments

This work is partly supported by Deutsche Forschungsge- meinschaft (DFG, German Research Foundation) in project number 389792660 (TRR 248, Center for Perspicuous Sys- tems) and Emmy Noether grant KR 4381/1-1 (DIAMOND).

References

[Abiteboulet al., 1994] Serge Abiteboul, Richard Hull, and Victor Vianu.Foundations of Databases. Addison Wesley, 1994.

[Ahmetajet al., 2018] Shqiponja Ahmetaj, Magdalena Or- tiz, and Mantas Simkus. Rewriting guarded existential rules into small datalog programs. InProc. 21st Int. Conf.

on Database Theory (ICDT’18), volume 98 of LIPIcs, pages 4:1–4:24. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 2018.

[Arefet al., 2015] Molham Aref, Balder ten Cate, Todd J.

Green, Benny Kimelfeld, Dan Olteanu, Emir Pasalic, Todd L. Veldhuizen, and Geoffrey Washburn. Design and implementation of the LogicBlox system. InProc. 2015 ACM SIGMOD Int. Conf. on Management of Data, pages 1371–1382. ACM, 2015.

(8)

[Baaderet al., 2007] Franz Baader, Diego Calvanese, Deb- orah McGuinness, Daniele Nardi, and Peter Patel- Schneider. The Description Logic Handbook: Theory, Implementation, and Applications. Cambridge University Press, second edition, 2007.

[Bagetet al., 2011] Jean-Franc¸ois Baget, Michel Lecl`ere, Marie-Laure Mugnier, and Eric Salvat. On rules with ex- istential variables: Walking the decidability line.Artificial Intelligence, 175(9–10):1620–1654, 2011.

[Bagetet al., 2015] Jean-Franc¸ois Baget, Michel Lecl`ere, Marie-Laure Mugnier, Swan Rocher, and Cl´ement Sipi- eter. Graal: A toolkit for query answering with existential rules. InProc. 9th Int. Web Rule Symposium (RuleML’15), volume 9202 ofLNCS, pages 328–344. Springer, 2015.

[Benediktet al., 2014] Michael Benedikt, Julien Leblay, and Efthymia Tsamoura. PDQ: proof-driven query answering over web-based data. PVLDB, 7(13):1553–1556, 2014.

[Benediktet al., 2017] Michael Benedikt, George Konstan- tinidis, Giansalvatore Mecca, Boris Motik, Paolo Papotti, Donatello Santoro, and Efthymia Tsamoura. Benchmark- ing the chase. InProc. 36th Symposium on Principles of Database Systems (PODS’17), pages 37–52. ACM, 2017.

[Carralet al., 2014] David Carral, Cristina Feier, Bernardo Cuenca Grau, Pascal Hitzler, and Ian Hor- rocks. EL-ifying ontologies. InProc. of the 7th Int. Joint Conf. onAutomated Reasoning (IJCAR’18), volume 8562 of Lecture Notes in Computer Science, pages 464–479.

Springer, 2014.

[Carralet al., 2017] David Carral, Irina Dragoste, and Markus Kr¨otzsch. Restricted chase (non)termination for existential rules with disjunctions. InProc. 26th Int. Joint Conf. on Artificial Intelligence (IJCAI’17), pages 922–

928. ijcai.org, 2017.

[Carralet al., 2018] David Carral, Irina Dragoste, and Markus Kr¨otzsch. The combined approach to query an- swering in Horn-ALCHOIQ. In Proc. 16th Int. Conf.

on Principles of Knowledge Representation and Reason- ing (KR’18), pages 339–348. AAAI Press, 2018.

[Carralet al., 2019] David Carral, Irina Dragoste, Markus Kr¨otzsch, and Christian Lewe. Chasing sets: How to use existential rules for expressive reasoning (extended techni- cal report). Available at https://iccl.inf.tu-dresden.de/web/

Inproceedings3212/en, 2019.

[Cuenca Grauet al., 2013] Bernardo Cuenca Grau, Ian Hor- rocks, Markus Kr¨otzsch, Clemens Kupke, Despoina Magka, Boris Motik, and Zhe Wang. Acyclicity notions for existential rules and their application to query answer- ing in ontologies. J. Artif. Intell. Res., 47:741–808, 2013.

[Dantsinet al., 2001] Evgeny Dantsin, Thomas Eiter, Georg Gottlob, and Andrei Voronkov. Complexity and expressive power of logic programming. ACM Computing Surveys, 33(3):374–425, 2001.

[Deutschet al., 2008] Alin Deutsch, Alan Nash, and Jef- frey B. Remmel. The chase revisited. InProc. 27th Sympo- sium on Principles of Database Systems (PODS’08), pages 149–158. ACM, 2008.

[Eiteret al., 2012] Thomas Eiter, Magdalena Ortiz, Man- tas Simkus, Trung-Kien Tran, and Guohui Xiao. Query rewriting for horn-shiq plus rules. In Proc. 26th AAAI Conf. on Artif. Intell. (AAAI’12). AAAI Press, 2012.

[Geertset al., 2014] Floris Geerts, Giansalvatore Mecca, Paolo Papotti, and Donatello Santoro. That’s all folks!

LLUNATIC goes open source.PVLDB, 7(13):1565–1568, 2014.

[Gottlobet al., 2014] Georg Gottlob, Sebastian Rudolph, and Mantas Simkus. Expressiveness of guarded existential rule languages. In Proc. 33rd ACM SIGMOD-SIGACT- SIGART Symposium on Principles of Database Systems (PODS’14), pages 27–38. ACM, June 2014.

[Kazakov, 2009] Yevgeny Kazakov. Consequence-driven reasoning for HornSHIQontologies. InProc. 21st Int.

Joint Conf. on Artif. Intell. (IJCAI’09), pages 2040–2045.

IJCAI, 2009.

[Kr¨otzschet al., 2013] Markus Kr¨otzsch, Sebastian Rudolph, and Pascal Hitzler. Complexities of Horn description logics.ACM Trans. Comput. Logic, 14(1):2:1–

2:36, 2013.

[Kr¨otzsch, 2011] Markus Kr¨otzsch. Efficient rule-based in- ferencing for OWL EL. InProc. 22nd Int. Joint Conf.

on Artif. Intell. (IJCAI’11), pages 2668–2673. AAAI Press/IJCAI, 2011.

[Kr¨otzschet al., 2019] Markus Kr¨otzsch, Maximilian Marx, and Sebastian Rudolph. The power of the terminat- ing chase. In Proc. 22nd Int. Conf. on Database Theory (ICDT’19), volume 127 of LIPIcs, pages 3:1–

3:17. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 2019.

[Nenovet al., 2015] Yavor Nenov, Robert Piro, Boris Motik, Ian Horrocks, Zhe Wu, and Jay Banerjee. RDFox: A highly-scalable RDF store. In Proc. 14th Int. Semantic Web Conf. (ISWC’15), Part II, volume 9367 of LNCS, pages 3–20. Springer, 2015.

[Ortizet al., 2010] Magdalena Ortiz, Sebastian Rudolph, and Mantas Simkus. Worst-case optimal reasoning for the Horn-DL fragments of OWL 1 and 2. InProc. 12th Int. Conf. on Principles of Knowledge Representation and Reasoning (KR’10), pages 269–279. AAAI Press, 2010.

[Simanˇc´ıket al., 2011] Frantiˇsek Simanˇc´ık, Yevgeny Kaza- kov, and Ian Horrocks. Consequence-based reasoning be- yond Horn ontologies. In Proc. 22nd Int. Joint Conf.

on Artif. Intell. (IJCAI’11), pages 1093–1098. AAAI Press/IJCAI, 2011.

[Steigmilleret al., 2014] Andreas Steigmiller, Thorsten Liebig, and Birte Glimm. Konclude: System description.

J. Web Semant., 27-28:78–85, 2014.

[Urbaniet al., 2016] Jacopo Urbani, Ceriel Jacobs, and Markus Kr¨otzsch. Column-oriented Datalog materializa- tion for large knowledge graphs. InProc. 30th AAAI Conf.

on Artif. Intell. (AAAI’16), pages 258–264. AAAI Press, 2016.

(9)

[Urbaniet al., 2018] Jacopo Urbani, Markus Kr¨otzsch, Ceriel J. H. Jacobs, Irina Dragoste, and David Carral.

Efficient model construction for Horn logic with VLog:

System description. In Proc. 9th Int. Joint Conf. on Automated Reasoning (IJCAR’18), volume 10900 of LNCS, pages 680–688. Springer, 2018.

[Zhouet al., 2015] Yujiao Zhou, Bernardo Cuenca Grau, Ya- vor Nenov, Mark Kaminski, and Ian Horrocks. PAGOdA:

Pay-as-you-go ontology query answering using a Datalog reasoner.J. of Artif. Intell. Res., 54:309–367, 2015.

(10)

(init) conceptName(a)∧empty(E)→getSU(a, E)

(SA) in(a, H)→SC(H, a)

(S0u) SC(H, a)∧axv(c>, c)→SC(H, c) (S1u) SC(H, a1)∧axv(a1, c)→SC(H, c) (S2u) SC(H, a1)∧SC(H, a2)∧axuv(a1, a2, c)→SC(H, c) (S+) SC(H, a)∧axv∃(a, r, b)∧empty(E)∧SU(b, E, B)→Ex(H, r, B) (S) Ex(H, r, K)∧SC(K, a)∧ax∃v(a, r, b)→SC(H, b) (S) Ex(H, r, K)∧SC(K, c)→SC(H, c) (Sα) Ex(H, r, K)∧SC(H, a)∧axv∀(a, r, b)→getSU(b, K) (Sβ) SU(b, K, U)∧Ex(H, r, K)∧SC(H, a)∧axv∀(a, r, b)→Ex(H, r, U) Figure 5: A simplified translation of the Datalog(S) program in Figure 2 into admissible rules.

A Evaluation Details

All files used in the input of our experiments can be found at https://cloudstore.zih.tu-dresden.de/index.php/s/

pwojlg9nO05ctnV?path=%2FIJCAI-2019-chasing-sets-evaluation.

A.1 Classification Experiment (A) Input Ontology Preprocessing

The ontologies selected for this experiment are not in Horn-ALC. Therefore, we first normalise these into the normal form given in [Carralet al., 2014] and then filter all axioms that are not Horn-ALC.

Simplified Classification RulesRCl

In order to run our experiments, we need to translate the Datalog(S) classification program discussed in Section 5 into an existential rule set, as shown in Section 4. This translation of the Datalog(S) rules from Figure 2 is shown in Figure 5, where rules(Sα),(Sβ)represent the translation to existential rules of Datalog(S) rule(R), rule(S0u)is the translation of rule(Ru) withn= 0, etc. The resulting existential rule setRCl– consisting of the rules in Figure 5, rules (4)–(6) and (13), and rule set {→conceptName(a)|a∈NC∩ O}– has been simplified to optimise performance, and we discuss these optimisations below.

Firstly, we observe that there is a one-to-one correspondence between the active conjunctions derived by the calculus in Figure 2 (left) and the non-empty sets derived by the related Datalog(S) program (right). We know that each set derived by a Datalog(S) program is represented by at least one null introduced during reasoning over the existential rules translation of such a program. Except for the null representing the empty set, each such null corresponds to an active conjunction. Therefore, in the existential rules translation, unary predicateAct - used to signal the correspondence between a null and an active conjunction - becomes redundant. We can then simplify the existential rule set by discarding all atoms withAct predicate (used in rules (RA),(Ru)withn= 0,(R+),(R), and rules of type (30)). Instead of the initialisation of active sets as exemplified in (30), we assertconceptName(a)for each concept nameaoccurring in the input ontology, and add the rule(init)(Figure 5) to our set.

Rule(init)generates nulls representing the initial singleton sets for each concept name of the input ontology, while rule(Sα) generates nulls representing new sets (conjunctions which, in turn, become active). For this reason, predicatein(rule(SA)) will only apply to the nulls introduced to satisfy rule (5), which represent sets that, in turn, correspond to the active conjunctions.

Secondly, we see that the singleton sets appearing in the head of rule(R+)have already been generated by the application of rule(init), as variablebcan only apply to a concept name. Hence, rule(R+)can be simplified to(S+)as shown in Figure 5.

Also, note that the translation of Datalog(S) rule(R)into existential rules(Sα)and(Sβ)has been optimised. We can directly obtain the union between the objectband the setKas we do in(Sα), instead of first obtaining the union between objectband the empty set, and then between the resulting singleton set{b}and the setK, as discussed in Section 4.

Additionally, we observe that in order to simulate the Datalog(S) program in Figure 2, only a subset of the rules that encode set features is needed: it is sufficient to use rules (4)–(6) for encoding the empty set and union with a singleton set (required by rules(init),(S+), and(S)), and rule (13) for encoding set membership (required by(SA)). In fact, (4)–(5) can be modified to eliminate the atomset(v)from the rule heads, as it is only used in rule (14), which is not needed here.

Finally, note that even though rules(R2u),(R),(R),(R)contain multiple occurrences of the same set-admitting variable in non-special predicates in the body, the normalisation discussed in Section 4 is not necessary forRCl. In Theorem 6, we show thatRCl preserves completeness, as distinct nulls that represent the same sets appear interchangeably in the sameSC facts generated during the chase (see Lemma 2). Therefore, for a given Horn-ALContologyO, the existential rule setRClcorrectly solves classification.

For the remainder of this section, we refer tochase(RCl)asC.

(11)

Lemma 2. Consider two nullsNandN0occurring inCsuch that[N]C = [N0]C.

• IfSC(N, t)∈ Cfor somet∈T, thenSC(N0, t)∈ C.

• IfEx(N, r, K)∈ Cfor somer, K∈T, thenEx(N0, r, K)∈ C.

Proof. LetF0, . . . ,Fmbe some sequence of sets of facts that satisfies all of the following.

• F0=∅andFm=C.

• For all1 ≤i≤m, there is a ruleρi =β → ∃y.η ∈ RCland a substitutionσisuch thatβσi ⊆ Fi−1,Fi=Fi−1∪ησi, andησi∈ F/ i−1.

We show via induction oni≥0that:

• IfSC(N, t)∈ Fifor somet∈T, thenSC(N0, t)∈ C.

• IfEx(N, r, K)∈ Fifor somer, K∈T, thenEx(N0, r, K)∈ C.

The base case is trivial, sinceF0=∅. For the induction step, we prove that the claim holds for1 ≤i≤massuming it to hold fori−1, following a case-by-case analysis depending onρi. Note that we are only interested in rules that produce facts of the formSC(N, t)orEx(N, r, K)(i.e., rules(SA),(S0u),(S1u),(S2u),(S+),(S),(S), and(Sβ)). For the other rules, the claim trivially holds by induction hypothesis (IH).

(SA) Letρ=in(a, H)→SC(H, a), andσi(H) =N. Then,in(σi(a), N)∈ Fi−1. Since[N]C = [N0]C and by rule (13), we have thatin(σi(a), N0)∈ C. Hence,SC(N0, σi(a))∈ C.

(S0u) Letρ=SC(H, a)∧axv(c>, c)→SC(H, c), andσi(H) =N. Then,{SC(N, σi(a)),axv(c>, σi(c)} ⊆ Fi−1. By IH, SC(N0, σi(a1))∈ C. Hence,SC(N0, σi(c))∈ C.

(S1u) Letρi =SC(H, a1)∧axv(a1, c)→SC(H, c), andσi(H) =N. Then,{SC(N, σi(a1)),axvi(a1), σi(c))} ⊆ Fi−1. By IH,SC(N0, σi(a1))∈ C. Hence,SC(N0, σi(c))∈ C.

(S2u) Let ρi = SC(H, a1) ∧ SC(H, a2) ∧ axuv(a1, a2, c) → SC(H, c), and σi(H) = N. Then, {SC(N, σi(a1)),SC(N, σi(a2)),axuvi(a1), σi(a2), σi(c))} ⊆ Fi−1. By IH,{SC(N0, σi(a1)),SC(N0, σi(a2))} ⊆ C. Hence,SC(N0, σi(c))∈ C.

(S+) Letρi=SC(H, a)∧axv∃(a, r, b)∧empty(E)∧SU(b, E, B)→Ex(H, r, B), andσi(H) =N. Then,{SC(N, σi(a))∧

axv∃i(a), σi(r), σi(b))∧empty(σi(E))∧SU(σi(b), σi(E), σi(B))} ⊆ Fi−1. By IH,SC(N0, σi(a))∈ C. Hence, Ex(N0, σi(r), σi(B))∈ C.

(S) Let ρi = Ex(H, r, K) ∧ SC(K, a) ∧ ax∃v(a, r, b) → SC(H, b), and σi(H) = N. Then, {Ex(N, σi(r), σi(K)),SC(σi(K), σi(a)),ax∃vi(a), σi(r), σi(b))} ⊆ Fi−1. By IH, Ex(N0, σi(r), σi(K)) ∈ C.

Hence,SC(N0, σi(b))∈ C.

(S) Forρi=Ex(H, r, K)∧SC(K, c)→SC(H, c), the proof is analogous to the case above.

(Sβ) Let ρi = SU(b, K, U) ∧ Ex(H, r, K) ∧ SC(H, a) ∧ axv∀(a, r, b) → Ex(H, r, U), and σi(H) = N.

Then, {SU(σi(b), σi(K), σi(U)),Ex(N, σi(r), σi(K)),SC(N, σi(a)),axv∀i(a), σi(r), σi(b))} ⊆ Fi−1. By IH, {Ex(N0, σi(r), σi(K)),SC(N0, σi(a))} ⊆ C. Hence,Ex(N0, σi(r), σi(U))∈ C.

For a functionf :N→Nand a factφ, we denote asf(φ)the fact obtained by replacing each syntactic occurrence of a null ninφwithf(n). For a set of factsF, we denote asf(F)the set of factsS

φ∈Ff(φ). We abuse notation and say that two sets of factsF1andF2areequal(F1=F2), if there is a bijectionfdefined on the nulls inF1with values in the nulls inF2such thatf(F1) =F2andf(F2) =F1. We also say thatF1 ⊆ F2, if there is a set of factsF10 such thatF1=F10 (according to the above equality definition), andF10 ⊆ F2.

Theorem 6. The setchase(RCl)is equal tochase(R0Cl), whereR0Clis the normalisation of the rules inRCl.

Proof. For brevity, we denotechase(R0Cl)asC0. Note thatC ⊆ C0follows from the fact that, for a ruleρ, its normalisationρ0, and a set of factsF, we have thatρ(F)⊆ρ0(F)(considering fact set equality as discussed above). We proceed to prove that C0⊆ C. LetF0, . . . ,Fmbe some sequence of sets of facts that satisfies all of the following.

• F0=∅andFm=C0.

• For all1≤i≤m, there is a ruleρ0i0→ ∃y.η∈ R0Cland a substitutionσisuch thatβ0σi⊆ Fi−1andFi=Fi−1∪ησi.

Referenzen

ÄHNLICHE DOKUMENTE

We say that a class C of finite τ -structures is definable in Datalog 1 if there exists a Datalog program Π with a distinguished predicate nullary goal such that Π derives goal on

Eiter et al. bounded Rudolph et al. bounded Bienvenu et al. bounded Carral et al. bounded Carral et al. bounded Horn- SRIQ Datalog 2exp. bounded Ortiz et al. unbounded Ahmetaj et

PRACTICAL USES OF EXISTENTIAL RULES IN KNOWLEDGE REPRESENTATION Part 1: Basics / Rules for Ontology Reasoning David Carral,1 Markus Krötzsch,1 and Jacopo Urbani2 1.. Vrije

Chasing Sets: How to Use Existential Rules for Expressing Reasoning David Carral, Irina Dragoste, Markus Krötzsch, Christian Lewe.. Datalog for

• Rules are a powerful data query paradigm (Datalog!) – applications in data management, program analysis, business analytics, social network

The disjunctive skolem chase is a sound and complete (albeit non-terminating) algorithm that can be used to solve conjunctive query answering over DL ontologies and programs

For the discussed languages with exponential time data complexity (i.e. weakly guarded and weakly frontier-guarded rules), we showed that, extended with negation on input facts,

• We show that R-stratified programs have unique stable models, so that reasoning becomes deterministic, and that if programs are also R-acyclic, reasoning becomes 2E XP T IME