<!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>OCL2FOL+: Coping with Undefinedness</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Carolina Dania</string-name>
          <email>carolina.dania@imdea.org</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Manuel Clavel</string-name>
          <email>manuel.clavel@imdea.org</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>IMDEA Software Institute</institution>
          ,
          <addr-line>Madrid</addr-line>
          ,
          <institution>Spain Universidad Complutense de Madrid</institution>
          ,
          <addr-line>Madrid</addr-line>
          ,
          <country country="ES">Spain</country>
        </aff>
      </contrib-group>
      <fpage>53</fpage>
      <lpage>62</lpage>
      <abstract>
        <p>At present, the OCL language includes two constants, null and invalid, to represent undefinedness. This e ectively turns OCL into a four-valued logic. It makes also problematic its mapping to first-order logic and, as a consequence, hinders the use of first-order automated-reasoning tools for OCL reasoning. We address this problem and propose a solution, grounded on the same principles underlying OCL2FOL, in order to cope with undefinedness in OCL.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1 Introduction</title>
      <p>
        In the past decade, there has been a plethora of proposals to map OCL [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ] into di erent
formalisms for which reasoning tools may be readily available. By choosing a
particular formalism each proposal commits to a di erent trade o between expressiveness
and termination, automation, or completeness (see [
        <xref ref-type="bibr" rid="ref12 ref5">12, 5</xref>
        ] and references). In
particular, most of these proposals have not considered the OCL language parts that deal with
undefinedness or generate it: basically, the constants null and invalid,1 the type-casting
operator, the division operator, and the operators any, oclIsUndefined and oclIsInvalid.
By doing so, these proposals try to turn OCL into a two-valued logic, so that it can
be more easily mapped to di erent formalisms for which reasoning tools already exist.
Notable exceptions to this trend are [
        <xref ref-type="bibr" rid="ref10 ref2 ref3 ref4">3, 4, 2, 10</xref>
        ] though [
        <xref ref-type="bibr" rid="ref10 ref2">2, 10</xref>
        ] only deals with null.
      </p>
      <p>
        In [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] we proposed a mapping from OCL to first-order logic, and we implemented
it in a tool called OCL2FOL. This mapping supports the direct use of SMT solvers
(e.g., Z3 [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] or Yices [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]) to check the satisfiability of OCL expressions, but under
specific restrictions both on the expressions that were allowed and on the instances of
data models that were KuhlmannG12Models checked.2 Not surprisingly, some of these
restrictions were imposed to avoid the problem of coping with undefinedness in OCL.
In particular, i) OCL2FOL only considers instances where all attributes are defined,
and ii) it does not allow expressions containing operators that can generate undefined
values. However, after experimenting with OCL2FOL, we have come to realize that
these restrictions impose severe limitations on the applicability of the tool (and we
conjecture that similar limitations will apply as well to other methodologies that are not
prepared to deal with undefinedness).
      </p>
      <p>In this paper we propose OCL2FOL+ which, although grounded on the same
principles underlying OCL2FOL, is designed to overcome the limitations of the latter with
1 Intuitively, null represents unknown/undefined values and invalid represents error/exceptions.
2 Class diagrams and object diagrams are prototypical examples, respectively, of data models
and of instances of data models.
regard to undefinedness in OCL.3 Let us explain the key di erence in a nutshell. Under
the aforementioned restrictions i) and ii), a Boolean OCL expression can only evaluate
to either true or false. Thus, to reason in this context using Boolean OCL expressions
it is su cient to define a mapping that formalizes when a Boolean OCL expressions
evaluates to true. This is precisely what we did in OCL2FOL. However, in the presence
of undefinedness, Boolean OCL expressions can also evaluate to null or invalid. To cope
with this fact, we now define in OCL2FOL+ four di erent mappings which formalize,
respectively, when a Boolean OCL expression evaluates to true, when to false, when to
null, and when to invalid.</p>
      <p>Organization. First, in Section 2, we recall the basic principles underlying the
mapping from OCL to first-order logic which is implemented in OCL2FOL. Then, in
Section 3, we discuss the key ideas behind the four mappings which are implemented in
OCL2FOL+ for coping with undefinedness in OCL. Next, in Section 4, we report on
the status of OCL2FOL+, and on some experiments that we have carried out with this
tool. Finally, we draw conclusions in Section 5.
2</p>
      <p>
        OCL2FOL
In [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] we define a mapping, called OCL2FOL, from a subset of OCL4 into first-order
logic. For the sake of space, we will refer here to this mapping as O2F . The key
property of O2F is the following: Let M be a data model, let I be an instance of M (where
all attributes values are defined) and let exp be a Boolean OCL expression (within the
O2F ’s range), whose context is also M. Then,
      </p>
      <p>Eval(exp,I) = true () O2Fenv(M; I; exp) j= O2F (exp)
(1)
where Eval(exp,I) is the value returned by the evaluation of the expression exp for the
instance I, and O2Fenv(M; I; exp) is the union of the set of formulas resulting from
calling three auxiliary mappings, namely, O2Fdata, O2Finst, and O2Fdef, on, respectively, the
data model M, the instance I, and the expression exp. That is,</p>
      <p>O2Fenv(M; I; exp) = O2Fdata(M) [ O2Finst(I) [ O2Fdef(exp)
Next, we briefly discuss these three auxiliary mappings, and then the key mapping
O2F . But before, consider the following remark, whose correctness is based on the
correctness of (1) and on the assumption that the evaluation of exp cannot possible
result in null or invalid.</p>
      <p>Remark 1. Let M be a data model, let I be an instance of M (where all attributes values
are defined), and let exp be a Boolean OCL expression (within the O2F ’s range), whose
context is also M. Then,</p>
      <p>
        Eval(exp,I) = false (= O2Fenv(M; I; exp) 6j= O2F (exp)
3 However, other limitations, like the inability to deal with the operator size and count, or with
collection-types di erent from Set do still apply to OCL2FOL+.
4 This subset includes arbitrary, possibly nested forAll, exists, select, reject, and collect iterator
expressions. However, collect-expressions must be followed by asSet. See [
        <xref ref-type="bibr" rid="ref1 ref6">6, 1</xref>
        ] for further
details.
      </p>
    </sec>
    <sec id="sec-2">
      <title>O2Fdata(M): Mapping data models M</title>
      <p>To simplify the presentation, we do not consider here class inheritance, multi-valued
attributes, or association-ends with multiplicities di erent from *.</p>
      <p>Classes are represented by predicates. In particular, for every two classes C and C0
in M, C , C0, the set O2Fdata(M) includes the following formula:</p>
      <p>8(x)(:(C(x) ^ C0(x)))
Then, attributes are represented as functions. Finally, association-ends are represented
as binary predicates. In particular, for every association between two classes C and C0,
with association-ends assoc and assoc0, the set O2Fdata(M) includes the formulas:
8(x; y)(assoc(x; y) , assoc0(y; x))
8(x; y)(assoc(x; y) ) C0(y)) ^ 8(x; y)(assoc(x; y) ) C(x))</p>
    </sec>
    <sec id="sec-3">
      <title>O2Finst(I): Mapping instances I</title>
      <p>Objects are represented by constants. In particular, for every object o in I of a class C,
the set O2Finst(I) includes the following formula:</p>
      <p>C(o)
Then, attributes values are represented by equalities, which all-together define the
corresponding functions. In particular, for every object o in I, if v is the value of its attribute
attr, then the set O2Finst(I) includes the following equality:</p>
      <p>attr(o) = v
Finally, links between objects are represented by formulas, which all-together define
the corresponding predicates. In particular, for every two objects o and o0 in I, if o0
is linked to o through o’s association-end assoc, then the set O2Finst(M) includes the
following formula:</p>
      <p>assoc(o; o0)</p>
    </sec>
    <sec id="sec-4">
      <title>O2Fdef (exp): Mapping definitions in expressions exp</title>
      <p>The OCL language includes operators (e.g., collect or select, but also union or
including) that define new collections, without naming them, using a certain property. We
represent these new collections by new predicates. In particular, for every sub-expression
of exp which defines a new collection, the set O2Fdef(exp) includes the formula that
formalizes that for every element for which the new predicate holds it also holds the
property which defines the new collection. Example 1 below illustrates, among other
things, this essential feature of our mapping from OCL to first-order logic.</p>
      <p>There are also operators in OCL (e.g., max or any) that refer to objects, without
naming it, using also a certain property. We represent these objects by new constants.
In particular, for every sub-expression of exp that refers, without naming it, to an object
using a property, then set O2Fdef(exp) includes the formula that formalizes that the
aforementioned property holds for the element referred to by the new constant.</p>
      <sec id="sec-4-1">
        <title>O2F (exp). Mapping expressions (but not aware of null or invalid)</title>
        <p>The map O2F is defined recursively over the structure of OCL expressions,
according to the following principles: First, each expression of the form C.allInstances() is
translated by a predicate formula whose predicate is the one representing the class C.
Second, each expression of type Boolean whose root symbol (the one at the root of the
tree representing the expression) is not, and, or, implies, xor, =, &gt;, &lt;, , , forAll,
exists, one, isUnique, isEmpty, notEmpty, includes, excludes, includesAll, excludesAll
is translated into a formula which mirror its logical structure. Third, each expression of
type Integer whose root symbol is +, , is translated by the corresponding functional
expression. Fourth, each expression of type Set whose root symbol is select, reject,
including, excluding, union, intersection, collect (followed by asSet) is translated by
a predicate formula, whose predicate’s definition is generated using O2Fdef. Finally,
each expression of type Integer whose root symbol is max or min (over collections) is
translated by a constant, whose definition is generated using O2Fdef.</p>
        <p>
          The recursive definition of O2F is rather technical, and we shall refer to [
          <xref ref-type="bibr" rid="ref1 ref6">6, 1</xref>
          ] for
further details. These technicalities are mainly due to the fact that, in order to capture
the semantics of a number of OCL operators (including the iterator operators, but also
others) we introduce fresh logical variables, which are then passed on to the subsequent
recursive calls and are used when translating the arguments of these operators. This and
other features of the mapping from OCL to first-order logic which is implemented in
OCL2FOL are illustrated by the following example.
        </p>
        <p>Example 1. Consider a simple data model Persons containing just one class Person,
with one attribute age of type Integer and a self-association whose association-ends are
friendsOf (x is a friend of y) and friendTo (y is considered a friend by x).</p>
        <p>Let exp be Person.allInstances()!notEmpty(). Then, O2F (exp) is the formula:</p>
        <sec id="sec-4-1-1">
          <title>9(x)(Person(x))</title>
          <p>where Person is the predicate that represents the class Person and x is a logical variable
introduced as part of the mapping of the operator notEmpty.</p>
          <p>Now, let exp be Person.allInstances()!exists(pjp.age 18). Then, O2F (exp) is
the following formula:</p>
          <p>9(x)(Person(x) ^ age(x) 18)
where age is the function that represents the attribute age and x is a logical variable
introduced as part of the mapping of the operator exists.</p>
          <p>Also, let exp be Person.allInstances()!select(pjp.age &gt; 18) !isEmpty(). Then,
O2F (exp) is the following formula:</p>
          <p>8(x)(:Select#1(x))
where x is a logical variable introduced as part of the mapping of the operator isEmpty
and Select#1 is the predicate that represents the collection defined by the expression
Person.allInstances()!select(pjp.age &gt; 18). The predicate Select#1 is, in turn,
defined, using the mapping O2Fdef, by the following formula:</p>
          <p>8(x)(Select#1(x) , (Person(x) ^ age(x) &gt; 18))</p>
          <p>Finally, let exp be
Person.allInstances()!collect(pjp.friendsOf)!asSet()!notEmpty(). Then, O2F (exp) is the following formula:
9(x)(Collect#1(x))
where x is a logical variable introduced as part of the mapping of the operator notEmpty
and Collect#1 is the predicate that represents the collection defined by the expression
Person.allInstances()!collect(pjp.friendsOf)!asSet(). The predicate Collect#1 is, in
turn, defined, using the mapping O2Fdef, by the following formula:</p>
        </sec>
        <sec id="sec-4-1-2">
          <title>8(x)(Collect#1(x) , 9(y)(Person(y) ^ friendsOf(y; x))</title>
          <p>where friendsOf is the predicate that represents the association-end friendsOf.
3</p>
          <p>OCL2FOL+: Coping with undefinedness
In a nutshell, the problem of undefinedness in OCL when trying to use existing
firstorder logic reasoning tools for OCL reasoning is the problem of mapping a four-valued
logic (true, false, null, and invalid) into a two-valued logic (true and false). In general,
when evaluating a Boolean OCL expression for an instance of a data model, the result
can be either true, false, null or invalid. However, when interpreting a formula in a
first-order model, the result can only be true or false. In other words, in the presence of
undefinedness, Remark 1 does not hold.</p>
          <p>To cope with undefinedness while at the same time being able to use SMT solvers,
as we did in OCL2FOL, to automatically carry out OCL reasoning, our solution consists
on defining four mappings, namely, O2Ftrue, O2Ffalse, O2Fnull, and O2Finval, such that
the following holds: Let M be a data model, let I be an instance of M (where now not all
attributes values need to be defined), and let exp be a Boolean OCL expression whose
context is M (within the O2F ’s range, extended now to include expressions built with
the type-casting operators, the division operator, and the operators any, oclIsUndefined,
and oclIsInvalid). Then,</p>
          <p>Eval(exp,I) = true () O2Fenv+(M; I; exp) j= O2Ftrue(exp)
Eval(exp,I) = false () O2Fenv+(M; I; exp) j= O2Ffalse(exp)</p>
          <p>Eval(exp,I) = null () O2Fenv+(M; I; exp) j= O2Fnull(exp)</p>
          <p>Eval(exp,I) = invalid () O2Fenv+(M; I; exp) j= O2Finval(exp)
where Eval(exp,I) is the value returned by the evaluation of the expression exp for the
instance I, and O2Fenv+(M; I; exp) is the union of the set of formulas resulting from
calling three auxiliary mappings, namely, O2Fdata+, O2Finst+, and O2Fdef+, on, respectively,
the data model M, the instance I, and the expression exp. As their names suggest, these
three mappings are extensions of the mappings O2Fdata, O2Finst, and O2Fdef. That is,</p>
          <p>O2Fenv+(M; I; exp) = O2Fdata+(M) [ O2Finst+(I) [ O2Fdef+(exp)
Next, we briefly discuss the content of these extensions, and afterwards the four key
mappings O2Ftrue, O2Ffalse, O2Fnull, and O2Finval.</p>
        </sec>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>O2Fdata+(M): Mapping data models M</title>
      <p>The values null or invalid are represented, respectively, by the constants null and invalid.
Moreover, we introduce two unary predicates IsNull and IsInvalid, to represent when
an element is null or invalid, and we add to the set O2Fdata+(M) the following formula:</p>
      <p>IsNull(null) ^ :IsInvalid(null) ^ :IsNull(invalid) ^ IsInvalid(invalid)</p>
      <p>Objects are neither null nor invalid.5 Therefore, for every class C in M, the set
O2Fdata+(M) contains the following additional formula:</p>
      <p>8(x)(C(x) ) :(IsNull(x) _ IsInvalid(x)))</p>
    </sec>
    <sec id="sec-6">
      <title>O2Finst+(I): Mapping instances I</title>
      <p>Attributes values may be undefined. Thus, for every object o in I, if the value of its
attribute attr is undefined, then the set O2Finst+(I) includes the following equality:
attr(o) = null
On the other hand, attributes values may be defined. Thus, for every object o in I, if v is
the (defined) value of its attribute attr, then the set O2Finst+(I) includes the formula:
:(IsNull(v) _ IsInvalid(v))</p>
    </sec>
    <sec id="sec-7">
      <title>O2Fdef+(exp): Mapping definitions in expressions exp</title>
      <p>Literals of primitive types are also neither null nor invalid. Thus, for every literal l in the
given expression exp, the set O2Fdef+(exp) contains the following additional formula:
:(IsNull(l) _ IsInvalid(l))</p>
      <sec id="sec-7-1">
        <title>Mapping expressions (aware of null and invalid)</title>
        <p>For the sake of space limitation, we shall not provide here the full recursive definitions
of our four mappings O2Ftrue, O2Ffalse, O2Fnull, O2Finval. Instead, we illustrate the main
ideas using examples. In particular, since the new mappings follow the same principles
than our original mapping O2F , we use as examples the same expressions that we used
in Example 1.</p>
        <p>According to the OCL’s semantics, if a collection contains invalid, the collection
itself evaluates to invalid. Furthermore, for every operator, except of course oclIsInvalid
and oclIsUndefined, if invalid happens to be passed as one of its arguments, the result
is invalid. We now take these facts into account when mapping operators on collection,
as shown in the following example. Notice, in particular, that we do not “reduce” a
collection containing invalid to invalid, but instead we “keep” it in that collection. Then,
when formalizing the semantics of operators on collections, we “check” if the given
collections may contain invalid, and proceed accordingly.</p>
        <p>Example 2. Let exp be Person.allInstances()!notEmpty().</p>
        <p>O2Ftrue(exp) = 9(x)(Person(x)) ^ 8(x)(Person(x) ) :IsInvalid(x))
O2Ffalse(exp) = 8(x)(:Person(x)) ^ 8(x)(Person(x) ) :IsInvalid(x))
5 At the model level, objects are instances of (UML) classes. Thus, they cannot be null nor
invalid. At the linguistic level, however, the constants null and invalid are instances of every
(OCL) class type.
Notice that, in the logical context provided by O2Fenv+, some of the above
expressions can be simplified. For example, 8(x)(Person(x) ) :IsInvalid(x)) can be reduced
to &gt;, since objects are neither null nor invalid; for the same reason, 9(x)(Person(x) ^
IsInvalid(x)) can be reduced to ?. However, for the sake of clarity, we will not perform
such optimizations in our examples.</p>
        <p>Now, if one of the elements in a disjunction is null, and the other element is neither
true nor invalid, then the disjunction itself evaluates to null. Similarly, if one the
elements in a disjunction is invalid, and the other element is not true, then the disjunction
itself evaluates to invalid. Now, in the case of the operator , if both arguments are null,
then evaluates to true. But if only one of the arguments, but not the other, is null, then
evaluates to invalid. And, if at least one element is invalid, or one argument is null, but
not the other, then evaluates to invalid. We take these facts into account when
mapping the iterator exists over collections and the operator between integers, as shown
in the following examples.</p>
        <p>Example 3. Let exp be Person.allInstances()! exists(pjp.age
O2Ftrue(exp) =
9(x)(Person(x) ^ O2Ftrue(x.age
18)) ^ 8(x)(Person(x) ) :IsInvalid(x))
18).</p>
        <p>O2Ffalse(exp) =</p>
        <p>8(x)(Person(x) ) O2Ffalse(x.age
O2Fnull(exp) =
9(x)(Person(x) ^ O2Fnull(x.age 18))
^ 8(x)(Person(x) ) (O2Ffalse(x.age
^ 8(x)(Person(x) ) :IsInvalid(x))
18)) ^ 8(x)(Person(x) ) :IsInvalid(x))
18) _ O2Fnull(x.age
18)))
O2Finval(exp) =
(9(x)(Person(x) ^ O2Finval(x.age 18))
^ 8(x)(Person(x) ) (O2Ffalse(x.age 18) _ O2Fnull(x.age 18)</p>
        <p>_ O2Finval(x.age 18))))
_ 9(x)(Person(x) ^ IsInvalid(x))
where, if exp is p.age &lt;= 18, then</p>
        <p>O2Ftrue(exp) =
(O2Fnull(p.age) ^ O2Fnull(18)) _
(age(p) 18</p>
        <p>^ :(O2Fnull(p.age) _ O2Fnull(18) _ O2Finval(p.age) _ O2Finval(18)))
O2Ffalse(exp) =
:(age(p) 18)</p>
        <p>^ :(O2Fnull(p.age) _ O2Fnull(18) _ O2Finval(p.age) _ O2Finval(18))
O2Fnull(exp) = ?
O2Finval(exp) =</p>
        <p>O2Finval(p.age) _ O2Finval(18) _ (O2Fnull(p.age) ^ :(O2Fnull(18))
_ (O2Fnull(18) ^ :(O2Fnull(p.age))
Next, recall that a collection resulting from the select-iterator contains every element
of the source-collection for which the body evaluates to true. However, we now take
into account that, if the source-collection contains invalid (and the same applies to the
other iterator operators), then the resulting collection will also contain invalid, as shown
in the following example.</p>
        <p>Example 4. Let exp be Person.allInstances()!select(pjp.age &gt; 18)!isEmpty().
O2Ftrue(exp) = 8(x)(:Select#1(x)) ^ 8(x)(Select#1(x) ) :IsInvalid(x))
O2Ffalse(exp) = 9(x)(Select#1(x)) ^ 8(x)(Select#1(x) ) :IsInvalid(x))
O2Finval(exp) = 9(x)(Select#1(x) ^ IsInvalid(x))
where Select#1 is the predicate that represents the collection defined by the
expression Person.allInstances()!select(pjp.age &gt; 18). The predicate Select#1 is, in turn,
defined by the following formula:</p>
        <p>8(x)(Select#1(x) , (Person(x) ^ (O2Ftrue(x.age &gt; 18) _ IsInvalid(x))))
Finally, recall that oclIsUndefined returns true when its argument is either null or
invalid, and false otherwise. Also, recall that the any-iterator returns null if no element in
the source-collection satisfies the given property. As expected, if the source-collection
contains invalid, the any-iterator also returns invalid. We now take into account all these
three facts, as shown in the following example:
Example 5. Let exp be Person.allInstances()!any(pjp.age &gt; 16).oclIsUndefined().
O2Ftrue(exp) = IsNull(Any#1) _ IsInvalid(Any#1)
O2Ffalse(exp) = :(IsNull(Any#1) _ IsInvalid(Any#1))
where Any#1 is the constant that represents the element defined by the expression
Person.allInstances()!any(pjp.age &gt; 16). The constant Any#1 is, in turn, defined by
the following formulas:
:(IsNull(Any#1) _ IsInvalid(Any#1)) )</p>
        <p>9(x)(Person(x) ^ O2Ftrue(x.age &gt; 16) ^ Any#1 = x)</p>
        <sec id="sec-7-1-1">
          <title>IsNull(Any#1) ,</title>
          <p>(8(x)(Person(x) ) (O2Ffalse(x.age &gt; 16) _ O2Fnull(x.age &gt; 16)
_ O2Finval(x.age &gt; 16)))
^ 8(x)(Person(x) ) :IsInvalid(x)))</p>
          <p>IsInvalid(Any#1) , 9(x)(Person(x) ^ IsInvalid(x))
4</p>
        </sec>
      </sec>
    </sec>
    <sec id="sec-8">
      <title>Tool support and case study</title>
      <p>
        We have implemented our mappings in a tool, called OCL2FOL+ [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. OCL2FOL+ takes
as input a data model M (the context), a set of Boolean OCL expressions exp1; : : : ; expn
(the hypothesis), a Boolean OCL expression expn+1 (the assertion), and one of the
following keywords (the type): true, false, null, inval. From the given input, the
1. Person.allInstances() &gt;forAll(pjp.age&gt;18)
2. Person.allInstances() &gt;exists(pjp.age&lt;=18)
3. Person.allInstances() &gt;exists(pjp.age.oclIsUndefined())
4. Person.allInstances() &gt;exists(pjp.oclIsUndefined())
5. Person.allInstances() &gt;forAll(pjp.oclIsUndefined())
6. Person.allInstances() &gt;notEmpty()
7. Person.allInstances() &gt;collect(pjp.age) &gt;asSet() &gt;exists(aja.oclIsUndefined())
8. Person.allInstances() &gt;any(pjp.age&gt;16).oclIsUndefined()
9. Person.allInstances() &gt;any(pjp.age&gt;16).age.oclIsInvalid()
10. not(Person.allInstances() &gt;any(pjp.age&lt;16).age.oclIsInvalid())
f1,2g f1,3g f2,3g f4g f5g f5,6g f1,7g f1,8g f1,6,8g f1,9g f1,6,9g f1,10g
O2Ftrue unsat unsat sat unsat sat unsat unsat sat unsat sat unsat unsat
tool OCL2FOL+ automatically generates the following set of formulas (in SMT-Lib 2.0
syntax):
      </p>
      <p>O2Fdata+(M) [ (Sin=1 O2Ftrue(expi)) [ (Sin=+11 O2Fdef+(expi)) [ O2Ftype(expn+1)
To validate OCL2FOL+ we have carried out a number of experiments. In particular,
each column in Table 1 shows the result of checking, using Z3, the satisfiability of the
set of formulas that results from calling OCL2FOL+ with Persons (context), the empty
set (hypothesis) and the conjunction of some formulas taken from Figure 1 plus the type
true (assertion).
5</p>
    </sec>
    <sec id="sec-9">
      <title>Conclusions and future work</title>
      <p>
        We have addressed the problem of coping with undefinedness in OCL while at the
same time being able to use SMT solvers (e.g., Z3 and Yices) to automatically carry
out OCL reasoning. Our solution follows the same principles underlying OCL2FOL,
but consists now of four mappings which formalize, respectively, when an expression
evaluates to true, when to false, when to null, and when to invalid. Our solution also
di ers from [
        <xref ref-type="bibr" rid="ref3 ref4">3, 4</xref>
        ], since we pursue di erent goals. In particular, while we are able to
support automated OCL reasoning, we can only cover a subset of OCL. On the other
hand, the solution presented in [
        <xref ref-type="bibr" rid="ref3 ref4">3, 4</xref>
        ], although it scovers the full OCL language, it can
only provide interactive theorem-proving capabilities. As part of this work, we have also
implemented our four mappings in a tool called OCL2FOL+ [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] , and we have applied
this tool for reasoning about OCL expressions in the presence of undefinedness. For this
case study we have used a non-trivial benchmark that we would like to propose as an
extension of [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ], following their invitation to provide scenarios which are not currently
covered: in particular, in their own words, “intensive use of the full semantics of OCL
(like the undefined value or collection semantics); this poses a challenge for the lifting
to two-valued logics.”
      </p>
      <p>
        Our future work will follow two main directions. On the one hand, we want to
formally prove that our four mappings are correct with respect to the OCL semantics;
unfortunately, the OCL semantics for undefinedness has been, in the past, in a constant
state of flux. On the other hand, we want to apply OCL2FOL+ for analyzing ActionGUI
models [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ], since they contain non-trivial Boolean OCL expressions which should never
evaluate to null or invalid: e.g., authorization constraints in permissions or conditions
in if-then-else statements (which are both expected to always evaluate to either true or
false), and arguments in actions (which, when referring to the object upon which an
action is to be executed, are expected to never evaluate to null or invalid).
Acknowledgements. We kindly thank Achim Brucker and Marco Guarnieri for our very
helpful discussions on the semantics of OCL undefinedness, and we also thank our
anonymous reviewers for their insightful comments and suggestions. This work is
partially supported by the EU FP7-ICT Project “NESSoS: Network of Excellence on
Engineering Secure Future Internet Software Services and Systems” (256980) by the
Spanish Ministry of Science and Innovation Project “DESAFIOS-10”
(TIN2009-14599C03-01), and by Comunidad de Madrid Program “PROMETIDOS-CM”
(S2009TIC1465).
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1. ActionGUI.
          <source>ActionGUI and OCL2FOL projects</source>
          ,
          <year>2012</year>
          . http://www.actiongui.org.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>K.</given-names>
            <surname>Anastasakis</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Bordbar</surname>
          </string-name>
          , G. Georg,
          <string-name>
            <given-names>and I.</given-names>
            <surname>Ray</surname>
          </string-name>
          .
          <article-title>On challenges of model transformation from UML to alloy</article-title>
          .
          <source>Software and System Modeling</source>
          ,
          <volume>9</volume>
          (
          <issue>1</issue>
          ):
          <fpage>69</fpage>
          -
          <lpage>86</lpage>
          ,
          <year>2010</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>A. D. Brucker</surname>
            ,
            <given-names>M. P.</given-names>
          </string-name>
          <string-name>
            <surname>Krieger</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          <string-name>
            <surname>Longuet</surname>
            , and
            <given-names>B.</given-names>
          </string-name>
          <string-name>
            <surname>Wol</surname>
          </string-name>
          .
          <article-title>A specification-based test case generation method for UML/OCL</article-title>
          . In J. Dingel and
          <string-name>
            <surname>A</surname>
          </string-name>
          . Solberg, editors,
          <source>MoDELS Workshops</source>
          , volume
          <volume>6627</volume>
          <source>of LNCS</source>
          , pages
          <fpage>334</fpage>
          -
          <lpage>348</lpage>
          ,
          <year>2010</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>A. D.</given-names>
            <surname>Brucker</surname>
          </string-name>
          and
          <string-name>
            <given-names>B.</given-names>
            <surname>Wol</surname>
          </string-name>
          . Featherweight OCL:
          <article-title>a study for the consistent semantics of OCL 2.3 in HOL</article-title>
          . In M. Balaban,
          <string-name>
            <given-names>J.</given-names>
            <surname>Cabot</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Gogolla</surname>
          </string-name>
          , and C. Wilke, editors,
          <source>OCL and Textual Modelling</source>
          , pages
          <fpage>19</fpage>
          -
          <lpage>24</lpage>
          . ACM,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <given-names>J.</given-names>
            <surname>Cabot</surname>
          </string-name>
          , R. Clariso´, E. Guerra, and J. de Lara.
          <article-title>Verification and validation of declarative model-to-model transformations through invariants</article-title>
          .
          <source>Journal of Systems and Software</source>
          ,
          <volume>83</volume>
          (
          <issue>2</issue>
          ):
          <fpage>283</fpage>
          -
          <lpage>302</lpage>
          ,
          <year>2010</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <given-names>M.</given-names>
            <surname>Clavel</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Egea</surname>
          </string-name>
          , and
          <string-name>
            <given-names>M. A.</given-names>
            <surname>Garc</surname>
          </string-name>
          ´ıa de Dios.
          <article-title>Checking unsatisfiability for OCL constraints</article-title>
          .
          <source>ECEASST</source>
          ,
          <volume>24</volume>
          ,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7. L. Mendonc¸a de Moura and
          <string-name>
            <surname>N. Bjørner.</surname>
          </string-name>
          <article-title>Z3: An e cient SMT solver</article-title>
          . In C.R. Ramakrishnan and J. Rehof, editors,
          <source>TACAS</source>
          , volume
          <volume>4963</volume>
          <source>of LNCS</source>
          , pages
          <fpage>337</fpage>
          -
          <lpage>340</lpage>
          . Springer,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <given-names>B.</given-names>
            <surname>Dutertre</surname>
          </string-name>
          and
          <string-name>
            <given-names>L.</given-names>
            <surname>Moura</surname>
          </string-name>
          .
          <article-title>Yices: An SMT solver</article-title>
          . http://yices.csl.sri.com,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <given-names>M.</given-names>
            <surname>Gogolla</surname>
          </string-name>
          ,
          <string-name>
            <surname>F.</surname>
          </string-name>
          <article-title>Bu¨ttner, and</article-title>
          <string-name>
            <given-names>J.</given-names>
            <surname>Cabot</surname>
          </string-name>
          .
          <article-title>Initiating a Benchmark for UML and OCL Analysis Tools</article-title>
          . In M. Veanes and L. Vigano`, editors,
          <source>TAP</source>
          , volume
          <volume>7942</volume>
          <source>of LNCS</source>
          , pages
          <fpage>115</fpage>
          -
          <lpage>132</lpage>
          . Springer,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <given-names>M.</given-names>
            <surname>Kuhlmann</surname>
          </string-name>
          and
          <string-name>
            <given-names>M.</given-names>
            <surname>Gogolla</surname>
          </string-name>
          .
          <article-title>From UML and OCL to relational logic and back</article-title>
          . In R. B. France,
          <string-name>
            <given-names>J.</given-names>
            <surname>Kazmeier</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Breu</surname>
          </string-name>
          , and C. Atkinson, editors,
          <source>MoDELS</source>
          , volume
          <volume>7590</volume>
          <source>of LNCS</source>
          , pages
          <fpage>415</fpage>
          -
          <lpage>431</lpage>
          . Springer,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11. Object Management Group.
          <source>Object Constraint Language specification Version 2.3</source>
          .1,
          <string-name>
            <surname>January</surname>
          </string-name>
          <year>2012</year>
          . http://www.omg.org/spec/OCL/2.3.1.
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <given-names>A.</given-names>
            <surname>Queralt</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Artale</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Calvanese</surname>
          </string-name>
          , and
          <string-name>
            <given-names>E.</given-names>
            <surname>Teniente.</surname>
          </string-name>
          OCL-Lite:
          <article-title>Finite reasoning on UML/OCL conceptual schemas</article-title>
          .
          <source>Data &amp; Knowledge Engineering</source>
          ,
          <volume>73</volume>
          :
          <fpage>1</fpage>
          -
          <lpage>22</lpage>
          ,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>