• Non ci sono risultati.

Formal Method Mod. 2 (Model Checking) Laboratory 11 Giuseppe Spallitta giuseppe.spallitta@unitn.it

N/A
N/A
Protected

Academic year: 2021

Condividi "Formal Method Mod. 2 (Model Checking) Laboratory 11 Giuseppe Spallitta giuseppe.spallitta@unitn.it"

Copied!
32
0
0

Testo completo

(1)

Formal Method Mod. 2 (Model Checking)

Laboratory 11

Giuseppe Spallitta giuseppe.spallitta@unitn.it

Università degli studi di Trento

June 3, 2021

(2)

Timed systems

Real time systems

I Correctness depends not only on the logical result but also on the time required to compute it.

I Common in safety-critical domains like: defense, transportation, health-care, space and avionics.

Timed Transition System (TTS) transitions are either discrete or time-elapses,

all clocks increase of the same amount in time-elapses.

Model checking for TTS is undecidable.

Timed Automata (TA) decidable restriction of TTS, finite time abstraction:

clocks compared only to constants.

discrete

time

Giuseppe Spallitta 1/22

(3)

Timed systems: representation

Timed Automata (TA)

Explicit graph representation of discrete states (nodes) and transitions (edges).

Symbolic representation of temporal aspects via (convex) constraints (location invariants,transition guards andresets).

c ≤ 5 c < 15

c ≥ 5 c..= 0

c > 3

`0 `1

Symbolic TTS

Logical formulae represent sets of states: p..= {s | s |= p)}.

Transition system symbolically represented by formula ϕ(X , X0).

There is a discrete transition from s0to s1iff s0(X ), s1(X0) |= ϕ(X , X0).

l = `0c ≤ 5 l = `1c < 15

(l = `1∧ l0= `0) →c > 3 (l = `0∧ l0= `1) → (c ≥ 5c0 = 0)

Giuseppe Spallitta 2/22

(4)

Outline

1. Timed nuXmv

2. Timed and infinite traces

3. Exercises

(5)

nuXmv for timed system: architecture

Timed traces Timed nuXmv Mt |= ϕt

reduction to untimed (Mt |= ϕt)⇐⇒(M |= ϕ)

trace timing (σ ∈ M)⇐⇒(σt∈ Mt)

Traces nuXmv M |= ϕ

Giuseppe Spallitta 1. Timed nuXmv

3/22

(6)

Timed nuXmv: input language [1/4]

Overview

I Must start with @TIME_DOMAIN continuous;

I Symbolic description of infinite transition system using: INIT, INVARandTRANS to specify initial, invariant and transition conditions.

I Model described as a synchronous composition of MODULE instances.

I Clock variables,

I time: built-in clock variable, I convex invariants over clocks, I URGENT: forbid time elapse.

Giuseppe Spallitta 1. Timed nuXmv

4/22

(7)

Timed nuXmv: input language [2/4]

Timed nuXmv adds

I clockvariable type, all clocksincrease of the same amount during timed transitions;

I time: built-inclock, can be used only in comparisons with constants;

I noncontinuoustype modifier: symbol can change its assignment during timed transitions;

I URGENT: freeze time: when one of theURGENTconditions is satisfied only discrete transitions are allowed;

I MTL0,∞ specifications, by “extending” LTL;

Giuseppe Spallitta 1. Timed nuXmv

5/22

(8)

Timed nuXmv: input language [3/4]

Timed nuXmv updates

I TRANSconstrain the discrete behaviour only, I INVAR:clocksallowed in invariants with shape:

no_clock_expr -> convex_clock_expr; I LTL operators: X , Y , U, S,

I Bounded LTL operators.

Giuseppe Spallitta 1. Timed nuXmv

6/22

(9)

Timed nuXmv: input language [4/4]

Specification

I Different operators to refer to the discrete next and timed next: X,X~; symmetrically for the past: Y,Y~.

I Time interval semantic to handle open intervals: a predicate p might hold in an interval (a, b] for a, b ∈ R.

I Operators to retrieve value of expression the next/last time an expression will hold/held: time_until,time_since,@F~ and@O~.

Giuseppe Spallitta 1. Timed nuXmv

7/22

(10)

Timed nuXmv: untiming

Timed to untimed model

I clocksymbols and time: variables of type real.

I δ: continuous positive variable, prescribes the amount of time elapse for every transition.

I ι: prescribes the alternation of singular [] and open (−) time intervals. discrete

time []

[](−) [] [] [](−)

[](−) []

[]

Giuseppe Spallitta 1. Timed nuXmv

8/22

(11)

Timed nuXmv: untiming

Properties rewriting

MTLfragment F[0,5] p

rewrite

LTL timed ((¬pUp) ∧ time_until (p) ≤ 5)∨

((¬pU ˜X p) ∧ time_until (p) < 5) untime

LTL untimed

((¬pUp) ∧ (time@ ˜F p) − time ≤ 5) ∨

((¬pU((¬ι ∧ p) ∨ X (¬ι ∧ p))) ∧ (time@ ˜F p) − time < 5)

Giuseppe Spallitta 1. Timed nuXmv

9/22

(12)

Outline

1. Timed nuXmv

2. Timed and infinite traces

3. Exercises

(13)

Timed and infinite traces

From untimed model execution to timed trace.

Issue

nuXmv traces must have shape: αβω, α and β sequences of states.

Complete for finite state systems.

TTS: time monotonically increasing, infinite state system, undecidable.

Identify traces expressible as: αβ(i )ω. Same problem can be found in infinite state transition systems.

Solution

Value assigned to variables at state s is function of the previous configuration assignments.

e.g. next(time)..= time + δ

discrete

time α

β(0) β(1)

. . .

Giuseppe Spallitta 2. Timed and infinite traces

10/22

(14)

Timed and infinite traces: operations

Three main operations on traces: simulation, execution and completion.

Simulation

Build a possible execution of the model. The trace can be built automatically by the system or the user can choose each state from the list of possible ones.

Exploit SMT-solver to perform a discrete transition or time-elapse to obtain next configuration.

Giuseppe Spallitta 2. Timed and infinite traces

11/22

(15)

Timed and infinite traces: operations

Execution

Check if a trace belongs to the language of the model.

Exploit SMT-solver to prove that for all possible iterations all prescribed transition can be performed.

Completion

A partial trace is completed so that it belongs to the model language.

Sound and complete technique requires to check if there exists a possible completion so that the completed trace belongs to the model language: quantifier alternation (∃∀).

Adopt sound but incomplete approach.

Giuseppe Spallitta 2. Timed and infinite traces

12/22

(16)

How to run: model [1/3]

I ./nuXmv -time -int: start nuXmv interactively and enable commands for timed models.

I go_time: process the model.

I write_untimed_model: dump SMV model corresponding to the input timed system.

Giuseppe Spallitta 2. Timed and infinite traces

13/22

(17)

How to run: verify [2/3]

I timed_check_invar: check invariants.

I timed_check_ltlspec: check LTL.

Mostly the same command line options of the corresponding commands for untimed models.

Giuseppe Spallitta 2. Timed and infinite traces

14/22

(18)

How to run: simulation and traces [3/3]

I timed_pick_state: pick initial state.

I timed_simulate: simulate the model starting from a given state.

I execute_traces: re-execute stored traces.

I execute_partial_traces: try to complete stored traces.

Giuseppe Spallitta 2. Timed and infinite traces

15/22

(19)

Semantics of temporal operators

Formally nuXmv uses a super-dense weakly-monotonic time model T ⊂ N × R+0.

A time point is a pair hi , r i where i ∈ N “counts the discrete steps”

and r ∈ R+0 is the time.

We say that hi , r i < hi0, r0i iff i < i0 or i = i0 and r < r0.

Giuseppe Spallitta 2. Timed and infinite traces

16/22

(20)

Semantics of temporal operators

σ, t |= φ is defined recursively on the structure of φ:

usual definition for predicates, conjunction and negation.

σ, t |=φ12 iff there exists t0≥ t, σ, t0|= φ2 and for all t00, t ≤ t00< t0, σ, t00|= φ1

σ, t |=φ1S φ2 iff there exists t0≤ t, σ, t0|= φ2 and for all t00, t0< t00≤ t, σ, t00|= φ1

σ, t |=X φ iff there exists t0 > t, σ, t0|= φ and there exists no t00, t < t00< t0

σ, t |= ˜X φ iff for all t0> t, there exists t00, t < t00< t0, σ, t00|= φ σ, t |=Y φ iff t > 0 and there exists t0 < t, σ, t0|= φ and

there exists no t00, t0 < t00< t σ, t |= ˜Y φ iff t > 0 and for all t0< t,

there exists t00, t0< t00< t0, σ, t00|= φ

Giuseppe Spallitta 2. Timed and infinite traces

17/22

(21)

LTL- MTL properties [1/2]

Let k, k1 and k2 be some constant real values such that 0 ≤ k ≤ k1 < k2 and let b a boolean symbol.

The following properties true or false?

I Y >˜

: false in the initial state.

I (¬Xb) → (X ¬b) : false, the first one holds in every time elapse, the second one holds only in discrete steps where ¬b holds in the next state.

I (¬ ˜X b) → ( ˜X ¬b) : false, as above but for time elapses. I (X ¬b) → (¬Xb) : true, the first one holds iff there is a

discrete step and ¬b holds in the next state, hence Xb is false. I ( ˜X ¬b) → (¬ ˜X b) : true, as above but for time elapses.

I (G ˜X >) → ((Gb) ∨ (G ¬b)) : true, the first part implies that we never perform a discrete transition and the truth value of b can only change in discrete transitions.

Giuseppe Spallitta 2. Timed and infinite traces

18/22

(22)

LTL- MTL properties [1/2]

Let k, k1 and k2 be some constant real values such that 0 ≤ k ≤ k1 < k2 and let b a boolean symbol.

The following properties true or false?

I Y >˜ : false in the initial state.

I (¬Xb) → (X ¬b)

: false, the first one holds in every time elapse, the second one holds only in discrete steps where ¬b holds in the next state.

I (¬ ˜X b) → ( ˜X ¬b) : false, as above but for time elapses. I (X ¬b) → (¬Xb) : true, the first one holds iff there is a

discrete step and ¬b holds in the next state, hence Xb is false. I ( ˜X ¬b) → (¬ ˜X b) : true, as above but for time elapses.

I (G ˜X >) → ((Gb) ∨ (G ¬b)) : true, the first part implies that we never perform a discrete transition and the truth value of b can only change in discrete transitions.

Giuseppe Spallitta 2. Timed and infinite traces

18/22

(23)

LTL- MTL properties [1/2]

Let k, k1 and k2 be some constant real values such that 0 ≤ k ≤ k1 < k2 and let b a boolean symbol.

The following properties true or false?

I Y >˜ : false in the initial state.

I (¬Xb) → (X ¬b) : false, the first one holds in every time elapse, the second one holds only in discrete steps where ¬b holds in the next state.

I (¬ ˜X b) → ( ˜X ¬b)

: false, as above but for time elapses. I (X ¬b) → (¬Xb) : true, the first one holds iff there is a

discrete step and ¬b holds in the next state, hence Xb is false. I ( ˜X ¬b) → (¬ ˜X b) : true, as above but for time elapses.

I (G ˜X >) → ((Gb) ∨ (G ¬b)) : true, the first part implies that we never perform a discrete transition and the truth value of b can only change in discrete transitions.

Giuseppe Spallitta 2. Timed and infinite traces

18/22

(24)

LTL- MTL properties [1/2]

Let k, k1 and k2 be some constant real values such that 0 ≤ k ≤ k1 < k2 and let b a boolean symbol.

The following properties true or false?

I Y >˜ : false in the initial state.

I (¬Xb) → (X ¬b) : false, the first one holds in every time elapse, the second one holds only in discrete steps where ¬b holds in the next state.

I (¬ ˜X b) → ( ˜X ¬b) : false, as above but for time elapses.

I (X ¬b) → (¬Xb)

: true, the first one holds iff there is a discrete step and ¬b holds in the next state, hence Xb is false. I ( ˜X ¬b) → (¬ ˜X b) : true, as above but for time elapses.

I (G ˜X >) → ((Gb) ∨ (G ¬b)) : true, the first part implies that we never perform a discrete transition and the truth value of b can only change in discrete transitions.

Giuseppe Spallitta 2. Timed and infinite traces

18/22

(25)

LTL- MTL properties [1/2]

Let k, k1 and k2 be some constant real values such that 0 ≤ k ≤ k1 < k2 and let b a boolean symbol.

The following properties true or false?

I Y >˜ : false in the initial state.

I (¬Xb) → (X ¬b) : false, the first one holds in every time elapse, the second one holds only in discrete steps where ¬b holds in the next state.

I (¬ ˜X b) → ( ˜X ¬b) : false, as above but for time elapses.

I (X ¬b) → (¬Xb) : true, the first one holds iff there is a discrete step and ¬b holds in the next state, hence Xb is false.

I ( ˜X ¬b) → (¬ ˜X b)

: true, as above but for time elapses. I (G ˜X >) → ((Gb) ∨ (G ¬b)) : true, the first part implies that

we never perform a discrete transition and the truth value of b can only change in discrete transitions.

Giuseppe Spallitta 2. Timed and infinite traces

18/22

(26)

LTL- MTL properties [1/2]

Let k, k1 and k2 be some constant real values such that 0 ≤ k ≤ k1 < k2 and let b a boolean symbol.

The following properties true or false?

I Y >˜ : false in the initial state.

I (¬Xb) → (X ¬b) : false, the first one holds in every time elapse, the second one holds only in discrete steps where ¬b holds in the next state.

I (¬ ˜X b) → ( ˜X ¬b) : false, as above but for time elapses.

I (X ¬b) → (¬Xb) : true, the first one holds iff there is a discrete step and ¬b holds in the next state, hence Xb is false.

I ( ˜X ¬b) → (¬ ˜X b) : true, as above but for time elapses.

I (G ˜X >) → ((Gb) ∨ (G ¬b))

: true, the first part implies that we never perform a discrete transition and the truth value of b can only change in discrete transitions.

Giuseppe Spallitta 2. Timed and infinite traces

18/22

(27)

LTL- MTL properties [1/2]

Let k, k1 and k2 be some constant real values such that 0 ≤ k ≤ k1 < k2 and let b a boolean symbol.

The following properties true or false?

I Y >˜ : false in the initial state.

I (¬Xb) → (X ¬b) : false, the first one holds in every time elapse, the second one holds only in discrete steps where ¬b holds in the next state.

I (¬ ˜X b) → ( ˜X ¬b) : false, as above but for time elapses.

I (X ¬b) → (¬Xb) : true, the first one holds iff there is a discrete step and ¬b holds in the next state, hence Xb is false.

I ( ˜X ¬b) → (¬ ˜X b) : true, as above but for time elapses.

I (G ˜X >) → ((Gb) ∨ (G ¬b)) : true, the first part implies that we never perform a discrete transition and the truth value of b can only change in discrete transitions.

Giuseppe Spallitta 2. Timed and infinite traces

18/22

(28)

LTL- MTL properties [2/2]

See files in examples.

Giuseppe Spallitta 2. Timed and infinite traces

19/22

(29)

Outline

1. Timed nuXmv

2. Timed and infinite traces

3. Exercises

(30)

Simple timed automaton

Write the SMV model corresponding to the timed automaton in the figure.

c ≤ 5 c < 15

c ≥ 5 c ..= 0

c > 3

`0 `1

Properties

I from location `0 we always reach `1 within 5 time units;

I if we are in `1 then for the next 3 time units we remain in `1; I if just arrived in `1 then for the next 3 time units we remain in

`1.

Giuseppe Spallitta 3. Exercises

20/22

(31)

Timed thermostat

I a thermostat has 2 states: on and off ;

I if the temperature is below 18 degrees the thermostat switches on.

I if the temperature is above 18 degrees the thermostat switches off.

I Every time the thermostat misure the temperature in the room, the temperature increases (if on) or decreases (if off ) by dt (with respect to the previous check);

I the thermostat measures the temperature at most (<) every max _dt time units.

I the temperature initially is in [18 − max_dt; 18 + max_dt].

Verify that the temperature is always in [18 − 2max _dt; 18 + 2max _dt]

Giuseppe Spallitta 3. Exercises

21/22

(32)

Homework

Try to encode the timed automata shown in the theoretical slide about timed automata.

Giuseppe Spallitta 3. Exercises

22/22

Riferimenti

Documenti correlati

Deadend states: reachable states which do not allow to proceed along a refinement of the abstract counter-example. Bad states: un-reachable states which allow to proceed along

Some exampes displayed in these slides are taken from [Clarke, Grunberg &amp; Peled, “Model Checking”, MIT Press], and their copyright is.. detained by

5 Symbolic Reachability for Hybrid Systems Multi-Rate and Rectangular Hybrid Automata Linear Hybrid Automata..

Projection to infinity: values allowed to enter the location, after waiting unbounded time Intersection with invariant φ: values allowed to enter the location, after waiting a

⇒ The solver returns SAT and, checking the output, the two true variables generate 32 as solution. Giuseppe

Bill has a series of job interviews this week (August 20th, 21st, 22nd and 23rd), each for a different type of position (copywriter, graphic design, sales rep and social media) at

Once you create your file using the TPTP format, you can feed it to the theorem prover using the command ./eprover –auto -s file.p:.. I If a proof is found, then the output string

I NEGATION is represented as (not &lt;var&gt;) I OR is represented as (or &lt;var1&gt; &lt;var2&gt;) I AND is represented as (and &lt;var1&gt; &lt;var2&gt;) I IF is represented