applying sos to mde

74
Semantics SOS DSL’s SOS for a DSL Conclusions Applying Structural Operational Semantics to MDE Define the Semantics of your DSL Tjerk Wolterink University of Twente March 30, 2009 1 / 45 Applying , Structural Operational Semantics , to MDE

Upload: tjerk-wolterink

Post on 10-May-2015

1.194 views

Category:

Technology


0 download

DESCRIPTION

Lecture presentation for the Advanced Design of Software Architectures 2 Course

TRANSCRIPT

Page 1: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Applying

Structural Operational Semanticsto MDE

Define the Semantics of your DSL

Tjerk Wolterink

University of Twente

March 30, 2009

1 / 45

Applying , Structural Operational Semantics , to MDE

Page 2: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Outline

1 Semantics

2 Structural Operational Semantics

3 Domain Specific Languages

4 Structural Operational Semantics for a DSL in MDE

5 Conclusions

2 / 45

Applying , Structural Operational Semantics , to MDE

Page 3: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Introduction

Observation MDE, generally, lacks formal semantics

Problem Statement Can Structural Operational Semantics (SOS)be successfully applied to MDE?

Research Objectives Make SOS useful for MDEProviding a semantic language named SemLang

Proof by example: apply SemLang

Build a tool, the Semantic Engine to simulate models

3 / 45

Applying , Structural Operational Semantics , to MDE

Page 4: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Outline

1 Semantics

2 Structural Operational Semantics

3 Domain Specific Languages

4 Structural Operational Semantics for a DSL in MDE

5 Conclusions

4 / 45

Applying , Structural Operational Semantics , to MDE

Page 5: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Language Definition

Abstract Syntax Determines the form and structure of programs

Textual languages, Iconic languages, DiagrammiclanguagesSpecification for parsers

Semantics Models the computational meaning of each program

Specification for compilers/interpretersDimension: Informal vs FormalDimension: Static vs Dynamic

5 / 45

Applying , Structural Operational Semantics , to MDE

Page 6: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Language Definition

Abstract Syntax Determines the form and structure of programs

Textual languages, Iconic languages, DiagrammiclanguagesSpecification for parsers

Semantics Models the computational meaning of each program

Specification for compilers/interpretersDimension: Informal vs FormalDimension: Static vs Dynamic

5 / 45

Applying , Structural Operational Semantics , to MDE

Page 7: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Informal Semantics

Meaning of a language is described using human readable text

Example:”’Semantics of Java && operator:

The && operator perform Conditional-AND operations on twoboolean expressions. This operator exhibit ”short-circuiting”behaviour, which means that the second operand is evaluated onlyif needed.

Advantages easy to read, easy to understand, easy to create

Disadvantages imprecise, ambiguous, not computer-readable, notuseful for mathematical techniques (like proofs,model checking etc.)

6 / 45

Applying , Structural Operational Semantics , to MDE

Page 8: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Informal Semantics

Meaning of a language is described using human readable text

Example:”’Semantics of Java && operator:

The && operator perform Conditional-AND operations on twoboolean expressions. This operator exhibit ”short-circuiting”behaviour, which means that the second operand is evaluated onlyif needed.

Advantages easy to read, easy to understand, easy to create

Disadvantages imprecise, ambiguous, not computer-readable, notuseful for mathematical techniques (like proofs,model checking etc.)

6 / 45

Applying , Structural Operational Semantics , to MDE

Page 9: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Formal Semantics

Semantic mapping from syntax L to a semantic domain S .M : L → S

Semantic domain: well known mathematical domain: naturalnumbers, graphs, labelled transition systems etc.

Semantic mapping: describes how the syntax relates to thesemantic domain

Approaches: Axiomatic, Denotational, Graph Transformations,Structural Operational Semantics

Advantages precise, computer-readable, useful for mathematicaltechniques (like proofs,system validation, simulationetc.)

Disadvantages often difficult to read, understand, create. Requiresunderstanding of the semantic domain.

7 / 45

Applying , Structural Operational Semantics , to MDE

Page 10: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Formal Semantics

Semantic mapping from syntax L to a semantic domain S .M : L → S

Semantic domain: well known mathematical domain: naturalnumbers, graphs, labelled transition systems etc.

Semantic mapping: describes how the syntax relates to thesemantic domain

Approaches: Axiomatic, Denotational, Graph Transformations,Structural Operational Semantics

Advantages precise, computer-readable, useful for mathematicaltechniques (like proofs,system validation, simulationetc.)

Disadvantages often difficult to read, understand, create. Requiresunderstanding of the semantic domain.

7 / 45

Applying , Structural Operational Semantics , to MDE

Page 11: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Static vs Dynamic Semantics

Static semantics models compile-time checks

Checks that can be performed before runningWell formednessType checking

Example: Type checking a type cast

(TypeA)new TypeB()Check that TypeA is a subclass of TypeB

Dynamic semantics models run-time behaviour

Concerned with the observable behaviour of a running programDescription of computational steps

Example: Evaluation of If-Expressions

if(a) then b

if a evaluates to true then evaluate b

8 / 45

Applying , Structural Operational Semantics , to MDE

Page 12: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Static vs Dynamic Semantics

Static semantics models compile-time checks

Checks that can be performed before runningWell formednessType checking

Example: Type checking a type cast

(TypeA)new TypeB()Check that TypeA is a subclass of TypeB

Dynamic semantics models run-time behaviour

Concerned with the observable behaviour of a running programDescription of computational steps

Example: Evaluation of If-Expressions

if(a) then b

if a evaluates to true then evaluate b

8 / 45

Applying , Structural Operational Semantics , to MDE

Page 13: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Outline

1 Semantics

2 Structural Operational Semantics

3 Domain Specific Languages

4 Structural Operational Semantics for a DSL in MDE

5 Conclusions

9 / 45

Applying , Structural Operational Semantics , to MDE

Page 14: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Overview of Structural Operational Semantics

(SOS & MSOS)

MSOS is Modular SOS

Semantic domain of SOS is a labelled terminal transition system(LTTS)

Definition

A LTTS is a quadruple (Q,T ,A,→) with Q as set of states, a set A oflabels α. A relation →⊆ Q × A × Q of labelled transitions ((s, α, s‘) is

written as sα

−→ s‘), and a set T ⊆ Q of terminal configurations such

that sα

−→ s‘ implies s /∈ T

SOS Specification consists of

Definitions of the sets Q, A and the end states T

A set of rules that specify the transition relation →

10 / 45

Applying , Structural Operational Semantics , to MDE

Page 15: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Overview of Structural Operational Semantics

(SOS & MSOS)

MSOS is Modular SOS

Semantic domain of SOS is a labelled terminal transition system(LTTS)

Definition

A LTTS is a quadruple (Q,T ,A,→) with Q as set of states, a set A oflabels α. A relation →⊆ Q × A × Q of labelled transitions ((s, α, s‘) is

written as sα

−→ s‘), and a set T ⊆ Q of terminal configurations such

that sα

−→ s‘ implies s /∈ T

SOS Specification consists of

Definitions of the sets Q, A and the end states T

A set of rules that specify the transition relation →

10 / 45

Applying , Structural Operational Semantics , to MDE

Page 16: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Overview of SOS

States are sentences that conform to an extension of the abstractsyntax: value-added syntax

Transitions are specified inductively by rules

A single transition can be proven by a set of rulesRules alter the structure of the states

Graphics from Structural Operational Semantics 1981 by G.D. Plotkin

11 / 45

Applying , Structural Operational Semantics , to MDE

Page 17: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Rules in SOS

A rule consist of transition assertions tt‘

−→ t“

The terms t, t‘, t“ are language sentences that may containmeta-variables

Rule Definitionc1, · · · , cn

c

A rule has zero or more conditions c1, · · · , cn and a conclusion c

c1, · · · , cn, c are transition assertions (tt‘

−→ t“)

c1, · · · , cn can also be simple assertions (equations)

Informal meaning: if c1, · · · , cn then c

Example if rule for a pseudo language

e1 → e1‘

if e1 then e2 → if e1‘ then e2

12 / 45

Applying , Structural Operational Semantics , to MDE

Page 18: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Rules in SOS

A rule consist of transition assertions tt‘

−→ t“

The terms t, t‘, t“ are language sentences that may containmeta-variables

Rule Definitionc1, · · · , cn

c

A rule has zero or more conditions c1, · · · , cn and a conclusion c

c1, · · · , cn, c are transition assertions (tt‘

−→ t“)

c1, · · · , cn can also be simple assertions (equations)

Informal meaning: if c1, · · · , cn then c

Example if rule for a pseudo language

e1 → e1‘

if e1 then e2 → if e1‘ then e2

12 / 45

Applying , Structural Operational Semantics , to MDE

Page 19: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Rules define the Transition Relation →

Given a set of rules, a triple (s, α, s‘) is in the transition relation ifand only if a finite branching tree can be formed that followssatisfies the following conditions:

1 All nodes are labelled by elements of Q × A × Q

2 the root nodes is labelled by (s, α, s‘)

3 for each node with n child nodes there is a rule c1,··· ,cn

cand an

interpretation of the meta-variables such that/

the label of the node is the interpretation of c

the labels of the child nodes are the interpretations of c1, · · · , cn.

Concrete examples will be given to make it easier to understand

13 / 45

Applying , Structural Operational Semantics , to MDE

Page 20: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Rules define the Transition Relation →

Given a set of rules, a triple (s, α, s‘) is in the transition relation ifand only if a finite branching tree can be formed that followssatisfies the following conditions:

1 All nodes are labelled by elements of Q × A × Q

2 the root nodes is labelled by (s, α, s‘)

3 for each node with n child nodes there is a rule c1,··· ,cn

cand an

interpretation of the meta-variables such that/

the label of the node is the interpretation of c

the labels of the child nodes are the interpretations of c1, · · · , cn.

Concrete examples will be given to make it easier to understand

13 / 45

Applying , Structural Operational Semantics , to MDE

Page 21: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Example: Simple Expression Lang

First define the valid structure of a program, the syntax:

Abstract syntax

Numbers: n ∈ N = {0, 1, 2, · · · }Binary Operators: bop ∈ Bop = {+,−, ∗, · · · }Expressions: e ∈ Exp = n | e0 bop e1

Example program

(2 + 3) ∗ 8

Exp

N

8

Bop

*

Exp

N

3

Bop

+

N

2

14 / 45

Applying , Structural Operational Semantics , to MDE

Page 22: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Simple Expressions Lang Semantics

The states Q are sentences of the language

Numbers N = {0, 1, 2, · · · } are end states T

No labels are used A = ∅

15 / 45

Applying , Structural Operational Semantics , to MDE

Page 23: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Simple Expressions Lang Semantics

The transition relation → is specified by a set of rules:

Evaluate lhs Rulee0 → e0‘

e0 bop e1 → e0‘ bop e1(1)

Evaluate rhs Rule

e1 → e1‘

n0 bop e1 → n0 bop e1‘(2)

15 / 45

Applying , Structural Operational Semantics , to MDE

Page 24: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Simple Expressions Lang Semantics

Evaluate plus Rule

bop = + n = n0 + n1

n0 bop n1 → n(1)

Evaluate multiply Rule

bop = ∗ n = n0 ∗ n1

n0 bop n1 → n(2)

15 / 45

Applying , Structural Operational Semantics , to MDE

Page 25: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Computation trace

First transition

(2 + 3) ∗ 8 → 5 ∗ 8

Transition proof

Initial state(2 + 3) ∗ 8

16 / 45

Applying , Structural Operational Semantics , to MDE

Page 26: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Computation trace

First transition

(2 + 3) ∗ 8 → 5 ∗ 8

Transition proof

2 + 3 → e0‘

(2 + 3) ∗ 8 → e0‘ ∗ 8

By applying the lhs evaluation rule:

e0 → e0‘

e0 bop e1 → e0‘ bop e1

16 / 45

Applying , Structural Operational Semantics , to MDE

Page 27: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Computation trace

First transition

(2 + 3) ∗ 8 → 5 ∗ 8

Transition proof

bop = + e0‘ = n0 + n1

2 + 3 → e0‘(2 + 3) ∗ 8 → e0‘ ∗ 8

By applying the evaluate plus rule:

bop = + n = n0 + n1

n0 bop n1 → n

16 / 45

Applying , Structural Operational Semantics , to MDE

Page 28: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Computation trace

First transition

(2 + 3) ∗ 8 → 5 ∗ 8

Transition proof

+ = + e0‘ = 2 + 3

2 + 3 → e0‘2 + 3 ∗ 8 → e0‘ ∗ 8

By substituting the meta variables

bop = + n0 = 2 n1 = 3

16 / 45

Applying , Structural Operational Semantics , to MDE

Page 29: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Computation trace

First transition

(2 + 3) ∗ 8 → 5 ∗ 8

Transition proof

Full proof+ = + e0‘ = 5

2 + 3 → 52 + 3 ∗ 8 → 5 ∗ 8

by substituting e0‘e0‘ = 2 + 3 = 5

16 / 45

Applying , Structural Operational Semantics , to MDE

Page 30: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Outline

1 Semantics

2 Structural Operational Semantics

3 Domain Specific Languages

4 Structural Operational Semantics for a DSL in MDE

5 Conclusions

17 / 45

Applying , Structural Operational Semantics , to MDE

Page 31: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Generic vs Specific Languages

GPL General PurposeLanguage

Large

Gap between languagedomain and problem domain

Users: software-engineers,programmers

Examples

C++, Java, Fortran, Lisp

DSL Domain SpecificLanguage

Small ( often extensions ofGPLs (embedded))

Closer to problem domain:captures domain knowledge

Users: Same as DSL plusdomain-experts, end-users

Examples

SQL, BNF, HTML, RegExp,XSLT

18 / 45

Applying , Structural Operational Semantics , to MDE

Page 32: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Defining a DSL

Executable vs Static DSL’s

Define domain concepts and relations in ametamodel

Plays the role of an abstract syntaxCaptures domain knowledge

Define concrete syntax (optionally)

Textually or visualProvides easier editing

Define semantics

Informally using code generation to a GPLFormally both dynamic and static semantics

19 / 45

Applying , Structural Operational Semantics , to MDE

Page 33: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Defining a DSL

Executable vs Static DSL’s

Define domain concepts and relations in ametamodel

Plays the role of an abstract syntaxCaptures domain knowledge

Define concrete syntax (optionally)

Textually or visualProvides easier editing

Define semantics

Informally using code generation to a GPLFormally both dynamic and static semantics

19 / 45

Applying , Structural Operational Semantics , to MDE

Page 34: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Defining a DSL

Executable vs Static DSL’s

Define domain concepts and relations in ametamodel

Plays the role of an abstract syntaxCaptures domain knowledge

Define concrete syntax (optionally)

Textually or visualProvides easier editing

Define semantics

Informally using code generation to a GPLFormally both dynamic and static semantics

19 / 45

Applying , Structural Operational Semantics , to MDE

Page 35: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Outline

1 Semantics

2 Structural Operational Semantics

3 Domain Specific Languages

4 Structural Operational Semantics for a DSL in MDE

5 Conclusions

20 / 45

Applying , Structural Operational Semantics , to MDE

Page 36: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Defining the Semantics of a DSL

Take an MDE approach: everything is a model

Define a DSL SemLang for defining semantics of other DSL’s

SemLang: The Semantic Language DSL

Builds upon SOS and MSOS

21 / 45

Applying , Structural Operational Semantics , to MDE

Page 37: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

SOS vs SemLang

SOS & MSOS

Abstract Syntax definesLanguage Structure

Sentences are states

→ States are trees

Rules contain syntax

SemLang

MetaModel defines DSLstructure

Models are states

→ states are graphs

Rules contain objectpatterns

SOS Rule

e1 → e1‘

if e1 then e2 → if e1‘ then e2

22 / 45

Applying , Structural Operational Semantics , to MDE

Page 38: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

SOS vs SemLang

SemLang Rule

C → C‘

IfExp(e1 = C, e2 = E) → IfExp(e1 = C‘, e2 = E)

22 / 45

Applying , Structural Operational Semantics , to MDE

Page 39: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Understanding SemLang

Understanding SemLang by example

For each DSL we define

MetaModelSample model (sample program)Semantics in SemLang

The sample model will be executed.

The DSL’s:

Simple Imperative LanguageActivity Diagram Language

23 / 45

Applying , Structural Operational Semantics , to MDE

Page 40: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Understanding SemLang

Understanding SemLang by example

For each DSL we define

MetaModelSample model (sample program)Semantics in SemLang

The sample model will be executed.

The DSL’s:

Simple Imperative LanguageActivity Diagram Language

23 / 45

Applying , Structural Operational Semantics , to MDE

Page 41: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Simple Imperative Language: MetaModel

24 / 45

Applying , Structural Operational Semantics , to MDE

Page 42: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Simple Imperative Language: Sample Model

Seq

Seq

c1

Assign

c0

Integer:10

Var

b

name

BinaryExp

Number

lhs

Var

rhs

Plus

bop

Assign

e

b

name

BinaryExp

lhs

Number

rhs

Minus

bop

Integer:3

val

Assign

e

a

name

Number

val

Integer:10

val

a

name

c0 c1

a

e name

25 / 45

Applying , Structural Operational Semantics , to MDE

Page 43: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Binary Expressions Rule

Computes = {Nil,Number}

L→NL

BinExp(lhs=L,bop=O,rhs=R)→BinExp(lhs=NL,bop=O,rhs=R) (3)

R→NR

BinExp(lhs=L,bop=O,rhs=R)→BinExp(lhs=L,bop=O,rhs=NR) (4)

26 / 45

Applying , Structural Operational Semantics , to MDE

Page 44: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Binary Expressions Rule

O∈PlusBinExp(lhs=L,bop=O,rhs=R)→Number(val=(L.val+R.val)) (3)

O∈MinusBinExp(lhs=L,bop=O,rhs=R)→Number(val=(L.val−R.val)) (4)

26 / 45

Applying , Structural Operational Semantics , to MDE

Page 45: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Rules for Seq commands

C0 → NC

Seq (c0 = C0, c1 = C1) → Seq (c0 = NC, c1 = C1)(5)

Seq (c0 = C0 , c1 = C1) → C1 (6)

27 / 45

Applying , Structural Operational Semantics , to MDE

Page 46: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Imperative Language requires a Store

In order to evaluate both a Var and a Assignment we need a store.

A store is defined as a function

Definition

A function is defined as:

functionName : DomainClass → RangeClass

A function contains zero or more tuples k 7→ v

{k1 7→ v1, k2 7→ v2, . . . , kn−1 7→ vn−1, kn 7→ vn}

28 / 45

Applying , Structural Operational Semantics , to MDE

Page 47: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Operations over Functions

Definition

Function invocation: If a is a function then a(k) equals:

a(k) =

{

v , k 7→ v ∈ a

Nil , k 7→ v /∈ a

Definition

Override expression: If a and b are functions then a [b] equals:

a [b] (k) =

{

vb , k 7→ vb ∈ b

va , k 7→ va ∈ a\b

29 / 45

Applying , Structural Operational Semantics , to MDE

Page 48: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Including Stores in SemLang

A state is now a tuple 〈M,F 〉 where:

1 M is the current model2 F is a set of functions

The functions in F represent the store

Rules can read and update functions in F

The transition relation tt‘

−→ t“ is extended:

1 Function invocations are allowed in the terms t, t‘ and t“2 The label t‘ can now contain function assignments

Function assignment format

tstoreName′=<functionexpression>−−−−−−−−−−−−−−−−−−−−→ t“

30 / 45

Applying , Structural Operational Semantics , to MDE

Page 49: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Including Stores in SemLang

A state is now a tuple 〈M,F 〉 where:

1 M is the current model2 F is a set of functions

The functions in F represent the store

Rules can read and update functions in F

The transition relation tt‘

−→ t“ is extended:

1 Function invocations are allowed in the terms t, t‘ and t“2 The label t‘ can now contain function assignments

Function assignment format

tstoreName′=<functionexpression>−−−−−−−−−−−−−−−−−−−−→ t“

30 / 45

Applying , Structural Operational Semantics , to MDE

Page 50: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Store definition and rules

store : String → Number (7)

Var (name = N) → store (N) (8)

E → NE

Assign (name = N, e = E) → Assign (name = N, e = NE)(9)

Assign (name = N, e = E )store′=store[{N 7→E}]−−−−−−−−−−−−−→ Nil (10)

31 / 45

Applying , Structural Operational Semantics , to MDE

Page 51: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Simulation

Model Simulation

Simulating the model using the tool: Semantic Engine

32 / 45

Applying , Structural Operational Semantics , to MDE

Page 52: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

First Transition: Proof

C0 → NC

Seq (c0 = C0, c1 = C1) → Seq (c0 = NC, c1 = C1)

33 / 45

Applying , Structural Operational Semantics , to MDE

Page 53: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

First Transition: Proof

Assign (name = N, e = E )store′=store[{N 7→E}]−−−−−−−−−−−−−→ Nil

Seq (c0 = C0, c1 = C1) → Seq (c0 = NC, c1 = C1)

33 / 45

Applying , Structural Operational Semantics , to MDE

Page 54: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

First Transition: Proof

Assign (”a” = N,Number(val = 10) = E )store′=store[{N 7→E}]−−−−−−−−−−−−−→ Nil

Seq (c0 = C0, c1 = C1) → Seq (c0 = NC, c1 = C1)

33 / 45

Applying , Structural Operational Semantics , to MDE

Page 55: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

First Transition: Proof

Assign (”a” = N,Number(val = 10) = E )store′=store[{”a”7→Number(val=10)}]−−−−−−−−−−−−−−−−−−−−−−−→ Nil

Seq (c0 = C0, c1 = C1) → Seq (c0 = NC, c1 = C1)

33 / 45

Applying , Structural Operational Semantics , to MDE

Page 56: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

First Transition: Proof

Assign (”a” = N,Number(val = 10) = E )store′=∅[{”a”7→Number(val=10)}]−−−−−−−−−−−−−−−−−−−−−→ Nil

Seq (c0 = C0, c1 = C1) → Seq (c0 = NC, c1 = C1)

33 / 45

Applying , Structural Operational Semantics , to MDE

Page 57: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

First Transition: Proof

Assign (”a” = N,Number(val = 10) = E )store′={”a”7→Number(val=10)}−−−−−−−−−−−−−−−−−−−→ Nil

Seq (c0 = C0, c1 = C1) → Seq (c0 = NC, c1 = C1)

33 / 45

Applying , Structural Operational Semantics , to MDE

Page 58: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

First Transition: Proof

Assign (”a” = N,Number(val = 10) = E )store′={”a”7→Number(val=10)}−−−−−−−−−−−−−−−−−−−→ Nil

Seq (c0 = C0, c1 = C1) → Seq (c0 = Nil, c1 = C1)

33 / 45

Applying , Structural Operational Semantics , to MDE

Page 59: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

First Transition: Proof

Seq (c0 = C0, c1 = C1)store′={”a” 7→Number(val=10)}−−−−−−−−−−−−−−−−−−−→

Seq (c0 = Nil, c1 = C1)

33 / 45

Applying , Structural Operational Semantics , to MDE

Page 60: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Activity Diagram Lang: MetaModel

34 / 45

Applying , Structural Operational Semantics , to MDE

Page 61: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Activity Diagram Lang: MetaModel

34 / 45

Applying , Structural Operational Semantics , to MDE

Page 62: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Activity Diagram Lang: MetaModel

34 / 45

Applying , Structural Operational Semantics , to MDE

Page 63: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Activity Diagram Lang: Example Model

35 / 45

Applying , Structural Operational Semantics , to MDE

Page 64: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Activity Diagram Lang: Example Model

Integer:5

Eq

test

c

Diagram

StopNode

nodes

StartNode

nodes

Assign

nodesVarDec

nodes

Test

nodes

b a

a

Plus

a

Integer:1 BinaryExp

bop

Var

lhs

Number

rhs

a

name

end

name

Number

Integer:1

value

namenext

name varName

BinaryExp

e

next

name varName

Number

e next

boprhs

Var

lhs

a

name

value name enext alternative

value

35 / 45

Applying , Structural Operational Semantics , to MDE

Page 65: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Activity Diagram Lang: Rules

Computes = {StopNode,Number,Bool} (11)

store : String → Object (12)

Diagram (nodes = NS 〈∃n ∈ StartNode〉) → n (13)

StartNode (next = N) → N (14)

36 / 45

Applying , Structural Operational Semantics , to MDE

Page 66: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Activity Diagram Lang: Test Rules

C → NC

Test (name = N, e = C,next = NN, alternative = A)→ Test (name = N, e = NC,next = NN, alternative = A)

(15)

C .value

Test (name = N, e = C ,next = NN, alternative = A) → NN

(16)

¬C .value

Test (name = N, e = C ,next = NN, alternative = A) → A

(17)

37 / 45

Applying , Structural Operational Semantics , to MDE

Page 67: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Activity Diagram Lang: VarDec

E → NE

VarDec (name = N, varName = VN, e = E,next = NN)→ VarDec (name = N,name = VN, e = NE,next = NN)

(18)

VarDec (name = N, varName = VN, e = E ,next = NN)store′=storeρ[{VN7→E}]−−−−−−−−−−−−−−→ NN (19)

38 / 45

Applying , Structural Operational Semantics , to MDE

Page 68: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Activity Diagram Lang: Assign Rules

E → NE

Assign (name = N, varName = VN, e = E,next = NN)→ Assign (name = N, varName = VN, e = NE,next = NN)

(20)

Assign (name = N, varName = VN, e = E ,next = NN)store′=storeρ[{VN7→E}]−−−−−−−−−−−−−−→ NN (21)

39 / 45

Applying , Structural Operational Semantics , to MDE

Page 69: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Simulation

Model Simulation

Simulating the model using the tool: Semantic Engine

40 / 45

Applying , Structural Operational Semantics , to MDE

Page 70: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Outline

1 Semantics

2 Structural Operational Semantics

3 Domain Specific Languages

4 Structural Operational Semantics for a DSL in MDE

5 Conclusions

41 / 45

Applying , Structural Operational Semantics , to MDE

Page 71: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Conclusions

SOS can be applied to MDE!

With some adjustmentsProof of conceptTool support for simulation

Future Research

Extend SemLang

Extend tool supportModel checkingCompiler Interpreter generation

42 / 45

Applying , Structural Operational Semantics , to MDE

Page 72: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Differences with Graph Transformations

Graph Transformations SemLang

Single rule for a transition

Rule matching hard:NP-complete

Sound theoretic basis

Expressive

Better graph awareness

Less use of metamodel

Not easy to map tointerpreters

Modularity may beproblematic

Multiple rule for a transition

Rule matching easy

Theoretic basis work inprogress

Limited Expressiveness(future research)

Locally tree oriented

Uses metamodel knowledge

Related to interpreter design

pattern

MSOS aimed at modularity(future research)

43 / 45

Applying , Structural Operational Semantics , to MDE

Page 73: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

Any Questions?

44 / 45

Applying , Structural Operational Semantics , to MDE

Page 74: Applying SOS to MDE

Semantics SOS DSL’s SOS for a DSL Conclusions

References I

D. Harel and B. Rumpe. Semantic of semantics Springer LNCS,2004.

Peter D. Mosses. Formal semantics of programming languages,an overview. Electronic Notes in Theoretical Computer Science

148, pages 41–73, 2006.

Gordon D. Plotkin. A structural approach to operationalsemantics. Technical report, University of Aarhus, Denmark, 1981.

Peter D. Mosses. Modular structural operational semantics.Journal of Logic and Algebraic Programming 60-61, pages 195–228,2004.

45 / 45

Applying , Structural Operational Semantics , to MDE