modelog – model- oriented development with executable logical object generation franklin ramalho...

47
MODELOG – Model-Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques Robin Advisor ORCAS Group

Upload: lambert-goodwin

Post on 25-Dec-2015

216 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

MODELOG – Model-Oriented Development with Executable Logical

Object Generation

Franklin RamalhoUniversidade Federal de Pernambuco

PhD candidate

Jacques RobinAdvisor

ORCAS Group

Page 2: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG2

Outline

1 Introduction and Motivation2 MDE and OMG Languages3 OOLP4 MODELOG5 Case Study6 Related Works7 Conclusions

Page 3: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG3

Introduction

• Initial role of UML (Unified Modeling Language) – Visual notation for high-level blueprints in Object-Oriented

Software Engineering (OOSE);– Standard, intuitive, expressive, extensible, many CASE tools

available.

• New roles for UML:– Model-Driven Engineering:

• Abstract visual syntax for meta-modeling;• Low-level specification language for fully automated code generation;• Formal specification language for formal verification.

– Knowledge-level representation language for:• Autonomous agents and multi-agent systems (MAS)• Semantic web service for knowledge management and intelligent

information retrieval

Page 4: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG4

Introduction

• Extensions to the UML:– OCL (Object Constraint Language);– MOF (Meta-Object Facility);– XMI (XML Metadata Interchange);– UML Profiles;– Formal Semantics for UML and OCL;– AUML (Agent UML).

Page 5: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG5

Model-Driven Engineering-Automatic generation of

complete structural and

behavioral code

-Real-size example fully

adopting a MDE approach

Formal Development

and model-checking- Integrated semantics for

UML and OCL

-Verification of executable

formal model

Semantic WebService

Development

SWS representation

and reasoning

Agent OrientedEngineering

- combine strengths of AO

extensions of OO and

Logic/Formal methods

- Automatic code generation

of OO Logic agents

Agile Development

- Fast prototyping

- Automatic structural and

behavioral code generation

Motivation

Page 6: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG6

MODELOG

MODELOG

• MODELOG goal: – Address all 5 new application areas of UML by single automated mapping– From UML2 class diagram w/ OCL2 structural constraints and behavior specifications– To executable, Turing-complete, programming language with formal semantics

Credito Debito

ParceiroPrograma

quantidadeDeClientes : Integer

Transacao

pontos : Integerdata : Data

programa() : ProgramFidelidade

Cliente

nome : StringpronomeTratamento : Stringmasculino : BooleandataAniversario : Data

idade()

Conta

pontos : Integer

creditar(pts : Integer)debitar(pts : Integer)estaVazia() : Boolean

0..*transacoes 0..*

Cartao

valido : BooleanvalidoDesde : Datavencimento : Datacor : enum{prata, ouro}nomeTratamentoCliente : String

0..*

transacoes

0..*

cartao

0..* cartoes0..*

proprietario

Servico

condicao : BooleanpontosADebitar : IntegerpontosACreditar : Integerdescricao : String

0..*

transacoes

0..*

0..* servicosOferecidos0..*

ProgramaFidelidade

cadastrar(c : Cliente)0..*0..* 0..*

programa

0..*1..*

1..*

1..*

parceiros1..*

Socio

0..10..1

cartaoNivelServico

nome : String

0..*

servicosDisponiveis

0..*

1..*1..*

{ordered}0..*0..*

nivelDoServico

8: fecha

Joao:Passageiro

Maria:Passageiro

a3:BotaoDeAndar

a5:BotaoDeAndar

cont:Controlador

elevador:Elevador

porta:Porta

1: aperta

2: atualiza

3: ilumina

7: desilumina

9: aperta

10: atualiza

11: desilumina

4: mova

5: chegou

6: abre

contJoao Maria a3 a5 elevador

aperta atualize

mova

ilumina

aperta

chegou

abra

mova

atualize

ilumina

UML

c1 : Customer

A8:CancelBurning

Burning[status = cancelled]

[True]

[True]

si : ServiceItem

A1:CheckCard[customerCard->includes(cc) and

cc.valid]

[False]

[False]cc : CustomerCard

A6:CompleteBurningBurning

[status = completed, points = SI.points]

A5:BurnServiceItem

[True]

[False]

la : LoyaltyAccount

A0:CheckEnrolled[customer->includes(c1)]

c1 : Customer

A8:CancelBurning

Burning[status = cancelled]

[True]

[True]

si : ServiceItem

A1:CheckCard[customerCard->includes(cc) and

cc.valid]

[False]

[False]cc : CustomerCard

A6:CompleteBurningBurning

[status = completed, points = SI.points]

A5:BurnServiceItem

[True]

[False]

la : LoyaltyAccount

A0:CheckEnrolled[customer->includes(c1)]

OCL

-UML2 class diagrams annotated with OCL2 structural constraintsand behavior specification

Target language: FloraObject-Oriented

Logic ProgrammingW3C Standard for

Semantic Web Services

Page 7: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG7

Outline

1 Introduction and Motivation2 MDE and OMG Languages3 OOLP4 MODELOG5 Case Study6 Related Works7 Conclusions

Page 8: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG8

Model-Driven Engineering

AbstractionScale

ExecutabilityScale

UML + NL Application

Requirements

UML Model

SourceCode

VirtualMachine

Code

BinaryCode

Current Standard Practice:Object-Oriented Development

Mix 2 orthogonal concerns: business

refinement and translation to platform

Page 9: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG9

Model-Driven Engineering

AbstractionScale

ExecutabilityScale

VirtualMachine

Code

BinaryCode

UML/OCLBusiness

CIM

UML/OCL Application

SpecificationPIM

UML/OCL ApplicationRealization

PIM

ProfiledUML/OCL

ApplicationRealization

PSM

SourceCode

Today’s MDE:Extreme Modeling

Page 10: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG10

Model-Driven Engineering

AbstractionScale

ExecutabilityScale

VirtualMachine

Code

BinaryCode

UML/OCLBusiness

CIM

UML/OCL Application

SpecificationPIM

UML/OCL ApplicationRealization

PIM

ProfiledUML/OCL

ApplicationRealization

PSM

SourceCode

Tomorrow’s MDE:UML Programming

ModelTranslation

Patterns

ModelRefinement

Patterns

Page 11: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG11

MDE Languages

Aplicação

TransformationEngine

TransformationEngine

TransformationEngine

Definições de transformação

Rule X{...}

Rule X{...}

Definições de transformação

Rule X{...}

Rule X{...}

Definições de transformação

Rule X{...}

Rule X{...}

PIM PSMCodeCIM

Meta-

modelMeta-

model

UML and OCL QVT, ATL, Flora, ATL-DT

Meta-meta-model

MOF, XMI, KM3, Ecore

UML Profiles

Page 12: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG12

IsoscelesTriangleScaleneTriangle

EquilateralTriangle

AtomicPolygon

{complete, disjoint}kind

{complete, disjoint}

{complete, disjoint}granularity

Triangle

isCompatible(other : Triangle, out selfSide : SegmentLine, out otherSide : SegmentLine) : boolean

SegmentLine

length : float

0..1+/ hypotenuse

0..1

3

+side

3

CompoundPolygon

ConvexPolygon

/ right : boolean2

0..*

+parts

2

0..*

Table

1..*+tans 1..*

Robot

availableRectangle(out new : Rectangle) : booleanavailablePentagon(out new : RightPentagon) : booleanavailableHexagon(out new : Hexagon) : booleanbuildRectange(out new : Rectangle) : booleanbuildPentagon(out new : RightPentagon) : booleanbuildHexagon(out new : Hexagon) : boolean

11

Source models: UML and OCL

context EquilateralTriangle inv inv_12:side->forAll(s1, s2 | s1.length = s2.length)

context Triangle::isCompatible(other:Triangle, selfSide:SegmentLine, otherSide:SegmentLine):booleanbody: letselfSide1 : SegmentLine = self.triangleSide->select(side = hypotenuse).adjacent->first().side,selfSide2 : SegmentLine = self.triangleSide->select(side = hypotenuse).adjacent->at(2).side,otherSide1 : SegmentLine = other.triangleSide->select(side =hypotenuse).adjacent->first().side,otherSide2 : SegmentLine = other.triangleSide->select(side = hypotenuse).adjacent->at(2).side,inself <> other and self.right and other.right andself.hypotenuse.length = other.hypotenuse.length and((selfSide1.length = otherSide1.length and selfSide2.length = otherSide2.length) or (selfSide1.length = otherSide2.length and selfSide2.length = otherSide1.length)) andselfSide = self.hypotenuse and otherSide = other.hypotenuse

context Triangle::hypotenuse : SegmentLinederive: let base : SegmentLine = triangleSide->select(position = TriangleSideKind::base)->asSequence()->first().side, left : SegmentLine = triangleSide->select(position = TriangleSideKind::left)->asSequence()->first().side, right : SegmentLine = triangleSide->select(position = TriangleSideKind::right)->asSequence()->first().side in if (base.length > left.length and base.length > right.length)

then baseelse if left.length > right.length

then leftelse right

endifendif

context Robot::buildRectangle(New:Rectangle):booleanpre: availableTriangle(part1) and availableTriangle(part2) and part1.isCompatible(part2, part1Side, part2Side)post: let pol3:Rectangle = pol3.oclIsNew() … in . . . table.convexPolygon->includes(pol3) and … New = pol3 and result = availableRectangle(New)

Page 13: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG13

AtomicPolygon

Triangle

isCompatible(other : Triangle, out selfSide : SegmentLine, out otherSide : SegmentLine) : boolean

ConvexPolygon

/ right : boolean

Classifier

StructuralFeature

Property

isDeriv ed : Boolean = f alseisReadOnly : Boolean = f alseisDeriv edUnion : Boolean = f alse/ def ault : Stringaggregation : AggregationKind = none/ isComposite : Boolean

Class

*

+/superClass

*

0..1 *

+class

0..1

+ownedAttribute

*

BehavioralFeature

ParameterType

Operation

isQuery : Boolean = f alse/ isOrdered : Boolean/ isUnique : Boolean/ lower : Integer/ upper : UnlimitedNatural

*

0..1

+ownedParameter *

+operation0..1

0..1+/ty pe 0..1

0..1*

+class

0..1

+ownedOperation

*

Feature

isStatic : Boolean = f alse

Page 14: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG14

Outline

1 Introduction and Motivation2 MDE and OMG Languages3 OOLP4 MODELOG5 Case Study6 Related Works7 Conclusions

Page 15: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG15

Target Model: Sequential Transaction Frame Logic (STFL)

ClassicalFirstOrderLogic

p1 ... pn c1 ... cn

StructuralDiagram

- class::superclass[...attri typOpi typei, ..., methj(...,paramjk,...) typOpj typej...]- object:class[...attri assignOp1 valuei, ...,methj(...,paramjk,...) assignOpj valuej ...]

BehavioralDiagram

OCL

a(X) (b, c)

W(b, c)

a(Y, b)

p1 ... pn c

DefiniteLogic

NormalLogic

p1 ... naf pn c

SequentialTransaction Logic

Connectives: , Predicates: delete, insert

HiLog

High OrderMeta-atoms

Frame Logic

OO atomsEquality

SequentialTransactionFrameLogic

Page 16: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG16

A STFL Program

Acct[withdraw(Amt)] :- Acct[balance-> Bal] Bal ≥ Amt Acct[change_balance( Bal, Bal - Amt)].

Acc[deposit(Amt)] :- Acct[balance-> Bal] Acct[change_balance( Bal, Bal + Amt)].

Acct[change_balance( Bal1, Bal2)] :- btdelete{Acct[balance->Bal1]} btinsert{Acct[balance-> Bal2]}.

transfer( Acct1, Acct2, Amt) :- Acct1[withdraw(Amt)] Acct2[deposit(Amt)].

buy(Client, Seller, Cost) :- transfer(Client, acc5, 0,5 * Cost) transfer(Client, Seller * Cost).

acc1[balance->50, owner->philip].

acc2[balance->600, owner->daniel].acc3[balance->1200. owner->roger].acc4[balance->10, owner->mary].

acc5[balance->5000, owner->broker].

?- buy(acc3, acc4, 500).

Page 17: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG17

STFL Denotational Semantics

SequentialTransactionFrameLogic

Frame Logic

FirstOrderPredicateLogic

SequentialTransaction Logic

HiLog

2-valued Herbrand Models

DefiniteLogic

NormalLogic

Well-founded 3-valued Herbrand Models

Data oracles (well-founded 3-valued Herbrand models) + transition oracles (execution paths)

Data oracles (optimistic 3-valued Herbrand models) + transition oracles (execution paths)

optmistic 3-valued Herbrand Models

Page 18: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG18

STFLP Semantics – Data Oracles

Od(D0) = M0

Od(D1) = M1

Od(D2) = M2

Od(D3) = M3

Od(D4) = M4

Od(D5) = M5

Od(D6) = M6

Od(D7) = M7

Od(D8) = M8

M0 = {acc1[balance->50], acc1[owner->philip], acc2[balance->600], acc2[owner->daniel],

acc3[balance->1200], acc3[owner->roger], acc4[balance->10], acc4[owner->mary],

acc5[balance->5000], acc5[owner->broker]}

M1 = {acc1[balance->50], acc1[owner->philip], acc2[balance->600], acc2[owner->daniel],

acc3[owner->roger], acc4[balance->10], acc4[owner->mary],

acc5[balance->5000], acc5[owner->broker]}

M2 = {acc1[balance->50], acc1[owner->philip], acc2[balance->600], acc2[owner->daniel], acc3[balance->1175], acc3[owner->roger], acc4[balance->10], acc4[owner->mary], acc5[balance->5000],

acc5[owner->broker]}

Page 19: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG19

STFLP Semantics – Transition Oracles

Ot(D0, D1) = btdelete{acc3[balance->1200]}

Ot(D1, D2) = btinsert{acc3[balance->1175]}

Ot(D2, D3) = btdelete{acc5[balance->5000]}

Ot(D3, D4) = btinsert{acc5[balance->5025)}

Ot(D4, D5) = btdelete{acc3[balance->1175]}

Ot(D5, D6) = btinsert{acc3[balance->675]}

Ot(D6, D7) = btidelete{acc4[balance->10]}

Ot(D7, D8) = btinsert{acc4[balance->510]}

Ot(D0, D2) = {acc3[change_balance(1200, 1175)], acc3[withdraw(25)]}

Ot(D2, D4) = {acc5[change_balance(5000, 5025)], acc5[deposit(25)]}

Ot(D0, D4) = transfer(roger, broker, 0,5 * 500)

Ot(D4, D6) = {acc3[change_balance(1175, 675)] , acc3[withdraw(500)]}

Ot(D6, D8) = {acc4[change_balance(10, 510)], acc4[deposit(500)]}

Ot(D4, D8) = transfer(roger, mary, 500)

Ot(D0, D8 = buy(roger, mary, 500)

Page 20: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG20

Outline

1 Introduction and Motivation2 MDE and OMG Languages3 OOLP4 MODELOG5 Case Study6 Related Works7 Conclusions

Page 21: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG21

MODELOG’s Approach

MOF Flora Metamodel

MOF OCL Metamodel

MOF UML Metamodel

MOF ATL Metamodel

Page 22: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG22

Flora Metamodel

DLP

GLP

<<r&g>>

STLP<<r&g>>

HLP

<<r&g>><<r&g>>

XSB <<r&g>>

<<combine>>

FLP

<<r&g>>

<<import>>

ISOProlog<<r&g>>

<<combine>>

<<import>>

STFLP

<<r&g>>

<<r&g>>

<<import>>

Flora<<r&g>>

XSB

<<r&g>>

<<import>>

ISOProlog

<<r&g>>

30 packages200 meta-classes

Page 23: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG23

MODELOG Modules

Class DiagramTransformations

Module

MODELOG

OCLTransformations

Module

Page 24: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG24

MODELOG Modules

Class Diagram Transformations Module

ClassTransformations

Module

AttributeTransformations

Module

OperationTransformations

Module

GeneralizationTransformations

Module

DependencyTransformations

Module

RealizationTransformations

Module

AssociationTransformations

Module

Page 25: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG25

MODELOG Modules

OCL Transformations Module

Constraint Transformations Module

Post-ConditionTransformations

Module

BodyTransformations

Module

DeriveTransformations

Module

InvariantTransformations

Module

OCL Expressions Transformations Module

VariableExpTransformations

Module

CallExpTransformations

Module

IFExpTransformations

Module

LiteralExpTransformations

Module

LetExpTransformations

Module

Page 26: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG26

Class Diagrams Transformation

1 convexPolygon[].2 convexPolygon[right *=> void].3 atomicPolygon[].4 atomicPolygon::convexPolygon.5 triangle[]. 6 triangle::atomicPolygon.7 triangle[hypotenuse *=> segmentLine]8 triangle[side *=>> segmentLine].9 segmentLine[].10 segmentLine[length *=> float].

0..1

AtomicPolygon

ConvexPolygon

/ right : boolean

SegmentLine

length : float

Triangle

+/ hypotenuse

0..1 3

+side

3

Page 27: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG27

1 module ClassTransformations;2 create OUT : Flora from IN : UMLOCL;3 rule Class2Flora{4 from c : UMLOCL!Class5 using {allStereotypes : Sequence(UMLOCL!Stereotype) = c.stereotype; }6 to7 class : Flora!SubClassFAtom( subClass <- subClass),8 subClass : Flora!Symbol(9 ground <- true,10 name <- c.name ),11 att : Flora!AttributeSignatureSpecification (12 feature <- umlLabel,13 host <- hostLabel,14 inheritable <- true,15 multiplicity <- Flora!MultiplicityKind::single,16 type <- typeLabel),17 umlLabel : Flora!Symbol( name <- 'uml'),18 hostLabel : Flora!Symbol( name <- c.name),19 typeLabel : Flora!Symbol(name <- 'umlMeta'),20 umlClassInstance : Flora!InstanceFAtom (21 object <- objectLabel,22 floraClass <- classLabel),23 objectLabel : Flora!Symbol(name <- thisModule.getOid(c.name, 'umlClass')),24 classLabel : Flora!Symbol( name <- 'umlClass'),25 umlMetaInstance : Flora!InstanceFAtom (26 object <- umlMetaObject,27 floraClass <- umlMetaClass),28 umlMetaObject : Flora!Symbol(name <- thisModule.getOid(c.name, 'umlMeta')),29 umlMetaClass : Flora!Symbol( name <- 'umlMeta'),..

ATL Transformation

7 class : Flora!SubClassFAtom( subClass <- subClass),8 subClass : Flora!Symbol(9 ground <- true,10 name <- c.name ),

Page 28: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG28

Class Diagrams Transformation

0..1

AtomicPolygon

ConvexPolygon

/ right : boolean

SegmentLine

length : float

Triangle

+/ hypotenuse

0..1 3

+side

3

1 convexPolygon[].2 convexPolygon[right *=> void].

3 atomicPolygon[].4 atomicPolygon::convexPolygon.

5 triangle[]. 6 triangle::atomicPolygon.7 triangle[hypotenuse *=> segmentLine]8 triangle[side *=>> segmentLine].

9 segmentLine[].10 segmentLine[length *=> float].

Page 29: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG29

1 module AttributeTransformations;2 create OUT : Flora from IN : UMLOCL; ...13 rule Attribute2Flora{14 from15 a : UMLOCL!Attribute16 using {17 Oid_umlAttr : String = thisModule.new('umlAttr'); ...20 }21 to22 att : Flora!AttributeSignatureSpecification (23 feature <- featureLabel,24 host <- hostLabel,25 inheritable <- true,26 multiplicity <- a.getMultiplicity(),27 type <- attTypeLabel),28 featureLabel : Flora!Symbol(name <- a.name),30 hostLabel : Flora!Symbol(name <- a.owner.name),31 attTypeLabel : Flora!Symbol(name <- a.type.name)32 ...

ATL Transformation

Page 30: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG30

Class Diagrams Transformation

0..1

AtomicPolygon

ConvexPolygon

/ right : boolean

SegmentLine

length : float

Triangle

+/ hypotenuse

0..1 3

+side

3

1 convexPolygon[].

2 convexPolygon[right *=> void].3 atomicPolygon[].4 atomicPolygon::convexPolygon.5 triangle[]. 6 triangle::atomicPolygon.7 triangle[hypotenuse *=> segmentLine]8 triangle[side *=>> segmentLine].9 segmentLine[].

10 segmentLine[length *=> float].

Page 31: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG31

Invariant Transformation

/* OCL invariant specification */context class inv inv_name:OCLExp

/* Flora code */#violated_inv_name(Self) :- Self:class and

naf (OCLExp)

Page 32: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG32

Derive Transformation

/* OCL specification for a derived property of a Class*/context Class::property : propertyTypederive: OCLExp

/* Flora code */Self[property *-> Result] :- Self:class and

Result = OCLExp.

Page 33: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG33

Pre and Post-conditions Transformation

/* OCL specification of the Class::operation method pre and post-conditions */context Class::operation(para : paramType) : booleanpre: preOCLExppost: postOCLExp

/* Flora code */Self[operation(Param)] :- Self:class and preOCLExp and

postOCLExp.

/* Flora code */Self[operation(Param) *-> Result] :- Self:class and

preOCLExp and Result = postOCLExp.

/* OCL specification of the Class::operation method pre and post-conditions */context Class::operation(para : paramType) : NonBooleanTypepre: preOCLExppost: postOCLExp

Page 34: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG34

CallExp Transformation

/* OCL implies operation */a implies b

/* Flora code */naf(a) or b

Page 35: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG35

Outline

1 Introduction and Motivation2 MDE and OMG Languages3 OOLP4 MODELOG5 Case Study6 Related Works7 Conclusions

Page 36: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG36

Case Study

• Representative of many classical AI tasks and OO modeling

• Rich application: structural and behavioral

• I have created Triangram– Table initially composed of atomic triangles– Goal: assembly a regular hexagon according to some rules

• Formed by:– UML class diagram containing 27 classes and diver relationships– More than 400 lines of OCL code– Eight Object diagrams illustrating the tans on the table initial

setting– More than 1000 lines of Flora code

Page 37: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG37

Triangram

tri1

tri2 tri3

tri5 tri7

3

3

3

33

4

4 4

4

3 3

5

3

4 5s11 s13

s12

s23s21

s22 s31

s32 s33

tri4

3

4 4

s41

s42 s43

s71 s72

s73

tri8

3

33s81 s82

s83

s51 s52

s53

tri6

4

3 3s61 s62

s63

tri1 + tri2 = rectangle1

3

4

5s11

s12

3

45

s21

s22

44

s33

rectangle1 + tri3 = pentagon1

3

4

5s11

s12

3

45

s21

s22

s32

3

44

s43

s42

44

s33

pentagon1 + tri4 = hexagon1

3

4

5s11

s12

3

45

s21

s22

s32

Page 38: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG38

Triangram Flora code

/* Flora code generated containing the table setting shown in Fig. 5.17 */1 bot:robot.2 bot[table->t1].3 t1:table[tans ->> {tri1, tri2, tri3, tri4, tri5, tri6, tri7, tri8}]. /* Flora code generated from the triangle tri1 shown in Fig. 5.17 */4 tri1:scaleneTriangle.5 tri1[right].6 s11:segmentLine[length -> 3].7 s12:segmentLine[length -> 4].8 s13:segmentLine[length -> 5].9 tri1[side ->> {s11, s12, s13}].10 tri1[triangleSide ->> {ts11, ts12, ts13}].11 ts11:triangleSide[triangle->tri1, side->s11, position->left, adjacent->>{ts12, ts13}].12 ts12:triangleSide[triangle->tri1, side->s12, position->base, adjacent->>{ts11, ts13}].13 ts13:triangleSide[triangle->tri1, side->s13, position->right, adjacent->>{ts11, ts12}].14 s11[triangleSide->>ts11].15 s12[triangleSide->>ts12].16 s13[triangleSide->>ts13].

Page 39: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG39

Triangram Flora Code

/* OCL invariant inv_9 */context Triangle inv inv_9:right implies hypotenuse->size() = 1

/* Flora code from inv_9 mapping */1 #violated_inv9(Self) :- Self:triangle and2 naf(3 (naf (Self[right])) or4 (Col = collectbag{Var | Self[hypotenuse->Var]} and 5 size(Col, 1))6 ).

/* Flora code generated containing a culprit object*/1 tri1:scaleneTriangle.2 tri1[right].3 s11:segmentLine[length -> 3].4 s12:segmentLine[length -> 4].5 s13:segmentLine[length -> 5].6 tri1[side ->> {s11, s12, s13}].7 tr1[hypotenuse -> s11].8 tri1[hypotenuse -> s12].

Flora-2 ?- #violated_inv9(X).YesX = tri1

/* Flora code from inv_9 mapping */

1 #violated_inv9(Self) :- Self:triangle and2 naf(3 OCLExp

6 ).

/* Flora code from inv_9 mapping */1 #violated_inv9(Self) :- Self:triangle and2 naf(

3 (naf (Self[right])) or4 (Col = collectbag{Var | Self[hypotenuse->Var]} and 5 size(Col, 1))6 ).

Page 40: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG40

Outline

1 Introduction and Motivation2 MDE and OMG Languages3 OOLP4 MODELOG5 Case Study6 Related Works7 Conclusions

Page 41: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG41

Related Works

• Not executable, very strict subset of UML/OCL 1.4 – [Kyas and Fecher, 04] maps UML/OCL to PVS input language– [Beckert et al., 02] maps UML/OCL 1.4 to Dynamic Logic– [Oliver, 99] purposes animation for validation– [Berardi, 02] maps only UML class diagrams to DLs– [Shen et al., 02] maps tor ASM– [Lilius and Paltor, 99] maps only UML to PROMELA– [Henocque, 04] maps UML/OCL to Z (only OCL invariants)– [Roe et al, 03] maps UML/OCL 1.4 to Object-Z

• Executable, but without a formal semantics– [Gray and Schach, 00] maps UML/OCL 1.4 to Prolog++

• Prolog++ does not have a formal semantics• Only for invariants• Fully manual• Prolog ++ does not support transactions nor meta-programming

Page 42: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG42

Related Works

• [Marcano and Levy, 02] and [Ledang and Souquières, 02] map UML/OCL to B (following a MDE approach)– Contemplates OCL 1.4– OCL metamodel pursued is not that provided by the OMG– Transformations expressed in T– B is no object-oriented– B does not support transactional operations– B does not support meta-programming– The Theorem-prover ATELIER B proves automatically about

70% of proof obligations

Page 43: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG43

Related Works

• Semantic Web Service– [Baclawski et al., 01] and [Cranefield, 01] maps UML to RDF

abd DAML-OIL, respectively– Only structural constraints– Generating only ontologies (Not Semantic Web Services)

Page 44: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG44

MODELOG through UML-OCL to

Flora mapping

Model-Driven Engineering-Automatic generation of

complete structural and

behavioral code

-Real-size example fully

adopting a MDE approach

Formal Development

and model-checking- Integrated semantics for

UML and OCL

-Verification of executable

formal model

Semantic WebService

Development

SWS representation

and reasoning

Agent OrientedEngineering

- combine strengths of AO

extensions of OO and

Logic/Formal methods

- Automatic code generation

of OO Logic agents

Agile Development

- Fast prototyping

- Automatic structural and

behavioral code generation

MODELOG

OCL Mini-course in

WMF 2003

WMF and ENTCS

2003

SBLP and JUCS2003

MoDELS 2005

WisME-MODELS

2004

WIRE Talk

Page 45: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG45

Outline

1 Introduction and Motivation2 MDE and OMG Languages3 OOLP4 MODELOG5 Case Study6 Related Works7 Conclusions

Page 46: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG46

Limitations

• Transformation definitions concerning OCL are not complete

• Transformations are not completely implemented

• Class diagram module does not cover active classes

• Flora metamodel does not cover all extra logical predicates

• Incomplete OCL specification of Flora metamodel

• EMF objects are generated instead of full textual Flora code

Page 47: MODELOG – Model- Oriented Development with Executable Logical Object Generation Franklin Ramalho Universidade Federal de Pernambuco PhD candidate Jacques

UFCG47

Future Work

• MODELOG as QVT or ATL transformation engine

• MODELOG as KobrA model checking engine

• MODELOG as Semantic Web Ontology and agent CASE tool

• Using metamodels for specifying and integrating formal semantics

• Proving conformance of the generated Flora code and the forthcoming UML and OCL formal semantics

• Extending MODELOG to cover other UML diagrams

• Specify Object diagram transformations