• Keine Ergebnisse gefunden

A Sample State Machine

N/A
N/A
Protected

Academic year: 2022

Aktie "A Sample State Machine"

Copied!
15
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

A Sample State Machine

Till Mossakowski Semantics of UML state machines

(2)

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

(3)

Environment Structures

Given a signatureH= (GH,AH,MH), ModEnv(H) consists of triples

Ω = (|Ω|, γ :GH →℘|Ω|, α:AH →(|Ω| → |Ω| ×℘(MH))) , where

|Ω|: set of data states,

ω ∈γ(g): state ω∈ |Ω|satisfies guardg,

0,m) =α(a)(ω): actionaleads from stateω ∈ |Ω|to state ω0∈ |Ω|producing the set of messages m⊆MH.

Till Mossakowski Semantics of UML state machines

(4)

Environment Sentences

The set of environmentsentences SenEnv(H) for an environment signatureH= (GH,AH,MH) comprises the expressions

gpre→[a]mBgpost

withgpre,gpost∈GH,a∈AH, andm⊆MH. Intuitive meaning: if pre-conditiongpre holds,

then, after executing a,

messagesm are produced and post-conditiongpost holds.

Ω|=EnvH gpre→[a]mBgpost holds if, and only if,

for all ω∈ |Ω|, ifω ∈γ(gpre) and (ω0,m0) =α(a)(ω), thenω0 ∈γ(gpost) andm⊆m0.

(5)

A Sample State Machine

Till Mossakowski Semantics of UML state machines

(6)

Signature and Sentences for the Sample State Machine

Environment signature:

guards true, trialsNum≤3,

actions user.ejectCard(); trialsNum = 0, trialsNum++, messages user.ejectCard(), bank.markInvalid(cardId) Sample environment sentences (forn∈N):

true→[user.ejectCard(); trialsNum = 0]{user.ejectCard()}

BtrialsNum == 0

trialsNum == n→[trialsNum++]∅BtrialsNum ==n+ 1

(7)

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)

LTS is deterministic, if|I|= 1 and|Post(s,a)| ≤1 ∀ s ∈S,a∈L

Till Mossakowski Semantics of UML state machines

(8)

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

for all 0≤i.

(9)

State Machines as Labeled Transition Systems

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

Signature: Σ = (EΣ,SΣ) (events and states) with EΣ∩SΣ=∅.

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

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

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

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

s0: initial state

Note: for simplicity, we omit hierarchical states.

Till Mossakowski Semantics of UML state machines

(10)

A Sample State Machine

(11)

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 for making the decision whether trialsNum<2 or trialsNum ≥2 has been resolved by combining the transitions.

Till Mossakowski Semantics of UML state machines

(12)

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).

(13)

The Induced Semantic Labeled Transition System, cont’d

Transition relation:

T ={((ω,p]p,s),m∩(MH\EΣ),(ω0,pC((m∩EΣ)∪ {s0}),s0))| ω∈γ(g), (ω0,m) =α(a)(ω), (s,(p,g,a),s0)∈T} ∪ {((ω,p]p,s),∅,(ω,p,s))|

∀(s,(p0,g,a),s0)∈T.p 6=p0∨ω /∈γ(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 generated completion events).

Till Mossakowski Semantics of UML state machines

(14)

Sample State Machine

(15)

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

Till Mossakowski Semantics of UML state machines

Referenzen

ÄHNLICHE DOKUMENTE

German Development Institute / Deutsches Institut für Entwicklungspolitik (DIE) 15 development aid in mitigating state fragility and forced migration is an especially contested

• events that cannot be handled in a state but should be kept in the event pool. • reconsidered when state

Actions (effects): operations of class diagram, assignments of attributes etc. Messages (triggers): signals and operations of

outgoing Transitions must target States in different Regions of an orthogonal State).

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

Instead of enhancing the Unified Modelling Language semantics, the approach of specifying the semantics of workflow charts using the formalism of Abstract State Machines has been

This includes probabilistic batch generation of test cases, which include expected observations, test execution and evaluation, as well as a probabilistic simulator for state