870 likes | 1k Views
Understanding and Comparing Model-Based Specification Notations. Jianwei Niu, Joanne Atlee, and Nancy Day University of Waterloo. Pseudo code: (a) For each static reaction X in EN, execute the action associated with X
E N D
Understanding and Comparing Model-Based Specification Notations Jianwei Niu, Joanne Atlee, and Nancy Day University of Waterloo
Pseudo code: (a) For each static reaction X in EN, execute the action associated with X (b) For each transition X in EN, let Sn and Sx be the set of states exited and entered, respectively; Formal semantics: Expressing a Notation’s Semantics Designers of specification notations document the semantics of their notations, to help specifiers use the notations correctly. Let EN be the set of enabled transitions and static reactions Definition: Let X = (X0,…,Xn) be a sequence of state configurations. Let SC be a system configuration whose state configuration is Xn. Let SC1 be a micro system configuration with respect to SC, and let be a micro-step from SC1 . Then SC= (X, , , , Y) is the micro system configuration reached by from SC1 if X = X1 - X1 {*(LCA(t)) | t } 2. 1 = {e | generates e } 3. = 1 { cr(c) | does not assign F to c } { cr(c) | assigns T to c } 4. (v) = x iff 1(v) = x and does not assign any value to v or assigns x to v 5. Y = Y1 {C (LCA(t), target(t), X) | t } - update the history of all the parents of states in Sx - delete the states in Sx from the list of states in which the system resides - execute actions associated with exiting states in Sx - execute the actions of X - execute the actions associated with entering the states in Sn - add to the list of states in which the system resides all of the states in Sn Harel et al. “The STATEMATE Semantics of Statecharts”, TOSEM, July 1996 Harel et al. “On the Formal Semantics of Statecharts”, LICS 1987
Template-Based Approach We propose a template-based approach [FSE’02] to structuring the operational semantics of model-based notations that • Separates a notation’s step semantics from its semantics of composition. CP1 CP2 CP3 CP4 HTS3 HTS4 HTS5 HTS1 HTS2
Template-Based Approach We propose a template-based approach [FSE’02] to structuring the operational semantics of model-based notations that • Separates a notation’s step semantics from its semantics of composition. • Extracts common semantics into templates. User instantiates the templates with parameters, to specify a notation’s distinct semantics. parameters Templates CP1 CP2 CP3 CP4 HTS3 HTS4 HTS5 HTS1 HTS2
Template Parameters RESET NEXT
Comparing Notation Variants statecharts STATEMATE RSML RESET NEXT NEXT RESET RESET NEXT Variables Events States Unused Agreement among All 3 notations Agreement among 2 notations No Agreement
CP1 CP2 CP3 CP4 HTS3 HTS4 HTS5 HTS1 HTS2 Outline of Today's Talk • Template semantics • Step semantics of basic components • Template parameters • Comparing notation variants • Composition operators • Expressing other notations’ semantics • SCR • SDL • Petri Nets
S0 S1 S2 S3 S5 S7 S9 S6 S8 S4 Basic ComponentsHierarchical Transition Systems (HTSs) • Control states, state hierarchy • Internal events • External events • Variables • Transitions: event [condition] / action source dest Nonconcurrent machines – concurrency is introduced when composing multiple HTSs
Step Semantics • Snapshot: observable point in execution (current control states, occurring events, variable values, etc.) • Operational Semantics: admissible steps between consecutive snapshots • micro-steps: execute a single transition • macro-steps: execute a sequence of micro-steps until a stable state is reached inputs micro-step micro-step micro-step macro-step
Step Semantics • Snapshot: observable point in execution (current control states, occurring events, variable values, etc.) • Operational Semantics: admissible steps between consecutive snapshots • micro-steps: execute a single transition • macro-steps: execute a sequence of micro-steps until a stable state is reached inputs micro-step micro-step micro-step macro-step
Step Semantics • Snapshot: observable point in execution (current control states, occurring events, variable values, etc.) • Operational Semantics: admissible steps between consecutive snapshots • micro-steps: execute a single transition • macro-steps: execute a sequence of micro-steps until a stable state is reached inputs micro-step micro-step micro-step macro-step
Step Semantics • Snapshot: observable point in execution (current control states, occurring events, variable values, etc.) • Operational Semantics: admissible steps between consecutive snapshots • micro-steps: execute a single transition • macro-steps: execute a sequence of micro-steps until a stable state is reached inputs micro-step micro-step micro-step macro-step
Step Semantics • Snapshot: observable point in execution (current control states, occurring events, variable values, etc.) • Operational Semantics: admissible steps between consecutive snapshots • micro-steps: execute a single transition • macro-steps: execute a sequence of micro-steps until a stable state is reached inputs micro-step micro-step micro-step macro-step
Step Semantics • Snapshot: observable point in execution (current control states, occurring events, variable values, etc.) • Operational Semantics: admissible steps between consecutive snapshots • micro-steps: execute a single transition • macro-steps: execute a sequence of micro-steps until a stable state is reached inputs micro-step micro-step micro-step Stable snapshot: no transitions enabled in the snapshot macro-step
Common Definitions of Template • enabled transitions:identifies which transitions are enabled by the snapshot’s states, events, and variable values • apply: applies a transition’s actions (new events, variable assignments) to the snapshot • micro-step: selects an enabled transition and applies its actions to the snapshot • macro-step: executes a sequence of micro-steps • reset: resets the snapshot at start of macro-step
Common Definitions of Template • enabled transitions:identifies which transitions are enabled by the snapshot’s states, events, and variable values • apply: applies a transition’s actions (new events, variable assignments) to the snapshot • micro-step: selects an enabled transition and applies its actions to the snapshot • macro-step: executes a sequence of micro-steps • reset: resets the snapshot at start of macro-step
Common Definitions of Template • enabled transitions:identifies which transitions are enabled by the snapshot’s states, events, and variable values • apply:applies a transition’s actions (new events, variable assignments) to the snapshot • micro-step: selects an enabled transition and applies its actions to the snapshot • macro-step: executes a sequence of micro-steps, • reset: resets the snapshot at start of macro-step
Common Definitions of Template • enabled transitions:identifies which transitions are enabled by the snapshot’s states, events, and variable values • apply: applies a transition’s actions (new events, variable assignments) to the snapshot • micro-step:selects an enabled transition and applies its actions to the snapshot • macro-step: executes a sequence of micro-steps • reset: resets the snapshot at start of macro-step
Common Definitions of Template • enabled transitions:identifies which transitions are enabled by the snapshot’s states, events, and variable values • apply: applies a transition’s actions (new events, variable assignments) to the snapshot • micro-step: selects an enabled transition and applies its actions to the snapshot • macro-step:executes a sequence of micro-steps • reset: resets the snapshot at start of macro-step
Common Definitions of Template • enabled transitions:identifies which transitions are enabled by the snapshot’s states, events, and variable values • apply: applies a transition’s actions (new events, variable assignments) to the snapshot • micro-step: selects an enabled transition and applies its actions to the snapshot • macro-step: executes a sequence of micro-steps • reset:resets the snapshot at start of macro-step
Example Functionenabled_trans(ss, T) returns the subset of transitions in T that are enabled in snapshot ss enabled_trans(ss, T) { T | enabling_states(ss, ) enabling_events(ss, ) enabling_cond(ss, ) } where enabling_states, enabling_events, enabling_cond are template parameters
Template Parameters how snapshot is reset at start of macro-step how snapshot changes when transition executes RESET NEXT how transitions are enabled
Example(Harel’s original statecharts) how snapshot is reset at start of macro-step how snapshot changes when transition executes NEXT RESET • where • IE- current internal events • Ia - current external events • O -output events • gen() - events generated by • trig() - ’s triggering events
Example(Harel’s original statecharts) how snapshot is reset at start of macro-step how snapshot changes when transition executes NEXT RESET • where • IE- current internal events • Ia - current external events • O -output events • gen() - events generated by • trig() - ’s triggering events
Example(Harel’s original statecharts) how snapshot is reset at start of macro-step how snapshot changes when transition executes NEXT RESET • where • IE- current internal events • Ia - current external events • O -output events • gen() - events generated by • trig() - ’s triggering events
Example(Harel’s original statecharts) how snapshot is reset at start of macro-step how snapshot changes when transition executes NEXT RESET • where • IE- current internal events • Ia - current external events • O -output events • gen() - events generated by • trig() - ’s triggering events
Example(Harel’s original statecharts) how snapshot is reset at start of macro-step how snapshot changes when transition executes NEXT RESET • where • IE- current internal events • Ia - current external events • O -output events • gen() - events generated by • trig() - ’s triggering events
Comparing Notation Variants statecharts STATEMATE RSML RESET NEXT NEXT RESET RESET NEXT Variables Events States Unused Agreement among All 3 notations Agreement among 2 notations No Agreement
Comparing Notation Variants statecharts STATEMATE RSML RESET NEXT NEXT RESET RESET NEXT Variables Events States Unused Agreement among All 3 notations Agreement among 2 notations No Agreement
Comparing Notation Variants statecharts STATEMATE RSML RESET NEXT NEXT RESET RESET NEXT Variables Events States Unused Agreement among All 3 notations Agreement among 2 notations No Agreement
Comparing Notation Variants statecharts STATEMATE RSML RESET NEXT NEXT RESET RESET NEXT Variables Events States Unused Agreement among All 3 notations Agreement among 2 notations No Agreement
Comparing Notation Variants statecharts STATEMATE RSML RESET NEXT NEXT RESET RESET NEXT Variables Events States Unused Agreement among All 3 notations Agreement among 2 notations No Agreement
Variant Variable Semantics statecharts RSML STATEMATE NEXT NEXT NEXT Variables • where • AV- current variable values • AVa - old variable values (from start of macro-step) • asn() - ’s variable assignments • last(asn()) - last of multiple assignments to same variable • eval(X, Y) - evaluates expressions in X wrt values in Y • cond() - ’s enabling conditions
Variant Variable Semantics statecharts RSML STATEMATE NEXT NEXT NEXT Variables • where • AV- current variable values • AVa - old variable values (from start of macro-step) • asn() - ’s variable assignments • last(asn()) - last of multiple assignments to same variable • eval(X, Y) - evaluates expressions in X wrt values in Y • cond() - ’s enabling conditions
Variant Variable Semantics statecharts RSML STATEMATE NEXT NEXT NEXT Variables • where • AV- current variable values • AVa - old variable values(from start of macro-step) • asn() - ’s variable assignments • eval(X, Y) - evaluates expressions in X wrt values in Y • cond() - ’s enabling conditions • last(asn()) - last of multiple assignments to same variable
Variant Variable Semantics statecharts RSML STATEMATE NEXT NEXT NEXT Variables • where • AV- current variable values • AVa - old variable values(from start of macro-step) • asn() - ’s variable assignments • eval(X, Y) - evaluates expressions in X wrt values in Y • cond() - ’s enabling conditions • last(asn()) - last of multiple assignments to same variable
Variant Variable Semantics statecharts RSML STATEMATE NEXT NEXT NEXT Variables • where • AV- current variable values • AVa - old variable values(from start of macro-step) • asn() - ’s variable assignments • eval(X, Y) - evaluates expressions in X wrt values in Y • cond() - ’s enabling conditions • last(asn()) - last of multiple assignments to same variable
Outline of Today's Talk • Template semantics • Step semantics of basic components • Template parameters • Comparing notation variants • Composition operators • Expressing other notations’ semantics • SCR • SDL • Petri Nets
Composition Operators • Constrain which/when components can take a step • Share snapshot information: • communicate events • consistent values among shared variables CP1 CP2 CP3 CP4 HTS3 HTS4 HTS5 HTS1 HTS2
AND-state Composition • IF: Both components are enabled • Both components execute simultaneously1 • Generated events are shared2 • Assignments to shared variables are resolved2 • ELSE: One component is enabled • Enabled component executes in isolation1 • Generated events are shared2 • Assignments to variables are shared2 1Components execute via their micro-step template definition. 2Components use their template parameters to receive shared events and variable values
Outline of Today's Talk • Template semantics • Step semantics of basic components • Template parameters • Comparing notation variants • Composition operators • Expressing other notations’ semantics • SCR • SDL • Petri Nets
Software Cost Reduction (SCR) An SCR specification specifies a system in terms of its variables and a history of how variables change value.
SCR An SCR specification specifies a system in terms of its variables and a history of how variables change value. Variable updates are specified as mathematical functions: Warning= Represented as a table: off if Mode=Off off if Mode Off Temp < 175 on if ModeOff Temp 175 where each table entry represents one case in the function’s definition.
SCR Template Parameters RESET NEXT
SCR Condition Tables We define a transition for every table entry: cond(): table-entry conditions, evaluated wrt current variable values: Mode {Heat, Maintain} Temp<175 asn(): bottom-level assignment Warning := off
SCR Condition Tables We define a transition for every table entry: cond(): table-entry conditions, evaluated wrt current variable values: Mode {Heat, Maintain} Temp<175 asn(): bottom-level assignment Warning := off
SCR Condition Tables We define a transition for every table entry: cond(): table-entry conditions, evaluated wrt current variable values: Mode {Heat, Maintain} Temp<175 asn(): bottom-level assignment Warning := off
SCR Condition Tables RESET NEXT • where • AV – current variable values • I – monitored (input) variable values • O – controlled (output) variable values • cond() – ’s enabling conditions • controlled(V) – controlled (output) variables in V
SCR Condition Tables RESET NEXT • where • AV – current variable values • I – monitored (input) variable values • O – controlled (output) variable values • cond() – ’s enabling conditions • controlled(V) – controlled (output) variables in V
SCR Condition Tables RESET NEXT • where • AV – current variable values • I – monitored (input) variable values • O – controlled (output) variable values • cond() – ’s enabling conditions • controlled(V) – controlled (output) variables in V