<!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>Encapsulation, Operator Overloading, and Error Class Mechanisms in OCL</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Vincent Bertram</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Bernhard Rumpe</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Michael von Wenckstern</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Fraunhofer FIT</institution>
          ,
          <addr-line>Sankt Augustin</addr-line>
          ,
          <country country="DE">Germany</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Software Engineering, RWTH Aachen University</institution>
          ,
          <addr-line>Aachen</addr-line>
          ,
          <country country="DE">Germany</country>
        </aff>
      </contrib-group>
      <fpage>17</fpage>
      <lpage>32</lpage>
      <abstract>
        <p>Checking models for correctness or compatibility using standard formal modeling techniques such as OCL has merits in abstraction and compactness. However, it is inconvenient for developers, since there are no standard mechanisms how to handle large and complex OCL constraints. Therefore, this paper presents an approach how to split complex OCL constraints into multiple ones by defining helper functions and pack these into an OCL/P library with encapsulation mechanisms. Another drawback of using complex OCL constraints at present is the lack of descriptive and user-friendly error messages. Hence, this paper introduces an OCL extension that allows specifying error classes by synthesizing witnesses pointing directly to constraint violations. All approaches are shown on Component &amp; Connector model examples, where OCL/P is used on the meta-level to verify backwards compatibility of interfaces.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>Static software verification is a software engineering discipline, analyzing
software against a given specification without running any line of code using formal
methods. These checks can identify modeling errors, potential problems, variant
and version incompatibilities within a single model or even among different ones.</p>
      <p>
        OCL [
        <xref ref-type="bibr" rid="ref19">19</xref>
        ] is a well-known, abstract and compact language to formalize
verification properties of models, e.g. consistency or well-formedness. Interface as
well as behavioral compatibility and even similarity rules [
        <xref ref-type="bibr" rid="ref1 ref20 ref23">23,1,20</xref>
        ] can be
described. This leads to a large set of OCL constraints. However, OCL does not
give answers to the following questions, which are needed to handle many OCL
constraints:
1. How to logically group OCL constraints?
2. How to split up complex constraints easily into multiple smaller ones?
3. How to use OCL operators for self-defined model structures?
4. How to produce meaningful user error messages?
The contribution of this paper is to answer these four questions, and to make
a first step towards the use of OCL in specifying complex constraints in even
different aspects, e.g. the verification domain. All concepts presented in this
paper will be explained using constraints for interface backward compatibility
between two Component &amp; Connector (C&amp;C) models.
(object diagram is an excerpt)
ADAS_V1: FunctionComponent
ADAS_V4: FunctionComponent
v_LimiterSetValue:
      </p>
      <p>SignalPort
in = true
:PrimitiveType</p>
      <p>Reference
KilometerPerHour:</p>
      <p>DerivedUnit
:Accuracy
value= 3.5</p>
      <p>Acceleration_pedal_pc:</p>
      <p>SignalPort
in = true
:Range
min = 0
max = 250</p>
      <p>res
:Resolution
value = 0.05</p>
      <p>Acceleration_pedal_pc:</p>
      <p>SignalPort
in = true
:Resolution res
value = 0.05</p>
      <p>:Range
min = 0
max = 250
v_LimiterSetValue:</p>
      <p>SignalPort
in = true
:PrimitiveType</p>
      <p>Reference</p>
      <p>None:
DerivedUnit
:Accuracy
value= 3.0
The paper is outlined as follows: Section 2 introduces the running example
and gives an informal introduction into the used C&amp;C models and their
interface compatibility rules. Section 3 presents a formal notation of C&amp;C models,
their meta-model, a semi-formal definition of interface-compatibility, as well as
a short introduction into OCL. Our first contribution in Section 4, presents
solutions for the first three questions by adding a library concept to OCL and by
making OCL modeling more convenient with operator overloading. Then
Section 5 shows an extension for generating counterexample witnesses based on error
classes which are “easy to understand” for the engineer, our second
contribution. A brief evaluation and discussion is provided in Section 6. At last, Section 7
compares our approaches with other researches, generating counterexamples for
OCL constraint violations.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Running Example</title>
      <p>Due to the highly competitive automotive market, automobile manufacturers
update their vehicles continuously with new features. Since a special single
feature does not affect every software part, individual components are updated to
successively replace old component versions with new ones.</p>
      <p>
        Figure 1 shows such a scenario where an Advanced Driver Assisted Systems
(ADAS) component version (ADAS V1 ) should be replaced by a more capable
version (ADAS V4 ). The representation as Object Diagram (OD) is done using
UML/P [
        <xref ref-type="bibr" rid="ref22">22</xref>
        ]. Since such a change can cause incompatibilities, the automotive
industry is constantly stating the structural (and/or behavioral) backward
compatibility. In this case one has to prove that ADAS V4 is backward compatible,
at least structural backward compatible to ADAS V1 . At this stage static model
verification comes into the game.
      </p>
      <p>Hence this paper shows engineering strategies how to formalize complex
constraints, e.g. these compatibility constraints, in OCL. Additionally, this paper
shows a mechanism which can be used to generate user friendly and meaningful
error messages for violated constraints. This approach is used to provide intuitive
feedback for the ones1 presented in Figure 1 (see red marked parts).</p>
      <p>ADAS V4 is incompatible to ADAS V1 , because ADAS V1 processes speed
limiter values assigned with the unit km/h and ADAS V4 processes the
values arriving at the port v LimiterSetValue dimensionless as direct bus
signals are not assigned to a specific unit. Also, the needed accuracy of the port
Acceleration pedal pc of ADAS V4 is less than the one in ADAS V1 meaning
that ADAS V4 cannot process sensor data having a noise of 3.5.</p>
      <p>
        The two ODs [
        <xref ref-type="bibr" rid="ref12 ref4">12,4</xref>
        ] in Figure 1 represent concrete C&amp;C instances which will
in practice be flashed into the automotive software. In our context, a component
is a unit executing computations (such as control commands to avoid accidents)
and/or storing data (e.g. previous sensor data for interpolation reasons) as well
as describing the information flow between components via typed ports [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ].
      </p>
      <p>
        The running example presented in this work is a simplified excerpt of a
model, used in the research project SPES XT2 and does not represent a real
world model, but provides reliable information without being overloaded with
irrelevant information. A more detailed version can be found in [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ].
3
      </p>
    </sec>
    <sec id="sec-3">
      <title>Preliminaries</title>
      <p>This section briefly describes some basics about C&amp;C models, respectively their
meta-model including data types, interface compatibility. It also provides some
information on OCL.
3.1</p>
      <sec id="sec-3-1">
        <title>Component and Connector Models</title>
        <p>
          C&amp;C models describe components, their interaction and how they are
hierarchically composed. Maoz et al. [
          <xref ref-type="bibr" rid="ref15">15</xref>
          ] define component models [
          <xref ref-type="bibr" rid="ref17">17</xref>
          ] as given in
Definition 1, which reflects their essence as formalized by ADLs AADL [
          <xref ref-type="bibr" rid="ref6">6</xref>
          ], ACME [
          <xref ref-type="bibr" rid="ref7">7</xref>
          ],
and MontiArc [
          <xref ref-type="bibr" rid="ref11">11</xref>
          ], or used in (commercial) tools Modelica [
          <xref ref-type="bibr" rid="ref18">18</xref>
          ] and Simulink [
          <xref ref-type="bibr" rid="ref16">16</xref>
          ].
Definition 1 (Component and Connector model [
          <xref ref-type="bibr" rid="ref15">15</xref>
          ]). A C&amp;C model is
a structure cncm = hCmps, Ports, Cons, subs, ports, typei where
– Cmps is a set of named components, cmp ∈ Cmps has a set of ports
ports(cmp) ⊆ Ports and a (possibly empty) set of immediate
subcomponents subs(cmp) ⊂ Cmps,
– Ports is a disjoint union of input and output ports where each port p ∈ Ports
has a name, a type type(p) ∈ Types, and belongs to exactly one component
p ∈ ports(cmp),
1 Section 6 explains the incompatibilities of both ADAS versions in more detail.
2 http://spes2020.informatik.tu-muenchen.de/spes_xt-home.html
«interface»
FunctionComponentElement
        </p>
        <sec id="sec-3-1-1">
          <title>FunctionComponent</title>
          <p>(class diagram is an excerpt)</p>
        </sec>
        <sec id="sec-3-1-2">
          <title>PortConnector</title>
        </sec>
        <sec id="sec-3-1-3">
          <title>String: name</title>
          <p>is implemented by
concrete SI units
1</p>
        </sec>
        <sec id="sec-3-1-4">
          <title>QuantityKind</title>
          <p>String: name
source
*
dest
0..1
*
1
«interface»
Unit
*
1
1
accuracy
1..*
«abstract»</p>
          <p>Port</p>
        </sec>
        <sec id="sec-3-1-5">
          <title>String: name</title>
        </sec>
        <sec id="sec-3-1-6">
          <title>Boolean: in</title>
        </sec>
        <sec id="sec-3-1-7">
          <title>PrimitiveType</title>
        </sec>
        <sec id="sec-3-1-8">
          <title>Reference</title>
          <p>*
ranges
1..*</p>
        </sec>
        <sec id="sec-3-1-9">
          <title>Range</title>
          <p>acc *
0..1</p>
        </sec>
        <sec id="sec-3-1-10">
          <title>Number</title>
          <p>implements
*
*
1
1</p>
        </sec>
        <sec id="sec-3-1-11">
          <title>Interface</title>
          <p>min
max
1
1
resolution</p>
        </sec>
        <sec id="sec-3-1-12">
          <title>Value</title>
          <p>»
f
O
e
c
n
a
t
s
n
i«
– Cons is a set of directed connectors con ∈ Cons, each of which connects two
ports con.src, con.tgt ∈ Ports of the same type, which belong to two sibling
components or to a parent component and one of its immediate
subcomponents, and
– Types is a finite set of type names.</p>
          <p>
            A C&amp;C model is valid iff no component is its own (transitive) subcomponent
and has at most one direct parent and subcomponents are connected legally with
respect to in-/output direction as well as their transmitted data types (see [
            <xref ref-type="bibr" rid="ref15">15</xref>
            ]
and [
            <xref ref-type="bibr" rid="ref21">21</xref>
            ] for complete definitions).
3.2
          </p>
        </sec>
      </sec>
      <sec id="sec-3-2">
        <title>Component and Connector Meta-Model</title>
        <p>
          Based on Definition 1 and an investigation of all common C&amp;C modeling
languages, a complete C&amp;C meta-model has been derived in [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ]. This subsection
recaps some of this C&amp;C meta-model elements that are necessary to understand
the OCL constraints used in this paper. Related names used in Definition 1 are
written in brackets after the meta-model elements.
        </p>
        <p>The meta-model in Figure 2 has a FunctionComponent (Cmps) containing
a set of subcomponents (realized by the contains association) as well as a
set of port connectors (Cons). Each FunctionComponent implements at least
one Interface, having a set of Ports (Ports). The component interface can
also have (but skipped for simplicity) extra-functional properties such as
latency, memory usage, etc. A Port can have either PrimiteTypeReferences
or CompositeTypeReferences, representing struct or array objects (skipped in
this figure). The primitive type reference holds all important information on
dataflows between ports with a primitive type such as Boolean, Enumeration or
Number. The QuantityKind represents the physical dimension of the SI basic
units. Each Unit interface has exactly one QuantityKind. Ranges represent all
values a port can send or receive, the values are between min and max with a
stepsize given in res.value; Accuracy is used to express the maximum difference
between the acutal value and a given sensor output.</p>
      </sec>
      <sec id="sec-3-3">
        <title>3.3 Interface Compatibility</title>
        <p>A component interface (see Figure 2) contains all structural information on how
a component communicates with its environment. If a component, e.g. newer
version, can replace another one, e.g. older component version, based on their
component’s interface information, the newer component is interface compatible
to the older one, also called backward compatible. In general component A is
interface compatible to B iff:
– component A has at least (it may have more) the same input and output
port names as component B,
– A’s input ports accept the same or more input values than B’s input ports,
and
– A’s output ports produce the same or fewer output values than B’s output
ports.</p>
        <p>It is not complicated to define interface compatibility, but still, one can face
a lot of small constraints: (1) primitive data type compatibility (e.g. when are
enumerations compatible), (2) unit compatibility such as km/h and m/s, (3)
ranges compatibility considering several ranges each of which may have different
minimum, maximum, accuracy as well as resolution values.
3.4</p>
      </sec>
      <sec id="sec-3-4">
        <title>Object Constraint Language</title>
        <p>
          According to Rumpe [
          <xref ref-type="bibr" rid="ref22">22</xref>
          ] OCL is a property-oriented modeling language defining
queries, model constraints such as invariants as well as pre- and postconditions.
This paper uses Rumpe’s OCL/Programmable (OCL/P), which is adjusted to
Java. Instead of using OCL 2.4’s 4-level Boolean [
          <xref ref-type="bibr" rid="ref19">19</xref>
          ], OCL/P is using a 2-level
binary logic making it more accessible to developers.
        </p>
        <p>
          Here, we recall shortly the OCL termini introduced by Rumpe (it is
incomplete; for a complete list see [
          <xref ref-type="bibr" rid="ref22">22</xref>
          ]):
Constraint: Is a Boolean statement about a system.
        </p>
        <p>Context: Is the context in which a constraint is embedded into; e.g. names of
classes, attributes and/or properties in Class Diagrams (CDs).</p>
        <p>InterfaceCompatibility</p>
        <p>FunctionComponent</p>
        <p>OCL/P
1context InterfaceCompatibility ic inv:
2 ic.v2BackwardsCompatibleToV1()
3 &lt;=&gt; …</p>
        <p>OCL 2.4
1context InterfaceCompatibility inv:
2 self.v2BackwardsCompatibleToV1()
3 = …
This section presents two syntactic sugars to OCL making it easier to define
complex constraints: (1) Defining an OCL library with expressions in a
functionlike way, and (2) Operator overloading to make OCL constraints more intuitive.
In OCL the definition expression defines new attributes and query operations to
existing models, which can be used in other constraints. This would allow us to
define a query method, e.g. IsBackwardsCompatibleTo (FunctionComponent
v1), to the CD model FunctionComponent. This approach makes the modeling
of an extra class InterfaceCompatibility in the CD redundant, which is an
advantage.</p>
        <p>In order to not create one large interface compatibility constraint, this
constraint depends on other compatibility constraints such as data type, range,
unit compatibility. But this would result in polluting CD with unnecessary, and
probably not reusable, query functions just to make one definition good
readable. Hence, we present a method for how to define an OCL library comfortably
with public (can be called from outside the library) and private (can only be
used inside this library) functions.
1library InterfaceCompatiblity is:
2 + def boolean v2BackwardsCompatibleToV1 (code is an excerpt)
3 (FunctionComponent v1, FunctionComponent v2) is:
4 result =
5 (forall Port ports1 in v1.implements.ports,</p>
        <p>Port ports2 in v2.implements.ports:</p>
        <p>dataTypeCompatible(ports1, ports2))
6 public method
7
8 &amp;&amp; …
9 - def boolean dataTypeCompatible(Port p1, Port p2) is:
10 result = …</p>
        <p>private method
1context FunctionComponent v1:
2 def boolean v2BackwardsCompatibleToV1(FunctionComponent v2) is:
OCL 2.4
1context FunctionComponent
2 def: v2BackwardsCompatibleToV1(v2: FunctionComponent) :Boolean =</p>
        <p>Figure 4 shows an excerpt of how to define a library using either OCL/P
or OCL 2.4. The result = keyword in line 4 has the same semantic as line 3
ic.v2BackwardsCompatible &lt;=&gt; in Figure 3. The - (private keyword) in line
&amp; ^ | &amp;&amp; || implies &lt;=&gt; ? :</p>
        <p>Low
prefix</p>
        <p>infix
High
&lt;&lt; &lt;
&gt;&gt; &lt;=
&gt;&gt;&gt; &gt;
&gt;=
instanceof
in
==
!=
~</p>
        <p>Priority
9 is not necessary, because all query functions inside the library are private by
default.</p>
        <p>Similar to C++’s mechanism that define new functions and operators as
member and non-member, new operations can also be defined without an explicit
given context for syntactical convenience. Exemplary, the top part in Figure 5
shows the convenience definition from Line 2-3 in Figure 4, which is
semantically equivalent to the definition inside the classifier FunctionComponent in the
bottom part in Figure 5 extending the class FunctionComponent with an extra
query function v2BackwardsCompatibleToV1.
4.2</p>
      </sec>
      <sec id="sec-3-5">
        <title>Operator Overloading</title>
        <p>For better readability OCL/P also supports prefix and infix operator
overloading; whereas it is not possible to change the operator precedence nor to define
a new operator symbol. It is also forbidden to overload operators with
predefined semantics, e.g. Number + Number. Table 1 lists all available OCL operators
grouped by their priority. Operators in the same group have the same precedence
and are bounded from left to right.</p>
        <p>Figure 6 shows an example of how to overload infix operators. Line 1 overloads
the equivalence operator ∼: Two units are equivalence iff they have the same unit
kind, e.g. Length, Velocity, and so on.</p>
        <p>Lines 3-7 specify whether a Number belongs to a specific Range; the Range’s
optional resolution is only considered if it is specified. The expression ∼r.res
becomes true if the Range r has no optional association res to an instance of
the class Resolution; if this is the case, the left part of the or (||) expression
is true and due to OCL/P’s short-circuit evaluation strategy the right part will
not be evaluated. The number 4.0 belongs to the range [3.0; 5.0], but 4.0 is
not part of the range [3.0; 5.0] with a resolution 0.6 containing only the values
{3.0; 3.6; 4.2; 4.8}.</p>
        <p>Line 8 shows that operator overloading is sensitive to its type arguments.
OCL resolves the overloaded functions or operators by matching first the ones
1def boolean infix (Unit u1) ~ (Unit u2) is:
2 result = u1.quantityKind == u2.quantityKind
3def boolean infix (Number v) in (Range r) is:
4 result =
5 v &gt;= r.min &amp;&amp; (Range r has no optional association res to Resolution)
6 v &lt;= r.max &amp;&amp;
7 (~r.res || (v - r.min) % r.res == 0)
8def boolean infix (Number v) in (List&lt;Range&gt; ranges) is:
9 result = exists Range r in ranges: v in r
10def boolean typeReferenceCompatible(PrimitiveTypeReference tR1,
11 PrimitiveTypeReference tR2) is:
12 let
13 PrimitiveTypeReference tR1c = tR1.convert(tR2.unit)
14 in
15 result =
16 tR1.unit ~ tR2.unit &amp;&amp;
17 forall Number v in tR1c.ranges:
18 v in tR2.ranges &amp;&amp;
19 …
(converts e.g. tR1 from 1 m in 100 cm)
with the instances’ exact types and then it tries to match the ones of the
instances’ supertypes.</p>
        <p>The function defined in lines 10-19 defines the compatibility of primitive type
references. Line 13 introduces a help variable to simplify the latter-on
specification using the let construct. The expression tR1.convert(tR2.unit) will not
be evaluated in line 13; it will be lazy evaluated when the variable tR1c is used
the first time in line 17 and only if line 16 becomes true. The overloaded
operators defined in lines 1 and 8 are called in lines 16, 17 and 18. The syntax of
overloading a prefix operator is shown in Figure 8.</p>
        <p>Figure 7 shows the OCL 2.4 equivalent. Due to the official OCL 2.4
documentation it is not possible to overload the ∼ operator, therefore it has been changed
to the = operator. Also OCL 2.4 does not allow to define operators in a
nonmember syntax, therefore intuitive operator definitions such as infix (Unit
u1) = (Unit u2) must be defined as a member function of the first operand
Unit:: ’=’ (u2: Unit) as shown in the first two lines.</p>
        <p>The expression tR1.unit = tR2.unit in line 16 maps OCL 2.4 to the
function tR1.unit. ’=’(tR2.unit). Since OCL 2.4 does not has a in operator as
OCL/P, this operator cannot be overloaded, and therefore, Figure 7 defines the
two functions isInRange and isInOneRange in lines 4 and 8, which are used in
line 17 till 19.</p>
        <p>OCL/P
1def boolean prefix ~ (Association a) is:
2 result = a.size &gt; 0</p>
        <p>Fig. 8: Example OCL prefix
Since OCL has no C-like postfix operators, such as ++3, there is no syntax for
overloading postfix operators. The operator ++ is not supported, since it modifies
the data structure; and this is not allowed in OCL.
5</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>OCL Error Classes for Intuitive Feedback</title>
      <p>This section shows a mechanism how to generate user-friendly error messages
if OCL constraints fail. These error messages can be domain-specific and hence
can give users all the information needed to trace down existing errors.</p>
      <p>The previous section has shown how compatibility constraints for
instantiations of PrimitiveTypeReference can be defined. One drawback of this OCL
definition is its restriction to a Boolean result for the user. The answer
satisfied (ADAS V4 is compatible to ADAS V1 ) or non-satisfied makes it hard to
understand where exactly the constraints failed in case of a negative answer.</p>
      <p>
        A definition of error classes overcomes this drawback by providing easy to
understand witness instantiations of an OCL error class. The top-left part in
Figure 9 shows a CD of UnitWitness, including the portName of the two
compared components that contain the two different units. The query stereotype in
this class facilitates all its methods to be side-effect free [
        <xref ref-type="bibr" rid="ref22">22</xref>
        ] which then can be
3 C-like pre- and postfix operators; and no method pre and post conditions.
      </p>
      <p>
        For more details see 3.4.3 in [
        <xref ref-type="bibr" rid="ref22">22</xref>
        ].
«query»
      </p>
      <p>UnitWitness
- readonly String portName
- readonly Unit unit1
- readonly Unit unit2
+ String getPortName()
+ Unit getUnit1()
+ Unit getUnit2()
OCL/P can navigate against
navigation direction
ports belong to different function
components (different interface names)
ports have the same name
units of the ports are not compatible
1context UnitWitness uw inv:
2 let
3
4
5
6
7 in
8
9
10
11</p>
      <p>SignalPort p1 = uw.getUnit1().</p>
      <p>primitiveTypeReference.signalPort;
SignalPort p2 = uw.getUnit2().</p>
      <p>primitiveTypeReference.signalPort;
p1.interface.name != p2.interface.name &amp;&amp;
uw.getPortName() == p1.name &amp;&amp;
uw.getPortName() == p2.name &amp;&amp;
!(uw.getUnit1() ~ uw.getUnit2())
CD + OCL/P context is replaced by</p>
      <p>OCL/P counterexample</p>
      <p>
        OCL/P
1counterexample String portName, Unit unit1, Unit unit2 inv UnitWitness:
2 let
3 SignalPort p1 = unit1.primitiveTypeReference.signalPort;
4 SignalPort p2 = unit2.primitiveTypeReference.signalPort;
5 in
6 p1.interface.name != p2.interface.name &amp;&amp;
7 portName == p1.name &amp;&amp; portName == p2.name &amp;&amp;
8 !(unit1 ~ unit2)
used in the top-right OCL context expression. Since this OCL code specifies only
valid UnitWitness elements, it is allowed to navigate against CD’s navigation
direction [
        <xref ref-type="bibr" rid="ref22">22</xref>
        ]; this is used to receive the ports to which the two units (getUnit1
and getUnit2) of the UnitWitness object uw belong to. Line 8 in Figure 9
specifies both ports as members of two different component interfaces and lines 9-10
constraint that the two ports have the same name as the one given in the
witness cw. Line 11 specifies the real witness condition, meaning both units are not
compatible to each other.
      </p>
      <p>A valid UnitWitness instantiation related to the OD in Figure 1 would have
the attribute values:
– portName="v LimiterSetValue",
– unit1="KilometerPerHour", and
– unit2="None".</p>
      <p>
        This witness instance can be used in templates for generating user friendly text
messages. In order to maintain only one kind of artifact (in this case OCL),
OCL has been extended by the counterexample keyword as demonstrated in
the bottom part of Figure 9. This code is semantically equivalent to the top part;
but can be read as a function specification that returns three values: a port name
and the two incompatible units. Apart from this example, each counterexample
OCL code can have n possible return values, but it must include an error class
name, specified after the inv keyword.
see [
        <xref ref-type="bibr" rid="ref19">19</xref>
        ]
OCL constraints have been used to define ContextCondtions in MontiArc, an
architectural description language for C&amp;C models developed at our chair.
Table 2 shows an excerpt of these context conditions. See [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ] for a full list and
expressive for examples.
      </p>
      <p>For each formalized ContextCondition also a counterexample class was given
to produce meaningful user feedback. A more complex example, has been
realized, forbids component type clones using OCL constraints to avoid
inconsistencies later. There, we forced that it is not allowed for two C&amp;C type definitions
CO1
R1
R2
R8
R11</p>
      <p>All names of model elements within a component namespace have to be unique.
Top-level component type definitions do not have instance names.</p>
      <p>Connectors may not pierce through component interfaces.</p>
      <p>Each outgoing port of a component type definition is used at most once as target
of a connector.</p>
      <p>Each incoming port of a subcomponent is used at most once as target of a
connector.</p>
      <p>The target port in a connection has to be compatible to the source port, i.e., the
type of the target port is identical or a supertype of the source port type.</p>
      <p>Inheritance cycles of component types are forbidden.
to have the same structural interface as well as the same internal structure. This
was later extended to match also structural similar components, e.g. Gain(2)
block, multiplying the input with two, and a Sum block connecting with the same
source, with two input ports.</p>
      <p>The interface compatibility check had similar constraints as the ones
detecting clones. Therefore we outsourced the type reference constraints, primitive as
well as complex ones, to an OCL library used by both checks.</p>
      <p>Introducing the OCL library concept with private and public constraints,
made it easier for us to organize this amount of constraints. Operator overloading
would not be necessary, but it made it easier to read OCL constraints, especially
for non-symmetric infix operators as the in one. The most important concept
was the introduction of error classes, because otherwise we were not able to use
OCL for MontiArc ContextConditions, since the user needs to know which C&amp;C
element causes a constraint to fail.</p>
      <p>To create even better user feedback, we prioritized error classes as it is shown
in Figure 11. There, every witness is an instances of exactly one error class. The
error prioritization is done by defining disjunct error classes, which ensures that
solely one error is causing the incompatibility for exactly one port of the C&amp;C
model instead of many different errors that are implied by the one main error (e.g.
unit compatibility is higher prioritized than range compatibility, because making
a unit dimensionless results in changing its value ranges and its accuracies).</p>
      <p>Figure 11 is the result which automotive engineers get when they ask for our
tool in cases where ADAS V4 can replace ADAS V1 from the running example
in Section 2. This figure shows further that error class witnesses can be
transformed to other models presenting constraint violations in an even more
userfriendly way. This example illustrated C&amp;C incompatibilities in Simulink , since
this is the de facto standard modeling tool used by automotive engineers. The
top left component ADAS V1 shows the ADAS in version 1, which is checked for
compatibility with ADAS V4 in version 4. Both form a witness for the
incompatibility between the two versions, since the enumeration types LeverAnglePro and
LeverAngle represent different data types. Another incompatibility is identified
by the second witness UnitIncompatibility. It shows that V LimiterSetValue’s
units are Km/h for ADAS V1 but None for ADAS V4 , which are not
compatible. Besides unit incompatibilities also range incompatibilities, as shown by
witness RangeIncompatibility, and can be detected too. Furthermore, accuracy
incompatibilities, e.g. the accuracy of the Acceleration pedal pc’s value 45.5
is ±3.5 in ADAS V1 and is only ±3.0 in ADAS V4 , shown by the witness
AccuracyIncompatibility in Figure 11, can be identified.
7</p>
    </sec>
    <sec id="sec-5">
      <title>Related Work and Conclusion</title>
      <p>
        OCL is often used to define static verification criteria for UML models, e.g. CDs
[
        <xref ref-type="bibr" rid="ref14">14</xref>
        ], behavior diagrams [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ], or even source code [
        <xref ref-type="bibr" rid="ref24">24</xref>
        ]; however, plain OCL code
as shown in [
        <xref ref-type="bibr" rid="ref24">24</xref>
        ] is hard to read; OCL/P with its infix support and Java based
notation, as it is more familiar to most programmers, tackles this issue.
      </p>
      <p>
        Similar to the approach presented in this paper, the checking of
compatibility requirements, OCL is used for defining requirement specifications to verify
embedded architectures [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. Specifying TLM 2.0 communication rules for C&amp;C
models in OCL allows validating communication compatibility between
components based on defined communication protocols [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ]. OCL is even used for
consistency constraint definitions between AUTOSAR and SysML models [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ].
      </p>
      <p>
        Usage of OCL in templates for SysML requirement specifications in
embedded software is done by [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] to verify user inputs during requirement specification.
Their verification tool even pinpoints, in some cases, to error columns in tables to
guide the user and thus avoid inaccurate or wrong instances of requirement
specifications. However they do not support guidance for complex OCL constraints
and error prioritization.
      </p>
      <p>
        Today, witnesses are mostly generated to validate the result of constraint
checks in order to avoid false positives [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]. None of these approaches allow the
specification of how user-friendly error messages should look like, based on
witnesses relation to their constraint violations. During our component interface
compatibility modeling process for C&amp;C models in the SPES XT context, where
63 OCL/P constraints were needed to fully specify component interface
compatibility, the four key questions for using complex OCL specification models have
been identified and can finally be answered:
1. How to logically group OCL constraints?
⇒ Create OCL libraries to structure the code and use their encapsulation
mechanisms with private and public constraint definition to hide unnecessary
details for developers who want to use only the main constraints (see Section
4.1).
2. How to split up complex constraints easily into multiple smaller ones?
⇒ Create smaller OCL helper constraints by using the easy to use OCL def
operator; there is no further need to create query classes first. Due to the
available non-member def syntax, splitting large OCL constraints, it is now
very similar to splitting large Java or C function into several smaller ones
(see Section 4.1).
3. How to use OCL operators for self-defined model structures?
⇒ Thanks to operator overloading, a well-known principle in many
programming languages, self-defined models, e.g. complex numbers defined as a CD,
can be accessed as intuitive (e.g. by using the + operator) as the OCL basic
types such as integer numbers (see Section 4.2).
4. How to produce meaningful user error messages?
⇒ In Section 5 this paper presented a methodology on how to specify and
prioritize error classes for users to generate intuitive user feedback.
This paper presented solutions to these above questions, by applying OCL as a
user-friendly and modular specification language for formal problems, e.g. static
software verification. Section 6 even demonstrated some use-cases where we
successfully used OCL with the new introduced concepts as specification language.
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Bertram</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Manhart</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Plotnikov</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Rumpe</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Schulze</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>von Wenckstern</surname>
          </string-name>
          , M.:
          <article-title>Infrastructure to Use OCL for Runtime Structural Compatibility Checks of Simulink Models</article-title>
          . In: Modellierung (
          <year>2016</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Beyer</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Dangl</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Dietsch</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Heizmann</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Stahlbauer</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>Witness validation and stepwise testification across software verifiers</article-title>
          .
          <source>In: FSE</source>
          (
          <year>2015</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Blouin</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Senn</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Turki</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          :
          <article-title>Defining an annex language to the architecture analysis and design language for requirements engineering activities support</article-title>
          .
          <source>In: MoDRE</source>
          (
          <year>2011</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Cengarle</surname>
            ,
            <given-names>M.V.</given-names>
          </string-name>
          , Gro¨nniger, H.,
          <string-name>
            <surname>Rumpe</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          :
          <article-title>System Model Semantics of Class Diagrams</article-title>
          .
          <source>Tech. rep., TU Braunschweig</source>
          (
          <year>2008</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          <issue>5</issue>
          .
          <string-name>
            <surname>Chang</surname>
            ,
            <given-names>C.H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lu</surname>
            ,
            <given-names>C.W.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kao</surname>
            ,
            <given-names>K.F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Chu</surname>
            ,
            <given-names>W.C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Yang</surname>
            ,
            <given-names>C.T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hsueh</surname>
            ,
            <given-names>N.L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hsiung</surname>
            ,
            <given-names>P.A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Koong</surname>
            ,
            <given-names>C.S.:</given-names>
          </string-name>
          <article-title>A SysML-Based Requirement Supporting Tool for Embedded Software</article-title>
          . In: SSIRI-C (
          <year>2011</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Feiler</surname>
            ,
            <given-names>P.H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gluch</surname>
            ,
            <given-names>D.P.</given-names>
          </string-name>
          :
          <article-title>Model-Based Engineering with AADL: An Introduction to the SAE Architecture Analysis</article-title>
          &amp;
          <string-name>
            <given-names>Design</given-names>
            <surname>Language. Addison-Wesley</surname>
          </string-name>
          (
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Garlan</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Monroe</surname>
          </string-name>
          , R.T.,
          <string-name>
            <surname>Wile</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          :
          <article-title>Acme: An architecture description interchange language</article-title>
          .
          <source>In: CASCON</source>
          . pp.
          <fpage>169</fpage>
          -
          <lpage>183</lpage>
          (
          <year>1997</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Giese</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hildebrandt</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Neumann</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          : Graph Transformations and
          <string-name>
            <surname>Model-Driven</surname>
            <given-names>Engineering</given-names>
          </string-name>
          , chap. Model Synchronization at Work:
          <article-title>Keeping SysML and</article-title>
          AUTOSAR Models Consistent. Springer (
          <year>2010</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Gogolla</surname>
          </string-name>
          , M., Hamann, L.,
          <string-name>
            <surname>Hilken</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Sedlmeier</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Nguyen</surname>
            ,
            <given-names>Q.D.</given-names>
          </string-name>
          :
          <article-title>Behavior Modeling with Interaction Diagrams in a UML and OCL Tool</article-title>
          . In:
          <string-name>
            <surname>BM-FA</surname>
          </string-name>
          (
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Haber</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>MontiArc - Architectural Modeling and Simulation of Interactive Distributed Systems</article-title>
          . Aachener Informatik-Berichte, Software Engineering, Shaker Verlag (
          <year>2016</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <surname>Haber</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ringert</surname>
            ,
            <given-names>J.O.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Rumpe</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          :
          <article-title>MontiArc - Architectural Modeling of Interactive Distributed and Cyber-Physical Systems</article-title>
          .
          <source>Tech. rep., RWTH Aachen</source>
          (
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <surname>Harel</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Rumpe</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          :
          <article-title>Meaningful Modeling: What's the Semantics of “Semantics”</article-title>
          ? IEEE Computer (
          <year>2004</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13.
          <string-name>
            <surname>Jain</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kumar</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Panda</surname>
            ,
            <given-names>P.R.</given-names>
          </string-name>
          :
          <article-title>A SysML Profile for Development and Early Validation of TLM 2.0 Models</article-title>
          . In: ECMFA (
          <year>2011</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          14.
          <string-name>
            <surname>Kuhlmann</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gogolla</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          :
          <string-name>
            <surname>From</surname>
            <given-names>UML</given-names>
          </string-name>
          and
          <article-title>OCL to Relational Logic and Back</article-title>
          . In: MODELS (
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          15.
          <string-name>
            <surname>Maoz</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ringert</surname>
            ,
            <given-names>J.O.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Rumpe</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          :
          <article-title>Synthesis of component and connector models from crosscutting structural views</article-title>
          .
          <source>In: FSE</source>
          . pp.
          <fpage>444</fpage>
          -
          <lpage>454</lpage>
          . ACM (
          <year>2013</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          16.
          <string-name>
            <surname>Mathworks</surname>
          </string-name>
          <article-title>: Simulink User's Guide</article-title>
          .
          <source>Tech. rep. (</source>
          <year>2015</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          17.
          <string-name>
            <surname>Medvidovic</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Taylor</surname>
          </string-name>
          , R.:
          <article-title>A Classification and Comparison Framework for Software Architecture Description Languages</article-title>
          .
          <source>IEEE Transactions on Software Engineering</source>
          (
          <year>2000</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          18.
          <string-name>
            <surname>Modelica Association: Modelica - A Unified</surname>
          </string-name>
          Object
          <article-title>-Oriented Language for Systems Modeling</article-title>
          .
          <source>Tech. rep. (</source>
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref19">
        <mixed-citation>
          19.
          <string-name>
            <surname>OMG:</surname>
          </string-name>
          <article-title>Object Constraint Language</article-title>
          ,
          <source>Version 2.4. Tech. rep. (</source>
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref20">
        <mixed-citation>
          20.
          <string-name>
            <surname>Richenhagen</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Rumpe</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Schloßer</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Schulze</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Thissen</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>von Wenckstern</surname>
          </string-name>
          , M.:
          <article-title>Test-Driven Semantical Similarity Analysis for Software Product Line Extraction</article-title>
          . In: SPLC (
          <year>2016</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref21">
        <mixed-citation>
          21.
          <string-name>
            <surname>Ringert</surname>
            ,
            <given-names>J.O.</given-names>
          </string-name>
          :
          <article-title>Analysis and Synthesis of Interactive Component and Connector Systems</article-title>
          . Shaker Verlag (
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref22">
        <mixed-citation>
          22.
          <string-name>
            <surname>Rumpe</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          :
          <article-title>Modeling with UML: Language, Concepts</article-title>
          ,
          <source>Methods</source>
          . Springer International (
          <year>July 2016</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref23">
        <mixed-citation>
          23.
          <string-name>
            <surname>Rumpe</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Schulze</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>von Wenckstern</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ringert</surname>
            ,
            <given-names>J.O.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Manhart</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          :
          <article-title>Behavioral Compatibility of Simulink Models for Product Line Maintenance and Evolution</article-title>
          . In: SPLC (
          <year>2015</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref24">
        <mixed-citation>
          24.
          <string-name>
            <surname>Seifert</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Samlaus</surname>
          </string-name>
          , R.:
          <article-title>Static Source Code Analysis using OCL</article-title>
          . In: OCL (
          <year>2008</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>