<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Defining a subset of OCL for expressing SWRL rules</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Sergey Lukichev</string-name>
          <email>Lukichev@tu-cottbus.de</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Institute of Informatics, Brandenburg University of Technology at Cottbus</institution>
        </aff>
      </contrib-group>
      <abstract>
        <p>OCL is a rich-syntax language for expressing integrity rules and many business rules can be expressed using OCL. On the other hand, UML/OCL is a mainstream modeling technology and adopting it for expressing rules in the upcoming Semantic Web is a good practical issue: rules can be initially expressed in UML/OCL and then mapped into OWL/SWRL. Since UML/OCL is more expressive than OWL/SWRL it is good to define a subset of OCL, which can easily be mapped into the SWRL. In this paper we define this subset of OCL, called OCL-Lite, by building a mapping from SWRL into OCL. In addition, we briefly sketch the correctness problem of this mapping in terms of language interpretations.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>There are two issues we have to motivate: i). Why the subset of OCL,
which can be mapped into SWRL is needed? ii). Why we build the
mapping from SWRL to OCL in order to define this subset?</p>
      <p>
        UML/OCL [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] is widely used among software engineers, while
the area of the Semantic Web lacks for modeling methodologies
and tools, comparable in popularity and maturity with UML/OCL.
Therefore, it is natural to reuse existing UML/OCL methodologies
and tools for modeling Semantic Web rules, which are expressed
in the Semantic Web Rule Language (SWRL) [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. The first arising
problem with mapping OCL constraints into SWRL rules is a rich
OCL syntax. It allows variety of expressions and not all of them can
be mapped into SWRL. There are a number of works on sharing
rules between OWL/SWRL and UML/OCL [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ], [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]. However,
these works are mainly focused on the technical side of the mapping,
in particular on the implementation of the metamodel
transformations using Query View Transformations (QWT). The main question,
which remains open in these works is what is exact subset of OCL,
which can be mapped into SWRL? In this work we bridge this gap
by defining a subset of OCL, called OCL-Lite, which can be mapped
into SWRL.
      </p>
      <p>
        In order to define OCL-Lite, we build a mapping from SWRL to
OCL. The expressivity of OCL is higher than the first order logic
since closures over object relations can be expressed in OCL but not
in FOL [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. Moreover, the syntax of SWRL is simpler than OCL,
therefore we build the mapping from the less expressive language to
the more expressive one, which is a natural method in determining
the mappable subset of OCL.
      </p>
      <p>The paper is structured as follows: section 2 contains the mapping
from SWRL to OCL, in section 3 the syntax of OCL-Lite is specified
and section 4 defines the problem of the semantical correctness of
SWRL to OCL mapping and lists open issues for the further research.
2</p>
      <p>
        Translating SWRL rules into OCL invariants
First, we remind the SWRL abstract syntax, which is originally
defined in [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. By I = Imp(Antec(A), Conseq(C)) we
denote a SWRL rule where A and C are conjunctions of SWRL
atoms. By classAtom(CD, t) we denote a SWRL class atom,
where CD is a class description, as defined in [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] (Section
2.3.2.3. OWL DL Restrictions) and t is an object variable or
an individual. By individualPropertyAtom(p, o1, o2) we
denote a SWRL individual property atom, where p is a
reference to a property, and o1 and o2 are object variables.
By A = datavaluedPropertyAtom(p, obj, val) we denote a
SWRL datatype property atom, where p is a reference to an datatype
property, obj is an object variable and val is a data value or a data
variable.
      </p>
      <p>
        According to the semantics of SWRL [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], SWRL rules are
integrity constraints in the form of logical implications.
      </p>
      <p>Let I = Imp(Antec(A), Conseq(C)) be a SWRL rule, then
the mapping T transforms it into an OCL invariant as follows:
T(I) := context class(X) inv:
T(A) implies T(C)</p>
      <p>The context class X of the resulting OCL invariant is class of a
universally quantified variable in the rule. This variable then is
renamed to self. If the rule has more than one universally quantified
variable, then X.allInstances()-&gt;forAll(y|e(y)) expression
is used recursively, where X is a class of the universally quantified
variable and e(y) is the OCL boolean expression, resulted from the
SWRL rule.</p>
      <p>In fact, using the SWRL syntax, it is possible to express
a rule, which cannot be mapped into a syntactically
correct OCL invariant. In particular, this is because SWRL
supports data variables, which are not explicitly supported
in OCL. For instance, if we have a conjunction of two
SWRL atoms: individualPropertyAtom(age, o, x) and
builtinAtom(&gt;, x, 18), where x is a data variable, then this
corresponds to the OCL expression o.age&gt;18, i.e. we have one
OCL expression from the conjunction of two SWRL atoms. If
the built-in atom is dropped, then the SWRL rule still remains
syntactically correct, while the resulting OCL expression will have
unknown symbol x. We do not define such possible mappings in this
paper and focus on the direct mappings of SWRL atoms.</p>
      <p>We do not describe how URIs are mapped into names of UML
classifiers since this task is about the mapping from OWL to UML
while we define the mapping of SWRL rules into OCL invariants.</p>
      <p>The body and the head of a SWRL rule is a conjunction of SWRL
atoms, therefore if A = A1, ..., An, then</p>
      <p>T(A) := T(A1) and ... and T(An)</p>
    </sec>
    <sec id="sec-2">
      <title>Let us consider the mapping of SWRL atoms.</title>
      <p>• If A = classAtom(id, t) is a SWRL class atom, where id is
an URI reference of the class and t is an object variable, then
T(A) := t.oclIsKindOf(id)
• If A = individualPropertyAtom(p, o1, o2) where p is a
reference to an individual property, o1 and o2 are object
variables, then</p>
      <p>T(A) := o1.p=o2
• If</p>
      <p>A = datavaluedPropertyAtom(p, obj, val) where p is a
reference to an individual property, obj is an object variable and
val is a data value or a data variable, then</p>
      <p>
        T(A) := obj.p=val
• If A = builtinAtom(builtin, {obj}) where builtin is
a SWRL builtin and {obj} is a list of datatype terms, then
the resulting OCL expression is of type Boolean and
depends on the built-in, for instance, if builtin is ’+’ then
A = builtinAtom(’+’, a,b,c) and T(A) := a=b+c.
If A = classAtom(CD, t) is a SWRL class atom with an OWL
description CD, then we define the mapping function case wise for
each possible OWL class description CD (the syntax of OWL class
descriptions is defined in [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]):
• If CD = UnionOf(CD1, CD2) where CD1 and CD2 are OWL
class descriptions, then
      </p>
      <p>T(classAtom(UnionOf(CD1, CD2), t)) :=
T(classAtom(CD1, t)) or T(classAtom(CD2,
t))
For instance, if CD = UnionOf(Winery, Brewery) then
T(classAtom(CD, t)) := t.oclIsKindOf(Winery)
or t.oclIsKindOf(Brewery)
• If CD = IntersectionOf(CD1, CD2) where CD1 and CD2 are
OWL class descriptions, then</p>
      <p>T(classAtom(CD, t)) := T(classAtom(CD1, t))
and T(classAtom(CD2, t))
• If CD = ComplementOf(CD1) where CD1 is an OWL class
descriptions, then</p>
      <p>T(classAtom(CD, t)) := not T(classAtom(CD1,
t))
• If CD = Restriction(oProp, allValuesFrom(CD1))
where oProp is a property and CD1 is a class description, then
T(classAtom(CD, t)) :=
t.oProp-&gt;forAll(x|T(classAtom(CD1, x)))
The variable x is unified with instances of the property collection
oProp . For instance, if</p>
      <p>CD = Restriction(hasMaker,</p>
      <p>allValuesFrom(Winery))
then
• If CD is
• If CD is
• If CD is</p>
      <p>T(classAtom(CD, t)) :=
t.hasMaker-&gt;forAll(x|</p>
      <p>T(classAtom(Winery, x))) :=
t.hasMaker-&gt;forAll(x|</p>
      <p>x.oclIsKindOf(Winery))
Restriction(oProp,</p>
      <p>someValuesFrom(CD1))
T(classAtom(CD, t)) :=
t.oProp-&gt;exists(x|</p>
      <p>T(classAtom(CD1, x)))
where oProp is a property and CD1 is a class description, then
Restriction(dProp, value(d))</p>
      <p>T(classAtom(CD, t)) := t.dProp=d
where dProp is a datatype property and d is data value, then
Restriction(objProp, mincardinality(n))
where objProp is a property and n is minimal cardinality, then</p>
      <p>T(classAtom(CD, t)) := t.objProp-&gt;size()&gt;=n
The mapping of restrictions with min- and max- cardinalities is
similar.
• If CD = OneOf({obj1,...,objn}) where obj1,...,objn
are object URIs, then</p>
      <p>T(classAtom(CD, t)) := t=obj1 or ... or
t=objn
An example of the class atom with oneOf description</p>
      <p>CA := classAtom(oneOf(White, Red), t)</p>
    </sec>
    <sec id="sec-3">
      <title>Then</title>
      <p>T(CA) := t=White or t=Red
An OWL enumerated class, which is specified by the direct
enumeration of its instances, can be represented in UML by means of
a UML enumeration class. Some additional mapping from OWL
enumerated classes into UML enumeration classes may be needed
in order to produce a syntactically correct OCL expression.
However, this is the problem of UML to OWL mapping, which is
beyond our rules mapping problem.</p>
      <p>In order to show how the mapping works, let us consider a rule ”If
the maker of a liquid is a winery, then the liquid is either a wine or a
cognac”. The rule in SWRL is:</p>
      <p>R=Implies(Antec(classAtom(Liquid, t)
classAtom(Restriction(hasMaker,</p>
      <p>allValuesFrom(Winery)), t))
Conseq(classAtom(</p>
      <p>UnionOf(Wine, Cognac), t)))</p>
    </sec>
    <sec id="sec-4">
      <title>The mapping of R into OCL:</title>
      <p>T(R):= context Liquid inv:</p>
      <p>T(classAtom(Restriction(hasMaker,
allValuesFrom(Winery)), t))
implies</p>
      <p>T(classAtom(UnionOf(Wine, Cognac), t)))
Which is finally:
context Liquid inv:
self.hasMaker-&gt;forAll(x|</p>
      <p>x.oclIsKindOf(Winery))
implies
self.oclIsKindOf(Wine) or
self.oclIsKindOf(Congnac)</p>
      <sec id="sec-4-1">
        <title>3 The syntax of OCL-Lite</title>
        <p>
          The syntax of OCL-Lite expressions is defined recursively so that
more complex expressions are built from simple ones. The definition
below is based on the result of the mapping, defined in the previous
section. In the syntax definition below we refer to OCL expressions,
which are based on navigation operations, as navigation expressions.
For instance, self.father.brothers is a navigation
expression, which is not a new concept on top of OCL, but just a denotation
of the existing OCL expression, also used in the OCL specification
[
          <xref ref-type="bibr" rid="ref1">1</xref>
          ]. A navigation expression may result into a collection of instances.
We introduce this denotation in order to simplify the OCL-Lite
syntax by eliminating various OCL operations, which are not supported
in SWRL.
1. self is a special variable, which type is given by the invariant
context;
2. For every OCL model type t there is an unlimited number of
variables vti, which are OCL expressions of type t;
3. If f is an OCL operation symbol with argument types t1, ..., tn
and result type tr, e1, ..., en are OCL expressions and type of ei
is ti for all 1 ≤ i ≤ n then f (e1, ..., en) is OCL expression of
type tr. The set of operation symbols includes:
• some of predefined data operations: +, −, ∗;
• attribute operations, for instance, self.age, e.salary;
• side-effect free operations defined by a class, for instance,
b.rentalDiscount();
• navigation by role
self.pickupBranch.
        </p>
        <p>names,
for
instance,
4. If e1 and e2 are OCL expressions of an appropriate type (which
provides an order relation, for instance, integer) then e1 &gt; e2,
e1 &lt; e2, e1 &gt;= e2, and e1 &lt;= e2 are Boolean OCL
expressions. Note, that symbols &gt;, &lt;, &gt;=, and &lt;= are OCL operations
in the OCL metamodel, however here we define OCL expressions
with these symbols separately since logically they are predicate
symbols, while expressions, defined in the previous item are
different types of terms;
5. If e is an object variable, then e.oclIsKindOf (C), where C is a
class name, is a Boolean expression;
6. If e1, e2 are Boolean expressions then e1 and e2, e1 or e2, not e1,
e1 implies e2 are Boolean expressions;
7. If e1, e2 are OCL expressions of the same type, then e1 = e2,
e1 &lt;&gt; e2 are Boolean expressions.
8. If e(x) is a navigation expression, where variable x is bound
by the quantifier, for instance, self.employee, then e(x) →
size() op n is Boolean expression, where op is either &gt;, &lt;, =,
&gt;=, &lt;=, or &lt;&gt;. We do not define an expression of the form
e(x).size(), where e is of any OCL collection type, for instance,
resulted from some operation on collections like includesAll()
since they are not defined in SWRL. The defined expression of
the form e(x) → size() op n is obtained via the mapping from
the SWRL class atom with cardinality restriction.
9. If e is a navigation expression, for instance, self.employee,
then e → f orAll(x|e1(x)) and e → exists(x|e1(x)) are
Boolean expressions, where e1(x) is a Boolean OCL expression
from variable x, which is bound by universal quantifier or
existential quantifier.
4</p>
      </sec>
      <sec id="sec-4-2">
        <title>Conclusion and future work</title>
        <p>In this paper we described the syntactic mapping from SWRL to
OCL and on the result of this mapping defined the syntax of
OCLLite, a simplified subset of the OCL syntax. OCL-Lite can be used for
expressing rules, which later can be mapped into the SWRL. Some
practical experiments with the implementation of this mapping are
available at the REWERSE I1 website2.</p>
        <p>The main open issue in this work is the semantic correctness of
the defined mapping. Having such mapping it is important to make
sure that the set of models of a SWRL rule f coincides with the set of
models of the OCL invariant t(f ). We describe the problem formally.</p>
        <p>Let I be an interpretation of SWRL rules and |= is a satisfaction
relation between interpretations and SWRL rules and there are the
following mappings:
• t : S → O, which maps SWRL rules into OCL invariants. It is a
syntactic transformation, which we have defined in this paper.
2
• T : SI → OI , which maps SWRL interpretations into OCL
interpretations.</p>
        <p>The task is to prove that for any SWRL interpretation J and SWRL
rule G if
then</p>
        <p>J |= G</p>
        <p>T (J ) |= t(G)</p>
        <p>The solution to this task is currently in our agenda and results will
be published soon.</p>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>Object</given-names>
            <surname>Constraint Language (OCL)</surname>
          </string-name>
          ,
          <year>v2</year>
          .0. OMG Final Adopted Specification.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>OWL</given-names>
            <surname>Web Ontology Language Semantic</surname>
          </string-name>
          and
          <string-name>
            <given-names>Abstract</given-names>
            <surname>Syntax</surname>
          </string-name>
          .
          <source>W3C Recommendation 10 February</source>
          <year>2004</year>
          . http://www.w3.org/2004/OWL.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>SWRL</given-names>
            <surname>: A Semantic Web</surname>
          </string-name>
          <article-title>Rule Language Combining OWL and RuleML</article-title>
          .
          <source>W3C Member Submission 21 May</source>
          <year>2004</year>
          . http://www.w3.org/Submission/SWRL/.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>Luis</given-names>
            <surname>Mandel</surname>
          </string-name>
          and Maria Victoria Cengarle.
          <article-title>On the expressive power of ocl</article-title>
          .
          <source>In FM '99: Proceedings of the Wold Congress on Formal Methods in the Development of Computing Systems-Volume I ,</source>
          pages
          <fpage>854</fpage>
          -
          <lpage>874</lpage>
          , London, UK,
          <year>1999</year>
          . Springer-Verlag.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>Milan</given-names>
            <surname>Milanovic</surname>
          </string-name>
          , Dragan Gasevic, Adrian Giurca, Gerd Wagner, and
          <string-name>
            <given-names>Vladan</given-names>
            <surname>Devedzic</surname>
          </string-name>
          .
          <article-title>On interchanging between owl/swrl and uml/ocl</article-title>
          .
          <source>In Proceedings of the OCLApps Workshop</source>
          , pages
          <fpage>81</fpage>
          -
          <lpage>95</lpage>
          , Genova, Italy, 2
          <year>October 2006</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>Milan</given-names>
            <surname>Milanovic</surname>
          </string-name>
          , Dragan Gasevic, Adrian Giurca, Gerd Wagner, and
          <string-name>
            <given-names>Vladan</given-names>
            <surname>Devedzic</surname>
          </string-name>
          .
          <article-title>Sharing owl/swrl and uml/ocl rules</article-title>
          .
          <source>In Proceedings of ACM/IEEE 9th International Conference on Model-Driven Engineering Languages and Systems (MODELS</source>
          <year>2006</year>
          ), Genova, Italy,
          <fpage>1</fpage>
          -
          <issue>6</issue>
          <year>October 2006</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>Milan</given-names>
            <surname>Milanovic</surname>
          </string-name>
          , Dragan Gasevic, Adrian Giurca, Gerd Wagner, and
          <string-name>
            <given-names>Vladan</given-names>
            <surname>Devedzic</surname>
          </string-name>
          .
          <article-title>Towards sharing rules between owl/swrl and uml/ocl</article-title>
          . In
          <source>Electronic Communications of European Association of Software Science and Technology</source>
          ,
          <year>2007</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>