• Aucun résultat trouvé

Advanced modelling techniques Formal verification, temporal logics, model-checking Laure Petrucci

N/A
N/A
Protected

Academic year: 2022

Partager "Advanced modelling techniques Formal verification, temporal logics, model-checking Laure Petrucci"

Copied!
293
0
0

Texte intégral

(1)

Advanced modelling techniques

Formal verification, temporal logics, model-checking

Laure Petrucci

Universit´e Paris 13

(2)

Objectives of the module

introduce formal models for critical systems specification automata

Petri nets their extensions

use model-checking to verify their properties reachability

deadlocks

properties expressed in LTL and CTL logics

(3)

Outline

1

Automata

Introductory notions

Automata

Execution and execution tree Atomic properties

Formal definitions

Automata Behaviour

Extensions of automata

Automata with variables

Synchronised product of automata Synchronisation by message passing

3

Model-checking CTL model-checking LTL model-checking

2

Temporal logic Language LTL

Formal syntax and semantics Illustration

Examples of LTL formulae

CTL

Formal syntax and semantics Illustration

Examples of CTL formulae

4

Symbolic model-checking

Computation of state sets Binary Decision Diagrams Automata representation

5

Reachability Properties

Reachability in temporal logic

Computation of the reachability

(4)

Automata

Outline

1

Automata

Introductory notions

Automata

Execution and execution tree Atomic properties

Formal definitions

Automata Behaviour

Extensions of automata

Automata with variables

Synchronised product of automata

Synchronisation by message passing

(5)

Automata Introductory notions

Automata

Intuitively, an automaton is a machine evolving from one state to another under the action of transitions.

Example: Digital clock 17:00

17:01 17:02

(6)

Automata Introductory notions

Automata

Intuitively, an automaton is a machine evolving from one state to another under the action of transitions.

Example: Digital clock 17:00

17:01 17:02

(7)

Automata Introductory notions

Automata

Intuitively, an automaton is a machine evolving from one state to another under the action of transitions.

Example: Digital clock

17:00 17:01

17:02

(8)

Automata Introductory notions

Automata

Intuitively, an automaton is a machine evolving from one state to another under the action of transitions.

Example: Digital clock

17:00 17:01 17:02

(9)

Automata Introductory notions

Automata

Intuitively, an automaton is a machine evolving from one state to another under the action of transitions.

Example: Digital clock

17:00 17:01 17:02

(10)

Automata Introductory notions

Automata

Example: Modulo 3 counter counts 0, 1, 2

initial value 0

allows operations increment and decrement

0 1

2

inc

inc inc

dec

dec

dec

(11)

Automata Introductory notions

Automata

Example: Modulo 3 counter counts 0, 1, 2

initial value 0

allows operations increment and decrement

0 1

2

inc

inc inc

dec

dec

dec

(12)

Automata Introductory notions

Automata

Example: Modulo 3 counter counts 0, 1, 2

initial value 0

allows operations increment and decrement

0 1

2 inc

inc inc

dec

dec

dec

(13)

Automata Introductory notions

Automata

Example: Modulo 3 counter counts 0, 1, 2

initial value 0

allows operations increment and decrement

0 1

2 inc

inc inc

dec

dec

dec

(14)

Automata Introductory notions

Automata

Example: Modulo 3 counter counts 0, 1, 2

initial value 0

allows operations increment and decrement

0 1

2 inc

inc inc

dec

dec

dec

(15)

Automata Introductory notions

Automata

Example: Digicode 3 keys A, B, C

code to open door ABA

if the wrong key is pressed the whole operation has to start again

0

1 A

B,C

B 2 A

C

A 3

B,C

Remark: The numbers in the states are the number of correct keys that

have already been pressed.

(16)

Automata Introductory notions

Automata

Example: Digicode 3 keys A, B, C

code to open door ABA

if the wrong key is pressed the whole operation has to start again

0

1 A

B,C

B 2 A

C

A 3

B,C

Remark: The numbers in the states are the number of correct keys that

have already been pressed.

(17)

Automata Introductory notions

Automata

Example: Digicode 3 keys A, B, C

code to open door ABA

if the wrong key is pressed the whole operation has to start again

0 1

A

B,C

B 2 A

C

A 3

B,C

Remark: The numbers in the states are the number of correct keys that

have already been pressed.

(18)

Automata Introductory notions

Automata

Example: Digicode 3 keys A, B, C

code to open door ABA

if the wrong key is pressed the whole operation has to start again

0 1

A B,C

B 2 A

C

A 3

B,C

Remark: The numbers in the states are the number of correct keys that

have already been pressed.

(19)

Automata Introductory notions

Automata

Example: Digicode 3 keys A, B, C

code to open door ABA

if the wrong key is pressed the whole operation has to start again

0 1

A B,C

B 2

A

C

A 3

B,C

Remark: The numbers in the states are the number of correct keys that

have already been pressed.

(20)

Automata Introductory notions

Automata

Example: Digicode 3 keys A, B, C

code to open door ABA

if the wrong key is pressed the whole operation has to start again

0 1

A B,C

B 2 A

C

A 3

B,C

Remark: The numbers in the states are the number of correct keys that

have already been pressed.

(21)

Automata Introductory notions

Automata

Example: Digicode 3 keys A, B, C

code to open door ABA

if the wrong key is pressed the whole operation has to start again

0 1

A B,C

B 2 A

C

A 3

B,C

Remark: The numbers in the states are the number of correct keys that

have already been pressed.

(22)

Automata Introductory notions

Automata

Example: Digicode 3 keys A, B, C

code to open door ABA

if the wrong key is pressed the whole operation has to start again

0 1

A B,C

B 2 A

C

A 3

B,C

Remark: The numbers in the states are the number of correct keys that

have already been pressed.

(23)

Automata Introductory notions

Executions of a model

0 1

A B,C

B 2 A

C

A 3

B,C

Execution

An execution is a sequence of states describing a possible evolution of the system.

0123 001201 001123

Questions

Which executions lead to opening the door?

Is there a possible infinite execution?

All those that end in state 3

For example 00000000...

(24)

Automata Introductory notions

Executions of a model

0 1

A B,C

B 2 A

C

A 3

B,C

Execution

An execution is a sequence of states describing a possible evolution of the system.

0123 001201 001123

Questions

Which executions lead to opening the door?

Is there a possible infinite execution?

All those that end in state 3

For example 00000000...

(25)

Automata Introductory notions

Executions of a model

0 1

A B,C

B 2 A

C

A 3

B,C

Execution

An execution is a sequence of states describing a possible evolution of the system.

0123 001201 001123

Questions

Which executions lead to opening the door?

Is there a possible infinite execution?

All those that end in state 3

For example 00000000...

(26)

Automata Introductory notions

Executions of a model

0 1

A B,C

B 2 A

C

A 3

B,C

Execution

An execution is a sequence of states describing a possible evolution of the system.

0123 001201 001123

Questions

Which executions lead to opening the door?

Is there a possible infinite execution?

All those that end in state 3

For example 00000000...

(27)

Automata Introductory notions

Execution tree

A tree to represent all possible executions root: initial state of the automaton

children of a node: its immediate successors (states accessible from the node in one step)

The digicode example

0 1

A B,C

B 2 A

C

A 3

B,C

0 0

0 0 1

1

0 1 2

1 0 0 1

1

0 1 2

2 0 3

. . .

(28)

Automata Introductory notions

Execution tree

A tree to represent all possible executions root: initial state of the automaton

children of a node: its immediate successors (states accessible from the node in one step)

The digicode example

0 1

A B,C

B 2 A

C

A 3

B,C

0 0

0 0 1

1

0 1 2

1 0 0 1

1

0 1 2

2 0 3

. . .

(29)

Automata Introductory notions

Execution tree

A tree to represent all possible executions root: initial state of the automaton

children of a node: its immediate successors (states accessible from the node in one step)

The digicode example

0 1

A B,C

B 2 A

C

A 3

B,C

0 0

0 0 1

1

0 1 2

1 0 0 1

1

0 1 2

2 0 3

. . .

(30)

Automata Introductory notions

Exercise

Execution tree for the modulo 3 counter

0 1

2 inc

dec dec

inc

inc dec

0 1

0 1 0 2

2 0 1

2 0 1 2

1 0 2

2 0 1 0 2

2 0 1

1 0 1 2

2 0 1

. . .

(31)

Automata Introductory notions

Exercise

Execution tree for the modulo 3 counter

0 1

2 inc

dec dec

inc

inc dec

0 1

0 1 0 2

2 0 1

2 0 1 2

1 0 2

2 0 1 0 2

2 0 1

1 0 1 2

2 0 1

. . .

(32)

Automata Introductory notions

Atomic properties

Atomic properties are elementary properties known to be true or false some atomic properties can be associated with each state

used to define more complex properties

Digicode atomic properties P

A

: A has just been pressed P

B

: B has just been pressed P

C

: C has just been pressed

Associate properties with states

0 1

PA

A B,C

2

PB

B A

C

3

PA

A

B,C

Prove the correct code was entered when the door opens

The door is open only in state 3. Its only predecessor is 2 and transition A is used from state 2 to state 3. So A is the last key pressed.

The only predecessor of 2 is 1, and transition B was used.

State 1 has two possible predecessors: 0 and 1, and both used A.

Therefore, the code entered ends with ABA.

(33)

Automata Introductory notions

Atomic properties

Atomic properties are elementary properties known to be true or false some atomic properties can be associated with each state

used to define more complex properties Digicode atomic properties

P

A

: A has just been pressed P

B

: B has just been pressed P

C

: C has just been pressed

Associate properties with states

0 1

PA

A B,C

2

PB

B A

C

3

PA

A

B,C

Prove the correct code was entered when the door opens

The door is open only in state 3. Its only predecessor is 2 and transition A is used from state 2 to state 3. So A is the last key pressed.

The only predecessor of 2 is 1, and transition B was used.

State 1 has two possible predecessors: 0 and 1, and both used A.

Therefore, the code entered ends with ABA.

(34)

Automata Introductory notions

Atomic properties

Atomic properties are elementary properties known to be true or false some atomic properties can be associated with each state

used to define more complex properties Digicode atomic properties

P

A

: A has just been pressed P

B

: B has just been pressed P

C

: C has just been pressed

Associate properties with states

0 1

PA

A B,C

2

PB

B A

C

3

PA

A

B,C

Prove the correct code was entered when the door opens

The door is open only in state 3. Its only predecessor is 2 and transition A is used from state 2 to state 3. So A is the last key pressed.

The only predecessor of 2 is 1, and transition B was used.

State 1 has two possible predecessors: 0 and 1, and both used A.

Therefore, the code entered ends with ABA.

(35)

Automata Introductory notions

Atomic properties

Atomic properties are elementary properties known to be true or false some atomic properties can be associated with each state

used to define more complex properties Digicode atomic properties

P

A

: A has just been pressed P

B

: B has just been pressed P

C

: C has just been pressed

Associate properties with states

0 1

PA A B,C

2 PB B A

C

3 PA A

B,C

Prove the correct code was entered when the door opens

The door is open only in state 3. Its only predecessor is 2 and transition A is used from state 2 to state 3. So A is the last key pressed.

The only predecessor of 2 is 1, and transition B was used.

State 1 has two possible predecessors: 0 and 1, and both used A.

Therefore, the code entered ends with ABA.

(36)

Automata Introductory notions

Atomic properties

Atomic properties are elementary properties known to be true or false some atomic properties can be associated with each state

used to define more complex properties Digicode atomic properties

P

A

: A has just been pressed P

B

: B has just been pressed P

C

: C has just been pressed

Associate properties with states

0 1

PA A B,C

2 PB B A

C

3 PA A

B,C

Prove the correct code was entered when the door opens

The door is open only in state 3. Its only predecessor is 2 and transition A is used from state 2 to state 3. So A is the last key pressed.

The only predecessor of 2 is 1, and transition B was used.

State 1 has two possible predecessors: 0 and 1, and both used A.

Therefore, the code entered ends with ABA.

(37)

Automata Introductory notions

Atomic properties

Atomic properties are elementary properties known to be true or false some atomic properties can be associated with each state

used to define more complex properties Digicode atomic properties

P

A

: A has just been pressed P

B

: B has just been pressed P

C

: C has just been pressed

Associate properties with states

0 1

PA A B,C

2 PB B A

C

3 PA A

B,C

Prove the correct code was entered when the door opens

The door is open only in state 3. Its only predecessor is 2 and transition A is used from state 2 to state 3. So A is the last key pressed.

The only predecessor of 2 is 1, and transition B was used.

State 1 has two possible predecessors: 0 and 1, and both used A.

Therefore, the code entered ends with ABA.

(38)

Automata Formal definitions

Formal definition of automata

Automaton

Let Prop be a set of atomic propositions. An automaton is a tuple A = hQ, E , T , q

0

, l, F i such that:

Q is a finite set of states

E is a finite set of transition labels T ⊆ Q × E × Q is a set of transitions q

0

is the initial state

l : Q −→ 2

Prop

associates with each state a finite set of atomic propositions

F is a set of final states

(39)

Automata Formal definitions

Example

The digicode example

0 1

A B,C

B 2 A

C

A 3

B,C

Q = {0, 1, 2, 3}

E = {A, B, C }

T = {(0, A, 1), (0, B, 0), (0, C , 0), (1, A, 1), (1, B, 2), (1, C , 0), (2, A, 3), (2, B, 0), (2, C , 0)} q

0

= 0

Prop = {P

A

, P

B

, P

C

}

l(0) = ∅, l (1) = {P

A

},

l(2) = {P

B

}, l(3) = {P

A

}

F = {3}

(40)

Automata Formal definitions

Example

The digicode example

0 1

A B,C

B 2 A

C

A 3

B,C

Q = {0, 1, 2, 3}

E = {A, B, C }

T = {(0, A, 1), (0, B, 0), (0, C , 0), (1, A, 1), (1, B, 2), (1, C , 0), (2, A, 3), (2, B, 0), (2, C , 0)} q

0

= 0

Prop = {P

A

, P

B

, P

C

}

l(0) = ∅, l (1) = {P

A

},

l(2) = {P

B

}, l(3) = {P

A

}

F = {3}

(41)

Automata Formal definitions

Example

The digicode example

0 1

A B,C

B 2 A

C

A 3

B,C

Q = {0, 1, 2, 3}

E = {A, B, C }

T = {(0, A, 1), (0, B, 0), (0, C , 0), (1, A, 1), (1, B, 2), (1, C , 0), (2, A, 3), (2, B, 0), (2, C , 0)} q

0

= 0

Prop = {P

A

, P

B

, P

C

}

l(0) = ∅, l (1) = {P

A

},

l(2) = {P

B

}, l(3) = {P

A

}

F = {3}

(42)

Automata Formal definitions

Example

The digicode example

0 1

A B,C

B 2 A

C

A 3

B,C

Q = {0, 1, 2, 3}

E = {A, B, C }

T = {(0, A, 1), (0, B, 0), (0, C , 0), (1, A, 1), (1, B, 2), (1, C , 0), (2, A, 3), (2, B, 0), (2, C , 0)}

q

0

= 0

Prop = {P

A

, P

B

, P

C

}

l(0) = ∅, l (1) = {P

A

},

l(2) = {P

B

}, l(3) = {P

A

}

F = {3}

(43)

Automata Formal definitions

Example

The digicode example

0 1

A B,C

B 2 A

C

A 3

B,C

Q = {0, 1, 2, 3}

E = {A, B, C }

T = {(0, A, 1), (0, B, 0), (0, C , 0), (1, A, 1), (1, B, 2), (1, C , 0), (2, A, 3), (2, B, 0), (2, C , 0)}

q

0

= 0

Prop = {P

A

, P

B

, P

C

}

l(0) = ∅, l (1) = {P

A

},

l(2) = {P

B

}, l(3) = {P

A

}

F = {3}

(44)

Automata Formal definitions

Example

The digicode example

0 1

A B,C

B 2 A

C

A 3

B,C

Q = {0, 1, 2, 3}

E = {A, B, C }

T = {(0, A, 1), (0, B, 0), (0, C , 0), (1, A, 1), (1, B, 2), (1, C , 0), (2, A, 3), (2, B, 0), (2, C , 0)}

q

0

= 0

Prop = {P

A

, P

B

, P

C

}

l(0) = ∅, l (1) = {P

A

},

l(2) = {P

B

}, l(3) = {P

A

}

F = {3}

(45)

Automata Formal definitions

Example

The digicode example

0 1

A B,C

B 2 A

C

A 3

B,C

Q = {0, 1, 2, 3}

E = {A, B, C }

T = {(0, A, 1), (0, B, 0), (0, C , 0), (1, A, 1), (1, B, 2), (1, C , 0), (2, A, 3), (2, B, 0), (2, C , 0)}

q

0

= 0

Prop = {P

A

, P

B

, P

C

} l(0) = ∅, l (1) = {P

A

}, l(2) = {P

B

}, l(3) = {P

A

}

F = {3}

(46)

Automata Formal definitions

Example

The digicode example

0 1

A B,C

B 2 A

C

A 3

B,C

Q = {0, 1, 2, 3}

E = {A, B, C }

T = {(0, A, 1), (0, B, 0), (0, C , 0), (1, A, 1), (1, B, 2), (1, C , 0), (2, A, 3), (2, B, 0), (2, C , 0)}

q

0

= 0

Prop = {P

A

, P

B

, P

C

}

l(0) = ∅, l (1) = {P

A

},

l(2) = {P

B

}, l(3) = {P

A

}

F = {3}

(47)

Automata Formal definitions

Exercise

Formal representation of the modulo 3 counter (no property)

0 1

2 inc

dec dec

inc

inc dec

Q = {0, 1, 2} E = {inc, dec}

T = {(0, inc, 1), (0, dec, 2), (1, inc, 2), (1, dec, 0), (2, inc, 0), (2, dec, 1), q

0

= 0

Prop = ∅

l(0) = l(1) = l (2) = ∅

F = ∅

(48)

Automata Formal definitions

Exercise

Formal representation of the modulo 3 counter (no property)

0 1

2 inc

dec dec

inc

inc dec

Q = {0, 1, 2}

E = {inc, dec}

T = {(0, inc, 1), (0, dec, 2), (1, inc, 2), (1, dec, 0), (2, inc, 0), (2, dec, 1), q

0

= 0

Prop = ∅

l(0) = l(1) = l (2) = ∅

F = ∅

(49)

Automata Formal definitions

Behaviour

Runs (or paths)

A run (or path) of an automaton A is a sequence σ of successive transitions (q

i

, e

i

, q

i0

) of A, i.e. such that ∀i , q

i+1

= q

0i

.

σ = q

1

−→

e1

q

2

−→

e2

q

3

−→

e3

q

4

. . .

The length of a run σ is its number of transitions |σ| ∈ N ∪ {ω}

where ω denotes infinity.

The i

th

state of σ is the state q

i+1

reached after i transitions.

Executions

A partial execution of A is a run starting from the initial state q

0

. A complete execution of A is an execution that is maximal. It is either infinite or ends in a state where no transition is possible. This state might be final (in F ), or a deadlock.

A state is reachable if there exists an execution in which it appears.

The complete executions define the behaviour of the automaton.

(50)

Automata Formal definitions

Behaviour

Runs (or paths)

A run (or path) of an automaton A is a sequence σ of successive transitions (q

i

, e

i

, q

i0

) of A, i.e. such that ∀i , q

i+1

= q

0i

.

σ = q

1

−→

e1

q

2

−→

e2

q

3

−→

e3

q

4

. . .

The length of a run σ is its number of transitions |σ| ∈ N ∪ {ω}

where ω denotes infinity.

The i

th

state of σ is the state q

i+1

reached after i transitions.

Executions

A partial execution of A is a run starting from the initial state q

0

. A complete execution of A is an execution that is maximal. It is either infinite or ends in a state where no transition is possible. This state might be final (in F ), or a deadlock.

A state is reachable if there exists an execution in which it appears.

The complete executions define the behaviour of the automaton.

(51)

Automata Formal definitions

Exercise

Mutual exclusion between two processes

two processes execute and need access to the same resource each process can request access to a critical section of its code they must not execute this part at the same time

when they have finished they signal they exit their critical section and loop back to their initial state

Questions

1

Model this problem with an automaton

2

Associate atomic properties with each state

3

Is the mutual exclusion requirement satisfied?

4

Is the system fair?

5

What would happen if you wanted to add a third process?

(52)

Automata Formal definitions

Exercise

0

1

2

3 4

5

6

7 req1

req 2

req 2 cs1

req1

cs2 cs

2 cs1 req2

req1 end1

end 2

end 1

end 2

2

P

i

: Process i is requesting access, C

i

: Process i is in its critical section, R

i

: Process i is at rest.

P

1

: states 1, 3, 7; P

2

: states 2, 3, 6; C

1

: states 4, 6; C

2

: states 5, 7; R

1

: states 0, 2, 5; R

2

: states 0, 1, 4

3

Yes: no state has both C

1

and C

2

4

No: run 0137137. . . never allows process 1 to enter its critical section

5

The number of states would blow up

(53)

Automata Formal definitions

Exercise

0

1

2

3 4

5

6

7 req1

req 2

req 2 cs1

req1

cs2 cs

2 cs1 req2

req1 end1

end 2

end 1

end 2

2

P

i

: Process i is requesting access, C

i

: Process i is in its critical section, R

i

: Process i is at rest.

P

1

: states 1, 3, 7; P

2

: states 2, 3, 6;

C

1

: states 4, 6; C

2

: states 5, 7;

R

1

: states 0, 2, 5; R

2

: states 0, 1, 4

3

Yes: no state has both C

1

and C

2

4

No: run 0137137. . . never allows process 1 to enter its critical section

5

The number of states would blow up

(54)

Automata Formal definitions

Exercise

0

1

2

3 4

5

6

7 req1

req 2

req 2 cs1

req1

cs2 cs

2 cs1 req2

req1 end1

end 2

end 1

end 2

2

P

i

: Process i is requesting access, C

i

: Process i is in its critical section, R

i

: Process i is at rest.

P

1

: states 1, 3, 7; P

2

: states 2, 3, 6;

C

1

: states 4, 6; C

2

: states 5, 7;

R

1

: states 0, 2, 5; R

2

: states 0, 1, 4

3

Yes: no state has both C

1

and C

2

4

No: run 0137137. . . never allows process 1 to enter its critical section

5

The number of states would blow up

(55)

Automata Formal definitions

Exercise

0

1

2

3 4

5

6

7 req1

req 2

req 2 cs1

req1

cs2 cs

2 cs1 req2

req1 end1

end 2

end 1

end 2

2

P

i

: Process i is requesting access, C

i

: Process i is in its critical section, R

i

: Process i is at rest.

P

1

: states 1, 3, 7; P

2

: states 2, 3, 6;

C

1

: states 4, 6; C

2

: states 5, 7;

R

1

: states 0, 2, 5; R

2

: states 0, 1, 4

3

Yes: no state has both C

1

and C

2

4

No: run 0137137. . . never allows process 1 to enter its critical section

5

The number of states would blow up

(56)

Automata Formal definitions

Exercise

0

1

2

3 4

5

6

7 req1

req 2

req 2 cs1

req1

cs2 cs

2 cs1 req2

req1 end1

end 2

end 1

end 2

2

P

i

: Process i is requesting access, C

i

: Process i is in its critical section, R

i

: Process i is at rest.

P

1

: states 1, 3, 7; P

2

: states 2, 3, 6;

C

1

: states 4, 6; C

2

: states 5, 7;

R

1

: states 0, 2, 5; R

2

: states 0, 1, 4

3

Yes: no state has both C

1

and C

2

4

No: run 0137137. . . never allows process 1 to enter its critical section

5

The number of states would blow up

(57)

Automata Extensions of automata

Extension with variables

Why and how to use variables?

more compact models, improving readability guards and assignments on transitions

Example: The digicode limited to 3 errors

0 1 2 3

A B,C

C

B,C

ctr<3 B,C ctr := ctr + 1

ctr<3 C ctr := ctr + 1

ctr<3 B,C ctr := ctr + 1

B A

A

var ctr: int;

ctr := 0

err ctr = 3

B,C

ctr := ctr + 1 ctr = 3

A,

C ctr := ctr + 1

ctr = 3 B,C ctr := ctr + 1 ctr<3

A ctr := ctr + 1;

(58)

Automata Extensions of automata

Extension with variables

Why and how to use variables?

more compact models, improving readability guards and assignments on transitions Example: The digicode limited to 3 errors

0 1 2 3

A B,C

C

B,C

ctr<3 B,C ctr := ctr + 1

ctr<3 C ctr := ctr + 1

ctr<3 B,C ctr := ctr + 1

B A

A

var ctr: int;

ctr := 0

err ctr = 3

B,C

ctr := ctr + 1 ctr = 3

A,

C ctr := ctr + 1

ctr = 3 B,C ctr := ctr + 1 ctr<3

A ctr := ctr + 1;

(59)

Automata Extensions of automata

Extension with variables

Why and how to use variables?

more compact models, improving readability guards and assignments on transitions Example: The digicode limited to 3 errors

0 1 2 3

A B,C

C

B,C

ctr<3 B,C ctr := ctr + 1

ctr<3 C ctr := ctr + 1

ctr<3 B,C ctr := ctr + 1

B A

A var ctr: int;

ctr := 0

err ctr = 3

B,C

ctr := ctr + 1 ctr = 3

A,

C ctr := ctr + 1

ctr = 3 B,C ctr := ctr + 1 ctr<3

A ctr := ctr + 1;

(60)

Automata Extensions of automata

Extension with variables

Why and how to use variables?

more compact models, improving readability guards and assignments on transitions Example: The digicode limited to 3 errors

0 1 2 3

A B,C

C

B,C

ctr<3 B,C ctr := ctr + 1

ctr<3 C ctr := ctr + 1

ctr<3 B,C ctr := ctr + 1

B A

A var ctr: int;

ctr := 0

err

ctr = 3 B,C

ctr := ctr + 1 ctr = 3

A,

C ctr := ctr + 1

ctr = 3 B,C ctr := ctr + 1 ctr<3

A ctr := ctr + 1;

(61)

Automata Extensions of automata

Extension with variables

Why and how to use variables?

more compact models, improving readability guards and assignments on transitions Example: The digicode limited to 3 errors

0 1 2 3

A

B,C

C

B,C

ctr<3 B,C ctr := ctr + 1

ctr<3 C ctr := ctr + 1

ctr<3 B,C ctr := ctr + 1

B A

A var ctr: int;

ctr := 0

err

ctr = 3 B,C

ctr := ctr + 1 ctr = 3

A,

C ctr := ctr + 1

ctr = 3 B,C ctr := ctr + 1 ctr<3

A ctr := ctr + 1;

(62)

Automata Extensions of automata

Extension with variables

Why and how to use variables?

more compact models, improving readability guards and assignments on transitions Example: The digicode limited to 3 errors

0 1 2 3

A

B,C

C

B,C

ctr<3 B,C ctr := ctr + 1

ctr<3 C ctr := ctr + 1

ctr<3 B,C ctr := ctr + 1

B A

A var ctr: int;

ctr := 0

err ctr = 3

B,C

ctr := ctr + 1 ctr = 3

A,

C ctr := ctr + 1

ctr = 3 B,C ctr := ctr + 1

ctr<3 A ctr := ctr + 1;

(63)

Automata Extensions of automata

Extension with variables

Why and how to use variables?

more compact models, improving readability guards and assignments on transitions Example: The digicode limited to 3 errors

0 1 2 3

A

B,C

C

B,C

ctr<3 B,C ctr := ctr + 1

ctr<3 C ctr := ctr + 1

ctr<3 B,C ctr := ctr + 1

B A

A

var ctr: int;

ctr := 0

err ctr = 3

B,C

ctr := ctr + 1 ctr = 3 A,C ctr := ctr + 1

ctr = 3 B,C ctr := ctr + 1 ctr<3

A ctr := ctr + 1;

(64)

Automata Extensions of automata

Extension with variables

Exercise: The digicode with 3 errors without variables

0,0 1,0 2,0 3,0

0,1 1,1 2,1 3,1

0,2 1,2 2,2 3,2

0,3 1,3 2,3 3,3

err A

A

A

A

A

A

A

A B

B

B

B B,C

B,C

B,C

B,C

B,C

B,C A

A

A C

C

C

B,C A,C B,C

(65)

Automata Extensions of automata

Extension with variables

Exercise: The digicode with 3 errors without variables

0,0 1,0 2,0 3,0

0,1 1,1 2,1 3,1

0,2 1,2 2,2 3,2

0,3 1,3 2,3 3,3

err A

A

A

A

A

A

A

A B

B

B

B B,C

B,C

B,C

B,C

B,C

B,C A

A

A C

C

C

B,C A,C B,C

(66)

Automata Extensions of automata

Synchronised product

Why?

each component of the system is designed as an automaton composition of automata

How?

independent actions lead to a cartesian product of states

synchronised actions occur simultaneously

(67)

Automata Extensions of automata

Synchronised product

Why?

each component of the system is designed as an automaton composition of automata

How?

independent actions lead to a cartesian product of states

synchronised actions occur simultaneously

(68)

Automata Extensions of automata

Synchronised product

3 counters, modulo 2, 3, 4: states

0,0,0 0,0,1 0,0,2 0,0,3

0,1,0 0,1,1 0,1,2 0,1,3

0,2,0 0,2,1 0,2,2 0,2,3

1,0,0 1,0,1 1,0,2 1,0,3

1,1,0 1,1,1 1,1,2 1,1,3

1,2,0 1,2,1 1,2,2

1,2,3

3 counters: some transitions

0,0,0 0,0,1

0,1,0 0,1,1

1,0,0 1,0,1

1,1,0 1,1,1

-,-,inc

inc,-,- -,inc,- inc,-,inc

inc,inc,- -,inc,inc

inc,inc,inc

(69)

Automata Extensions of automata

Example: Synchronised counters

Modulo 2 counter

0 1

inc,dec

inc,dec

Modulo 3 counter

0 1

2 inc

dec

inc dec

inc dec

Modulo 4 counter

0 1

2 3

inc

dec inc

dec

inc

decinc

dec

Synchronised actions: all counters increment or decrement simultaneously

0,0,0 1,1,1

0,2,2 1,0,3 0,1,0 1,2,1

0,0,2 1,1,3

0,2,0 1,0,1

0,1,2

1,2,3 inc

dec

inc dec

inc dec

inc dec

inc

dec dec inc

inc

dec

inc

dec

inc

dec

inc

dec

inc

dec

inc

dec

(70)

Automata Extensions of automata

Example: Synchronised counters

Modulo 2 counter

0 1

inc,dec

inc,dec

Modulo 3 counter

0 1

2 inc

dec

inc dec

inc dec

Modulo 4 counter

0 1

2 3

inc

dec inc

dec

inc

decinc

dec

Synchronised actions: all counters increment or decrement simultaneously

0,0,0 1,1,1

0,2,2 1,0,3 0,1,0 1,2,1

0,0,2 1,1,3

0,2,0 1,0,1

0,1,2

1,2,3 inc

dec

inc dec

inc dec

inc dec

inc

dec dec inc

inc

dec

inc

dec

inc

dec

inc

dec

inc

dec

inc

dec

(71)

Automata Extensions of automata

Example: Synchronised counters

Modulo 2 counter

0 1

inc,dec

inc,dec

Modulo 3 counter

0 1

2 inc

dec

inc dec

inc dec

Modulo 4 counter

0 1

2 3

inc

dec inc

dec

inc

decinc

dec

Synchronised actions: all counters increment or decrement simultaneously

0,0,0 1,1,1 0,2,2 1,0,3 0,1,0 1,2,1

0,0,2 1,1,3

0,2,0 1,0,1

0,1,2 1,2,3

inc

dec

inc dec

inc dec

inc dec

inc

dec dec inc

inc

dec

inc

dec

inc

dec

inc

dec

inc

dec

inc

dec

(72)

Automata Extensions of automata

Formal definition of the cartesian product

Let (A

i

)

1≤i≤n

be a family of automata A

i

= hQ

i

, E

i

, T

i

, q

0i

, l

i

, F

i

i.

Cartesian product of automata

The cartesian product A

1

× · · · × A

n

of the automata in the family is the automaton A = hQ, E , T , q

0

, l, F i such that :

Q = Q

1

× · · · × Q

n

E = Q

1≤i≤n

(E

i

∪ {−}) (where − represents an empty action) T = {((q

1

, . . . , q

n

), (e

1

, . . . , e

n

), (q

10

, . . . , q

0n

)) |

∀1 ≤ i ≤ n, (e

i

= − ∧ q

i0

= q

i

) ∨ (e

i

6= − ∧ (q

i

, e

i

, q

i0

) ∈ T

i

)}

q

0

= (q

01

, . . . , q

0n

)

∀(q

1

, . . . , q

n

) ∈ Q : l((q

1

, . . . , q

n

)) = S

1≤i≤n

l

i

(q

i

)

F = {(q

1

, . . . , q

n

) ∈ Q | ∃1 ≤ i ≤ n, q

i

∈ F

i

}

(73)

Automata Extensions of automata

Formal definition of the synchronised product

Let (A

i

)

1≤i≤n

be a family of automata A

i

= hQ

i

, E

i

, T

i

, q

0i

, l

i

, F

i

i.

Synchronisation set

The synchronisation set, denoted Sync describes all permitted simultaneous actions:

Sync ⊆ Y

1≤i≤n

(E

i

∪ {−})

Synchronised product of automata

The synchronised product of (A

i

)

1≤i≤n

over a set Sync is the cartesian

product restricted to E = Sync .

(74)

Automata Extensions of automata

Formal definition of the synchronised product

Let (A

i

)

1≤i≤n

be a family of automata A

i

= hQ

i

, E

i

, T

i

, q

0i

, l

i

, F

i

i.

Synchronisation set

The synchronisation set, denoted Sync describes all permitted simultaneous actions:

Sync ⊆ Y

1≤i≤n

(E

i

∪ {−})

Synchronised product of automata

The synchronised product of (A

i

)

1≤i≤n

over a set Sync is the cartesian

product restricted to E = Sync .

(75)

Automata Extensions of automata

Synchronisation by message passing

Message passing: a special case of synchronised product

!m send a message m

?m receive a message m

reception and sending occur simultaneously

they concern the same message

(76)

Automata Extensions of automata

Synchronisation by message passing

Example: a small lift

Model of a lift in a 3 floors building, composed of:

the cabin which goes up and down according to the current floor and the lift controller commands

3 doors (one per floor) which open and close according to the controller’s commands

a controller which operates the lift

(77)

Automata Extensions of automata

Example: the lift

Cabin

0 1 2

?up

?down

?down

?up

?down

?up

i

th

door

Ci Oi

?openi

?closei

?closei

?openi

Controller

floor0 floor1 floor2

at0 at1 at2

02 20

!close0

!open0

!close1

!open1

!close2

!open2 !down

!up !down

!up

!down

!down

!up

!up

Properties

A door on a floor cannot open while the cabin is on a different floor

The cabin cannot move while one of the doors is open

(78)

Automata Extensions of automata

Example: the lift

Cabin

0 1 2

?up

?down

?down

?up

?down

?up

i

th

door

Ci Oi

?openi

?closei

?closei

?openi

Controller

floor0 floor1 floor2

at0 at1 at2

02 20

!close0

!open0

!close1

!open1

!close2

!open2 !down

!up !down

!up

!down

!down

!up

!up

Properties

A door on a floor cannot open while the cabin is on a different floor

The cabin cannot move while one of the doors is open

(79)

Automata Extensions of automata

Exercise

Mutual exclusion problem

1

Model the mutual exclusion problem with message passing:

one automaton per participating process (2 processes) a controller

2

How do you add a new process? Give the model for 3 processes, and explain how to generalise it to n processes

process i,

idlei reqi csi

!requesti enteri

!endi

n process automata controller: n states occ

controller

free occ1

occ2

?request 1

!end 1

?request

!end 2 2

Références

Documents relatifs

RFC 3323, A Privacy Mechanism for the Session Initiation Protocol (SIP) (S): [RFC3323] defines the Privacy header field, used by clients to request anonymity for

While a CA is typically advised against issuing a certificate with a validity period that spans a greater period of time than the validity period of the CA’s certificate that

The other transfer modes (Block, Compressed) do not close the connection to indicate the end of file. They have enough FTP encoding that the data connection can

The other transfer modes (Block, Compressed) do not close the connection to indicate the end of file. They have enough FTP encoding that the data connection can

– Model checking WCTL is decidable (in PSPACE) for the priced timed automata with one clock [BOU 07a]: WCTL is a specification language (its syntax is the same as TCTL) to

This result is in contrast to the case of probabilistic timed automata with an arbitrary number of clocks, for which the application of the forward reachability algorithm results in

L’arnaque : le modèle doit être suffisamment abstrait pour que son exploration soit réalisable... Exemple: algorithme

However, no Hankel determinants of the (mixed) Euler numbers have been obtained. The reason for that is that some Hankel determinants of the Euler numbers are null. This implies