=Paper= {{Paper |id=Vol-1417/paper9 |storemode=property |title=Datalog+, RuleML and OWL 2: Formats and Translations for Existential Rules |pdfUrl=https://ceur-ws.org/Vol-1417/paper9.pdf |volume=Vol-1417 |dblpUrl=https://dblp.org/rec/conf/ruleml/BagetGLMRS15 }} ==Datalog+, RuleML and OWL 2: Formats and Translations for Existential Rules== https://ceur-ws.org/Vol-1417/paper9.pdf
               Datalog+, RuleML and OWL 2:
         Formats and Translations for Existential Rules

       Jean-François Baget, Alain Gutierrez, Michel Leclère, Marie-Laure Mugnier,
                            Swan Rocher, and Clément Sipieter

                            Inria, CNRS and University of Montpellier
                                            France


         Abstract. This paper is devoted to formats and translations for Datalog+. We
         first introduce the dlgp format, which extends classical Datalog format to Dat-
         alog+. It allows to encode facts, existential rules (including equality), negative
         constraints and conjunctive queries. Moreover, for compatibility with Semantic
         Web languages, this format includes Web notions (IRIs and literals, according to
         Turtle syntax). Second, we define a translation from dlgp to the Datalog+ frag-
         ment of RuleML. Third, we define a translation from OWL 2 to dlgp. We point
         out that the composition of both translations allows to import OWL 2 to RuleML.
         The associated parsers and translators are available.


1     Introduction
The novel framework of existential rules, also known as Datalog+ (and Datalog± for
its decidable fragments) raised considerable interest in the last years, specially in the
context of ontology-mediated query answering. For the theoretical foundations of this
framework, we refer the reader to [CGK08,BLMS09,CGL09,BLMS11,KR11,CGP12].
A sublanguage of RuleML corresponding to Datalog+ has been recently defined (see
Deliberation RuleML 1.01).1
    This paper is devoted to formats and translators for the existential rule framework.
It can be seen as a companion to the paper [BLM+ 15] devoted to Graal, a toolkit for
querying existential rule knowledge bases. First, we introduce a textual format, called
dlgp, for “Datalog+”. This format is indeed an extension of the classical Datalog format
to Datalog+. In addition, to ensure compatibility with Semantic Web languages, the
current version (2.0) includes Web notions like IRIs and literals. Second, we briefly
present a translation from dlgp to (the Datalog+ sublanguage of) RuleML, which is
quite direct. Third, we define a translation from OWL 2 to dlgp. More precisely, we
define OWL 2 ER, an OWL 2 profile that can be translated into the existential rule
framework. In particular, this profile generalizes so-called tractable profiles of OWL
2. Our translator from OWL 2 to dlgp accepts as input any OWL 2 file but ignores
(parts of) OWL 2 axioms that cannot be recast as axioms of OWL 2 ER. Note that the
composition of both translations allows to import OWL 2 to RuleML.
    The dlgp parser, as well as translators from dlgp to RuleML and from OWL 2 to dlgp
are available online at http://graphik-team.github.io/graal/ (Graal home-
page). The paper focuses on salient aspects of these three points and illustrates them
 1
     http://wiki.ruleml.org/index.php/Specification_of_Deliberation_RuleML_1.01
2         J.-F. Baget, A. Gutierrez, M. Leclère, M.-L. Mugnier, S. Rocher, C. Sipieter

by examples. Details on the dlgp format and OWL 2 ER profile (including OWL 2 ER
grammar) can be found in technical reports available on Graal website.

Preliminaries. We recall here the basic components of the existential rule framework:
facts, (pure) existential rules, which include equality rules, negative constraints and
conjunctive queries. We consider logical atoms of the form p(t1 . . . tn ), where p is a
predicate of any arity greater or equal to one (i.e., n ≥ 1) and the ti are variables or
constants. We also consider equality atoms (of the form t1 = t2 ). By conjunction, we
mean a conjunction of such atoms.

    – A (pure) existential rule is a positive rule of the form ∀X∀Y (B[X, Y ] → ∃Z
      H[X, Z]), where X, Y and Z are sets of variables, B (the body) is a conjunc-
      tion with variables in X and Y , and H (the head) is a conjunction with variables
      in X and Z; hence Z denotes the set of variables that occur in H but not in B; a
      specific kind of pure existential rules are equality rules, whose head is restricted to
      an equality atom.
    – A fact is an existentially closed conjunction, i.e., of the form ∃XF[X], where F is
      a conjunction whose set of variables is exactly X. Note that we generalize here the
      classical notion of a fact defined as a ground atom. Indeed, a fact is usually seen as
      a rule with an empty body, hence the previous definition is in line with existential
      rules. Moreover, existential variables in facts allow to naturally encode unknown
      values in databases (“nulls”) or blank nodes in RDF.
    – A negative constraint is the negation of a fact, i.e., of the form ¬∃XC[X]; equiva-
      lently, it can be seen as a rule with a head restricted to the always-false symbol ⊥:
      ∀X(C[X] → ⊥);
    – A conjunctive query is an existentially quantified conjunction, in which the free
      variables are called answer variables. It can also be seen as a rule of the form
      ∀X∀Y (B[X, Y ] → ans(X)), where ans is a special predicate and X is the set of
      answer variables.

      The following running example illustrates these different components.

Example 1 (Running example). We consider a vocabulary composed of the following
predicates, with their arity mentioned after their name: Project/1, Researcher/1, isPro-
ject/3, hasCost/2, hasExpertise/2, isMember/2. The unary predicates can be seen as
types of entities (i.e., classes or concepts); the ternary predicate isProject relates a
project, the area of this project and the leader of this project; the predicate hasCost
relates a project and its cost, while predicates hasExpertise and isMember relate a re-
searcher to an area and to a project, respectively.
    We consider a knowledge base built on this vocabulary composed of the following
three facts and four rules:
    – F1 = Researcher(a), where a is a constant
      “Individual a is a researcher”
    – F2 = ∃X∃Y (isM ember(a, X) ∧ isP roject(X, kr, Y ) ∧ hasCost(X, 1.5)),
      where a, kr and 1.5 are constants;
      “Individual a is member of a project in the kr area which has a cost of 1.5”
          Datalog+, RuleML and OWL 2: Formats and Translations for Existential Rules          3

     – F3 = Researcher(b) ∧ hasExpertise(b, sw), where b and sw are constants
       “Individual b is a researcher who has expertise in the sw area”
     – R1 = ∀X∀Y ∀Z(isP roject(X, Y, Z) → isM ember(Z, X))
       “Every leader of a project is a member of this project”
     – R2 = ∀X∀Y (Researcher(X)∧ hasExpertise(X, Y ) →
                                              ∃Z∃L (isP roject(Z, Y, L) ∧ isM ember(X, Z)))
       “Every researcher expert in an area is a member of a project in that area”
     – R3 = ∀X∀Y ∀Z(isP roject(X, Y, Z) ∧ isP roject(X, Y, Z 0 ) → Z = Z 0 )
       “Every project has at most one leader”
     – R4 = ∀X(Researcher(X) ∧ P roject(X) → ⊥)
       “Classes Researcher and Project are disjoint”

    R1 is a (plain) Datalog rule since it has no existential variable. R3 is an equality
rule. R4 is a negative constraint. Note that Fact F3 can be decomposed into two atomic
facts, whereas F2 cannot because its atoms are linked by the variable X. Here are two
examples of conjunctive queries on this vocabulary:
     – Q1 = ∃Y ∃Z(Researcher(X) ∧ isM ember(X, Y ) ∧ isP roject(Y, kr, Z))
       “find all researchers members of a project in kr”
     – Q2 = ∃X∃ZisP roject(X, sw, Z)
       “is there a project in the sw area ?”

   The set of answers to Q1 on the knowledge base is {a} (found in F1 ∧ F2 ). The
answer to Q2 is yes (which requires to consider F3 ∧ R2 ).

    In the next sections, we present the dlgp format, then its translation to RuleML, and
finally the translation from OWL 2 to dlgp.


2      The Datalog+ format (dlgp)

The dlgp format is a textual exchange format, meant to be at once human-friendly,
concise and easy to parse. It can be seen as an extension of the commonly used format
for plain Datalog. In particular, rules are of the form head :- body. Note that a
comma is interpreted as a logical ∧, even in a rule head. Quantifiers are omitted since
there is no ambiguity. We remind that variables that occur in the head and not in the
body are existentially quantified.
    In Datalog, variables begin with an uppercase letter, while constants and predicates
begin with a lowercase letter. To make the dlgp format compatible with data from the
Semantic Web, more elaborate kinds of identifiers are mandatory. That is why dlgp
deals with the notions of IRI and literal, as detailed later.
    The following example shows a dlgp encoding of the knowledge from Example 1.
The predicates that begin with an uppercase letter are enclosed in angle brackets (<>).
The directives @facts, @rules, @constraints, @queries are optional indica-
tions for the reader or the parser. 2 Knowledge elements are preceded by an optional
label (enclosed in square brackets).
 2
     These directives allow the parser to be sooner informed of the nature of coming statements.
     However, the parser is free to ignore them.
4         J.-F. Baget, A. Gutierrez, M. Leclère, M.-L. Mugnier, S. Rocher, C. Sipieter

Example 2 (Running example in dlgp).
% this dlgp file encodes Example 1
@facts
[F1] (a).
[F2] isMember(a,X), isProject(X, kr, Y), hasCost(X,1.5).
[F3] (b), hasExpertise(b,sm).
@rules
[R1] isMember(Z,X) :- isProject(X,Y,Z).
[R2] isProject(Z,Y,L), isMember(X,Z) :- (X), hasExpertise(X,Y).
[R3] Z1=Z2 :- isProject(X,Y,Z1), isProject(X,Y,Z2).
@constraints
[R_4] ! :- (X), (X).
@queries
[Q1] ? (X) :- isMember(X,Y), isProject(Y, kr, Z).
[Q2] ? :- isProject(X,sw,Z).


   Other features of dlgp have been added for compatiblity with Semantic Web lan-
guages:

    – predicates and constants can be denoted by IRIs;
    – constants can be literals;
    – namespaces are introduced;
    – a universal class can be declared (e.g., Thing in OWL 2);
    – whether the Unique Name Assumption is made or not can be specified.

    To implement these features, we rely on Turtle syntax.3 In particular, a predicate
or a constant can be denoted by an IRI in Turtle format, which can be written in three
forms: a relative IRI, an absolute IRI or a prefixed name. Relative and absolute IRIs are
strings of the form  (IRIREF in Turtle grammar). A prefixed name is a string
prefixed by a namespace (PrefixedName in Turtle grammar); moreover, the classical
Datalog notation (a string beginning with a lowercase letter) is allowed and understood
as a relative IRI. A constant can also be a literal (literal in Turtle grammar).
    For instance, here are different ways of writing a predicate:

    – pred (classical Datalog notation);
    –  (a relative IRI, whose base is specified by a directive of the form
      @base );
    –  (an absolute IRI)
    – ex:pred (a prefixed name; the IRI associated with the prefix ex is specified by a
      directive of the form @prefix ex: 

    All these forms can be used to encode a constant. Moreover, constants can be de-
scribed by literals, e.g., -5.1, true, "constant", or any other Turtle literal. Note
that the tokens true and false are interpreted as Boolean literals and not as IRIs.
    The following example shows another dlgp encoding of the knowledge from Exam-
ple 1 using IRIs and namespaces.

Example 3 (Running example in dlgp with IRIs and namespaces).
 3
     http://www.w3.org/TR/turtle/
         Datalog+, RuleML and OWL 2: Formats and Translations for Existential Rules         5

@prefix ex:  % namespace
@facts
[F1] ex:Researcher(ex:a).
[F2] ex:isMember(ex:a,X), ex:isProject(X, ex:kr, Y), ex:hasCost(X,1.5).
[F3] ex:Researcher(ex:b), ex:hasExpertise(ex:b,ex:sw).
@rules
[R1] ex:isMember(Z,X) :- ex:isProject(X,Y,Z).
[R2] ex:isProject(Z,Y,L), ex:isMember(X,Z) :- ex:Researcher(X),
ex:hasExpertise(X,Y).
[R3] Z1=Z2 :- ex:isProject(X,Y,Z1), ex:isProject(X,Y,Z2).
@constraints
[R_4] ! :- ex:Researcher(X), ex:Project(X).
@queries
[Q1] ? (X) :- ex:isMember(X,Y), ex:isProject(Y, kr, Z).
[Q2] ? :- ex:isProject(X,ex:sw,Z).


      The complete grammar of dlgp is available on Graal website.


3      From dlgp to RuleML

The translation from dlgp to RuleML targets more precisely the Datalog+ fragment of
Deliberation RuleML 1.01. This sublanguage includes:

    – positive facts,
    – universally quantified implications,
    – existentials in the heads of implications,
    – equality,
    – falsity in the heads of implications,
    – conjunctions in the heads of implications.

     The translation from dlgp to this sublanguage is quite direct. Since existential quan-
tification in facts is not allowed in this sublanguage, we translate each existential vari-
able in facts by a new constant 4 , as illustrated in Example 4. This example also illus-
trates the translation of datatypes.

Example 4 (Fact with existential variables and datatypes).
[F2] isMember(a,X), isProject(X, kr, Y), hasCost(X, 1.5).


  isMemberai0
  isProjecti0kri1
  hasCosti0
    1.5



    Example 5 illustrates the translation of existential rules. Constraints are translated
in the same manner with an empty disjunction in the head.

Example 5 (Rule with existential variables in the head).
 4
     To preserve the semantics of the knowledge base, the unique name assumption should not be
     made on these new constants.
6       J.-F. Baget, A. Gutierrez, M. Leclère, M.-L. Mugnier, S. Rocher, C. Sipieter

[R2] isProject(Z,Y,L), isMember(X,Z) :- (X), hasExpertise(X,Y).


  XY
    
      ResearcherX
      hasExpertiseXY
    
      LZ
        isProjectZYL
        isMemberXZ
      
    
  



    Example 6 illustrates the translation of queries.

Example 6 (Query).
[Q1] ? (X) :- isMember(X,Y), isProject(Y, kr, Z).


  YZ
    isMemberXY
    isProjectYkrZ
  



    Finally, Example 7 shows how IRIs are translated.

Example 7 (Fact with IRI).
@prefix ex: 
[F1] ex:Researcher(ex:a).


  
    
    
  



    The full translation of Example 3 to RuleML is available on Graal website.


4   From OWL 2 to dlgp: the ER profile

We introduce here the ER (for Existential Rule) profile of OWL 2, for which all axioms
can be translated into dlgp statements. We point out that all axioms that can be written
in existing profiles of OWL 2 (namely EL, QL and RL) are axioms of ER.
    For space requirements and the sake of simplicity, we do not discuss here datatypes
nor literals. Axioms used for datatypes and literals always correspond to a similar axiom
used for classes and individuals (for instance DataIntersectionOf corresponds to
ObjectIntersectionOf). They are thus processed similarly in our translation.
          Datalog+, RuleML and OWL 2: Formats and Translations for Existential Rules             7

4.1     Preliminary Notions

Basic objects in an OWL 2 ontology are entities, such as classes, properties and indi-
viduals. These entities are identified by IRIs. We associate an OWL 2 individual i with
the logical constant i, an OWL 2 class C with the unary predicate C, and an OWL 2
property p with the binary predicate p.5
    Entities are used to build expressions, such as class expressions or property ex-
pressions. We present these expressions both in OWL 2 functional notation, such as
ObjetIntersectionOf(A, ObjectComplementOf(B)), and in their DL no-
tation such as A u ¬B; they both identify the class whose elements are in A and
not in B. For every class expression C, we can build a FOL formula ΦC (x) whose
only free variable is x, expressing that “x is an element of the class C”. For instance,
ΦAu¬B (x) = A(x) ∧ ¬B(x). In the same way, for every property expression p, we can
build a FOL formula ΦP (x, y) whose only free variables are x and y, expressing that
“the relation p holds between the subject x and the object y”.
    An OWL 2 ontology is a set of axioms, built from expressions (we do not discuss
here annotations, which have no logical translation). The axiom SubclassOf(A,
B) means that all elements of A are also elements of B. It is written A v B in DL no-
tation. This axiom is translated into a FOL formula (without free variable) ∀x (A(x) →
B(x)). Almost all OWL 2 axioms can be translated into formulas of the form ∀~x(B(~x) →
H(~x)) where B(~x) and H(~x) are FOL formulas whose only free variable is x. These
formulas cannot always be translated into dlgp, as shown in Example 8.

Example 8. The axiom C v A u ¬B is translated by the formula ∀x (C(x) → A(x) ∧
¬B(x). It is equivalent to the conjunction of the two formulas ∀x (C(x) → A(x))
and ∀x (C(x) → ¬B(x)). The first is expressed by the dlgp rule A(X) :- C(X)
and the second by the dlgp constraint ! :- B(X), C(X). In contrast, the axiom
A u ¬B v C cannot be translated into dlgp.

     The ER (for existential rules) profile of OWL 2 is obtained by putting syntactic re-
strictions on OWL 2 expressions and axioms, in order to ensure that all axioms have an
equivalent translation in dlgp. This profile defines different kinds of class expressions,
according to the position they can fill in a formula of the form ∀~x(B(~x) → H(~x)).
EquivClass expressions can appear in both sides of such an implication, as will be dis-
cussed in Sect. 4.2. SubClass expressions can only appear in the left side (Sect. 4.3),
while SuperClass expressions can only appear in the right side (Sect. 4.4). We show in
Sect. 4.5 that any OWL 2 axiom can either be easily translated into dlgp or is equivalent
to a formula of the form ∀~x(B(~x) → H(~x)), that can be translated when it complies
with the restrictions of the ER profile.
 5
     We already discuss here the particular case of two specific classes, Thing and Nothing
     (respectively written > and ⊥ in DL). Thing is the universal class that contains everything
     and Nothing is the empty class. They are used as any other class in our framework, though
     their particular semantics is expressed in dlgp by the two following dlgp statements that must
     be present in every dlgp knowledge base translating an OWL 2 ontology: the dlgp constraint
     ! :- Nothing(X); and the dlgp annotation @top Thing that declares that the universal
     class in the knowledge base is named Thing.
8          J.-F. Baget, A. Gutierrez, M. Leclère, M.-L. Mugnier, S. Rocher, C. Sipieter

    In this paper, all axioms and expression constructors will be presented according to
the format given in Tab. 1.

                                      Type of axiom or expression
Name of axiom or expression
Axiom or expression in OWL 2 functional syntax DL syntax Logical translation
Optional comments.

                               Table 1. General format of tables




4.2     EquivClass expressions
A FOL formula F(~x) is said to be conjunctive when it is in the form ∃~z (C1 [~x, ~z] ∧
. . . ∧ Cp [~x, ~z]) where the Ci [~x, ~z] are (positive) atoms whose variables are in ~x ∪ ~z.6
Property 1. For every property expression p, Φp (x, y) is a conjunctive formula. See
Tab. 2.
    In the ER profile, an EquivClass expression is a class expression built, without any
other restriction, from the constructors listed in Tab. 3.
Property 2. For every EquivClass expression C, ΦC (x) is equivalent to a conjunctive
formula.
      The following property is the basis of our transformation from OWL 2 to dlgp.
Property 3. Every formula of the form ∀~x(B(~x) → H(~x)) where B(~x) and H(~x) are
conjunctive can be translated into an equivalent dlgp rule.
Example 9. The class expression ∃p·(∃q ·C) is translated into FOL by Φ∃p·(∃q·C) (x) =
∃y1 (p(x, y1 ) ∧ (∃y2 (q(y1 , y2 ) ∧ C(y2 )))). By putting it in prenex form, we obtain the
conjunctive formula ∃y1 ∃y2 (p(x, y1 )∧q(y1 , y2 )∧C(y2 )). Thus the axiom D v ∃p·(∃q·
C) is translated by the dlgp rule: p(X, Y1), q(Y1, Y2), C(Y2) :- D(X).
    As a final remark on the translation of implications of conjunctive formulas, we
point out that formulas of the form ∀x(B(x) → Thing(x)) or ∀x(Nothing(x) →
H(x)) do not bring any information, thus do not need to be translated; that formulas of
the form ∀x(B(x) → Nothing(x)) can be directly translated into a dlgp constraint;
and that formulas of the form ∀x(x = a → B(x)) can be directly translated into a dlgp
fact.
Example 10. The axiom A v ∃p · ⊥ is translated by the FOL formula ∀x(A(x) →
(∃y(p(x, y) ∧ Nothing(y)))), which can be simplified in ∀x(A(x) → Nothing(x)),
and thus can be expressed by the dlgp constraint ! :- A(X)
   The axiom {a} v ∃p · C is translated by the FOL formula ∀x ((x = a) →
∃y(p(x, y) ∧ C(y)) and thus can be expressed by the dlgp fact: p(a, Y), C(Y).
 6
     Moreover, we always simplify such a conjunctive formula: it is equivalent to Nothing(x) if
     one of its atoms is some Nothing(y), and we can remove all atoms of the form Thing(y)
     without changing the semantics (unless the formula is restricted to a single atom Thing(x)).
          Datalog+, RuleML and OWL 2: Formats and Translations for Existential Rules                            9

                                          Object Property Expressions
Object Property
p                                        p             p(x, y)
Inverse Object Property
ObjectInverseOf(p)                       p−            p(y, x)
                                              Property Expression Chain
ObjectPropertyChain(p1 , . . . , pk ) p1 · . . . · pk ∃z1 . . . ∃zk−1 (Φp1 (x, z1 ) ∧ . . . ∧ Φpk (zk−1 , y))
Note that the arguments of a property expression chain are always object property expressions.

                             Table 2. Property expressions in OWL 2.


                                              EquivClass expressions
Class
C                                           C          C(x)
Intersection of Class Expressions
ObjectIntersectionOf(C1 , . . . , Ck ) C1 u . . . u Ck ΦC1 (x) ∧ . . . ∧ ΦCk (x)
Existential Quantification
ObjectSomeValuesFrom(p, C)                  ∃p · C     ∃y (Φp (x, y) ∧ ΦC (y))
Individual Value Restriction
ObjectHasValue(p, i)                        ∃p · {i}   Φp (x, i)
Self-Restriction
ObjectHasSelf(p)                            ∃p · Self  Φp (x, x)
Minimum Cardinality - Restricted to n = 0 or 1
ObjectMinCardinality(0, p, C)               ≥ 0pC      Thing(x)
ObjectMinCardinality(1, p, C)               ≥ 1pC      ∃y (Φp (x, y) ∧ ΦC (y))
Enumeration of Individuals - Restricted to n = 1
ObjectOneOf(i)                              {i}        x=i

                          Table 3. EquivClass expressions constructors



4.3     SubClass expressions

A FOL formula F(~x) is said to be disjunctive when it is a disjunction F1 (~x) ∨ . . . ∨
Fk (~x) of conjunctive formulas. In that case, we say that the disjunction is of size k.7
    In the ER profile, a SubClass expression is a class expression built, without any
other restriction, from the constructors listed in Tab. 4.

Property 4. If C is a SubClass expression, ΦC (x) is equivalent to a disjunctive formula.

Example 11. The SubClass expression (A t B) u ∃p · (A t B) is translated by the FOL
formula (A(x)∨B(x))∧∃y(p(x, y)∧(A(y)∨B(y))). It is equivalent to the disjunctive
formula FAA (x)∨FAB (x)∨FBA (x)∨FBB (x) where FAA (x) = ∃y(A(x)∧p(x, y)∧
A(y)), FAB (x) = ∃y(A(x) ∧ p(x, y) ∧ B(y)), FBA (x) = ∃y(B(x) ∧ p(x, y) ∧ A(y))
and FBB (x) = ∃y(B(x) ∧ p(x, y) ∧ B(y)).

   Note that putting the formula translating a SubClass expression into its disjunctive
form can be exponential in the size of the initial formula.
 7
     We always simplify a disjunctive formula: it is equivalent to Thing(x) if one of its conjunctive
     formulas is Thing(x), and we can remove all conjunctive formulas of the form Nothing(x)
     without changing the semantics (unless the formula is restricted to a single conjunctive formula
     Nothing(x)).
10        J.-F. Baget, A. Gutierrez, M. Leclère, M.-L. Mugnier, S. Rocher, C. Sipieter

                                            EquivClass expressions
All EquivClass expressions constructors: Atomic class expressions (including Thing and Nothing),
ObjectIntersectionOf, ObjectSomeValuesFrom, ObjectHasValue, ObjectHasSelf,
ObjectMinCardinality (restricted to n = 0 or 1), ObjectOneOf (restricted to n = 1).
                                             SubClass expressions
Union of class expressions
ObjectUnionOf(C1 , . . . , Ck ) C1 t . . . t Ck ΦC1 (x) ∨ . . . ∨ ΦCk (x)
Enumeration of individuals (unrestricted)
ObjectOneOf(i1 , . . . , ik )    {i1 , . . . , ik } x = i1 ∨ . . . ∨ x = ik

                           Table 4. SubClass expressions constructors.



Property 5. Every formula of the form ∀~x(B(~x) → H(~x)), where B(~x) is a disjunctive
formula of size k and H(~x) is a conjunctive formula, can be translated into an equivalent
conjunction of k dlgp rules.

Example 12. The axiom (A t B) u ∃p · (A t B) v ∃q · > is translated by the
four following dlgp rules: q(X, Z) :- A(X), p(X, Y), A(Y) and q(X, Z)
:- A(X), p(X, Y), B(Y) and q(X, Z):- B(X), p(X, Y), A(Y) and
q(X, Z) :- B(X), p(X, Y), B(Y).


4.4   SuperClass expressions

Contrary to what happens with EquivClass and SubClass expressions, all OWL 2 con-
structors can appear in ER SuperClass expressions. Hence, these expressions can also
use, in addition to the constructors already presented, the constructors listed in Tab. 5.
However, we impose syntactic restrictions on the possible interactions between these
constructors.

Definition 1. SuperClass expressions are defined inductively. A SuperClass expression
is either an EquivClass expression; the intersection C1 u . . . u Ck of SuperClass ex-
pressions Ci ; the complement ¬C of a SubClass expression C; the universal restriction
∀p·C of a SuperClass expression C; or the maximum cardinality ≤ n p C of a SubClass
expression C, when n is restricted to 0 or 1.


Property 6. A formula ∀x (ΦB (x) → ΦH (x)), where B is a SubClass expression and
H is a SuperClass expression, is equivalent to a conjunction of formulas of the form
∀x (B(x) → H(x)), where B(x) is disjunctive and H(x) is conjunctive.

Proof. We show the property inductively on the SuperClass expression H.
    If H is an EquivClass expression, then the property is immediate.
    If H = H1 u . . . u Hk , then our formula is equivalent to the conjunction of formulas
∀x (ΦB (x) → ΦHi (x)), where the Hi are SuperClass expressions.
    If H = ¬H 0 , then our formula is equivalent to ∀x (ΦB (x) ∧ ΦH 0 (x) →
Nothing(x)). Since both B and H 0 are SubClass expressions, the conjunction of
ΦB (x) and ΦH 0 (x) is equivalent to a disjunctive formula.
         Datalog+, RuleML and OWL 2: Formats and Translations for Existential Rules                                11

Complement of Class Expressions
ObjectComplementOf(C)                         ¬C      ¬ΦC (x)
Is a SuperClass expression when C is a SubClass expression
Universal Quantification
ObjectAllValuesFrom(p, C)                     ∀p · C ∀y (Φp (x, y) → ΦC (y)
Is a SuperClass expression when C is a SuperClass expression
Maximum Cardinality
ObjectMaxCardinality(n, p, C)                 ≤ npC ∀y1 . . . ∀yn+1 ((Φp (x, y1 ) ∧ ΦC (y1 ) ∧ . . . ∧ Φp (x, yn+1 ) ∧
                                                      ΦC (yn+1 )) → ∨1≤i