• Keine Ergebnisse gefunden

Putting it together, semantically: Semantics of UML state machines

N/A
N/A
Protected

Academic year: 2022

Aktie "Putting it together, semantically: Semantics of UML state machines"

Copied!
22
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Putting it together, semantically:

Semantics of UML state machines

Till Mossakowski1

Otto-von-Guericke Universit¨at Magdeburg, Germany

June 28, 2016

(2)

Overview

Class diagram Environment signature

Environment structure

State machine SM signature

syntactic LTS

Semantic LTS

based on based on

based on

LTS = labeled transition system

combine

(3)

Overview — Syntax & Semantics

Class diagram Environment signature

Environment structure

State machine SM signature

syntactic LTS

Semantic LTS

based on based on

based on

LTS = labeled transition system

combine

Syntax

Semantics

can be read off from the diagrams

meaning of the diagram, expressed in some mathematical domain

(4)

A Sample State Machine

userCom.card(c) / cardId = c

[trialsNum >= 3] / userCom.keepCard();

bankCom.markInvalid(cardId);

trialsNum = 0

bankCom.reenterPIN / / bankCom.verify(cardId, pin)

bankCom.verified / / userCom.ejectCard(); trialsNum = 0

pin = p

userCom.PIN(p) /

[trialsNum < 3] / trialsNum++

Idle PINEntered

Verifying

Verified CardEntered

ATM Behaviour stm

(5)

Overview

Class diagram Environment signature Environment structure

State machine SM signature

syntactic LTS

Semantic LTS

based on based on

based on

LTS = labeled transition system

combine

(6)

Environment Signatures

Anenvironment signature is a triple of sets H = (GH,AH,MH) of guards, actions, and messages.

Guards: formulas in some logical language, e.g. OCL.

Actions (effects): operations of class diagram, assignments of attributes etc.

Messages (triggers): signals and operations of class diagram

(7)

Overview

Class diagram Environment signature

Environment structure

State machine SM signature

syntactic LTS

Semantic LTS

based on based on

based on

LTS = labeled transition system

combine

(8)

Environment Structures

Given a signatureH= (GH,AH,MH), anenvironment structure Ω is given by:

Ω = (|Ω|,|=⊆ |Ω| ×GH, α ⊆ |Ω| ×AH×℘(MH)× |Ω|) , where

|Ω|: set of data states,

ω |= g: stateω∈ |Ω|satisfies guard g, (ω,a,m, ω0)∈α, also written ω−−→a,m

ω0: action a leads from state ω∈ |Ω|to stateω0 ∈ |Ω|producing the set of messages m⊆MH.

Example: take|Ω|to be the data states of a UML class diagram.

Actionsacan be e.g. variable updates.

(9)

A Sample State Machine

userCom.card(c) / cardId = c

[trialsNum >= 3] / userCom.keepCard();

bankCom.markInvalid(cardId);

trialsNum = 0

bankCom.reenterPIN / / bankCom.verify(cardId, pin)

bankCom.verified / / userCom.ejectCard(); trialsNum = 0

pin = p

userCom.PIN(p) /

[trialsNum < 3] / trialsNum++

Idle PINEntered

Verifying

Verified CardEntered

ATM Behaviour stm

(10)

Signature for the Sample State Machine

Environment signature:

guards true, trialsNum≤3,

actions user.ejectCard(); trialsNum = 0, trialsNum++, messages user.ejectCard(), bank.markInvalid(cardId)

(11)

Overview

Class diagram Environment signature

Environment structure

State machine SM signature

syntactic LTS

Semantic LTS

based on based on

based on

LTS = labeled transition system

combine

(12)

Labeled Transition Systems

Definition (Labeled Transition System)

A labeled transition system LTS is a tuple (S,L,→,I), where S is a set of states,

L is a set of actions,

→⊆S×L×S is a transition relation, and I ⊆S is a set of initial states.

Optionally, there can also be a set of final states (in this case, an LTS is the same a a finite automaton).

We writes →a s0 for (s,a,s0)∈→.

Definition (Direct successors)

Post(s,a) ={s0 ∈S|s →a s0} (fors ∈S,a∈L) Definition (Deterministic LTS)

(13)

Runs of Labeled Transition Systems

Definition (Finite run)

Given an LTS (S,L,→,I), a finite runρ is a finite alternating sequence of states and actions starting with somes0 ∈I and ending with a state

ρ=s0a1s1. . .ansn such thatsi ai+1

−→si+1

for all 0≤i <n. n ≥0 is the length of the run.

Definition (Infinite run)

Given an LTS (S,L,→,I), an infinite runρ is a infinite alternating sequence of states starting with somes0∈I

ρ=s0a1s1a2s2. . . such that si ai+1

−→si+1

(14)

Overview

Class diagram Environment signature

Environment structure

State machine SM signature syntactic LTS

Semantic LTS

based on based on

based on

LTS = labeled transition system

combine

(15)

State Machines as Labeled Transition Systems

Given: H = (GH,AH,MH) environment signature.

Astate machine signature is given by a pair of sets: Σ = (EΣ,SΣ) (events and states) withEΣ∩SΣ =∅.

Labels: L= (EΣ∪SΣ)×GH×AH

triggering event (declared or completion event), guard, action Syntactic labeled transition systemof a state machine:

(SΣ,L,T ⊆SΣ×L×SΣ,{s0})

T: transition relation, representing transitions from a state to another state.

s0: initial state

(16)

A Sample State Machine

userCom.card(c) / cardId = c

[trialsNum >= 3] / userCom.keepCard();

bankCom.markInvalid(cardId);

trialsNum = 0

bankCom.reenterPIN / / bankCom.verify(cardId, pin)

bankCom.verified / / userCom.ejectCard(); trialsNum = 0

pin = p

userCom.PIN(p) /

[trialsNum < 3] / trialsNum++

Idle PINEntered

Verifying

Verified CardEntered

ATM Behaviour stm

(17)

Syntactic LTS for Sample State Machine

Signature: (EATM,SATM) with

EATM ={card,PIN,reenterPIN,PINVerified}

SATM={Idle,CardEntered,PINEntered,Verifying,PINVerified}

The syntactic LTS of the state machine:

({(Idle,(card,true,cardId = c),CardEntered), (CardEntered,(PIN,true,pin = p),PINEntered),

(PINEntered,(PINEntered,true,bank.verify(cardId, pin)),Verifying), (Verifying,(reenterPIN,trialsNum<2,trialsNum++),

CardEntered), . . .},{Idle}) In particular, PINEntered occurs both as a state and as a

completion event in the third transition. The junction pseudostate

(18)

Overview

Class diagram Environment signature

Environment structure

State machine SM signature

syntactic LTS

Semantic LTS

based on based on

based on

LTS = labeled transition system

combine

(19)

The Induced Semantic Labeled Transition System

Syntactic LTS Θ: control statesSΣ

Semantic LTS ∆Θ: control and data states:

States: C =|Ω| ×℘(EΣ∪SΣ)×SΣ

environment state, an event pool, and a control state Labels: L=℘(MH) set of messages

The event pool may contain both events declared in the signature (from signals and operations) and completion events (represented by states).

(20)

The Induced Semantic Labeled Transition System, cont’d

Transition relation:

(ω,p::p,s)−−−→m\EΣ

Θ

0,pC((m∩EΣ)∪ {s0}),s0) if

∃s −p[g]/a−−−→

T s0. ω|=g ∧ω −−→a,m

ω0 (ω,p::p,s)−−→

Θ (ω,p,s) if

∀s p

0[g]/a

−−−−→

T s0.p 6=p0∨ω6|=g p]p: p is next event to be processed

pCp0: adds eventsp0 to pool p m∩(MH\EΣ): messages emitted

(m∩EΣ)∪ {s0}: accepted events inEΣ and completion event when entering state s0 are added to the event pool.

When no transition is triggered by the current event, the event is discarded (this will happen, in particular, to all superfluously

(21)

Sample State Machine

userCom.card(c) / cardId = c

[trialsNum >= 3] / userCom.keepCard();

bankCom.markInvalid(cardId);

trialsNum = 0

bankCom.reenterPIN / / bankCom.verify(cardId, pin)

bankCom.verified / / userCom.ejectCard(); trialsNum = 0

pin = p

userCom.PIN(p) /

[trialsNum < 3] / trialsNum++

Idle PINEntered

Verifying

Verified CardEntered

ATM Behaviour stm

(22)

Protocol state machines

Protocol state machines: pre- and a postcondition instead of guards and effects.

Events that do not fire a transition are an error.

The syntactic LTS is changed to:

(T ⊆SΣ×(GH×EΣ×GH×℘(MH))×SΣ,{s0}) where

the two occurrences of GH represent the pre- and the post-conditions,

℘(MH) represents the messages that have to be sent out in executing the triggering event

Referenzen

ÄHNLICHE DOKUMENTE

the set of natural numbers with the usual ordering ≤ the set of natural numbers with the ordering “x can be divided by y”. the lexicographic order on strings (used for sorting)

A UML class diagram is strongly consistent, if there is at least one snapshot intepreting all classes as non-empty sets satisfying all its conditions... Semantics of aggregations

If the water tank is empty and the coffee machine is switched on, in model A the “keep warm” function is activated.. In the same situation, model B simply

actions user.ejectCard(); trialsNum = 0, trialsNum++, messages user.ejectCard(), bank.markInvalid(cardId).. .}, {Idle}) In particular, PINEntered occurs both as a state and as

I Eect: Actions caused by transition Idle knocking[doorClosed]/openDoor Greet.. State Machine Signature

1,3-Dipolar cycloaddition of azomethine ylides derived from acenaphthylene-1,2-dione and 5- methyl-benzo[b]-thiophene-2,3-dione with L-proline, thiazolidine-4-carboxylic acid

The Circular Dichroism (CD) spectrum of -lactamase from Escherichia coli (TEM-1) has been calculated with the matrix method on the basis of the x-ray diffraction structure.. All

We shall now formulate two auxiliary results which will be used in the proof of Theorem 3.. Stochastic Models of Control and Economic