You are on page 1of 6

Forum on Specification and Design Languages 2008

UML 2.0 Interactions with OCL/RT Constraints


Daniel Calegari Garcı́a Marı́a Victoria Cengarle Nora Szasz
Instituto de Computación Institut für Informatik Facultad de Ingeniera
Universidad de la República Technische Universität München Universidad ORT
Montevideo 11300, Uruguay Garching bei München 85748, Germany Montevideo 11100, Uruguay
Email: dcalegar@fing.edu.uy Email: cengarle@in.tum.de Email: szasz@ort.edu.uy

Abstract—The Unified Modeling Language 2.0 Interactions some properties defined in terms of the semantics, like re-
language describes inter-component behavior. However, it cannot finement of interactions and constraints. These definitions are
define meaningful time constraints. OCL for Real Time is a intended for formal verification of system properties.
language for real-time constraints specification well-suited for
describing constraints on interactions. This work defines a formal Some languages like UML/RT [5] and ROOM [6] extend
semantics for the merger of those languages. The semantics allows UML for real-time specifications. These works do not present
the recognition of valid and invalid behaviors of a system with formal semantics and only take into account basic timing an-
time constraints. An analysis of the properties derived from the notations. Some other works define the semantics of UML 2.0
semantics is also done. In particular, the notions of refinement of Interaction as those in [4,7–11]. However, only a few of them
interactions and refinement of constraints, intended for formal
verification, are explored. consider interactions with basic time constraints. Finally, there
are several approaches for coping with time and events in OCL
I. I NTRODUCTION and related specification languages for the UML. As far as
we know, only in [12] there is an OCL extension to be used
Behavioral specifications describe how system elements with interactions; this work focuses on liveness properties and
interact over time. Inter-component behavior can partially be does not consider any formal semantics. A detailed comparison
specified using the Unified Modeling Language 2.0 Interac- between related works can be found in [13].
tions language [1]. This language is not expressive enough, it The remainder of this paper is structured as follows.
lacks constructs for the specification of constraints. The Object Section II briefly introduces the UML 2.0 Interactions and
Constraint Language (OCL [2]) is part of the UML and it is a OCL/RT languages. A formal semantics for an enhanced
natural candidate to complement the language for interactions. UML 2.0 Interactions language with OCL/RT constraints
The OCL, however, has some limitations: it offers neither time support is presented in Section III. The semantics is used
nor signal handling constructs, it is incapable of expressing in Section IV to review the notions of implementation and
general liveness properties or performance aspects of systems refinement of an interaction, and to present the notion of re-
conveniently. OCL for Real Time (OCL/RT) is an extension finement of constraints. Section V presents a short summary of
of OCL which covers these aspects [3]. the practical application of the concepts developed in previous
Our concern is to set the ground for lifting UML 2.0 sections. Finally, Section VI presents a short summary with
interactions to a formal design technique. The UML 2.0 concluding remarks and an outline of future work.
specification introduces some guidelines for the formal under-
standing of interactions. However, the specification is rather II. BACKGROUND
vague and obscure in some aspects since it is given in natural We briefly review the background of our work. Although
language. In [4] a denotational semantics is defined intended we assume the reader is familiar with UML interactions, we
to verify traces (sequences of messages) against interactions present UML 2.0 Interaction and OCL/RT languages.
specifications; this semantics allows to discern when a trace
is positive (a valid execution), negative (an invalid execution), A. UML 2.0 Interactions
or inconclusive for a given interaction. UML 2.0 Interactions [1] describe possible message ex-
We go a step beyond and relate the language of interactions changes between system instances. A message is a commu-
with OCL/RT. We propose a formal semantics for the merger nication between two instances and is defined by two events,
of UML 2.0 Interactions language and OCL/RT, based on representing the sending and the receiving of that message.
the works mentioned above. The semantics recognizes valid Interactions are graphically represented by Sequence Dia-
and invalid behavior of a system execution considering both grams. They focus on message interchange among lifelines.
interaction structure and constraints satisfaction. We also study The instances involved in the diagram are on the horizontal
axis, each one is represented by an object rectangle with
This work has been partially sponsored by the Uruguayan Technological the object or class name. Below the rectangle, a vertical
Development Program PDT Project 54-106 ”Extensions of UML models for
behavioral design of real-time systems and product lines”, and the DFG project dashed line called lifeline represents the instance execution
rUML. over time. Communications between instances are represented

978-1-4244-2265-4/08/$25.00 © 2008 IEEE Page 167


Forum on Specification and Design Languages 2008

as horizontal message arrows between the instance lifelines. System states are formalized by dynamic bases. A dynamic
Sequence Diagrams are read from top to bottom to view the basis comprises an implementation of the predefined OCL
exchange of messages taking place as time passes. types and their operations, as well as the set of current
Each interaction may contain sub-interactions called in- instances of classes together with their attribute valuations,
teraction fragments, which can be structured and combined connections to other instances, and implementations of opera-
using interaction operators. The resulting combined fragments tions. OCL/RT constraints restrict system runs. A system run
enclose messages or fragments within a rectangular frame ρ is a finite or infinite sequence of pairs of dynamic bases and
with the name of the operator shown in a pentagram at the finite sets of events. OCL/RT is equipped with an operational
upper-left corner. These define special behavior like sequential, semantics that permits the derivation of judgments of the form
parallel, and iterative composition of interactions, alternative,
optional and invalid interactions, and interactions considering (ρ, i); γ  c ↓ v
and ignoring a set of messages, among others. The UML where ρ is a system run, i an index of ρ, γ a variable
also introduces visual elements to express time and duration environment, c an OCL/RT constraint, and v a value. Such
observations, and time and duration constraints. a judgement conveys that c evaluates to v at the ith system
As an example, consider the interaction in Figure 1 where state in the system run ρ using the variable environment γ.
an instance a of A sends the message n to an instance b of B
and b responds sending up to N times the message m. There III. C ONSTRAINED I NTERACTIONS
is a visual constraint restricting the duration of message n
between 0 and 3 time units. The abstract syntax of the fragment of the language of
UML 2.0 defined in [4] is extended with OCL/RT time
constraints as shown in Figure 2. The production rule
constraint(Term, Interaction) considers an OCL/RT term
and the interaction over which the term is evaluated; the Term
must be of boolean type, expressions of other type are not
permitted.

Interaction ::= Basic


| CombinedFragment
CombinedFragment ::= strict (Interaction, Interaction)
Figure 1. Interaction with a combined fragment
| seq (Interaction, Interaction)
| par (Interaction, Interaction)
[4] defines the abstract syntax of the language by a
| loop (Nat, (Nat|∞), Interaction)
context-free grammar which does not consider all the features
| ignore (Messages, Interaction)
introduced by the UML 2.0 specification. They also define
| alt (Interaction, Interaction)
the semantics of interactions, which decides when a trace
| neg (Interaction)
(sequence of messages) is positive (a valid execution) or
| assert (Interaction)
negative (an invalid execution) for some interaction.
| constraint (Term, Interaction)
B. OCL/RT Figure 2. Abstract syntax of interactions with OCL/RT constraints (fragment)
OCL/RT (OCL for Real Time) is defined in [3] as an exten-
sion of OCL 1.4 for real-time and reactive systems constraints In order to consider timed events the meta-class Event
specification. The language is based on the notion of traces (UML 1.5) was extended in [3]. Each event shows the time at
of events with timestamps and allows the specification of the which it occurred by a link to the primitive data type Time that
temporal behavior of a system. The constraints are evaluated represents the global system time, as in the original definition.
over sequences of system states (system execution) instead of It is assumed that Time comes with a total ordering relation
just on a given state as OCL does. ≤ for comparing time values, an associative and commutative
For the definition of OCL/RT constraints, that are evaluated binary operation + for adding time values, and a class attribute
over a sequence of system states, a new clause is introduced
now that always yields the current system time.
context C We extend the event meta-model as shown in Figure 3 in
constr: c
order to model a system based on message passing through
where C is a classifier and c an OCL/RT constraint. instances. Every (partial) message is composed of at least
OCL is furthermore extended with particular OCL/RT fea- one and at most two events representing the sending of that
tures: the modality always c and the satisfaction operator message by an instance (of a classifier) and the reception of it
@η. The modality always c satisfies the constraint c over by another instance (possibly the same). Any classifier instance
a system run when the constraint evaluates to true in every is linked to all its current events, message events among them.
system state. The satisfaction operator @η yields the value of There is also a well-formedness rule on system runs: send and
a given expression at the system state where event η occurred. receive events of the same message must occur in this order.

978-1-4244-2265-4/08/$25.00 © 2008 IEEE Page 168


Forum on Specification and Design Languages 2008

«primitive»
event that is not of interest for some given interaction, e.g. an
1 * 1 Time
Classifier Event attribute value change, such that its occurrence is nevertheless
events at considered for it may cause a state change. System runs
receiver 1 1 sender +now() : Time
contain every event occurred during the system execution,
1..2 1
while interactions can specify partial behavior of the system.
MessageEvent Message
We say that the instance s is active for snd(s, r, m) and,
similarly, that the instance r is active for rcv(s, r, m). We
define a binary, symmetric conflict relation < > ⊆ E × E on
events: If an instance is active for both events η1 and η2 then
SndMsgEvent RcvMsgEvent
η1 < > η2 . Trivially, τ < > η for any η ∈ Eτ .
Given an event η ∈ E, the occurrence time of the event
Figure 3. Event model for messages can be retrieved by the map at : E → T. The domain T is
equipped with a total ordering relation ≤ for comparing time
values and a binary operation + for adding time values.
As an example, consider the interaction in Figure 1. The We write lin at (E) for all possible linearizations of the set
constraint on the first message can be expressed as follows: of events E given by the function at, i.e., l ∈ lin at (E) if, and
context B only if l is the isomorphism class [(X, ≤X , λX )] of the totally
def: sndN : Event = ordered, labeled sets (X, ≤X , λX ) with λX : X → E bijective
events->select(e | e.oclIsTypeOf(SndMsgEvent) and such that ∀x , x ∈ X . at(λ (x )) < at(λ (x )) =⇒
1 2 X 1 X 2
and e.message.name = "n")->any()
def: rcvN : Event = x 1 ≤ X x 2 and ∀x 1 , x 2 ∈ X . x 1 ≤ X x 2 ∨ x2 ≤ X x 1 .
events->select(e | e.oclIsTypeOf(RcvMsgEvent) A basic interaction is given by an event-labeled pomset [14]
and e.message.name = "n")->any() [(X, ≤X , λX )] such that conflicting events do not occur con-
constr: always((rcvN.at <= sndN.at + 3)@rcvN) currently, i.e., if x1 , x2 ∈ X with λX (x1 ) < > λX (x2 ), then
The abstract syntax term representing the diagram of Fig- x 1 ≤ X x 2 or x 2 ≤ X x 1 . An event-labeled pomset is a pomset
ure 1 is thus with an injective labeling function λ X : X → E (or simply
λ). The order x1 ≤X x2 is interpreted as “the occurrence
seq (constraint (ϕ1 , B1 ), loop (0, N, B2 )) of event λ(x1 ) precedes the occurrence of event λ(x2 )”. The
where B1 is a basic interaction representing the dispatch and empty interaction [(∅, ∅, ∅)] is denoted by ε.
arrival of message n, B2 is a basic interaction representing We write lin(p) for all possible linearizations of a pomset p,

the dispatch and arrival of message m, and ϕ1 is the above i.e., all traces that extend the ordering of p: [(X , ≤X  , λX  )] ∈

constraint. Notice that there exists an implicit weak sequence lin([(X, ≤ X , λ X )]) if, and only if, X = X, λ X  = λX , and
between B1 and the loop. ≤ X ⊆≤ X  where x 1 ≤ X  x 2 or x 2 ≤ X  x 1 for all x1 , x2 ∈ X  .
We adapt the formal semantics in [4] to recognize valid and System states are formalized by dynamic bases. A system-
invalid behavior for some given interaction with constraints. run ρ is a finite or infinite sequence of pairs of dynamic bases
We use a more expressive notion of trace: a system run. This and finite sets of events possibly containing the silent event τ

notion allows the use of OCL/RT constraints in interactions (ω 0 , H 0 ), (ω 1 , H 1 ), (ω 2 , H 2 ), . . . ∈ (Σ × ℘ ≤ω τ E )
and the fusion of both semantics. As in [4] the semantics is ∪ (Σ×℘≤ω Eτ )∞
divided into two fragments: one that does not contain occur- such that if η1 ∈ Hi \ {τ } and η2 ∈ Hj \ {τ } with i < j,
rences of the neg nor assert operators (positive fragment), then at(η1 ) < at(η2 ). The dynamic basis ω0 defines the initial
and the other that contains them (negative fragment). In what system state; ωn is transformed into ωn+1 by a single system
follows we first introduce the unified semantic domains and step where the events in Hn occur.
then present both fragments of the semantics. We denote by ω(ρ)n the nth dynamic basis in ρ, by H(ρ)n
the nth set of events in ρ, and by ρ(n) the nth pair of dynamic
A. Semantic Domains basis and set of events in the system run ρ. The empty system
We assume four primitive domains for events E, messages run is denoted by ε.
M, abstract time points T and natural numbers N. An event Given a system run ρ, we define:

η ∈ E is either of the form snd(s, r, m) or of the form • the partition of a system run ρ as the set of pairs (ρ1 , ρ2 )
rcv(s, r, m), representing the dispatch and the arrival of with ρ1 and ρ2 system runs such that ∀j ∈ N . ω(ρi )j =
message m from sender instance s to receiver instance r, ω(ρ)j (i = 1, 2) and ∀j ∈ N . {H(ρ1 )j , H(ρ2 )j } is a
respectively. Events are univocally identified, i.e., two arbitrary partition of the set of events H(ρ)j .

events, even if they are both a send (or receive) event of the • rem(ρ) as the system run ρ resulting from removing
same message from the same sender to the same receiver, can every pair (ωi , ∅) from ρ.
be distinguished. • concurrence ρ as the set of pairs of system runs
We let certain events be anonymous or unobservable by (rem(ρ1 ), rem(ρ2 )) such that (ρ1 , ρ2 ) ∈ ρ∗ .
replacing them by a predefined silent event denoted by τ . We • strict sequencing ρ; as the set of pairs (ρ1 , ρ2 ) ∈ ρ such
define the domain Eτ as E ∪ {τ }. A silent event represents an that ∃k ∈ N . ∀i ∈ N . 0 ≤ i ≤ k ⇒ H(ρ1 )i = H(ρ)i and

978-1-4244-2265-4/08/$25.00 © 2008 IEEE Page 169


Forum on Specification and Design Languages 2008

k < i ⇒ H(ρ2 )i−k = H(ρ)i . where both the constraint and the interaction must be satisfied
• weak sequencing ρ;< > as the set  of pairs of system runs in order to consider a system run positive. In this case, it is not

 1 , ρ2 ) ∈ ρ  such that ∀η 1 ∈ n H(ρ1 )n \ {τ }, η2 ∈ possible to consider positive a system run where constraints
n H(ρ 2 )n \ {τ } . η1 >
< η2 ⇒ at(η1 ) < at(η2 ). are not valid, not even the empty system run.
• filter (M )(ρ), with M ∈ M, as the set of system runs Consider the example in Figure 1 and the system runs
that result of the removal of some events from ρ whose
ρ1 = (ω0 , {snd(a, b, n, at 1 ), rcv(a, b, n, at 2 )}) and
messages are labelled by elements in M and subsequently
ρ2 = (ω0 , {snd(a, b, n, at 1 ), rcv(a, b, n, at 2 )})
eliminating pairs with empty set of events, i.e., rem(ρ ) ∈
(ω1 , {snd(b, a, m, at 3 ), rcv(b, a, m, at 4 )})
filter (M )(ρ) if ∀i ∈ N . ω(ρ)i = ω(ρ )i ∧ H(ρ )i ⊆
H(ρ)i , and any η ∈ H(ρ)i \ H(ρ )i is of the form either Both system runs positively satisfy seq (B1 , loop (0, N, B2 )).
snd(s, r, m) or rcv(s, r, m) with m ∈ M . In the case of ρ1 , it satisfies the interaction since the operator
loop accepts the empty system run and (ρ1 , ε) ∈ ρ1;< >.
B. The Positive Fragment
However, the system runs are valid for the whole interaction
The semantics of the positive fragment of the language (with depending on the assignments for at i .
no occurrences of negation and assertion) is defined by an
inductive positive satisfaction relation between system runs Table I
T IME ASSIGNMENTS FOR THE EXAMPLE
and interactions, denoted by ρ |=p S and read system run ρ
positively satisfies interaction S, as shown in Figure 4. at i Assignment 1 Assignment 2 Assignment 3
 at 1
ρ |=p B if lin at ( i H(ρ)i \ {τ }) ⊆ lin(B) 0 0 0
ρ |=p strict(S1 , S2 ) if ∃(ρ1 , ρ2 ) ∈ ρ; . ρi |=p Si (i = 1, 2) at 2 2 4 3
at 3 3 5 7
ρ |=p > . ρi |=p Si (i = 1, 2)
seq(S1 , S2 ) if ∃(ρ1 , ρ2 ) ∈ ρ;<
at 4 4 6 9
ρ |=p par(S1 , S2 ) if ∃(ρ1 , ρ2 ) ∈ ρ . ρi |=p Si (i = 1, 2)

ρ |=p loop(0, 0, S) if i H(ρ)i \ {τ } = ∅
 With the first and third time assignments in Table I, the
ρ |=p loop(0, n + 1, S) if i H(ρ)i \ {τ } = ∅ ∨
reception of n is done before 3 time units since the sending
ρ |=p seq(S, loop(0, n, S))
of n. In consequence, ϕ1 is satisfied and both system runs
ρ |=p loop(m + 1, n + 1, S) if ρ |=p seq(S, loop(m, n, S))
are valid. The proof of this is developed as follows:
ρ |=p loop(m, ∞, S) if ∃n ≥ m . ρ |=p loop(m, n, S)
ρ |=p ignore(M, S) if ∃ρ1 . ρ1 ∈ filter (M )(ρ) ∧ ρ1 |=p S ρ2 (0) |=p B1 (ρ2 (0), 0); ∅
ϕ1 ↓ true
ρ |=p alt(S1 , S2 ) if ρ |=p S1 ∨ ρ |=p S2 ρ2 (0) |=p constraint(ϕ1 , B1 )

ρ |=p constraint(ϕ, S) if (ρ, 0); ∅


ϕ ↓ true ∧ ρ |=p S then,
ρ2 (0) |=p constraint(ϕ1 , B1 )
Figure 4. Semantics of the positive fragment ρ2 (1) |=p loop(0, N, B2 ) (ρ2 (0), ρ2 (1)) ∈ ρ2;<
>
ρ2 |=p seq(constraint(ϕ1 , B1 ),loop(0, N, B2 ))
The base case considers a system run possibly containing
one or more occurrences of the silent event τ . Silent events If we consider the second assignment, the constraint is not
are ignored in order to verify the satisfaction of a given system satisfied and consequently the system run is not positive but
run. A system run satisfies a basic interaction if every possible negative as we show next.
linearization of all its events but τ (with respect to their
occurrence time) is included in the linearization of the basic C. The Negative Fragment
interaction (with respect to its partial ordering). The semantics of the negative fragment of the language
In order to satisfy strict, seq and par operators, the (with occurrences of negation and assertion) is defined by an
system run is partitioned in two and the satisfaction is verified inductive negative satisfaction relation between system runs
for each resulting system run. Performing a partition of a and interactions, denoted by ρ |=n S and read system run ρ
system run may produce empty set of events Hi in the negatively satisfies interaction S, as shown in Figure 5.
resulting system runs. Those sets are removed, with their As in [4] we regard the empty system run and also those
corresponding dynamic bases, since they represent transitions with events besides possibly τ as being positive for neg (S).
taken by some other parts of the interaction. We change the negative satisfaction rule following the same
The ignore operator is evaluated by filtering some events idea as sequential operators: after traversing a negative frag-
of the system run. The loop operator is equivalent to its ment a system run will always be negative no matter what
unfolding as weak sequencing of its interaction arguments. The happens afterwards. A system run positively satisfying S is
alt operator is evaluated as the disjunction of the satisfaction positive for assert(S), otherwise the system run is negative.
of the system run in both interaction fragments. For the operators strict and seq we adopt the view
Finally, there is a satisfaction rule to evaluate whether a sys- that the only system runs that are negative are those that
tem run positively satisfies an OCL/RT-constrained interaction. either run through the first operand negatively or fulfil the
The constraint fragment is interpreted as a conjunction first operand positively and the second operand negatively.

978-1-4244-2265-4/08/$25.00 © 2008 IEEE Page 170


Forum on Specification and Design Languages 2008


ρ |=p neg(S) if i H(ρ)i \ {τ } = ∅
a concrete specification refines an abstract specification if
ρ |=p assert(S) if ρ |=p S any model of the concrete specification is also a model
of the abstract one. Below, we adapt the set of definitions
ρ |=n strict(S1 , S2 ) if ∃(ρ1 , ρ2 ) ∈ ρ; . (ρ1 |=n S1 ∨
(ρ1 |=p S1 ∧ ρ2 |=n S2 )) originally given in [4] for implementation and refinement of
ρ |=n seq(S1 , S2 ) if ∃(ρ1 , ρ2 ) ∈ ρ;< an interaction to our semantic domains.
> . (ρ1 |=n S1 ∨
(ρ1 |=p S1 ∧ ρ2 |=n S2 )) Definition 1 (Implementation of Interactions). A process is an
ρ |=n par(S1 , S2 ) if ∃(ρ1 , ρ2 ) ∈ ρ . ((ρ1 |=n S1 ∧ ρ2 |=n S2 ) ∨ arbitrary set of system runs. A process I is an implementation
(ρ1 |=n S1 ∧ ρ2 |=p S2 ) ∨
(ρ1 |=p S1 ∧ ρ2 |=n S2 ))
of an interaction S, written I |= S, if
1. ∃ρ ∈ I . ρ |=p S
ρ |=n loop(0, n + 1, S) if ρ |=n seq(S, loop(0, n, S))
2. ∀ρ ∈ I . ρ n S
ρ |=n loop(m + 1, n + 1, S) if ρ |=n seq(S, loop(m, n, S))
An interaction S is implementable if there is a process I such
ρ |=n loop(m, ∞, S) if ∃n ≥ m . ρ |=n loop(m, n, S)
that I |= S.
ρ |=n ignore(M, S) if ∃ρ1 . ρ1 ∈ filter (M )(ρ) ∧ ρ1 |=n S
ρ |=n alt(S1 , S2 ) if ρ |=n S1 ∧ ρ |=n S2 Definition 2 (Refinement). An interaction S  refines an inter-
ρ |=n neg(S) if ∃(ρ1 , ρ2 ) ∈ ρ; . ρ1 |=p S action S, written S ; S  , if any implementation of S  is also
ρ |=n assert(S) if ρ p S an implementation of S, i.e., ∀I . I |= S  ⇒ I |= S.
With these definitions we can increase the set of re-
ρ |=n constraint(ϕ, S) if (ρ, 0); ∅
ϕ ↓ false ∨ ρ |=n S
finement rules given in [4]. We show one of them in the
Figure 5. Semantics of the negative fragment following lemma. It is straightforward to prove that S ;
constraint(ϕ, S) for any constraint ϕ and interaction S.
Lemma 1. Let S and S  be interactions with S  implementable
A similar instance is taken towards par where at least one
and not overspecified, let ϕ be a constraint. If S ; S  , then
operand has to be run through negatively in order to make a
constraint(ϕ, S) ; constraint(ϕ, S  ).
run negative. The loop and ignore operators follow the same
idea as in the positive fragment, while for the alt operator Proof: Let I be a process with I |= constraint(ϕ, S  ).
both operands have to be run through negatively. (a) ∃ρ ∈ I . ρ |=p constraint(ϕ, S  ). Thus (by the
Finally, there is a satisfaction rule to evaluate whether positive satisfaction relation) ρ  ϕ ↓ true ∧ ρ |=p S  , and
a system run negatively satisfies an OCL/RT constrained thus ρ n S  as S  is not overspecified. Then ρ |=p S by
interaction. The negative rule is interpreted as the “negation” definition of ;, and thus, ρ |=p constraint(ϕ, S).
of the positive satisfaction rule: either the constraint evaluates (b) ∀ρ ∈ I . ρ n constraint(ϕ, S  ). Thus (by the
to false or the system run negatively satisfies the interaction. negative satisfaction relation) ρ  ϕ ↓ false ∧ ρ n S  . Now,
We had that the system runs ρ1 and ρ2 of above satisfy the let I’ be a process such that I’ |= S’. Then, I’ ∪ {ρ} |= S’,
interaction of Figure 1 depending on the value of ati . For the and thus I’ ∪ {ρ} |= S because S ; S’. Finally, ρ n S, and
second time assignment, ϕ1 is not satisfied and consequently hence, ρ n constraint(ϕ, S).
the system run is negative for the interaction: From (a) and (b) we conclude that I |= constraint(ϕ, S),
thus constraint(ϕ, S) ; constraint(ϕ, S  ).
ρ2 (0) |=n constraint(ϕ1 , B1 ) In analogy to Definition 2, we define constraint refinement.
ρ2 (1) |=p loop(0, N, B2 ) (ρ2 (0), ρ2 (1)) ∈ ρ2;<
>
ρ2 |=n seq(constraint(ϕ1 , B1 ),loop(0, N, B2 )) Definition 3 (Constraint Refinement). A constraint ϕ refines
a constraint ϕ, written ϕ ; ϕ if, for any system run ρ,
D. Summary of Constraints Satisfaction 1. ρ  ϕ ↓ true ⇒ ρ  ϕ ↓ true
The satisfaction rule for constraints, defined in the previous 2. ρ  ϕ ↓ undef ⇒ ρ  ϕ ↓ false
section, states that a system run ρ is positive for an interaction
constraint(ϕ, S) if the system run positively satisfies the We can also define a further refinement rule.
interaction S and also ϕ evaluates to true. If ρ negatively Lemma 2. Let ϕ and ϕ be constraints, let S be an interaction.
satisfies the interaction S or ϕ evaluates to false, the system If ϕ ; ϕ , then constraint(ϕ, S) ; constraint(ϕ , S).
run ρ negatively satisfies the interaction constraint(ϕ, S).
In any other case, the system run ρ is considered inconclusive. Proof: Let I be a process with I |= constraint(ϕ , S).
Finally, a system run can be both positive and negative. In this (a) ∃ρ ∈ I . ρ |=p constraint(ϕ , S). Thus (by the
case, we speak of an overspecified interaction. positive satisfaction relation) ρ  ϕ ↓ true ∧ ρ |=p S.
In the following, by ρ  ϕ ↓ v abbreviates (ρ, 0); ∅  ϕ ↓ v. Then (by Definition 3) ρ  ϕ ↓ true, and finally, ρ |=p
constraint(ϕ, S).
IV. I MPLEMENTATION AND R EFINEMENT (b) ∀ρ ∈ I . ρ n constraint(ϕ , S). Thus (by the
Refinement means adding information to a specification to negative satisfaction relation) one of the following cases
make it closer to an implementation. This can be formally occur: (1) ρ  ϕ ↓ true ∧ ρ n S. Then (by Definition
defined using the notion of refinement by model inclusion: 3) ρ  ϕ ↓ true, and finally ρ n constraint(ϕ, S);

978-1-4244-2265-4/08/$25.00 © 2008 IEEE Page 171


Forum on Specification and Design Languages 2008

(2) ρ  ϕ ↓ undef ∧ ρ n S. Then (by Definition 3) with an expressive support of complex constraints in interac-
ρ  ϕ ↓ false and in consequence ρ n constraint(ϕ, S) tions. We also reviewed the notions of implementation and
From (a) and (b) we conclude that I |= constraint(ϕ, S), refinement of interactions, we extended the set of refinement
and thus the thesis holds. rules intended for formal verification, and we introduced the
The interaction of the example in Figure 1 can be refined by notion of constraint refinement.
adding a new constraint ϕ2 which states that every message Since some kind of constraints are not relevant for the
m must be sent within 3 time units since the reception of n: interactions, OCL/RT is not used in its full potential. Future
context B work is needed in order to extend the language to specify
def: sndM : Set(Event) = state-based constraints suited for temporal logic reasoning.
events->select(e | e.oclIsTypeOf(SndMsgEvent) Moreover, system runs do not consider termination events for
and e.message.name = "m") operations nor synchronization of messages. Both concepts are
def: rcvN : Event = needed to develop a integrated behavioral specification model
events->select(e | e.oclIsTypeOf(RcvMsgEvent)
and e.message.name = "n")->any() connecting other development activities as intra-component
constr: always(sndM->forAll(e | specifications and design by contract.
e.at < rcvN.at + 3)) Our approach tends to ensure software quality attributes
by verification of the generated models at early development
The third assignment of Table I makes the system run invalid
stages. A formal background helps to prevent from ambigu-
for constraint(ϕ2 , seq(constraint(ϕ1 , B1 ), loop(0,
ous, imprecise, contradictive and error-prone specifications.
N, B2 ))) while it is valid for seq(constraint(ϕ1 , B1 ),
This approach allows a tighter control of the processes and
loop(0, N, B2 )). The interactions can also be refined by a
improves software reliability. Our intention is not capricious
constraint refinement. If we restrict the duration of n to
since software modeling and formal verification are strongly
{0..2}, only the first assignment makes the system run valid.
related in growing engineering approaches nowadays.
V. I N P RACTICE ACKNOWLEDGMENT
A practical analysis is mandatory for a fine-tuning and a The authors are indebted to Alexander Knapp for fruitful
careful utilization of the proposal. [13] presents some exam- discussions on the subject.
ples, taken from the literature, that apply our approach; these
examples are not repeated here due to space reasons. R EFERENCES
UML 2.0 Interactions can graphically specify basic timing [1] “UML 2.0 Superstructure,” Object Management Group, For-
mal Specification formal/05-07-04, 2005. [Online]. Available:
constraints, as defined in [1]. These kind of constraints are http://www.omg.org/docs/formal/05-07-04
simple time and duration observations and/or constraints. They [2] “UML 2.0 Object Constraint Language,” Object Management Group,
can be expressed with OCL/RT assigning to them a concrete Formal Specification formal/06-05-01, 2006. [Online]. Available:
http://www.omg.org/cgi-bin/doc?formal/06-05-01
meaning in the evaluation of a system-run. Besides, OCL/RT [3] M. V. Cengarle and A. Knapp, “Towards OCL/RT,” Lecture Notes in
allows specifying more complex constraints involving also Computer Science, vol. 2391, pp. 390–409, 2002.
system instances, message events and global variables. Conse- [4] M. V. Cengarle and A. Knapp, “UML 2.0 Interactions: Semantics and
Refinement,” in Proc. 3rd Intl. Work. on Critical Systems Development
quently our approach is one of the most powerful proposals in with UML. Technische Universität München, 2004, pp. 85–99.
order to specify real-time constraints in UML 2.0 Interactions. [5] B. P. Douglass, Real-Time UML: Advances in the UML for Real-Time
As far as we know, only the work in [12] analyzes an OCL Systems, 3rd ed. Addison Wesley, 2004.
[6] B. Selic, G. Gullekson, and P. T. Ward, Real-Time Object-Oriented
extension to be used with interactions. There, the problem Modeling. Wiley, 1994.
of synchronization and the specification of liveness prop- [7] H. Störrle, “Semantics of Interactions in UML 2.0,” Proc. 2003 IEEE
erties (normally expressed at the level of state diagrams) Symp. on Human Centric Computing Languages and Environments, pp.
129–136, 2003.
are addressed. Our work does not address the problem of [8] Ø. Haugen, R. Kobro, K. Husa, and K. Stølen, “Why Timed Sequence
synchronization but the use of OCL/RT allows specifying Diagrams Require Three-Event Semantics,” Lecture Notes in Computer
some liveness properties. We think that our work and that Science, vol. 3466, pp. 1–25, 2005.
[9] R. Grosu and S. Smolka, “Safety-Liveness Semantics for uml 2.0 se-
in [12] are complementary, and a fusion of both can be quence diagrams.” in Proc. 5th Intl. Conf. on Application of Concurrency
made in order to investigate the relation between constrained to System Design. IEEE Computer Society, 2005, pp. 6–14.
interactions and timed state machines. [10] Y. Hammal, “Branching Time Semantics for UML 2.0 Sequence Dia-
grams.” Lecture Notes in Computer Science, vol. 4229, pp. 259–274,
VI. C ONCLUSIONS AND O UTLOOK 2006.
[11] A. Cavarra and J. Küster-Filipe, “Formalizing Liveness-Enriched Se-
This work contributes to the clarification on the use of time quence Diagrams Using ASMs,” Lecture Notes in Computer Science,
constraints in inter-component behavioral specifications. Based vol. 3052, pp. 62–77, 2004.
[12] A. Cavarra and J. Küster-Filipe, “Combining Sequence Diagrams and
on previous works, we developed a semantics for an enhanced OCL for Liveness.” Electronic Notes in Theorical Computer Science,
UML 2.0 Interactions language with OCL/RT constraints vol. 115, pp. 19–38, 2005.
support. The resulting denotational semantics evaluates the [13] D. Calegari, “UML 2.0 Interactions with OCL/RT Constraints,” InCo-
PEDECIBA, Master Thesis Report TR07-17, 2007. [Online]. Available:
positivity/negativity of a system run within an interaction, con- http://www.fing.edu.uy/inco/pedeciba/bibliote/tesis/tesis-calegari.pdf
sidering both interaction structure and constraints satisfaction. [14] V. Pratt, “Modelling Concurrency with Partial Orders,” International
To the best of our knowledge, our semantics is the only one Journal of Parallel Programming, vol. 15, no. 1, pp. 33–71, 1986.

978-1-4244-2265-4/08/$25.00 © 2008 IEEE Page 172

You might also like