The STATEMATE Semantics of Statecharts

31
The STATEMATE The STATEMATE Semantics of Semantics of Statecharts Statecharts David Harel and Amnon Naamad 1996. Jolan Farkas Jolan Farkas

description

The STATEMATE Semantics of Statecharts. David Harel and Amnon Naamad 1996. Jolan Farkas. Overview. Introduction Basic concepts of semantics Hierarchy of states Orthogonality of states Transitions History Other issues. Statecharts. STATEMATE. No consensus about semantics - PowerPoint PPT Presentation

Transcript of The STATEMATE Semantics of Statecharts

Page 1: The STATEMATE Semantics of Statecharts

The STATEMATE The STATEMATE Semantics of StatechartsSemantics of Statecharts

David Harel and Amnon Naamad

1996.

Jolan FarkasJolan Farkas

Page 2: The STATEMATE Semantics of Statecharts

04/22/23CS 367 2/32

OverviewOverview

Introduction Basic concepts of semantics

– Hierarchy of states– Orthogonality of states– Transitions– History

Other issues

Statecharts

Page 3: The STATEMATE Semantics of Statecharts

04/22/23CS 367 3/32

STATEMATESTATEMATE

No consensus about semantics Clarity, simplicity, intuitive Unofficial language => no official semantics Main difference between Harel’s (87) and P&S (91)

– Changes occurring in a given step take effect in the current step or in the next one

– STATEMATE implements the latter approach

Statecharts - STATEMATE

Page 4: The STATEMATE Semantics of Statecharts

04/22/23CS 367 4/32

Commercial ToolCommercial Tool

Real-life complex systems Support of different styles of modeling Simple and intuitive VHDL adopted the same approach

Statecharts - STATEMATE

Page 5: The STATEMATE Semantics of Statecharts

04/22/23CS 367 5/32

TopicsTopics

Statechart notions– Hierarchy of states– Orthogonality– History connector

Not unique to statecharts– Combinational assignments– Priority of transitions– Generic charts– Multi-value logic– Queues

i-Logic documents

Statecharts - Topics

Page 6: The STATEMATE Semantics of Statecharts

04/22/23CS 367 6/32

The BasicsThe Basics

Page 7: The STATEMATE Semantics of Statecharts

04/22/23CS 367 7/32

The BasicsThe Basics

Model of reactive systems Backbone: activity-chart

– Hierarchical dataflow diagram– Functional capabilities of the system– Dynamically noncommitting

Behavioral aspect: control activities– One for each activity– Controls the dynamics of subactivities and their dataflow

Statecharts - Basics

Page 8: The STATEMATE Semantics of Statecharts

04/22/23CS 367 8/32

Structure of Activity HierarchyStructure of Activity Hierarchy

A1S1

A11S11

A112 S112

A1123A111

A12A13

A131S13

Activity

Control activity

Statecharts - Basics

Page 9: The STATEMATE Semantics of Statecharts

04/22/23CS 367 9/32

The Basics …The Basics …cont’dcont’d

State hierarchy– OR: substances in exclusive OR relation– AND: orthogonal components related by AND– BASIC: at the hierarchy bottom

Statecharts - Basics

A

B

C

D

E F

Page 10: The STATEMATE Semantics of Statecharts

04/22/23CS 367 10/32

The Basics …The Basics …cont’dcont’d

Transition labeling: e[c]/a– e: event, triggers the transition– c: condition, guards transition from being taken– a: action carried out if and when transition is taken

Actions associated with the entrance to or exit from a state S– Entrance to: on transition leading to S– Exit from: on transition exiting from S

Statecharts - Basics

Page 11: The STATEMATE Semantics of Statecharts

04/22/23CS 367 11/32

The Basics …The Basics …cont’dcont’d

Static reactions– Same format: e[c]/a– Carried out as long as the system is in the given state

• Transition in virtual susbtate VS• VS is orthogonal to all substates and SR’s

Statecharts - Basics

A

B C

SR: ev/act

t1

A

B

C

Dt1

ev/act

=

Page 12: The STATEMATE Semantics of Statecharts

04/22/23CS 367 12/32

The Basics …The Basics …cont’dcont’d

Throughout vs. within– Throughout: active upon entering, stops upon leaving– Within: active when system is in S, stops when exiting

Schedule– sc!(a, d): d time units later

Timeout– tm(e, d): d time units after e

Statecharts - Basics

Page 13: The STATEMATE Semantics of Statecharts

04/22/23CS 367 13/32

The Basics …The Basics …cont’dcont’d

Behavior– Described by possible runs: series of statuses

• Initial status: first snapshot• Each subsequent: by executing a step

– Status: detailed internal information– Step: status change on external stimuli and internal changes

Statecharts - Basics

Page 14: The STATEMATE Semantics of Statecharts

04/22/23CS 367 14/32

PrinciplesPrinciples

Reactions and changes sensed after step-completion Events: live for step-duration, not remembered Decisions based on situation at the beginning of the step A maximal subset of non-conflicting transitions and SR’s

is always executed Execution of a step takes zero time

Statecharts - Principles

Page 15: The STATEMATE Semantics of Statecharts

04/22/23CS 367 15/32

Principles …Principles …cont’dcont’d

Less trivial situations– Enabled conflicting transitions in the same step– Transition crosses boundary of nested states

(exited/entered states ?)

Statecharts - Principles

Page 16: The STATEMATE Semantics of Statecharts

04/22/23CS 367 16/32

Basic System ReactionsBasic System Reactions

Page 17: The STATEMATE Semantics of Statecharts

04/22/23CS 367 17/32

Basic system reactionsBasic system reactions

Configuration: C is the maxl set of states that the system can be in simultaneously– C contains R– If C contains an OR state O, it contains exactly 1 substate of O– If C contains an AND state A, it contains all substates of A– The only states in C are those required above.– Closed upwards, sufficient to know its basic states

Statecharts – Basic system reactions

Page 18: The STATEMATE Semantics of Statecharts

04/22/23CS 367 18/32

Basic system reactionsBasic system reactions

Basic configuration– maxl set of basic states that the system can be in simultaneously

Statecharts – Basic system reactions

S

EB1

B2

C1

C2

D1

D2

B C DA

Full: {S, A, B, C, D}Basic: {B1, C1, D1}

Full: {S, E}Basic: {E}

Page 19: The STATEMATE Semantics of Statecharts

04/22/23CS 367 19/32

Basic system reactionsBasic system reactions

4 operation types– Transitions– Static reactions– Entering actions– Exiting actions

Statecharts – Basic system reactions

BA

S

t1:ev/act

1. ev occurs2. t1 enabled3. Execute act4. exited(A), entered(B)

generated, sensed in next step (SR’s)

5. in(A)=false, in(B)=true6. Actions on exit(A),

enter(B) executed7. All enabled SR’s of S8. Within/throughout:

deactivated in A, activated in B

Page 20: The STATEMATE Semantics of Statecharts

04/22/23CS 367 20/32

Compound TransitionsCompound Transitions

Statecharts – Compound transitions

Execution of a step must always lead to a legal configuration

Actual transition: a set of separate transitions Basic compound transition (CT)

– Maxm chain of transition segments executable as single transition– Joint and fork are AND connectors– Condition, selection, and junction are OR connectors– Initial, continuation and full CT

Page 21: The STATEMATE Semantics of Statecharts

04/22/23CS 367 21/32

Dealing with HistoryDealing with History

Statecharts – Dealing with History

Two kinds of History connectors– H: target is one substate of S– H*: target is basic configuration relative to S

H

B2 B1

B S

At1:eC

t2:[C1][C2]

t3 ![C2]!

Page 22: The STATEMATE Semantics of Statecharts

04/22/23CS 367 22/32

Scope of TransitionsScope of Transitions

Statecharts – Dealing with History

Full CT– Source contains states only (no connectors)– Target contains basic states and termination connectors only– Every two source and every two target states are mutually

orthogonal– Target set is maximal– Enabled, if at beginning of the step system is in all of its source

states and its trigger is true

Page 23: The STATEMATE Semantics of Statecharts

04/22/23CS 367 23/32

Scope of TransitionsScope of Transitions

Statecharts – Dealing with History

Scope of tr– The lowest OR state in the state hierarchy– Common ancestor of all sources and targets of tr

H

V R

UW

Zt2

SAB

B1

B2

C1

C2

C

t1

SW

t1

t2

Page 24: The STATEMATE Semantics of Statecharts

04/22/23CS 367 24/32

Conflicting TransitionsConflicting Transitions

Statecharts – Dealing with History

Two CTs are in conflict if their scopes cannot be orthogonal or exclusive– Nondeterminism vs. priority

B C

U S

D

At1t2

t3

t4 t1 vs. t2t4 vs. {t1, t2, t3}

Page 25: The STATEMATE Semantics of Statecharts

04/22/23CS 367 25/32

Racing ConditionsRacing Conditions

Statecharts – Dealing with History

Racing condition: one action changes, others use the value of some variable in the same step– Ex.: X := X+1, Y := X*5

Working with supersteps => between transitions or actions

Race situation: Different (but still legal) execution orders of enabled transitions provide different results

Page 26: The STATEMATE Semantics of Statecharts

04/22/23CS 367 26/32

Racing ConditionsRacing Conditions

Statecharts – Dealing with History

Race situation

E F

S

G

At1: e / f

t2: f / X:=5

t3: f t4: / Y:=X+1

B

C D

Page 27: The STATEMATE Semantics of Statecharts

04/22/23CS 367 27/32

Two Models of TimeTwo Models of Time

Statecharts – Dealing with History

Synchronous time model– A single step every time unit– Highly synchronous systems

Asynchronous time model– The system reacts whenever an external change occurs– Several external changes simultaneously– Superstep: Several steps in a single point in time

Steps take zero time

Page 28: The STATEMATE Semantics of Statecharts

04/22/23CS 367 28/32

New IssuesNew Issues

Page 29: The STATEMATE Semantics of Statecharts

04/22/23CS 367 29/32

Combinational AssignmentsCombinational Assignments

Statecharts – Dealing with History

Associated with the entire chart Continuous function

– Recomputed immediately after any parameter change– Possible loops

A := 5 when B = 3 else 10B := 3 when A > 5 else 4

– The event changed(var) generated only when it has a new value at the end of CA execution

Page 30: The STATEMATE Semantics of Statecharts

04/22/23CS 367 30/32

Priority of TransitionsPriority of Transitions

Statecharts – Dealing with History

Two aspects– Structural priority of a compound transition– Priority number of a transition segment

Structural priority determinant– Based on the source(s)

and target(s) of CT C

D

BS

Et1

Ft3

t2

Page 31: The STATEMATE Semantics of Statecharts

04/22/23CS 367 31/32

Priority of TransitionsPriority of Transitions

Statecharts – Dealing with History

Priority number– The first different segment is definitive

S T1

T2

T3

T4

T5

T6

(5)

(5) (5)

(6)

(6)

(7)

(8)

(8)

(8)(40)