23.10.2012 Views

Shahar Maoz, Jan Oliver Ringert, and Bernhard Rumpe

Shahar Maoz, Jan Oliver Ringert, and Bernhard Rumpe

Shahar Maoz, Jan Oliver Ringert, and Bernhard Rumpe

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CISC836: Models in Software Development Fall 2011<br />

CD2All CD2Alloy:<br />

Class Diagrams Analysis<br />

Using Alloy Revisited<br />

<strong>Shahar</strong> <strong>Maoz</strong>, <strong>Jan</strong> <strong>Oliver</strong> <strong>Ringert</strong>, <strong>and</strong> <strong>Bernhard</strong> <strong>Rumpe</strong><br />

AMAL KHALIL Paper Presentation<br />

About the Paper<br />

�� In: Model Driven Engineering Languages <strong>and</strong> Systems<br />

(MODELS 2011), Wellington, New Zeal<strong>and</strong>. pp. 592-<br />

607, LNCS 6981, 2011.<br />

Th 1 st h Sh h M f l PhD<br />

� The 1 st author, <strong>Shahar</strong> <strong>Maoz</strong>, was formerly a PhD<br />

student of David Harel (Co-founder of Statecharts).<br />

13/11/2011<br />

1


Agenda<br />

� Introduction<br />

� Background<br />

� The CD2Alloy Plug-In<br />

� The CD2Alloy Translation<br />

� The CD2Alloy Specific Features<br />

� Di Discussion i<br />

� Related Work<br />

� Conclusion<br />

Introduction<br />

� Alloyy is a textual modelingg language g g developed p byy Daniel<br />

Jackson <strong>and</strong> his team at MIT.<br />

� It is a formal language which has a concise syntax <strong>and</strong> formal semantics.<br />

� It has been used primarily, with its analyzer, in analyzing code for conformance<br />

to a specification <strong>and</strong> as an automatic test case generator.<br />

�� On the other h<strong>and</strong> h<strong>and</strong>, the Unified Modeling Language (UML) is<br />

the de-facto st<strong>and</strong>ard for modeling in the field of objectoriented<br />

systems.<br />

� It is a semi-formal language, since its syntax <strong>and</strong> static semantics are defined<br />

precisely but its dynamic semantics are not specified formally.<br />

13/11/2011<br />

2


Introduction<br />

� Model Transformation has been extensively used to allow analysis of UML models<br />

by transferring these models to formal languages, which in turn can be used for<br />

conducting various types of automated analysis.<br />

� It allows the designer to benefit from the capabilities provided by these formal<br />

languages <strong>and</strong> the analysis tools associated with them.<br />

� It helps in verifying <strong>and</strong> improving the models at earlier stages of the development<br />

process <strong>and</strong> hence increasing the reliability of software systems.<br />

� I should not forget to mention that for such transformation to be beneficent it has to<br />

be a bidirectional transformation, which means that the outcome of the analysis<br />

should also be transferred back to the language used in the design space.<br />

Introduction<br />

� An example of such transformation is UML2Alloy.<br />

� The method adopted in this tool makes use of Model<br />

Driven Architecture (MDA) techniques for defining <strong>and</strong><br />

implementing the transformations from models captured<br />

in the UML class diagram <strong>and</strong> OCL into Alloy.<br />

� In the MDA a model transformation is defined by<br />

mapping the constructs of the meta-model of a source<br />

language into constructs of the meta meta-model model of a<br />

�<br />

destination language.<br />

Then every model, which is an instance of the source<br />

meta-model, can be automatically transformed to an<br />

instance of the destination meta-model with the help of a<br />

model transformation framework [3].<br />

13/11/2011<br />

3


Introduction<br />

� For UML2Alloy, the instance of the destination model is an Alloy instance<br />

which can be analyzed to identify the inconsistencies between various parts<br />

of the design defined by the source model <strong>and</strong> to identify if the model is<br />

under- or over-constrained.<br />

� Alloy can produce a counter-example helping to reveal the source of<br />

inconsistency.<br />

� If a counter-example is found, it must be transferred to a UML objectdiagram<br />

which is an instance of the class diagram in the design space that<br />

represents a violation of a property of the system.<br />

Introduction<br />

� Snapshots from the UML2Alloy tool are shown.<br />

The input to the tool is an<br />

XMI file of the UML class<br />

diagram created by<br />

ArgoUML.<br />

The output from the<br />

tool in the form of<br />

object diagrams.<br />

13/11/2011<br />

4


Introduction<br />

� This paper presents a new translation of UML class diagrams to Alloy, which is<br />

based on a deeper embedding strategy, as the authors claim.<br />

� Rather than mapping each CD construct to a semantically equivalent Alloy construct, the<br />

new translation defines (some of) the CD constructs as new concepts within Alloy.<br />

� For example, class inheritance is not mapped to its Alloy's counterpart – the extends<br />

keyword. Instead, it is defined using several of Alloy's language constructs – facts,<br />

functions, <strong>and</strong> predicates, whose semantics reflects the semantics of class inheritance in CDs<br />

[1] [1].<br />

� The new translation is implemented in a prototype Eclipse plug-in called CD2Alloy.<br />

� The authors claim that existing translations are missing the support for several CD<br />

language features such as multiple inheritance <strong>and</strong> interface implementation <strong>and</strong><br />

are limited to the basic analysis of a single CD.<br />

Introduction<br />

� The paper starts with a brief background on the CD <strong>and</strong> OD languages<br />

<strong>and</strong> a short overview on Alloy.<br />

� After that it describes the new translation from CDs to Alloy <strong>and</strong> back to<br />

ODs, side by side with the shallow translation demonstrated by UML2Alloy.<br />

� The paper then shows how the new translation can be used to solve several<br />

analysis problems involving more than one CD.<br />

� Following that, a comprehensive comparison between the existing shallow<br />

translations <strong>and</strong> the new one, considering their strengths <strong>and</strong> weaknesses is<br />

provided with a thorough discussion of related work <strong>and</strong> a brief conclusion.<br />

13/11/2011<br />

5


Background<br />

Class <strong>and</strong> Object Diagrams<br />

� The authors used the CD <strong>and</strong> OD sub-languages of a refined alternative of UML,<br />

called UML/P, which is designed for low-level design <strong>and</strong> implementation.<br />

� The semantics of CDs is given in terms of sets of objects <strong>and</strong> relationships between<br />

these objects. It is defined using three parts:<br />

1. A definition of the syntactic domain, i.e., the syntax of the modeling language CD <strong>and</strong><br />

its context conditions conditions.<br />

2. A semantic domain, consisting of all finite object models.<br />

3. A mapping [sem: CD � P(OM)], which relates each syntactically well-formed CD<br />

to a set of constructs in the semantic domain OM.<br />

Background<br />

A Brief Overview of Alloy<br />

� Alloy is a textual modeling language based on relational first-order logic.<br />

� An Alloy module consists of signature declarations, fields, facts <strong>and</strong> predicates.<br />

� Each signature denotes a set of atoms, which are the basic entities in Alloy.<br />

� Relations between two or more signatures are represented using fields <strong>and</strong> are interpreted as sets of<br />

tuples of atoms.<br />

� Facts are statements that define constraints on the elements of the model.<br />

� Predicates are parameterized constraints that can be included in other predicates or facts.<br />

� Alloy modules can be analyzed using Alloy Analyzer, a fully automated constraint solver.<br />

� This is done by a translation of the module into a Boolean expression, which is analyzed by SAT solvers<br />

embedded within the Analyzer.<br />

� The tool can find the instances that prove the satisfiability of the user-specified predicates within the<br />

given scope.<br />

13/11/2011<br />

6


The CD2Alloy Plug-In<br />

� The input for the implementation is a textual<br />

specification ifi ti off a UML/P CD th thatt iis written itt iin<br />

MontiCore (a framework for an efficient<br />

development of domain-specific languages)<br />

�<br />

grammar <strong>and</strong> generated Eclipse editor.<br />

The transformation to Alloy is implemented using<br />

template written in FreeMaker (a Java-based<br />

template engine that can be used to generate any<br />

kind of text output) output).<br />

� The execution of the generated module’s run<br />

�<br />

comm<strong>and</strong>s is done using Alloy’s APIs.<br />

CD2Alloy allows you to edit a CD, to analyze it<br />

using Alloy, to view the generated Alloy code, <strong>and</strong><br />

to view the instances that the SAT solver finds back<br />

in the form of ODs.<br />

The CD2Alloy Plug-In<br />

� Snapshots from the CD2Alloy<br />

tool are shown.<br />

13/11/2011<br />

7


The CD2Alloy Translation<br />

�� CD2Alloy takes a<br />

CD as input <strong>and</strong><br />

generates an Alloy<br />

module.<br />

�� The module consists<br />

of two parts:<br />

1. A generic part<br />

The CD2Alloy Translation<br />

13/11/2011<br />

8


The CD2Alloy Translation<br />

2. ACDspecific p part, p , which includes a predicate p that describe<br />

the CD itself.<br />

The CD2Alloy Translation<br />

� Snapshots from the CD2Alloy<br />

Plug-In <strong>and</strong> the output from the<br />

Alloy module generated.<br />

13/11/2011<br />

9


The CD2Alloy Translation<br />

� Similar transformation is done using the UML2Alloy but with the need to<br />

write a specific OCL constraint to specify the multiplicity ranges.<br />

The CD2Alloy Specific Features<br />

� The semantics of composition<br />

requires i th that t a parttcannott exist without a whole <strong>and</strong> that it<br />

belongs to exactly one whole.<br />

� The semantics of CD’s<br />

composition has no counterpart<br />

in Alloy <strong>and</strong> so it isn’t supported<br />

by existing translations such as<br />

UML2Alloy.<br />

� Butitissupportedbythenew<br />

translation.<br />

13/11/2011<br />

10


The CD2Alloy Specific Features<br />

� Inheritance, Interfaces <strong>and</strong> Multiple Inheritance<br />

� The translation of UML2Alloy uses Alloy’s built-in support for inheritance <strong>and</strong><br />

hence directly maps CD class inheritance to Alloy’s extends keyword.<br />

� In the new translation the semantics of inheritance is explicitly expressed using sub<br />

functions that define the set of sub classes of each class.<br />

� The use of these functions provides the flexibility required to support multiple<br />

inheritance.<br />

� This feature is not supported by existing translations like UML2Alloy.<br />

� Similar functions are used to support interfaces. Every interface is defined by a<br />

function that returns all classes implementing the interface.<br />

� Also existing translations do not support interfaces.<br />

The CD2Alloy Specific Features<br />

� Here is an example p on multiple p<br />

inheritance.<br />

13/11/2011<br />

11


The CD2Alloy Specific Features<br />

� Example p on multiple p inheritance (Cont.): ( )<br />

The CD2Alloy Specific Features<br />

� Multiple CD Analysis<br />

� The new translation allows you to solve several analysis problems that involve more than<br />

one class diagram.<br />

� Examples of such analysis problems are intersection <strong>and</strong> refinement.<br />

� To h<strong>and</strong>le the creation of multiple CDs in one Alloy module, we need to do the<br />

followings:<br />

�� Define signatures for the union of classes from all input CDs CDs.<br />

� Divide the CD specific functions (sub class functions, enumeration value functions) between<br />

the CDs by adding the suffix CDi to all the functions generated for the i-th CD.<br />

� Create several predicates, cd1, cd2, etc., one for each of the input CDs. Each predicate<br />

cdi uses the functions with suffix CDi <strong>and</strong> defines constraints to not include any objects of<br />

classes not in cdi.<br />

13/11/2011<br />

12


The CD2Alloy Specific Features<br />

� Multiple CD Analysis Example<br />

The CD2Alloy Specific Features<br />

� Multiple CD Analysis Example<br />

(Cont.)<br />

� Analyzing the two class<br />

diagrams cd1 & cd2 reveals<br />

that the intersection is not<br />

�<br />

empty.<br />

It also shows that neither cd1<br />

nor cd2 is a refinement of each<br />

other.<br />

13/11/2011<br />

13


The CD2Alloy Specific Features<br />

� Multiple CD Analysis Example (Cont.)<br />

� On the other h<strong>and</strong>, analyzing the two class<br />

diagrams cd1 & cd3 reveals that cd3 is a<br />

(strict) refinement of cd1.<br />

� Note that cd m is a (strict) refinement of<br />

cd n iff:<br />

� The predicate cdm <strong>and</strong> not cdn is inconsistent<br />

(has no instances) instances).<br />

&&<br />

� The predicate cdn <strong>and</strong> not cdm is consistent (has<br />

instances).<br />

i.e. all instances of cdm arealsoinstancesof<br />

cdn (but not vice versa).<br />

Discussion<br />

� CD2Alloy demonstrates the tradeoff between the readability <strong>and</strong><br />

intuitiveness of a simple shallow translation in one h<strong>and</strong> <strong>and</strong> the<br />

expressiveness of a deeper translation on the other h<strong>and</strong>.<br />

13/11/2011<br />

14


Related Work<br />

�� The authors in this paper provide a thorough<br />

discussion of the related work including most, if not<br />

all, the existing tools in the subject area.<br />

� Tools such as UML2Alloy, UML CD, UML ODs,<br />

UML2CSP UML2CSP, UML/OCL UML/OCL, the USE tool tool, <strong>and</strong> CDDiff are<br />

briefly discussed.<br />

Conclusion<br />

� CD2Alloy is a translation from UML CDs to Alloy, which takes<br />

the advantage of the Alloy’s expressive power <strong>and</strong><br />

advances the state-of-the-art in CD analysis.<br />

� Since MDE is currently in the research stage, having more<br />

than one possible translation can be worthwhile.<br />

� The choice of which translation to use depends on the<br />

specific f needs off the application at h<strong>and</strong>.<br />

� Future work includes additional language features <strong>and</strong><br />

analyses such as constrained generalization sets.<br />

13/11/2011<br />

15


References<br />

� S.<strong>Maoz</strong>,J.O.<strong>Ringert</strong>,B.<strong>Rumpe</strong>.CD2Alloy: Class Diagrams Analysis Using Alloy<br />

Revisited. In Model Driven Engineering Languages <strong>and</strong> Systems (MODELS 2011),<br />

Wellington, New Zeal<strong>and</strong>. pp. 592-607, LNCS 6981, 2011. [1]<br />

� K. Anastasakis, B. Bordbar, G. Georg, <strong>and</strong> I. Ray. On challenges of model<br />

transformation from UML to Alloy. Software <strong>and</strong> Systems Modeling, 9(1):69-86,<br />

2010. [3]<br />

�� S. M. A. Shah, K. Anastasakis, <strong>and</strong> B. Bordbar. From UML to Alloy <strong>and</strong> back again.<br />

In S. Ghosh, editor, MoDELS Workshops, volume 6002 of LNCS, pages 158-171.<br />

Springer, 2009. [22]<br />

� S.<strong>Maoz</strong>,J.O.<strong>Ringert</strong>,<strong>and</strong>B.<strong>Rumpe</strong>.CDDiff: Semantic differencing for class<br />

diagrams. InECOOP, volume 6813 of LNCS, pages 230-254. Springer, 2011. [16]<br />

THANK YOU<br />

?<br />

Fall 2011<br />

AMAL KHALIL Paper Presentation<br />

13/11/2011<br />

16

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!