• Non ci sono risultati.

Formal Methods: Module I: Automated Reasoning Ch. 04: Linear Temporal Logic

N/A
N/A
Protected

Academic year: 2021

Condividi "Formal Methods: Module I: Automated Reasoning Ch. 04: Linear Temporal Logic"

Copied!
131
0
0

Testo completo

(1)

Formal Methods:

Module I: Automated Reasoning Ch. 04: Linear Temporal Logic

Roberto Sebastiani

DISI, Università di Trento, Italy – roberto.sebastiani@unitn.it URL: http://disi.unitn.it/rseba/DIDATTICA/fm2021/

Teaching assistant:Giuseppe Spallitta– giuseppe.spallitta@unitn.it

M.S. in Computer Science, Mathematics, & Artificial Intelligence Systems Academic year 2020-2021

last update: Tuesday 13thApril, 2021, 13:56

Copyright notice: some material (text, figures) displayed in these slides is courtesy of R. Alur, M. Benerecetti, A. Cimatti, M. Di Natale, P. Pandya, M. Pistore, M. Roveri, C. Tinelli, and S.Tonetta, who detain its copyright. Some exampes displayed in these slides are taken from [Clarke, Grunberg & Peled, “Model Checking”, MIT Press], and their copyright is

detained by the authors. All the other material is copyrighted by Roberto Sebastiani. Every commercial use of this material is strictly forbidden by the copyright laws without the authorization of the authors. No copy of these slides can be

displayed in public without containing this copyright notice.

1 / 61

(2)

Outline

1

Transition Systems as Kripke Models Kripke Models

Languages for Transition Systems Properties

2

Linear Temporal Logic – LTL Generalities on Temporal Logics LTL: Syntax and Semantics

Some LTL Model Checking Examples

3

Exercises

2 / 61

(3)

Outline

1

Transition Systems as Kripke Models Kripke Models

Languages for Transition Systems Properties

2

Linear Temporal Logic – LTL Generalities on Temporal Logics LTL: Syntax and Semantics

Some LTL Model Checking Examples

3

Exercises

3 / 61

(4)

Outline

1

Transition Systems as Kripke Models Kripke Models

Languages for Transition Systems Properties

2

Linear Temporal Logic – LTL Generalities on Temporal Logics LTL: Syntax and Semantics

Some LTL Model Checking Examples

3

Exercises

4 / 61

(5)

Kripke Models

Theoretical role: the semantic framework for a variety of logics

Modal Logics

Description Logics Temporal Logics ...

Practical role: used to describereactive systems:

nonterminating systems withinfinitebehaviors (e.g. communication protocols, hardware circuits);

represent thedynamic evolutionof modeled systems;

a state includes values to state variables, program counters, content of communication channels.

can be animated and validated before their actual implementation

5 / 61

(6)

Kripke Models

Theoretical role: the semantic framework for a variety of logics

Modal Logics

Description Logics Temporal Logics ...

Practical role: used to describe reactive systems:

nonterminating systems withinfinitebehaviors (e.g. communication protocols, hardware circuits);

represent thedynamic evolutionof modeled systems;

a state includes values to state variables, program counters, content of communication channels.

can be animated and validated before their actual implementation

5 / 61

(7)

Kripke Model: Formal Definition

A Kripke model hS, I, R, AP, Li consists of

afiniteset of states S;

a set ofinitial states I ⊆ S;

a set oftransitions R ⊆ S × S;

a set ofatomic propositions AP;

alabeling function L : S 7−→ 2AP.

We assume R

total: for every state s, there

exists (at least) one state s

0

s.t. (s, s

0

) ∈ R Sometimes we use variables with discrete bounded values v

i

∈ {d

1

, ..., d

k

} (can be encoded with dlog(k )e Boolean variables)

p q

1

2

3 4

p

Remark

Unlike with other types of Automata (e.g., Buechi), in Kripke models the values of all variables are always assigned in each state.

6 / 61

(8)

Kripke Model: Formal Definition

A Kripke model hS, I, R, AP, Li consists of

afiniteset of states S;

a set ofinitial states I ⊆ S;

a set oftransitions R ⊆ S × S;

a set ofatomic propositions AP;

alabeling function L : S 7−→ 2AP.

We assume R

total: for every state s, there

exists (at least) one state s

0

s.t. (s, s

0

) ∈ R Sometimes we use variables with discrete bounded values v

i

∈ {d

1

, ..., d

k

} (can be encoded with dlog(k )e Boolean variables)

p q

1

2

3 4

p

Remark

Unlike with other types of Automata (e.g., Buechi), in Kripke models the values of all variables are always assigned in each state.

6 / 61

(9)

Kripke Model: Formal Definition

A Kripke model hS, I, R, AP, Li consists of

afiniteset of states S;

a set ofinitial states I ⊆ S;

a set oftransitions R ⊆ S × S;

a set ofatomic propositions AP;

alabeling function L : S 7−→ 2AP.

We assume R

total: for every state s, there

exists (at least) one state s

0

s.t. (s, s

0

) ∈ R Sometimes we use variables with discrete bounded values v

i

∈ {d

1

, ..., d

k

} (can be encoded with dlog(k )e Boolean variables)

p q

1

2

3 4

p

Remark

Unlike with other types of Automata (e.g., Buechi), in Kripke models the values of all variables are always assigned in each state.

6 / 61

(10)

Kripke Model: Formal Definition

A Kripke model hS, I, R, AP, Li consists of

afiniteset of states S;

a set ofinitial states I ⊆ S;

a set oftransitions R ⊆ S × S;

a set ofatomic propositions AP;

alabeling function L : S 7−→ 2AP.

We assume R

total: for every state s, there

exists (at least) one state s

0

s.t. (s, s

0

) ∈ R Sometimes we use variables with discrete bounded values v

i

∈ {d

1

, ..., d

k

} (can be encoded with dlog(k )e Boolean variables)

p q

1

2

3 4

p

Remark

Unlike with other types of Automata (e.g., Buechi), in Kripke models the values of all variables are always assigned in each state.

6 / 61

(11)

Kripke Model: Formal Definition

A Kripke model hS, I, R, AP, Li consists of

afiniteset of states S;

a set ofinitial states I ⊆ S;

a set oftransitions R ⊆ S × S;

a set ofatomic propositions AP;

alabeling function L : S 7−→ 2AP.

We assume R

total: for every state s, there

exists (at least) one state s

0

s.t. (s, s

0

) ∈ R Sometimes we use variables with discrete bounded values v

i

∈ {d

1

, ..., d

k

} (can be encoded with dlog(k )e Boolean variables)

p q

1

2

3 4

p

Remark

Unlike with other types of Automata (e.g., Buechi), in Kripke models the values of all variables are always assigned in each state.

6 / 61

(12)

Kripke Model: Formal Definition

A Kripke model hS, I, R, AP, Li consists of

afiniteset of states S;

a set ofinitial states I ⊆ S;

a set oftransitions R ⊆ S × S;

a set ofatomic propositions AP;

alabeling function L : S 7−→ 2AP.

We assume R

total: for every state s, there

exists (at least) one state s

0

s.t. (s, s

0

) ∈ R Sometimes we use variables with discrete bounded values v

i

∈ {d

1

, ..., d

k

} (can be encoded with dlog(k )e Boolean variables)

p q

1

2

3 4

p

Remark

Unlike with other types of Automata (e.g., Buechi), in Kripke models the values of all variables are always assigned in each state.

6 / 61

(13)

Kripke Model: Formal Definition

A Kripke model hS, I, R, AP, Li consists of

afiniteset of states S;

a set ofinitial states I ⊆ S;

a set oftransitions R ⊆ S × S;

a set ofatomic propositions AP;

alabeling function L : S 7−→ 2AP.

We assume R total: for every state s, there exists (at least) one state s

0

s.t. (s, s

0

) ∈ R Sometimes we use variables with discrete bounded values v

i

∈ {d

1

, ..., d

k

} (can be encoded with dlog(k )e Boolean variables)

p q

1

2

3 4

p

Remark

Unlike with other types of Automata (e.g., Buechi), in Kripke models the values of all variables are always assigned in each state.

6 / 61

(14)

Kripke Model: Formal Definition

A Kripke model hS, I, R, AP, Li consists of

afiniteset of states S;

a set ofinitial states I ⊆ S;

a set oftransitions R ⊆ S × S;

a set ofatomic propositions AP;

alabeling function L : S 7−→ 2AP.

We assume R total: for every state s, there exists (at least) one state s

0

s.t. (s, s

0

) ∈ R Sometimes we use variables with discrete bounded values v

i

∈ {d

1

, ..., d

k

} (can be encoded with dlog(k )e Boolean variables)

p q

1

2

3 4

p

Remark

Unlike with other types of Automata (e.g., Buechi), in Kripke models the values of all variables are always assigned in each state.

6 / 61

(15)

Kripke Model: Formal Definition

A Kripke model hS, I, R, AP, Li consists of

afiniteset of states S;

a set ofinitial states I ⊆ S;

a set oftransitions R ⊆ S × S;

a set ofatomic propositions AP;

alabeling function L : S 7−→ 2AP.

We assume R total: for every state s, there exists (at least) one state s

0

s.t. (s, s

0

) ∈ R Sometimes we use variables with discrete bounded values v

i

∈ {d

1

, ..., d

k

} (can be encoded with dlog(k )e Boolean variables)

p q

1

2

3 4

p

Remark

Unlike with other types of Automata (e.g., Buechi), in Kripke models the values of all variables are always assigned in each state.

6 / 61

(16)

Kripke Structures: Two Alternative Representations:

each state identifies univocally the values of the atomic propositions which hold there

each state is labeled by a bit vector

{ } {q}

{p} {p, q}

7 / 61

(17)

Kripke Structures: Two Alternative Representations:

each state identifies univocally the values of the atomic propositions which hold there

each state is labeled by a bit vector

{ } {q}

{p} {p, q}

0 0 0 1

1 0 1 1

7 / 61

(18)

Example: a Kripke model for mutual exclusion

N1, N2 turn=0

turn=1

turn=2

turn=2

turn=2

turn=1 turn=1

turn=1

turn=2

T1, C2

N1, C2 T1, T2

T1, T2

N1, T2

C1, T2 C1, N2

T1, N2

N = noncritical, T = trying, C = critical User 1 User 2

8 / 61

(19)

Path in a Kripke Model

A path in a Kripke model M is an infinite sequence of states π = s

0

, s

1

, s

2

, . . . ∈ S

ω

such that s

0

∈ I and (s

i

, s

i+1

) ∈ R.

N1, N2 turn=0

N1, N2 turn=0

turn=1

turn=2

turn=2 turn=2

turn=1 turn=1

turn=1

turn=2

T1, C2 N1, C2 T1, T2 T1, T2

N1, T2

C1, T2 C1, N2

T1, N2

turn=1

turn=1 turn=1

turn=1 T1, T2

C1, T2 C1, N2

T1, N2 turn=1

turn=2

turn=2 turn=2

turn=1 turn=1

turn=1

turn=2

T1, C2 N1, C2 T1, T2 T1, T2

N1, T2

C1, T2 C1, N2

T1, N2

A state s is reachable in M if there is a path from the initial states to s.

9 / 61

(20)

Composing Kripke Models

Complex Kripke Models are tipically obtained by composition of smaller ones

Components can be combined via

asynchronouscomposition.

synchronouscomposition,

10 / 61

(21)

Asynchronous Composition

Interleaving of evolution of components.

At each time instant, one component is selected to perform a transition.

x = 1 x = 0

y = b y = b

x = 0 y = a

x = 1 y = a

y = b y = a

x = 1 x = 0

asynchronous

composition

Typical example: communication protocols.

11 / 61

(22)

Asynchronous Composition/Product: formal definition

Asynchronous product of Kripke models

Let M

1def

= hS

1

, I

1

, R

1

, AP

1

, L

1

i, M

2def

= hS

2

, I

2

, R

2

, AP

2

, L

2

i. Then the asynchronous product M

def

= M

1

||M

2

is M

def

= hS, I, R, AP, Li, where

S ⊆ S

1

× S

2

s.t.,

∀hs

1

, s

2

i ∈ S, ∀l ∈ AP

1

∩ AP

2

, l ∈ L

1

(s

1

) iff l ∈ L

2

(s

2

) I ⊆ I

1

× I

2

s.t. I ⊆ S

R(hs

1

, s

2

i, ht

1

, t

2

i) iff (R

1

(s

1

, t

1

) and s

2

= t

2

) or (s

1

= t

1

and R

2

(s

2

, t

2

)) AP = AP

1

∪ AP

2

L : S 7−→ 2

AP

s.t. L(hs

1

, s

2

i)

def

= L

1

(s

1

) ∪ L

2

(s

2

).

Note: combined states must agree on the values of Boolean variables.

Asynchronous composition is associative:

(...(M

1

||M

2

)||...)||M

n

) = (M1||(M

2

||(...||M

n

)...) = M

1

||M

2

||...||M

n

12 / 61

(23)

Asynchronous Composition/Product: formal definition

Asynchronous product of Kripke models

Let M

1def

= hS

1

, I

1

, R

1

, AP

1

, L

1

i, M

2def

= hS

2

, I

2

, R

2

, AP

2

, L

2

i. Then the asynchronous product M

def

= M

1

||M

2

is M

def

= hS, I, R, AP, Li, where

S ⊆ S

1

× S

2

s.t.,

∀hs

1

, s

2

i ∈ S, ∀l ∈ AP

1

∩ AP

2

, l ∈ L

1

(s

1

) iff l ∈ L

2

(s

2

) I ⊆ I

1

× I

2

s.t. I ⊆ S

R(hs

1

, s

2

i, ht

1

, t

2

i) iff (R

1

(s

1

, t

1

) and s

2

= t

2

) or (s

1

= t

1

and R

2

(s

2

, t

2

)) AP = AP

1

∪ AP

2

L : S 7−→ 2

AP

s.t. L(hs

1

, s

2

i)

def

= L

1

(s

1

) ∪ L

2

(s

2

).

Note: combined states must agree on the values of Boolean variables.

Asynchronous composition is associative:

(...(M

1

||M

2

)||...)||M

n

) = (M1||(M

2

||(...||M

n

)...) = M

1

||M

2

||...||M

n

12 / 61

(24)

Asynchronous Composition: Example 1

1

3 4

2 1

3 4

2

A A

A A

B B

B B

C C

C C

A B

C

1

3 4

2

1

3 4

2

13 / 61

(25)

Asynchronous Composition: Example 2

1

3 4

2 A A

A B

C C

C

A B

C

4

1

3

2

x=0 x=0

x=0

x=0

x=0

x=1

x=1

1

3

2

non−reachable state

x=0 x=0

x=0

x=0

x=0 x=0

x=1

14 / 61

(26)

Asynchronous Composition: Example 2

1

3 4

2 A A

A

C C

C

A B

C

1

3

2

x=0 x=0

x=0

x=0

x=0

x=1

x=1

1

3

2

x=0 x=0

x=0

x=0

x=0 x=0

.

15 / 61

(27)

Synchronous Composition

Components evolve in parallel.

At each time instant, every component performs a transition.

y = b y = a

x = 1 x = 0

synchronous

composition

x = 0 y = a

x = 1 x = 0

x = 1 y = a

y = b y = b

Typical example: sequential hardware circuits.

16 / 61

(28)

Synchronous Composition/Product: formal definition

Synchronous product of Kripke models

Let M

1def

= hS

1

, I

1

, R

1

, AP

1

, L

1

i, M

2def

= hS

2

, I

2

, R

2

, AP

2

, L

2

i. Then the synchronous product M

def

= M

1

× M

2

is M

def

= hS, I, R, AP, Li, where

S ⊆ S

1

× S

2

s.t.,

∀hs

1

, s

2

i ∈ S, ∀l ∈ AP

1

∩ AP

2

, l ∈ L

1

(s

1

) iff l ∈ L

2

(s

2

) I ⊆ I

1

× I

2

s.t. I ⊆ S

R(hs

1

, s

2

i, ht

1

, t

2

i) iff (R

1

(s

1

, t

1

) and R

2

(s

2

, t

2

)) AP = AP

1

∪ AP

2

L : S 7−→ 2

AP

s.t. L(hs

1

, s

2

i)

def

= L

1

(s

1

) ∪ L

2

(s

2

).

Note: combined states must agree on the values of Boolean variables.

Synchronous composition is associative:

(...(M

1

×M

2

)×...)× M

n

) = (M1×(M

2

×(...×M

n

)...) = M

1

×M

2

×...×M

n

17 / 61

(29)

Synchronous Composition/Product: formal definition

Synchronous product of Kripke models

Let M

1def

= hS

1

, I

1

, R

1

, AP

1

, L

1

i, M

2def

= hS

2

, I

2

, R

2

, AP

2

, L

2

i. Then the synchronous product M

def

= M

1

× M

2

is M

def

= hS, I, R, AP, Li, where

S ⊆ S

1

× S

2

s.t.,

∀hs

1

, s

2

i ∈ S, ∀l ∈ AP

1

∩ AP

2

, l ∈ L

1

(s

1

) iff l ∈ L

2

(s

2

) I ⊆ I

1

× I

2

s.t. I ⊆ S

R(hs

1

, s

2

i, ht

1

, t

2

i) iff (R

1

(s

1

, t

1

) and R

2

(s

2

, t

2

)) AP = AP

1

∪ AP

2

L : S 7−→ 2

AP

s.t. L(hs

1

, s

2

i)

def

= L

1

(s

1

) ∪ L

2

(s

2

).

Note: combined states must agree on the values of Boolean variables.

Synchronous composition is associative:

(...(M

1

×M

2

)×...)× M

n

) = (M1×(M

2

×(...×M

n

)...) = M

1

×M

2

×...×M

n

17 / 61

(30)

Synchronous Composition: Example 1

1

3 4

2

A B

C

A A

A A

B B

B B

C C

C C 1

3 4

2 1

3 4

2

1

3 4

2

18 / 61

(31)

Synchronous Composition: Example 2

1

3 4

2

A B

C

A A

A B

C C

C 1

3

2

4

1

3

2

x=0 x=0

x=0

x=0

x=0

x=1

x=1

x=1

x=0 x=0

x=0

x=0 x=0

x=0

NON−reachable state

19 / 61

(32)

Synchronous Composition: Example 2 (cont.)

1

3 4

2

A B

C

A

A B

C C

C 1

3 4

1

3

2

x=0 x=0

x=0

x=0

x=0

x=1

x=1

x=1 x=0

x=0

x=0 x=0

x=0

20 / 61

(33)

Outline

1

Transition Systems as Kripke Models Kripke Models

Languages for Transition Systems Properties

2

Linear Temporal Logic – LTL Generalities on Temporal Logics LTL: Syntax and Semantics

Some LTL Model Checking Examples

3

Exercises

21 / 61

(34)

Description languages for Kripke Model

Most often a Kripke model is not given explicitly (states, arcs),...

... rather it is usually presented in a

structured language

(e.g., SMV, PROMELA, StateCharts, VHDL, ...)

even a piece of SW can be seen as a Kripke model!

Each component is presented by specifying

state variables: determine the set of atomic propositions AP, the state space S and the labeling L.

initial values of variables V: determine the set ofinitial states I.

described as a relation I(V0)in terms of state variables at step 0 instructions:determine thetransition relation R.

described as a relation R(V , V0)in terms ofcurrent state variables V andnext state variables V0

Aka as

symbolic representation of a Kripke model

Remark

Tipically symbolic description are much more compact (and intuitive) than the explicit representation of the Kripke model.

22 / 61

(35)

Description languages for Kripke Model

Most often a Kripke model is not given explicitly (states, arcs),...

... rather it is usually presented in a structured language (e.g., SMV, PROMELA, StateCharts, VHDL, ...)

even a piece of SW can be seen as a Kripke model!

Each component is presented by specifying

state variables: determine the set of atomic propositions AP, the state space S and the labeling L.

initial values of variables V: determine the set ofinitial states I.

described as a relation I(V0)in terms of state variables at step 0 instructions:determine thetransition relation R.

described as a relation R(V , V0)in terms ofcurrent state variables V andnext state variables V0

Aka as

symbolic representation of a Kripke model

Remark

Tipically symbolic description are much more compact (and intuitive) than the explicit representation of the Kripke model.

22 / 61

(36)

Description languages for Kripke Model

Most often a Kripke model is not given explicitly (states, arcs),...

... rather it is usually presented in a structured language (e.g., SMV, PROMELA, StateCharts, VHDL, ...)

even a piece of SW can be seen as a Kripke model!

Each component is presented by specifying

state variables: determine the set of atomic propositions AP, the state space S and the labeling L.

initial values of variables V: determine the set ofinitial states I.

described as a relation I(V0)in terms of state variables at step 0 instructions:determine thetransition relation R.

described as a relation R(V , V0)in terms ofcurrent state variables V andnext state variables V0

Aka as

symbolic representation of a Kripke model

Remark

Tipically symbolic description are much more compact (and intuitive) than the explicit representation of the Kripke model.

22 / 61

(37)

Description languages for Kripke Model

Most often a Kripke model is not given explicitly (states, arcs),...

... rather it is usually presented in a structured language (e.g., SMV, PROMELA, StateCharts, VHDL, ...)

even a piece of SW can be seen as a Kripke model!

Each component is presented by specifying

state variables: determine the set of atomic propositions AP, the state space S and the labeling L.

initial values of variables V: determine the set ofinitial states I.

described as a relation I(V0)in terms of state variables at step 0 instructions:determine thetransition relation R.

described as a relation R(V , V0)in terms ofcurrent state variables V andnext state variables V0

Aka as

symbolic representation of a Kripke model

Remark

Tipically symbolic description are much more compact (and intuitive) than the explicit representation of the Kripke model.

22 / 61

(38)

Description languages for Kripke Model

Most often a Kripke model is not given explicitly (states, arcs),...

... rather it is usually presented in a structured language (e.g., SMV, PROMELA, StateCharts, VHDL, ...)

even a piece of SW can be seen as a Kripke model!

Each component is presented by specifying

state variables: determine the set of atomic propositions AP, the state space S and the labeling L.

initial values of variables V: determine the set ofinitial states I.

described as a relation I(V0)in terms of state variables at step 0 instructions:determine thetransition relation R.

described as a relation R(V , V0)in terms ofcurrent state variables V andnext state variables V0

Aka as

symbolic representation of a Kripke model

Remark

Tipically symbolic description are much more compact (and intuitive) than the explicit representation of the Kripke model.

22 / 61

(39)

Description languages for Kripke Model

Most often a Kripke model is not given explicitly (states, arcs),...

... rather it is usually presented in a structured language (e.g., SMV, PROMELA, StateCharts, VHDL, ...)

even a piece of SW can be seen as a Kripke model!

Each component is presented by specifying

state variables: determine the set of atomic propositions AP, the state space S and the labeling L.

initial values of variables V: determine the set ofinitial states I.

described as a relation I(V0)in terms of state variables at step 0 instructions:determine thetransition relation R.

described as a relation R(V , V0)in terms ofcurrent state variables V andnext state variables V0

Aka as

symbolic representation of a Kripke model

Remark

Tipically symbolic description are much more compact (and intuitive) than the explicit representation of the Kripke model.

22 / 61

(40)

Description languages for Kripke Model

Most often a Kripke model is not given explicitly (states, arcs),...

... rather it is usually presented in a structured language (e.g., SMV, PROMELA, StateCharts, VHDL, ...)

even a piece of SW can be seen as a Kripke model!

Each component is presented by specifying

state variables: determine the set of atomic propositions AP, the state space S and the labeling L.

initial values of variables V: determine the set ofinitial states I.

described as a relation I(V0)in terms of state variables at step 0 instructions:determine thetransition relation R.

described as a relation R(V , V0)in terms ofcurrent state variables V andnext state variables V0

Aka as

symbolic representation of a Kripke model

Remark

Tipically symbolic description are much more compact (and intuitive) than the explicit representation of the Kripke model.

22 / 61

(41)

Description languages for Kripke Model

Most often a Kripke model is not given explicitly (states, arcs),...

... rather it is usually presented in a structured language (e.g., SMV, PROMELA, StateCharts, VHDL, ...)

even a piece of SW can be seen as a Kripke model!

Each component is presented by specifying

state variables: determine the set of atomic propositions AP, the state space S and the labeling L.

initial values of variables V: determine the set ofinitial states I.

described as a relation I(V0)in terms of state variables at step 0 instructions:determine thetransition relation R.

described as a relation R(V , V0)in terms ofcurrent state variables V andnext state variables V0

Aka as

symbolic representation of a Kripke model

Remark

Tipically symbolic description are much more compact (and intuitive) than the explicit representation of the Kripke model.

22 / 61

(42)

The SMV language

The input language of the SMV M.C. (and N

U

SMV)

Booleans, enumerative and bounded integers as data types now enriched with other constructs, e.g. in NuXMV language An SMV program consists of:

Declarations of the state variables (e.g., b0);

Assignments that define theinitial states (e.g., init(b0) := 0).

Assignments that define thetransition relation (e.g., next(b0) := !b0).

Allows for both synchronous and asyncronous composition of modules (though synchronous interaction more natural)

23 / 61

(43)

Example: a Simple Counter Circuit

MODULE main VAR

v0 : boolean;

v1 : boolean;

out : 0..3;

ASSIGN

init(v0) := 0;

next(v0) := !v0;

init(v1) := 0;

next(v1) := (v0 xor v1);

out := toint(v0) + 2*toint(v1);

v0

v1

v1 v0 v10 v00

0 0 0 1

0 1 1 0

1 0 1 1

1 1 0 0

00

11 01

10

I(V ) = (¬v

0

∧ ¬v

1

)

R(V , V

0

) = (v

00

↔ ¬v

0

) ∧ (v

10

↔ v

0

L v

1

)

24 / 61

(44)

Example: a Simple Counter Circuit

MODULE main VAR

v0 : boolean;

v1 : boolean;

out : 0..3;

ASSIGN

init(v0) := 0;

next(v0) := !v0;

init(v1) := 0;

next(v1) := (v0 xor v1);

out := toint(v0) + 2*toint(v1);

v0

v1

v1 v0 v10 v00

0 0 0 1

0 1 1 0

1 0 1 1

1 1 0 0

00

11 01

10

I(V ) = (¬v

0

∧ ¬v

1

)

R(V , V

0

) = (v

00

↔ ¬v

0

) ∧ (v

10

↔ v

0

L v

1

)

24 / 61

(45)

Standard Programming Languages

Standard programming languages are typically sequential

=⇒

Transition relation defined in terms also of the

program counter

Numbers & values Booleanized

...

10. i = 0;

11. acc = 0.0;

12. while (i<dim) { 13. acc += V[i];

14. i++;

15. } ...

....

(pc = 10) → ((i0=0) ∧ (pc0=11)) (pc = 11) → ((acc0=0.0) ∧ (pc0=12)) (pc = 12) → ((i < dim) → (pc0=13)) (pc = 12) → (¬(i < dim) → (pc0=16))

(pc = 13) → ((acc0=acc + read (V , i)) ∧ (pc0=14)) (pc = 14) → (i0=i + 1) ∧ (pc0=15))

(pc = 15) → (pc0=16)) ...

25 / 61

(46)

Standard Programming Languages

Standard programming languages are typically sequential

=⇒

Transition relation defined in terms also of the

program counter

Numbers & values Booleanized

...

10. i = 0;

11. acc = 0.0;

12. while (i<dim) { 13. acc += V[i];

14. i++;

15. } ...

....

(pc = 10) → ((i0=0) ∧ (pc0=11)) (pc = 11) → ((acc0=0.0) ∧ (pc0=12)) (pc = 12) → ((i < dim) → (pc0=13)) (pc = 12) → (¬(i < dim) → (pc0=16))

(pc = 13) → ((acc0=acc + read (V , i)) ∧ (pc0=14)) (pc = 14) → (i0=i + 1) ∧ (pc0=15))

(pc = 15) → (pc0=16)) ...

25 / 61

(47)

Standard Programming Languages

Standard programming languages are typically sequential

=⇒

Transition relation defined in terms also of the

program counter

Numbers & values Booleanized

...

10. i = 0;

11. acc = 0.0;

12. while (i<dim) { 13. acc += V[i];

14. i++;

15. } ...

....

(pc = 10) → ((i0=0) ∧ (pc0=11)) (pc = 11) → ((acc0=0.0) ∧ (pc0=12)) (pc = 12) → ((i < dim) → (pc0=13)) (pc = 12) → (¬(i < dim) → (pc0=16))

(pc = 13) → ((acc0=acc + read (V , i)) ∧ (pc0=14)) (pc = 14) → (i0=i + 1) ∧ (pc0=15))

(pc = 15) → (pc0=16)) ...

25 / 61

(48)

Standard Programming Languages

Standard programming languages are typically sequential

=⇒

Transition relation defined in terms also of the

program counter

Numbers & values Booleanized

...

10. i = 0;

11. acc = 0.0;

12. while (i<dim) { 13. acc += V[i];

14. i++;

15. } ...

....

(pc = 10) → ((i0=0) ∧ (pc0=11)) (pc = 11) → ((acc0=0.0) ∧ (pc0=12)) (pc = 12) → ((i < dim) → (pc0=13)) (pc = 12) → (¬(i < dim) → (pc0=16))

(pc = 13) → ((acc0=acc + read (V , i)) ∧ (pc0=14)) (pc = 14) → (i0=i + 1) ∧ (pc0=15))

(pc = 15) → (pc0=16)) ...

25 / 61

(49)

Outline

1

Transition Systems as Kripke Models Kripke Models

Languages for Transition Systems Properties

2

Linear Temporal Logic – LTL Generalities on Temporal Logics LTL: Syntax and Semantics

Some LTL Model Checking Examples

3

Exercises

26 / 61

(50)

Safety Properties

Bad events never happen

deadlock: two processes waiting for input from each other, the system is unable to perform a transition.

no reachable state satisfies a “bad” condition,

e.g. never two processes in critical section at the same time

can be refuted by a

finite

behaviour

Ex.: it is never the case that p.

p

27 / 61

(51)

Safety Properties

Bad events never happen

deadlock: two processes waiting for input from each other, the system is unable to perform a transition.

no reachable state satisfies a “bad” condition,

e.g. never two processes in critical section at the same time

can be refuted by a finite behaviour

Ex.: it is never the case that p.

p

27 / 61

(52)

Safety Properties

Bad events never happen

deadlock: two processes waiting for input from each other, the system is unable to perform a transition.

no reachable state satisfies a “bad” condition,

e.g. never two processes in critical section at the same time

can be refuted by a finite behaviour

Ex.: it is never the case that p.

p

27 / 61

(53)

Liveness Properties

Something desirable will eventually happen

sooner or later this will happen

can be refuted by

infinite

behaviour

−p −p −p −p −p −p

−p

−p

an infinite behaviour can be typically presented as a loop

28 / 61

(54)

Liveness Properties

Something desirable will eventually happen

sooner or later this will happen

can be refuted by infinite behaviour

−p −p −p −p −p −p

−p

−p

an infinite behaviour can be typically presented as a loop

28 / 61

(55)

Liveness Properties

Something desirable will eventually happen

sooner or later this will happen

can be refuted by infinite behaviour

−p −p −p −p −p −p

−p

−p

an infinite behaviour can be typically presented as a loop

28 / 61

(56)

Fairness Properties

Something desirable will happen infinitely often

important subcase of liveness

whenever a subroutine takes control, it will always return it (sooner or later)

can be refuted by infinite behaviour

a subroutine takes control and never returns it

p

p p p

p

p p p

an infinite behaviour can be typically presented as a loop

29 / 61

(57)

Fairness Properties

Something desirable will happen infinitely often

important subcase of liveness

whenever a subroutine takes control, it will always return it (sooner or later)

can be refuted by infinite behaviour

a subroutine takes control and never returns it

p

p p p

p

p p p

an infinite behaviour can be typically presented as a loop

29 / 61

(58)

Fairness Properties

Something desirable will happen infinitely often

important subcase of liveness

whenever a subroutine takes control, it will always return it (sooner or later)

can be refuted by infinite behaviour

a subroutine takes control and never returns it

p

p p p

p

p p p

an infinite behaviour can be typically presented as a loop

29 / 61

(59)

Outline

1

Transition Systems as Kripke Models Kripke Models

Languages for Transition Systems Properties

2

Linear Temporal Logic – LTL Generalities on Temporal Logics LTL: Syntax and Semantics

Some LTL Model Checking Examples

3

Exercises

30 / 61

(60)

Outline

1

Transition Systems as Kripke Models Kripke Models

Languages for Transition Systems Properties

2

Linear Temporal Logic – LTL Generalities on Temporal Logics LTL: Syntax and Semantics

Some LTL Model Checking Examples

3

Exercises

31 / 61

(61)

Computation tree vs. computation paths

Consider the following Kripke structure:

done

!done

Its execution can be seen as:

an infinite set of computation paths

an infinite computation tree

done

done

done done done done

!done

!done

!done

!done

32 / 61

(62)

Computation tree vs. computation paths

Consider the following Kripke structure:

done

!done

Its execution can be seen as:

an infinite set of computation paths

done done done

!done

!done

!done

!done

done done

done

!done !done

!done !done !done

!done

...

an infinite computation tree

done

done

done done done done

!done

!done

!done

!done

32 / 61

(63)

Computation tree vs. computation paths

Consider the following Kripke structure:

done

!done

Its execution can be seen as:

an infinite set of computation paths

done done done

!done

!done

!done

!done

done done

done

!done !done

!done !done !done

!done

...

an infinite computation tree

done

done

done done done done

!done

!done

!done

!done

32 / 61

(64)

Computation tree vs. computation paths

Consider the following Kripke structure:

done

!done

Its execution can be seen as:

an infinite set of computation paths

done done done

!done

!done

!done

!done

done done

done

!done !done

!done !done !done

!done

...

an infinite computation tree

done

done

done done done done

!done

!done

!done

!done

32 / 61

(65)

Temporal Logics

Express properties of “Reactive Systems”

nonterminating behaviours, without explicit reference to time.

Linear Temporal Logic (LTL)

interpreted over each path of the Kripke structure linear model of time

temporal operators

“Medieval”: “since birth, one’s destiny is set”.

Computation Tree Logic (CTL)

interpreted over computation tree of Kripke model branching model of time

temporal operators plus path quantifiers

“Humanistic”: “one makes his/her own destiny step-by-step”.

33 / 61

(66)

Temporal Logics

Express properties of “Reactive Systems”

nonterminating behaviours, without explicit reference to time.

Linear Temporal Logic (LTL)

interpreted over each path of the Kripke structure linear model of time

temporal operators

“Medieval”: “since birth, one’s destiny is set”.

Computation Tree Logic (CTL)

interpreted over computation tree of Kripke model branching model of time

temporal operators plus path quantifiers

“Humanistic”: “one makes his/her own destiny step-by-step”.

33 / 61

(67)

Temporal Logics

Express properties of “Reactive Systems”

nonterminating behaviours, without explicit reference to time.

Linear Temporal Logic (LTL)

interpreted over each path of the Kripke structure linear model of time

temporal operators

“Medieval”: “since birth, one’s destiny is set”.

Computation Tree Logic (CTL)

interpreted over computation tree of Kripke model branching model of time

temporal operators plus path quantifiers

“Humanistic”: “one makes his/her own destiny step-by-step”.

33 / 61

(68)

Outline

1

Transition Systems as Kripke Models Kripke Models

Languages for Transition Systems Properties

2

Linear Temporal Logic – LTL Generalities on Temporal Logics LTL: Syntax and Semantics

Some LTL Model Checking Examples

3

Exercises

34 / 61

(69)

Linear Temporal Logic (LTL): Syntax

An atomic proposition is a LTL formula;

if

ϕ1

and

ϕ2

are LTL formulae, then

¬ϕ1, ϕ1∧ ϕ2, ϕ1∨ ϕ2, ϕ1→ ϕ2, ϕ1↔ ϕ2, ϕ1⊕ ϕ2

are LTL formulae;

if

ϕ1

and

ϕ2

are LTL formulae, then

1, ϕ12,1,1

are LTL formulae, where

X, G, F, U are the “next”, “globally”,

“eventually”,“until” temporal operators respectively.

Another operator

R “releases” (the dual of U) is used sometimes.

35 / 61

(70)

Linear Temporal Logic (LTL): Syntax

An atomic proposition is a LTL formula;

if ϕ

1

and ϕ

2

are LTL formulae, then ¬ϕ

1

, ϕ

1

∧ ϕ

2

, ϕ

1

∨ ϕ

2

, ϕ

1

→ ϕ

2

, ϕ

1

↔ ϕ

2

, ϕ

1

⊕ ϕ

2

are LTL formulae;

if

ϕ1

and

ϕ2

are LTL formulae, then

1, ϕ12,1,1

are LTL formulae, where

X, G, F, U are the “next”, “globally”,

“eventually”,“until” temporal operators respectively.

Another operator

R “releases” (the dual of U) is used sometimes.

35 / 61

(71)

Linear Temporal Logic (LTL): Syntax

An atomic proposition is a LTL formula;

if ϕ

1

and ϕ

2

are LTL formulae, then ¬ϕ

1

, ϕ

1

∧ ϕ

2

, ϕ

1

∨ ϕ

2

, ϕ

1

→ ϕ

2

, ϕ

1

↔ ϕ

2

, ϕ

1

⊕ ϕ

2

are LTL formulae;

if ϕ

1

and ϕ

2

are LTL formulae, then

1

, ϕ

12

,

1

,

1

are LTL formulae, where X, G, F, U are the “next”, “globally”,

“eventually”,“until” temporal operators respectively.

Another operator

R “releases” (the dual of U) is used sometimes.

35 / 61

(72)

Linear Temporal Logic (LTL): Syntax

An atomic proposition is a LTL formula;

if ϕ

1

and ϕ

2

are LTL formulae, then ¬ϕ

1

, ϕ

1

∧ ϕ

2

, ϕ

1

∨ ϕ

2

, ϕ

1

→ ϕ

2

, ϕ

1

↔ ϕ

2

, ϕ

1

⊕ ϕ

2

are LTL formulae;

if ϕ

1

and ϕ

2

are LTL formulae, then

1

, ϕ

12

,

1

,

1

are LTL formulae, where X, G, F, U are the “next”, “globally”,

“eventually”,“until” temporal operators respectively.

Another operator R “releases” (the dual of U) is used sometimes.

35 / 61

(73)

LTL semantics: intuitions

LTL is given by the standard boolean logic enhanced with the following temporal operators, which operate through paths hs

0

, s

1

, ..., s

k

, ...i:

“Next” X: Xϕ is true in s

t

iff ϕ is true in s

t+1

“Finally” (or “eventually”) F: Fϕ is true in s

t

iff ϕ is true in some s

t0

with t

0

≥ t

“Globally” (or “henceforth”) G: Gϕ is true in s

t

iff ϕ is true in all s

t0

with t

0

≥ t

“Until” U: ϕUψ is true in s

t

iff, for some state s

t0

s.t t

0

≥ t:

ψis true in st0 and

ϕis true in all states st00s.t. t ≤ t00<t0

“Releases” R: ϕRψ is true in s

t

iff, for all states s

t0

s.t. t

0

≥ t:

ψis trueor

ϕis true in some states st00with t ≤ t00<t0

“ψ can become false only if ϕ becomes true first"

36 / 61

(74)

LTL semantics: intuitions

finally P

F P

globally P

G P

X P

next P P until q

P U q

37 / 61

(75)

LTL: Some Noteworthy Examples

Safety: “it never happens that a train is arriving and the bar is up”

G(¬(train_arriving ∧ bar_up))

Liveness: “if input, then eventually output”

G(input → Foutput)

Releases: “the device is not working if you don’t first repair it”

(repair_device

R ¬working_device)

Fairness: “infinitely often send ”

GFsend

Strong fairness: “infinitely often send implies infinitely often recv.”

GFsend → GFrecv 38 / 61

Riferimenti

Documenti correlati

 Esistono matrici simmetriche che non

Sul tavolo si possono tenere solo i fogli forniti, una penna, libretto e/o documenti.. Non si pu` o usare

But these properties are far from to be essential: in particular, more important would be to know that the matrix A is well conditioned.. (Of course, all this is convenient if S is

In fact we can find an orthonormal basis of eigenvectors, corresponding respectively to the eigenvalues 2, −2, 3, −3... All answers must be given using the usual

Indeed, when M increases, the uniform and Lipschitz constants of V M 0 deteriorate and we had to assume a bounded Lipschitz continuous kernel in the Mean Field theory, with

Tizio vuole dipingere le stanze, in modo che stanze adiacenti abbiano colori diversi, usando il minimo numero possibile di colori. Fare un disegno dell’appartamento in cui si

Given the following generalized Büchi automaton A def = hQ, Σ, δ, I, FT i, with two sets of accepting states FT def = {F 1, F 2} s.t.. Ex:

Modeling infinite computations of reactive systems Given an Alphabet Σ (e.g... Infinite