Академический Документы
Профессиональный Документы
Культура Документы
Pallab Dasgupta
Dept. of Computer Science & Engineering
Indian Institute of Technology, Kharagpur
Formal Analysis of Hybrid Systems
Indian Institute of Technology Kharagpur Pallab Dasgupta
A Model for Hybrid System
A hybrid systemH= (Loc, Var, Lab, Edg, Act, Inv) Consists of six components:
1. A finite set Locof vertices called locations.
2. A finite set Var of real valued variables.
We write Vfor the set of valuations. A valuation is a function that assigns a real-value
(x) R to each variable x Var.
A state is a pair (, ) consisting of a location Loc and a valuation V.
3. A finite set Labof synchronizationlabels.
Lab necessarily contains the stutter label , i.e. Lab.
Indian Institute of Technology Kharagpur Pallab Dasgupta
4. A finite set Edgof edges called transitions.
Each transition e = (, a,, ) consists of :
A source location Loc,
A target location Loc,
A synchronization label a Lab
A transition relation V
2
For each location Locthere is a set Con Var of controlled variables and a
stutter transition of the form (, , ID
con
, ), where (, ) Id
con
iff for all
variables x Var, either x Conor (x) = (x).
The transition e is enabled in a state (, ) if for some valuation V, ( , )
. The state (, ) is then said to be a transition successor of (, ).
A Model for Hybrid System
Indian Institute of Technology Kharagpur Pallab Dasgupta 4
5. A labeling function Actthat assigns to each location Loc a set of activities.
Each activity is a function from the nonnegative reals R
0
to V.
The activities of each location are time-invariant.
6. A labeling function Invthat assigns to each location Loc an invariant Inv() V.
The system may stay at a location only if the location invariant is true; that is,
some discrete transition must be taken before the invariant becomes false.
The hybrid system His time-deterministicif for every location Loc and every
valuation V, there is at most one activity f Act() with f(0) =. The activity f,
then, is denoted by
[].
A Model for Hybrid System
Indian Institute of Technology Kharagpur Pallab Dasgupta 5
The runs of a hybrid system
The state of a hybrid system can change in two ways:
By a discreteand instantaneoustransition that changes both the control location and the
values of the variables according the transition relation;
By a timedelaythat changes only the values of the variables according to the activities of
the current location.
Indian Institute of Technology Kharagpur Pallab Dasgupta
A run of the hybrid system H, then, is a finite or infinite sequence
of states
i
=(
i
,
i
) nonnegative reals t
i
R
0
and activities f Act(
i
), such that for all
i 0:
1. f
i
(0) =
i
2. For all 0 t t
i
, f
i
(t) Inv(
i
)
3. The state
i+1
is a transition successor of the state
The state
i
is called a time successor of the state
I
;
The state
i+1
is called a successorof
i
.
We write [H] for the set of runs of the hybrid systemH.
6
.... :
2
2
1
1
t
f 2
t
f 1
0
t
0
f 0
The runs of a hybrid system
)) ( , (
'
i i i i
t f =
Indian Institute of Technology Kharagpur Pallab Dasgupta
Hybrid systems as transition systems
With the hybrid system H, we associate the labeled transition system
H
=(, Lab"
R
0
,), when the steprelationis the union of the following two:
The transition-step relations
a
, for a Lab,
The time-step relations
t
, for t R
0
7
( ) ( ) ( )
( ) ( )
' '
' ' '
, ,
, , , , ,
a
Inv Edg a
( ) ( ) ( ) ( )
( ) ( ) ( ) t f
Inv t f t t 0 0 f Act f
a
, ,
.
' '
=
Indian Institute of Technology Kharagpur Pallab Dasgupta
The stutter transitions ensure that the transition system
H
is reflexive. For all states ,
, , , Where =(, v) and for all t R
0
,
It follows that for every hybrid systems, the set of runs is closed under prefixes,
suffixes, stuttering, and fusion [HNSY94].
For time-deterministic hybrid systems, Time can progress by the amount t R
0
from
the state (, v) if this is permitted by the invariant of location ; that is :
We can rewrite the time-step rule for time-deterministic systems as :
8
( )
' '
, ,
a ' ' t ' ' t
f
lab. a iff Act f
[ ]( ) [ ]( ) ( )
Inv t v t t v tcp
' '
. t 0 iff
[ ]( )
( ) [ ]( ) ( ) t v v
t v tcp
t
, ,
Hybrid systems as transition systems
Indian Institute of Technology Kharagpur Pallab Dasgupta 9
Example: Thermostat
When the heater is off, the temperature:
When the heater is on:
The resulting time-deterministic hybrid system is shown below:
( )
Kt
e t x
=
( ) ( )
Kt Kt
e 1 h e t x
+ =
Indian Institute of Technology Kharagpur Pallab Dasgupta
The Parallel composition of hybrid systems
Let H
1
=(Loc
1
Var, Lab
1
, Edg
1
, Act
1
, Inv
1
) and H
2
=(Loc
2
Var, Lab
2
, Edg
2
, Act
2
, Inv
2
) be two
hybrid systems over a common set Var of variables.
Let it be so that whenever H
1
performs a discrete transition with the synchronization
label a Lab
1
Lab
2
, then so does H
2
.
The product H
1
xH
2
is the hybrid system (Loc
1
xLoc
1
, Var, Lab
1
ULab
2
, Edg, Act, Inv)
such that:
((
1
,
2
), a, , (
1
,
2
) Edg iff
1) (
1
, a
1
,
1
,
1
) Edg
1
and (
2
, a
2
,
2
,
2
) Edg
2
2) Either a
1
=a
2
=a; or a
1
Lab
2
and a
2
= ; or a
1
= and a
2
Lab
1,
3) =
1
2
;
Act(
1
,
2
) = Act
1
(
1
) Act
2
(
2
)
Inv(
1
,
2
) = Inv
1
(
1
) Inv
2
(
2
)
10
Indian Institute of Technology Kharagpur Pallab Dasgupta
It follows that all runs of the product system are runs of both component systems:
The product of two time-deterministic hybrid systems is also time-deterministic.
11
[ ] [ ] [ ] [ ]
2 2 Loc 2 1 1 1 Loc 2 1
H H H and H H H
The Parallel composition of hybrid systems
Indian Institute of Technology Kharagpur Pallab Dasgupta
Linear Hybrid Systems
A linear termover the set Var of variables is linear combination of the variables in Var
with integer coefficients.
A linear formula over Var is a boolean combination of inequalities between linear terms
over Var.
The time-deterministic hybrid system H =(Loc Var, Lab, Edg, Act, Inv) is linear if its
activities, invariants, and transition relations can be defined by linear expressions over
the set Var of variables:
1. For all locations Loc , the activities Act() are defined by a set of differential equations of
the form , one for each variable x Var , where k
x
is an integer constant: for all
valuation v V, variables x Var , and nonnegative reals t R
0
.
12
x
k x =
.
[ ]( ) ( ) t v
x
+ =
x
k x v t
Iteration-1
L1
L2
L3
L4
L5
Error
i=0;
[i>10]
[i10]
i=i+2;
[i<5]
[i5]
Int
{0,2}
{0,2}
{2,4}
Iteration-2
L1
L2
L3
L4
L5
Error
i=0;
[i>10]
[i10]
i=i+2;
[i<5]
[i5]
Int
{0,2,4}
{0,2,4}
{2,4,6}
{6}
Iteration-3
Indian Institute of Technology Kharagpur Pallab Dasgupta 23
Abstract Interpretation
Sample program:
int i=0
do {
assert( i <= 10);
i = i+2;
} while (i < 5);
L1
L2
L3
L4
L5
Error
i=0;
[i>10]
[i10]
i=i+2;
[i<5]
[i5]
Philosophy:
Use an abstract domain instead of value sets
Example: We may use value intervals instead of
value sets
[min, max]
[0,0]
[0,0]
[2,2]
[ ]
Iteration-1
L1
L2
L3
L4
L5
Error
i=0;
[i>10]
[i10]
i=i+2;
[i<5]
[i5]
[min, max]
[0,2]
[0,2]
[2,4]
[ ]
Iteration-2
L1
L2
L3
L4
L5
Error
i=0;
[i>10]
[i10]
i=i+2;
[i<5]
[i5]
[min, max]
[0,4]
[0,4]
[2,6]
[5,6]
Iteration-3
Actually, the value 5 is not possible her
Indian Institute of Technology Kharagpur Pallab Dasgupta
The Reachability Problem for Linear Hybrid Systems
Let and are two states of a hybrid system H.
The state is reachable from the state , written * if there is a run of Hthat
starts in and ends in .
The reachability question asks, then, if * f or two given states and of a
hybrid system H.
The verification of invariance properties is equivalent to the reachability question: a set
R of states is an invariant of the hybrid system Hiff no state in - R is reachable
from an initial state of H.
24
Indian Institute of Technology Kharagpur Pallab Dasgupta
A decidability result
A linear hybrid system is simpleif all linear atoms in location invariabts and transition
guards are of the form x k or k x, for a variable xVar and an integer constant k.
For multirate timed systems the simplicity condition prohibits the comparison of
skewed clocks with different rates.
Theorem 3.1: The reachability problem is decidable for simple multirate timed
systems.
25
Indian Institute of Technology Kharagpur Pallab Dasgupta
Two Undecidability results
Theorem 3.2: The reachability problem is undecidable for 2-rate timed systems.
Theorem 3.3: The reachability problem is undecidable for simple integrator systems.
26
Indian Institute of Technology Kharagpur Pallab Dasgupta
The verification of Linear Hybrid Systems
Forward Analysis: Preliminary Definitions
Given a location Locand a set of valuations P V, the forward time closure of Pat is the
set of valuations that are reachable from some valuation v P.
Thus for all valuation v , There exist a valuation v Pand a nonnegative real
tR
0
such that (, v)
(, v )
Given transition e= (, a, , ) and a set of valuation P V, the post condition post
e
[P] of Pwith
respect to eis the set of valuations that are reachable from some valuation v Pby executing the
transition e;
Thus for all valuations v post
e
[P], there exists a valuation v P such that (, v)
a
(, v)
27
P
[ ]( ) [ ]( ) t t v P v v v' tcp P v . R t V, v iff '
0
P
[ ] ( ) ' v' v, P V.v v iff P post v
e
R ,
Loc
R
=
[ ]
( )
[ ] ( )
R R
Edge e
e
' ,
post , ' post
=
=
The verif. of Lin. Hyb. Sys.: Forward Analysis
Indian Institute of Technology Kharagpur Pallab Dasgupta 29
A symbolic run of the linear hybrid system His a finite or infinite sequence
: (
0
, P
0
) (
1
, P
1
) (
i
, P
i
)
of regions such that for all i 0, there exists of transitions e
i
from
i
to
i +1
and
The symbolic run a represents the set of all runs of the form
such that (
i
, v
i
) (
i
, P
i
) for all i 0.
[ ]
i
i e i
P post P
=
+1
( ) ( ) ... , ,
1 0
1 1 0 0
t t
v v
of valuations
is the least fixpoint of the set of equations:
.
30
The verif. of Lin. Hyb. Sys.: Forward Analysis
( ) * I
( ) * ' . ' * I iff I
( )
I I
Loc
,
=
( ) ( )
R I
Loc
, *
=
[ ] X post I X =
( )
[ ]
'
, '
X post I X
e
Edg e =
=
Indian Institute of Technology Kharagpur Pallab Dasgupta
Lemma 4.1: For all linear hybrid systems H, if P V is a linear
set of valuations, then for all locations Loc and transitions
e Edg, both and post
e
[P] are linear sets of valuations.
By Lemma 4.1, if Ris a linear region, then so are both and
post
e
[R]
31
P
R
The verif. of Lin. Hyb. Sys.: Forward Analysis
Indian Institute of Technology Kharagpur Pallab Dasgupta 32
Example, Forward Analysis: The leaking gas
burner
. . . Contd.
Recap:
Indian Institute of Technology Kharagpur Pallab Dasgupta
Let I be the set of initial states defined by the linear formula
The set of reachable states is characterized by the least fixpoint of the two
equations
which can be iteratively computed as
33
( ) 0 1 = = = = = z y x pc
I
( ) * I
[ ]
1
2 ) 1 , 2 ( 1
0 post z y x = = = =
( )
[ ]
2
1 2 , 1 2
post false =
[ ]
1 , 2 ) 1 , 2 ( 1 , 1 , 1
=
i i i
post
[ ]
2
1 , 1 ) 1 , 2 ( 1 , 2 , 2
=
i i i
post
of
P at is the set of valuations from which it is possible to reach some valuation v P
by letting time progress:
Thus for all valuations v P
[ ]( ) [ ]( ) t v tcp P v t v v R v iff P v
0
' ' . '
),
Given a region R , the initial region (* R) of R is the set of all states from
which a state in R is reachable:
Notice that R (* R).
35
( ) R R
Loc
=
[ ]
( )
[ ] ( ) R pre R pre
e
Edg e
,
, ' =
=
( ) ' * R. ' iff R *
Indian Institute of Technology Kharagpur Pallab Dasgupta
Proposition 4.2 Let R =
Loc
(, R
of valuations is the
least fixpoint of the set.
Lemma 4.2 For all linear hybrid systems H, if P V is a linear set of
valuations, then for all locations Loc and transitions eEdg, both P
and pre
e
[P] are linear sets of valuations.
36
[ ] X pre R X =
( )
[ ]
X pre R X
e
Edg e
'
' , =
=
'
, '
X post I X
e
Edg e =
=
Indian Institute of Technology Kharagpur Pallab Dasgupta
An approximate solution to these problems is provided by abstract interpretation
techniques.
Union of polyhedra is approximated by their convex hull. Let denote the convex hull
operator:
The system of equations becomes:
To enforce the convergence of iterations, we apply Cousot's widening technique.
39
( )
[ ]
'
' ,
X post I X
e
Edg e =
=
( )
( )
( )
( )
[ ]
1
'
, '
1
=
=
n
e
Edg e
n
X post I X F
( ) ( )
( )
1 1
=
n n n
X X X
The verif. of Lin. Hyb. Sys.: Approximate Analysis
Indian Institute of Technology Kharagpur Pallab Dasgupta
Approximation Operators:
42
The verif. of Lin. Hyb. Sys.: Approximate Analysis
Indian Institute of Technology Kharagpur Pallab Dasgupta
Example, Approximate Analysis: The leaking gas
burner
With I defined by
I
= (pc= 1 x= y= z= 0), we have with
and (choosing location 1 as the only widening location):
43
( )
2 1
* X X I =
( )
( ) 2 1 i X X
n
i i
, , lim = =
( ) ( )
( )
( )
( )
[ ]
1
1 n
2 1 2
1 n
1
n
1
X post 0 z y x X X
= = = =
,
( )
( )
( )
[ ]
2
n
1 2 1
n
2
X post X
,
=
Indian Institute of Technology Kharagpur Pallab Dasgupta
Analysis of Leaking Gas Burner
44
Source: [Gonnord, Halbwachs, LNCS 4134] Combining widening and acceleration in linear relation analysis.
Step-1: Leaking location reached with {t=l=0}, and as time elapses we get the
polyhedron {0 t = l 10} (Region (1) in Fig. 2.a)
Indian Institute of Technology Kharagpur Pallab Dasgupta
Analysis of Leaking Gas Burner
45
Source: [Gonnord, Halbwachs, LNCS 4134] Combining widening and acceleration in linear relation analysis.
Step-2: Non-leaking location is reached with {0 t = l 10}. As time elapses, we
get {0 l 10, t l }. (Region (2) in Fig. 2.b)
Indian Institute of Technology Kharagpur Pallab Dasgupta
Analysis of Leaking Gas Burner
46
Source: [Gonnord, Halbwachs, LNCS 4134] Combining widening and acceleration in linear relation analysis.
Step-3: We go back to leaking location with {0 l 10, t l+50 }, (Region (3) in Fig. 2.c)
Convex hull with {t = l =0 } gives {0 l 10, t 6l }, (Region (4) in Fig. 2.c)
Indian Institute of Technology Kharagpur Pallab Dasgupta
Analysis of Leaking Gas Burner
47
Source: [Gonnord, Halbwachs, LNCS 4134] Combining widening and acceleration in linear relation analysis.
Step-3 (contd): Time passage yields {0 l 20, t l, t 6l 50 }. Now standard
widening yields {0 l t, t 6l 50 }. (Region (5) in Fig. 2.c)
Indian Institute of Technology Kharagpur Pallab Dasgupta
Minimization
We extend the next relation to regions:
We write for the reflexive transitive closure of
Let be a partition of the state space . A region R is stable if for all R
The partition is a bisimulation if every region R is stable.
48
Minimization
Indian Institute of Technology Kharagpur Pallab Dasgupta
The minimization procedure returns YES iff I R
F
.
State-space minimization:
50
*
Minimization
Indian Institute of Technology Kharagpur Pallab Dasgupta
Model Checking
Timed computation tree logic:
Let Cbe a set of clocks not in Var; that is C Var = .
A state predicate is a linear formula over the set Var Cof variables.
The formulas of TCTL, then, are defined by the following grammar, where is a state
predicate and z C.
The formal is closed if all occurrences of a clock z Care within the scope of a reset
quantifier z.
51
::= | |
1
2
| z. |
1
u
2
|
1
u
2
Indian Institute of Technology Kharagpur Pallab Dasgupta
Timed Computation Tree Logic
The closed formulas of TCTL are interpreted over the state space
of a linear hybrid system H.
A state satisfies the TCTL-formula
1
u
2
if there exists a run
of H from to a state satisfying
2
such that
1
2
continuously holds along the run.
A state satisfies the TCTL-formula
1
u
2
if every divergent
run of H from leads to a state satisfying
2
such that
1
2
continuously holds from to .
Clocks can be used to express timing constraints.
E.g. z. (trueu ( z 5)) asserts that there is a run on
which is satisfied within 5 time units.
52
Indian Institute of Technology Kharagpur Pallab Dasgupta
Timed Computation Tree Logic
Standard abbreviations:
1. trueu
2. trueu
3.
4.
5.
<5
z. ( (z< 5))
53
Indian Institute of Technology Kharagpur Pallab Dasgupta
Timed Computation Tree Logic
Let be a run of the linear hybrid system H, with
i
=(
i
,
i
) for all
i 0:
A position of is a pair (i, t) consisting of a nonnegative integer i and a
nonnegative real t t
i
.
The position of are ordered lexicographically; that is , (i, t) (j, t) iff i < j, or i = j
and t t.
For all positions =(i, t) of ,
The state () at the position of is (
i
,
[v
i
](t)), and
The time
() at the position of is t+
j<i
t
j
A clock valuation is function from Cto R
0
.
By + twe denote the clock valuation such that (z) = (z) + tfor all
clocks z C.
By [z := 0] we denote the valuation such that (z) = 0 and (z ) =
(z) for all clocks z z.
An extended state (, ) consists of a state and a clock valuation .
54
...
1 0
1 0
t t
=
Indian Institute of Technology Kharagpur Pallab Dasgupta
Timed Computation Tree Logic
The extended state(, ) satisfies the TCTL-formula ,denoted (, ) if:
55
Let be a closed formula of TCTL. We write if (, ) for all clock
valuations .
The Linear hybrid system Hsatisfies , denoted H , if all states of Hsatisfy .
Indian Institute of Technology Kharagpur Pallab Dasgupta
The model-checking algorithm
The Characteristic set of is the set of states that satisfy .
Given a closed TCTL-formula , a model-checking algorithm computes
the characteristic set
Definition of binary next or single step until operator :
Given two regions R, R , the region R R is the set of states that have
a successor R such that all states between and are contained in R
R :
I.e., ( ,) (R R) iff:
I.e., the operator is a single-step until operator.
For a linear formula , we extend the tcp operator such that
56
( ) ( ) ( ) ( ) ( ) ( ) ' ' , . ' ' , ' , , , ' ' , ' R R t v t t 0 v v R t R v
t 0
+
[ ][ ]( ) [ ]( ) ( ) ( ) ' . ' 0 iff tcp
Inv t v t t t v
Indian Institute of Technology Kharagpur Pallab Dasgupta
The model-checking algorithm
For a state = (, v) we write [] for the function
) we write.
Now, for two regions R, R , we define the region RR as
Lemma 4.3: For all linear hybrid systems H, if R and R are two linear regions of H,
then so is R R.
57
[ ][ ]( ) [ ][ ]( ) t v R tcp iff t R tcp