The document discusses applying structural operational semantics (SOS) to model-driven engineering (MDE). It introduces SOS and outlines how it can be used to formally define the semantics of domain-specific languages (DSLs) in MDE. The document presents an example of using SOS to define the semantics of a simple expression language to demonstrate how SOS rules specify the transition relation between language states. The goal is to make SOS useful for MDE by providing a semantic language and tool to simulate models defined using DSLs.
1. 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
Applying , Structural Operational Semantics , to MDE
1 / 45
2. Semantics SOS DSL’s SOS for a DSL Conclusions
Outline
Semantics
1
Structural Operational Semantics
2
Domain Specific Languages
3
Structural Operational Semantics for a DSL in MDE
4
Conclusions
5
Applying , Structural Operational Semantics , to MDE
2 / 45
3. 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 MDE
Providing a semantic language named SemLang
Proof by example: apply SemLang
Build a tool, the Semantic Engine to simulate models
Applying , Structural Operational Semantics , to MDE
3 / 45
4. Semantics SOS DSL’s SOS for a DSL Conclusions
Outline
Semantics
1
Structural Operational Semantics
2
Domain Specific Languages
3
Structural Operational Semantics for a DSL in MDE
4
Conclusions
5
Applying , Structural Operational Semantics , to MDE
4 / 45
5. Semantics SOS DSL’s SOS for a DSL Conclusions
Language Definition
Abstract Syntax Determines the form and structure of programs
Textual languages, Iconic languages, Diagrammic
languages
Specification for parsers
Semantics Models the computational meaning of each program
Specification for compilers/interpreters
Dimension: Informal vs Formal
Dimension: Static vs Dynamic
Applying , Structural Operational Semantics , to MDE
5 / 45
6. Semantics SOS DSL’s SOS for a DSL Conclusions
Language Definition
Abstract Syntax Determines the form and structure of programs
Textual languages, Iconic languages, Diagrammic
languages
Specification for parsers
Semantics Models the computational meaning of each program
Specification for compilers/interpreters
Dimension: Informal vs Formal
Dimension: Static vs Dynamic
Applying , Structural Operational Semantics , to MDE
5 / 45
7. 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 two
boolean expressions. This operator exhibit ”short-circuiting”
behaviour, which means that the second operand is evaluated only
if needed.
Advantages easy to read, easy to understand, easy to create
Disadvantages imprecise, ambiguous, not computer-readable, not
useful for mathematical techniques (like proofs,
model checking etc.)
Applying , Structural Operational Semantics , to MDE
6 / 45
8. 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 two
boolean expressions. This operator exhibit ”short-circuiting”
behaviour, which means that the second operand is evaluated only
if needed.
Advantages easy to read, easy to understand, easy to create
Disadvantages imprecise, ambiguous, not computer-readable, not
useful for mathematical techniques (like proofs,
model checking etc.)
Applying , Structural Operational Semantics , to MDE
6 / 45
9. 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: natural
numbers, graphs, labelled transition systems etc.
Semantic mapping: describes how the syntax relates to the
semantic domain
Approaches: Axiomatic, Denotational, Graph Transformations,
Structural Operational Semantics
Advantages precise, computer-readable, useful for mathematical
techniques (like proofs,system validation, simulation
etc.)
Disadvantages often difficult to read, understand, create. Requires
understanding of the semantic domain.
Applying , Structural Operational Semantics , to MDE
7 / 45
10. 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: natural
numbers, graphs, labelled transition systems etc.
Semantic mapping: describes how the syntax relates to the
semantic domain
Approaches: Axiomatic, Denotational, Graph Transformations,
Structural Operational Semantics
Advantages precise, computer-readable, useful for mathematical
techniques (like proofs,system validation, simulation
etc.)
Disadvantages often difficult to read, understand, create. Requires
understanding of the semantic domain.
Applying , Structural Operational Semantics , to MDE
7 / 45
11. 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 running
Well formedness
Type 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 program
Description of computational steps
Example: Evaluation of If-Expressions
if(a) then b
if a evaluates to true then evaluate b
Applying , Structural Operational Semantics , to MDE
8 / 45
12. 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 running
Well formedness
Type 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 program
Description of computational steps
Example: Evaluation of If-Expressions
if(a) then b
if a evaluates to true then evaluate b
Applying , Structural Operational Semantics , to MDE
8 / 45
13. Semantics SOS DSL’s SOS for a DSL Conclusions
Outline
Semantics
1
Structural Operational Semantics
2
Domain Specific Languages
3
Structural Operational Semantics for a DSL in MDE
4
Conclusions
5
Applying , Structural Operational Semantics , to MDE
9 / 45
14. 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 of
labels α. 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 →
Applying , Structural Operational Semantics , to MDE
10 / 45
15. 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 of
labels α. 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 →
Applying , Structural Operational Semantics , to MDE
10 / 45
16. Semantics SOS DSL’s SOS for a DSL Conclusions
Overview of SOS
States are sentences that conform to an extension of the abstract
syntax: value-added syntax
Transitions are specified inductively by rules
A single transition can be proven by a set of rules
Rules alter the structure of the states
Graphics from Structural Operational Semantics 1981 by G.D. Plotkin
Applying , Structural Operational Semantics , to MDE
11 / 45
17. Semantics SOS DSL’s SOS for a DSL Conclusions
Rules in SOS
t‘
A rule consist of transition assertions t −→ t“
The terms t, t‘, t“ are language sentences that may contain
meta-variables
Rule Definition
c1 , · · · , cn
c
A rule has zero or more conditions c1 , · · · , cn and a conclusion c
t‘
c1 , · · · , cn , c are transition assertions (t −→ 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
Applying , Structural Operational Semantics , to MDE
12 / 45
18. Semantics SOS DSL’s SOS for a DSL Conclusions
Rules in SOS
t‘
A rule consist of transition assertions t −→ t“
The terms t, t‘, t“ are language sentences that may contain
meta-variables
Rule Definition
c1 , · · · , cn
c
A rule has zero or more conditions c1 , · · · , cn and a conclusion c
t‘
c1 , · · · , cn , c are transition assertions (t −→ 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
Applying , Structural Operational Semantics , to MDE
12 / 45
19. 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 if
and only if a finite branching tree can be formed that follows
satisfies the following conditions:
All nodes are labelled by elements of Q × A × Q
1
the root nodes is labelled by (s, α, s‘)
2
c1 ,··· ,cn
for each node with n child nodes there is a rule and an
3
c
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
Applying , Structural Operational Semantics , to MDE
13 / 45
20. 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 if
and only if a finite branching tree can be formed that follows
satisfies the following conditions:
All nodes are labelled by elements of Q × A × Q
1
the root nodes is labelled by (s, α, s‘)
2
c1 ,··· ,cn
for each node with n child nodes there is a rule and an
3
c
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
Applying , Structural Operational Semantics , to MDE
13 / 45
21. 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
Exp
Exp Bop N
(2 + 3) ∗ 8
N Bop N * 8
2 + 3
Applying , Structural Operational Semantics , to MDE
14 / 45
22. 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 = ∅
Applying , Structural Operational Semantics , to MDE
15 / 45
23. 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 Rule
e0 → e0 ‘
(1)
e0 bop e1 → e0 ‘ bop e1
Evaluate rhs Rule
e1 → e1 ‘
(2)
n0 bop e1 → n0 bop e1 ‘
Applying , Structural Operational Semantics , to MDE
15 / 45
24. Semantics SOS DSL’s SOS for a DSL Conclusions
Simple Expressions Lang Semantics
Evaluate plus Rule
bop = + n = n0 + n1
(1)
n0 bop n1 → n
Evaluate multiply Rule
bop = ∗ n = n0 ∗ n1
(2)
n0 bop n1 → n
Applying , Structural Operational Semantics , to MDE
15 / 45
25. 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
Applying , Structural Operational Semantics , to MDE
16 / 45
26. 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
Applying , Structural Operational Semantics , to MDE
16 / 45
27. 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
Applying , Structural Operational Semantics , to MDE
16 / 45
28. 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
Applying , Structural Operational Semantics , to MDE
16 / 45
29. 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→5
2+3 ∗ 8→5 ∗ 8
by substituting e0 ‘
e0 ‘ = 2 + 3 = 5
Applying , Structural Operational Semantics , to MDE
16 / 45
30. Semantics SOS DSL’s SOS for a DSL Conclusions
Outline
Semantics
1
Structural Operational Semantics
2
Domain Specific Languages
3
Structural Operational Semantics for a DSL in MDE
4
Conclusions
5
Applying , Structural Operational Semantics , to MDE
17 / 45
31. Semantics SOS DSL’s SOS for a DSL Conclusions
Generic vs Specific Languages
DSL Domain Specific
GPL General Purpose Language
Language
Small ( often extensions of
Large GPLs (embedded))
Gap between language Closer to problem domain:
domain and problem domain captures domain knowledge
Users: software-engineers, Users: Same as DSL plus
programmers domain-experts, end-users
Examples Examples
C++, Java, Fortran, Lisp SQL, BNF, HTML, RegExp,
XSLT
Applying , Structural Operational Semantics , to MDE
18 / 45
32. Semantics SOS DSL’s SOS for a DSL Conclusions
Defining a DSL
Executable vs Static DSL’s
Define domain concepts and relations in a
metamodel
Plays the role of an abstract syntax
Captures domain knowledge
Define concrete syntax (optionally)
Textually or visual
Provides easier editing
Define semantics
Informally using code generation to a GPL
Formally both dynamic and static semantics
Applying , Structural Operational Semantics , to MDE
19 / 45
33. Semantics SOS DSL’s SOS for a DSL Conclusions
Defining a DSL
Executable vs Static DSL’s
Define domain concepts and relations in a
metamodel
Plays the role of an abstract syntax
Captures domain knowledge
Define concrete syntax (optionally)
Textually or visual
Provides easier editing
Define semantics
Informally using code generation to a GPL
Formally both dynamic and static semantics
Applying , Structural Operational Semantics , to MDE
19 / 45
34. Semantics SOS DSL’s SOS for a DSL Conclusions
Defining a DSL
Executable vs Static DSL’s
Define domain concepts and relations in a
metamodel
Plays the role of an abstract syntax
Captures domain knowledge
Define concrete syntax (optionally)
Textually or visual
Provides easier editing
Define semantics
Informally using code generation to a GPL
Formally both dynamic and static semantics
Applying , Structural Operational Semantics , to MDE
19 / 45
35. Semantics SOS DSL’s SOS for a DSL Conclusions
Outline
Semantics
1
Structural Operational Semantics
2
Domain Specific Languages
3
Structural Operational Semantics for a DSL in MDE
4
Conclusions
5
Applying , Structural Operational Semantics , to MDE
20 / 45
36. 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
Applying , Structural Operational Semantics , to MDE
21 / 45
37. Semantics SOS DSL’s SOS for a DSL Conclusions
SOS vs SemLang
SemLang
SOS & MSOS
MetaModel defines DSL
Abstract Syntax defines
structure
Language Structure
Models are states
Sentences are states
→ states are graphs
→ States are trees
Rules contain object
Rules contain syntax
patterns
SOS Rule
e1 → e1 ‘
if e1 then e2 → if e1 ‘ then e2
Applying , Structural Operational Semantics , to MDE
22 / 45
38. 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)
Applying , Structural Operational Semantics , to MDE
22 / 45
39. Semantics SOS DSL’s SOS for a DSL Conclusions
Understanding SemLang
Understanding SemLang by example
For each DSL we define
MetaModel
Sample model (sample program)
Semantics in SemLang
The sample model will be executed.
The DSL’s:
Simple Imperative Language
Activity Diagram Language
Applying , Structural Operational Semantics , to MDE
23 / 45
40. Semantics SOS DSL’s SOS for a DSL Conclusions
Understanding SemLang
Understanding SemLang by example
For each DSL we define
MetaModel
Sample model (sample program)
Semantics in SemLang
The sample model will be executed.
The DSL’s:
Simple Imperative Language
Activity Diagram Language
Applying , Structural Operational Semantics , to MDE
23 / 45
41. Semantics SOS DSL’s SOS for a DSL Conclusions
Simple Imperative Language: MetaModel
Applying , Structural Operational Semantics , to MDE
24 / 45
42. Semantics SOS DSL’s SOS for a DSL Conclusions
Simple Imperative Language: Sample Model
Seq
c1 c0
Seq Assign
c0 c1 e name
Assign Assign Number a
e name e name val
BinaryExp b BinaryExp a Integer:10
lhs rhs bop lhs rhs bop
Number Var Plus Var Number Minus
val name name val
Integer:10 a b Integer:3
Applying , Structural Operational Semantics , to MDE
25 / 45
43. Semantics SOS DSL’s SOS for a DSL Conclusions
Binary Expressions Rule
Computes = {Nil, Number}
L→NL
(3)
BinExp(lhs=L,bop=O,rhs=R)→BinExp(lhs=NL,bop=O,rhs=R)
R→NR
(4)
BinExp(lhs=L,bop=O,rhs=R)→BinExp(lhs=L,bop=O,rhs=NR)
Applying , Structural Operational Semantics , to MDE
26 / 45
44. Semantics SOS DSL’s SOS for a DSL Conclusions
Binary Expressions Rule
O∈Plus
(3)
BinExp(lhs=L,bop=O,rhs=R)→Number(val=(L.val+R.val))
O∈Minus
(4)
BinExp(lhs=L,bop=O,rhs=R)→Number(val=(L.val−R.val))
Applying , Structural Operational Semantics , to MDE
26 / 45
45. Semantics SOS DSL’s SOS for a DSL Conclusions
Rules for Seq commands
C0 → NC
(5)
Seq (c0 = C0, c1 = C1) → Seq (c0 = NC, c1 = C1)
Seq (c0 = C0 , c1 = C1) → C1 (6)
Applying , Structural Operational Semantics , to MDE
27 / 45
46. 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 → v
{k1 → v1 , k2 → v2 , . . . , kn−1 → vn−1 , kn → vn }
Applying , Structural Operational Semantics , to MDE
28 / 45
47. Semantics SOS DSL’s SOS for a DSL Conclusions
Operations over Functions
Definition
Function invocation: If a is a function then a(k) equals:
,k → v ∈ a
v
a(k) =
Nil , k → v ∈ a
/
Definition
Override expression: If a and b are functions then a [b] equals:
, k → vb ∈ b
vb
a [b] (k) =
, k → va ∈ ab
va
Applying , Structural Operational Semantics , to MDE
29 / 45
48. Semantics SOS DSL’s SOS for a DSL Conclusions
Including Stores in SemLang
A state is now a tuple M, F where:
M is the current model
1
F is a set of functions
2
The functions in F represent the store
Rules can read and update functions in F
t‘
The transition relation t −→ t“ is extended:
Function invocations are allowed in the terms t, t‘ and t“
1
The label t‘ can now contain function assignments
2
Function assignment format
storeName ′ =<functionexpression>
t − − − − − − − − − − → t“
−−−−−−−−−−
Applying , Structural Operational Semantics , to MDE
30 / 45
49. Semantics SOS DSL’s SOS for a DSL Conclusions
Including Stores in SemLang
A state is now a tuple M, F where:
M is the current model
1
F is a set of functions
2
The functions in F represent the store
Rules can read and update functions in F
t‘
The transition relation t −→ t“ is extended:
Function invocations are allowed in the terms t, t‘ and t“
1
The label t‘ can now contain function assignments
2
Function assignment format
storeName ′ =<functionexpression>
t − − − − − − − − − − → t“
−−−−−−−−−−
Applying , Structural Operational Semantics , to MDE
30 / 45
50. 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
(9)
Assign (name = N, e = E) → Assign (name = N, e = NE)
store ′ =store[{N→E }]
Assign (name = N, e = E ) − − − − − − − Nil
− − − − − −→ (10)
Applying , Structural Operational Semantics , to MDE
31 / 45
51. Semantics SOS DSL’s SOS for a DSL Conclusions
Simulation
Model Simulation
Simulating the model using the tool: Semantic Engine
Applying , Structural Operational Semantics , to MDE
32 / 45
52. Semantics SOS DSL’s SOS for a DSL Conclusions
First Transition: Proof
C0 → NC
Seq (c0 = C0, c1 = C1) → Seq (c0 = NC, c1 = C1)
Applying , Structural Operational Semantics , to MDE
33 / 45
53. Semantics SOS DSL’s SOS for a DSL Conclusions
First Transition: Proof
store ′ =store[{N→E }]
Assign (name = N, e = E ) − − − − − − − Nil
− − − − − −→
Seq (c0 = C0, c1 = C1) → Seq (c0 = NC, c1 = C1)
Applying , Structural Operational Semantics , to MDE
33 / 45
54. Semantics SOS DSL’s SOS for a DSL Conclusions
First Transition: Proof
store ′ =store[{N→E }]
Assign (”a” = N, Number(val = 10) = E ) − − − − − − − Nil
− − − − − −→
Seq (c0 = C0, c1 = C1) → Seq (c0 = NC, c1 = C1)
Applying , Structural Operational Semantics , to MDE
33 / 45
55. Semantics SOS DSL’s SOS for a DSL Conclusions
First Transition: Proof
Assign (”a” = N, Number(val = 10) = E )
store ′ =store[{”a”→Number(val=10)}]
− − − − − − − − − − − − Nil
− − − − − − − − − − −→
Seq (c0 = C0, c1 = C1) → Seq (c0 = NC, c1 = C1)
Applying , Structural Operational Semantics , to MDE
33 / 45
56. Semantics SOS DSL’s SOS for a DSL Conclusions
First Transition: Proof
Assign (”a” = N, Number(val = 10) = E )
store ′ =∅[{”a”→Number(val=10)}]
− − − − − − − − − − − Nil
− − − − − − − − − −→
Seq (c0 = C0, c1 = C1) → Seq (c0 = NC, c1 = C1)
Applying , Structural Operational Semantics , to MDE
33 / 45
57. Semantics SOS DSL’s SOS for a DSL Conclusions
First Transition: Proof
Assign (”a” = N, Number(val = 10) = E )
store ′ ={”a”→Number(val=10)}
− − − − − − − − − − Nil
− − − − − − − − −→
Seq (c0 = C0, c1 = C1) → Seq (c0 = NC, c1 = C1)
Applying , Structural Operational Semantics , to MDE
33 / 45
58. Semantics SOS DSL’s SOS for a DSL Conclusions
First Transition: Proof
Assign (”a” = N, Number(val = 10) = E )
store ′ ={”a”→Number(val=10)}
− − − − − − − − − − Nil
− − − − − − − − −→
Seq (c0 = C0, c1 = C1) → Seq (c0 = Nil, c1 = C1)
Applying , Structural Operational Semantics , to MDE
33 / 45
59. Semantics SOS DSL’s SOS for a DSL Conclusions
First Transition: Proof
Seq (c0 = C0, c1 = C1)
store ′ ={”a”→Number(val=10)}
−− − − − − − − − −
− − − − − − − − −→
Seq (c0 = Nil, c1 = C1)
Applying , Structural Operational Semantics , to MDE
33 / 45
60. Semantics SOS DSL’s SOS for a DSL Conclusions
Activity Diagram Lang: MetaModel
Applying , Structural Operational Semantics , to MDE
34 / 45
61. Semantics SOS DSL’s SOS for a DSL Conclusions
Activity Diagram Lang: MetaModel
Applying , Structural Operational Semantics , to MDE
34 / 45
62. Semantics SOS DSL’s SOS for a DSL Conclusions
Activity Diagram Lang: MetaModel
Applying , Structural Operational Semantics , to MDE
34 / 45
63. Semantics SOS DSL’s SOS for a DSL Conclusions
Activity Diagram Lang: Example Model
Applying , Structural Operational Semantics , to MDE
35 / 45
64. Semantics SOS DSL’s SOS for a DSL Conclusions
Activity Diagram Lang: Example Model
Diagram
nodes
StartNode
nodes
next name nodes
VarDec a
nodes nodes
e name varName next
Number b a Test
value next name e next alternative
StopNode Integer:1 test BinaryExp Assign
name lhs rhs bop e name varName
end Var Number Eq BinaryExp c a
name value rhs lhs bop
a Integer:5 Number Var Plus
value name
Integer:1 a
Applying , Structural Operational Semantics , to MDE
35 / 45
65. 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)
Applying , Structural Operational Semantics , to MDE
36 / 45
66. 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)
Applying , Structural Operational Semantics , to MDE
37 / 45
67. Semantics SOS DSL’s SOS for a DSL Conclusions
Activity Diagram Lang: VarDec
E → NE
(18)
VarDec (name = N, varName = VN, e = E, next = NN)
→ VarDec (name = N, name = VN, e = NE, next = NN)
VarDec (name = N, varName = VN, e = E , next = NN)
store ′ =storeρ [{VN→E }]
− − − − − − − → NN
−−−−−−− (19)
Applying , Structural Operational Semantics , to MDE
38 / 45
68. 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ρ [{VN→E }]
− − − − − − − → NN
−−−−−−− (21)
Applying , Structural Operational Semantics , to MDE
39 / 45
69. Semantics SOS DSL’s SOS for a DSL Conclusions
Simulation
Model Simulation
Simulating the model using the tool: Semantic Engine
Applying , Structural Operational Semantics , to MDE
40 / 45
70. Semantics SOS DSL’s SOS for a DSL Conclusions
Outline
Semantics
1
Structural Operational Semantics
2
Domain Specific Languages
3
Structural Operational Semantics for a DSL in MDE
4
Conclusions
5
Applying , Structural Operational Semantics , to MDE
41 / 45
71. Semantics SOS DSL’s SOS for a DSL Conclusions
Conclusions
SOS can be applied to MDE!
With some adjustments
Proof of concept
Tool support for simulation
Future Research
Extend SemLang
Extend tool support
Model checking
Compiler Interpreter generation
Applying , Structural Operational Semantics , to MDE
42 / 45
72. Semantics SOS DSL’s SOS for a DSL Conclusions
Differences with Graph Transformations
Graph Transformations SemLang
Multiple rule for a transition
Single rule for a transition
Rule matching easy
Rule matching hard:
Theoretic basis work in
NP-complete
progress
Sound theoretic basis
Limited Expressiveness
Expressive
(future research)
Better graph awareness
Locally tree oriented
Less use of metamodel
Uses metamodel knowledge
Not easy to map to
Related to interpreter design
interpreters
pattern
Modularity may be
MSOS aimed at modularity
problematic
(future research)
Applying , Structural Operational Semantics , to MDE
43 / 45
73. Semantics SOS DSL’s SOS for a DSL Conclusions
Any Questions?
Applying , Structural Operational Semantics , to MDE
44 / 45
74. 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 operational
semantics. 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.
Applying , Structural Operational Semantics , to MDE
45 / 45