towards constraint-based model types: a generalised formal foundation for model genericity
TRANSCRIPT
Towards Constraint-Based Model Types: A Generalised
Formal Foundation for Model Genericity
Steffen Zschaler
22 July 2014
VAO, York
Towards Constraint-Based Model Types: A Generalised
Formal Foundation for Model Genericity
Steffen Zschaler
22 July 2014
VAO, York
Reuse in model management
22/07/2014 2
Model transformation specifications
Untyped
• No documentation
of assumptions
• No checking of
applicability for a
given model
Typed over one
specific meta-model
• Only work for models
that instantiate the
particular meta-model
• Need to rewrite
transformation from
scratch for any
similar meta-model.
Reuse in model management
22/07/2014 2
Model transformation specifications
Untyped
• No documentation
of assumptions
• No checking of
applicability for a
given model
Typed over one
specific meta-model
• Only work for models
that instantiate the
particular meta-model
• Need to rewrite
transformation from
scratch for any
similar meta-model.
We need a type system that is both sufficiently lax and
sufficiently precise to capture the best of both worlds.
(NB Can think of such model types as views on the
models to be manipulated.)
Existing approaches
• Two attempts at such type systems
exist:
– Model Typing (Steel, Guy, Combemale, et al.)
– Model Concepts (de Lara, Guerra, Rose, et
al.)
• All have problems
22/07/2014 3
Example problems
22/07/2014 4
mmo NewSM (s : Simple) {
s += new StateMachine ()
}
StateMachineState
name: String
Transition
event: String
initialState
0..1
containedState *
src
1
tgt
1
incoming
*
*
outgoing
Difference between Simple and Mandatory-startMandatory-start <:Steel Simple
Example problems
22/07/2014 4
mmo NewSM (s : Simple) {
s += new StateMachine ()
}
StateMachineState
name: String
Transition
event: String
initialState
0..1
containedState *
src
1
tgt
1
incoming
*
*
outgoing
Difference between Simple and Mandatory-start
Error: Allows passing in
Mandatory-start instance, but breaks it.
Mandatory-start <:Steel Simple
mmo NewSM (s : Mandatory-start) {
sm := new StateMachine () ;
sm.initialState += new State () ;
s += sm
}
Example problems
22/07/2014 4
StateMachineState
name: String
Transition
event: String
initialState
0..1
containedState *
src
1
tgt
1
incoming
*
*
outgoing
Difference between Simple and Mandatory-startMandatory-start <:Guy Simple
mmo NewSM (s : Mandatory-start) {
sm := new StateMachine () ;
sm.initialState += new State () ;
s += sm
}
Example problems
22/07/2014 4
StateMachineState
name: String
Transition
event: String
initialState
0..1
containedState *
src
1
tgt
1
incoming
*
*
outgoing
Difference between Simple and Mandatory-start
Over-restriction: Would work with any
Simple instance, but cannot specify.
Mandatory-start <:Guy Simple
Two general problems
1. Focus on external contracts
– Can validate invocations but not
implementations
2. No formal definition
– Cannot analyse correctness
22/07/2014 5
Towards a solution
1. Provide a formalisation
– Explicit type system for model types
– Explicitly include constraints on the structure
of acceptable models
2. Define a notion of an internal contract
– In the paper defined through a set of type
inference rules
– Key really: Dataflow analysis of MMO
implementation
22/07/2014 6
Example
22/07/2014
Statements typed by
their effect on
system states
data flow analysis
States assign model types
to variables (see paper)
See paper for type rules
Example
22/07/2014
Append rule generates
additional constraints.
Here: Forbids mandatory
associations from StateMachine.
See paper for type rules
Conclusions and Outlook
• Need better understanding of generic
model types
– Internal contracts
– Constraint-based model types may provide
the basis
• Proper formalisation needed
• Limits of data-flow analysis?
22/07/2014 8