The Analysis of Infinite-State Systems
Bernard Boigelot Universit´ e de Li` ege http://www.montefiore.ulg.ac.be/˜boigelot/
1
The Analysis of Infinite-State Systems Bernard Boigelot Universit - - PowerPoint PPT Presentation
The Analysis of Infinite-State Systems Bernard Boigelot Universit e de Li` ege http://www.montefiore.ulg.ac.be/ boigelot/ 1 1. Introduction 2 Infinite-State Systems A model can have an infinite number of configurations because of
Bernard Boigelot Universit´ e de Li` ege http://www.montefiore.ulg.ac.be/˜boigelot/
1
2
Infinite-State Systems A model can have an infinite number of configurations because of
Example: Bakery algorithm:
repeat forever: x1 := x2 + 1; await x2 = 0 or x1 ≤ x2; critical; x1 := 0; || repeat forever: x2 := x1 + 1; await x1 = 0 or x2 < x1; critical; x2 := 0;
Example: Leaking gas burner (hybrid system).
˙ x = 1 ˙ y = 1 ˙ z = 1 x ≤ 1 x ≤ 1 − → x := 0 x ≥ 30 − → x := 0 ∧ z = 0 x = 0 ∧ y = 0 L ¬L ˙ x = 1 ˙ y = 1 ˙ z = 0
3
– Parallel composition of an arbitrary number of identical processes.
|| || || || || · · · ||
– Dynamic instantiation of processes. – Recursive procedure calls. Example:
visit(node n): . . . if not(leaf(n)) then
{
visit(n.left); visit(n.right);
}
4
Analyzing Infinite-State Systems: Motivation There are many good reasons to write infinite-state models:
Example: Concurrent machines communicating through unbounded FIFO channels.
5
Modeling Infinite-State Systems In this course, we consider systems modeled by extended automata:
domains.
6
Example: Bakery algorithm.
2 1 2 1 x1 = x2 = 0 x1 := x2 + 1 x1 := 0 x1 ≤ x2 x2 == 0 x1 == 0 x2 := x1 + 1 x2 := 0 x2 < x1
7
Dealing with Infinite Control In some cases, unbounded control can be transformed into unbounded data by
= ⇒
l1 = 2 l2 = 2 l3 = 1
help of additional variables.
8
Analyzing Extended Automata Our goal is to check reachability properties:
configurations. Motivations:
properties.
can do. Remark: For most classes of extended automata, reachability is undecidable! Our solutions will take the form of semi-algorithms.
9
Analyzing Extended Automata: Main Issues
finite data structures. The chosen representation system must be – concise and efficient; – closed over some essential operations.
reachable configurations. These must be powerful enough to capture the “source of infiniteness” in the model under analysis.
10
11
State-Space Exploration Principles:
Algorithm: S := S0; T := S; while S = ∅ : S := θ(S) \ T; T := T ∪ S.
...
S0 S3 S2 S1
Problem: Exploration does not terminate if the reachability depth of all the configurations is unbounded. Solution: Meta-transitions.
12
Meta-Transitions Principles:
reachability.
configurations from a finite one.
(c, v) (c′, m1) (c′, m2) (c′, m3) . . .
m 13
Accelerated State-Space Exploration Idea : Adding meta-transitions to the transition relation of the model can speed up state-space exploration (and even make it terminate). Example :
[1] [2] [3] [4] x := 0 even?(x) x := x + 2 x > 1000000
The effect of the loop [2] − → [3] − → [2] can be computed in one step.
14
State-space exploration :
{([1], ⊥)} {([2], 2k + 2) | k ∈ N} {([4], 2k + 1000002) | k ∈ N} {([3], 2k + 2) | k ∈ N} {([2], 0)} {([3], 2)} {([2], 2)} x := x + 2 x := 0 even?(x) x := x + 2 even?(x) x > 1000000 m {([2], 2k) | k ∈ N}
− → T = {([1], ⊥), ([2], 2k), ([3], 2k + 2), ([4], 2k + 1000002) | k ∈ N }
15
Symbolic Representation of Data Sets In order to be able to implement symbolic state-space exploration, one needs a representation system for sets of data values. Requirements:
meta-transition should be decidable.
16
Automata-Based Representations Principles:
automaton that accepts L forms a representation of S. Advantages:
algorithms.
17
Example: Unbounded FIFO Channels Framework:
1 × Σ∗ 2 × · · · × Σ∗ n, where
– n > 0 is the number of channels, – each Σi is the finite message alphabet of the i-th channel qi; – the Σi are assumed to be distinct.
– send operations qi!a, and – receive operations qi?a for each i ≤ n and a ∈ Σi.
qi?a qi qi!a a a · · ·
18
Encoding Channel Contents Principles:
(w1, . . . , wn) onto the concatenation w1 · w2 · · · wn of the individual channel contents. The set of valid encodings is thus V = Σ∗
1 · Σ∗ 2 · · · Σ∗ n.
U ⊆ Σ∗
1 × Σ∗ 2 × · · · × Σ∗ n is a finite-state automaton accepting the
language ES(U). Property: The sets that are representable by QDDs are exactly those that can be expressed as a finite union of Cartesian products of regular languages over the message alphabets.
19
QDDs: Data Operations Send:
a+b: a a b a a b b (q!b)[a+b]:
Receive:
(q?a)[a+b]: a a b
20
Iterating Sequences of Data Operations In order to add meta-transitions to a channel system, one must be able to compute the effect of repeating a sequence of channel operations. To compute σ∗(A) from a sequence of operations σ and a QDD A, we proceed as follows:
k σk(A).
21
Iterating a Sequence on a QDD
a∗b: a b a b a b (q!b; q?a)∗[a∗b]: b b b · · · b
Theorem: This operation can always be performed if there is no more than one channel in the system.
22
QDDs: Operations on Multiple Channels
QDD corresponding to the relevant channel.
represented as a QDD. Example: (q1!a; q2!b)∗. The problem comes from the ability to count the number of iterations from the content of two or more channels.
channels.
23
24
Framework
P x ≤ q − →
x + b, with P ∈ Zm×n, q ∈ Zm, A ∈ Zn×n, and b ∈ Zn. Example:
2 1 2 1 x1 = x2 = 0 x1 := x2 + 1 x1 := 0 x1 ≤ x2 x2 == 0 x1 == 0 x2 := x1 + 1 x2 := 0 x2 < x1
25
Number Decision Diagrams Principles:
first.
satisfy −rp−1 ≤ z < rp−1. Examples: Enc2(12) = 0+1100 Enc2(−7) = 1+001.
26
component, in a fixed order.
Synchronous encoding: Enc2((−4, 6, 3)) = (1, 0, 0)+(1, 1, 0)(0, 1, 1)(0, 0, 1) Serial encoding: Enc2((−4, 6, 3)) = (100)+110011001.
encodings of all the elements in S.
27
From Linear Constraints to NDDs An NDD representing the set { x ∈ Zn | a. x = b} can be constructed by
in q reads a solution of a. x = β(q);
q
q′
β(q) = β(q′) − a. d r
28
Example: 2x − y = −4
11 01 10 00 10 01 11 00 10 00 11 00 10 q0 −4 −2 −3 −1 29
NDDs: Expressiveness Theorem: A set S ⊆ Zn is representable by an NDD in a base r > 1 iff it can be defined in the first-order theory Z, +, ≤, Vr, where Vr(z) is the greatest power of r that divides z. Theorem: A set S ⊆ Zn is representable by an NDD in any base r > 1 iff it can be defined in the first-order theory Z, +, ≤ (i.e., Presburger arithmetic). Automata-based representations of sets thus provide a simple algorithm for deciding Presburger arithmetic.
30
NDDs: Meta-transitions Applying a meta-transition m amounts to computing the image of a set by (P x ≤ q → x := A x + b)∗, The effect of the transformation θ ≡ x := A x + b can be a combination
θ∗(S) = S ∪ θ(S);
θ∗(S) = S ∪ θ(S) ∪ θ2(S) ∪ · · · ∪ θp−1(S);
31
. . .
θ∗(S) = S + v∗ = { x + k v | x ∈ S ∧ k ∈ N}, where v is the translation vector.
. . .
θ∗(S) = {λk x | x ∈ S ∧ k ∈ N}, where λ is the scaling factor.
32
Projections, rotations, and translations can always be applied to NDDs. Scalings are only allowed if the factor λ is a rational power of the representation base. Theorem: The iteration of a linear transformation x := A x + b preserves the representability of sets in a base r > 1 iff there exist m ∈ N and p ∈ N0 such that
Notes:
computing the representation of θ∗(S) given S.
33
Example
x2
x1
Not iterable.
x2
−x1
· · · Iterable!
34
Application: The Lift Controller The system is composed of
The number of floors N can be
O(N2)),
all the values of N greater than 1).
35
Lift Controller: Simple-PROMELA Model
int c = 1, g = 1, a = 0, N = 10; process motor { do :: go_up: atomic { a == 1 -> up: a = 0; c = c + 1 } :: go_down: atomic { a == 2 -> down: a = 0; c = c - 1 }
} process control { do :: too_low: atomic { c < g -> a = 1 } ; raise: a == 0 :: too_high: atomic { c > g -> a = 2 } ; lower: a == 0 :: atomic { c == g -> do :: low: g < N -> incr: g = g + 1 :: high: g > 1 -> decr: g = g - 1 :: break
:: assert c >= 1 :: assert c <= N
meta (low), incr, low; meta (high), decr, high } meta (control.too_low, motor.go_up), control.raise, motor.up, motor.go_up, control.too_low; meta (control.too_high, motor.go_down), control.lower, motor.down, motor.go_down, control.too_high; 36
Lift Controller: Runtime Statistics
N Rel. Reach. ttot (s)
2 1751 123 8.51 344124 3 1751 175 9.25 397672 4 1751 337 14.17 730296 5 1751 349 13.28 707100 6 1751 402 17.53 888602 7 1751 355 14.36 746420 8 1751 601 23.69 1231180 9 1751 609 20.75 1138864 10 1751 664 26.82 1323048 100 1751 1306 69.78 2579876 1000 1751 1913 140.02 3701240 10000 1751 2684 220.02 5072576 100000 1751 3329 325.06 6283068 1000000 1751 3938 462.04 7399076 ∞ 849 181 9.91 578332 any 2295 231 57.83 2403828
37
Lift Controller: Sample LASH run (N = 1000000000)
Compilation statistics: number of gates : 0. number of processes : 3. number of variables : 4. total number of control locations : 11. number of synchronized transitions : 0. number of meta-transitions : 4. Translating the transition relation... with transitions : 1647 NDD state(s). with synchronised transitions : 1647 NDD state(s). with transitions & meta-transitions : 4017 NDD state(s). Translating the set of initial states... initial set : 218 NDD state(s). Starting state-space exploration...
Fixpoint reached in 11 step(s). *** Program validated. Runtime statistics: residual memory : 0 byte(s). max memory : 4344928 byte(s). 38
39
Framework We consider linear hybrid automata:
– a rectangular activity R(v) : l ≤ ˙
u. – an invariant I(v) : P x ≤ q.
– a guard G(e) : P ′ x ≤ q ′. – an assignment A(e) : x := A′ x + b.
40
Linear Hybrid Automata: Semantics A configuration (v′, x′) can be reached from a configuration (v, x) by
∃e : e = (v, v′), x ∈ G(e), ( x, x′) ∈ A(e), and x′ ∈ I(v′).
v = v′, ∃t ≥ 0 : x + t l ≤ x′ ≤ x + t u, and x′ ∈ I(v), where ( l, u) = R(v).
41
Linear Hybrid Automata: Example “Leaking Gas Burner” model:
˙ x = 1 ˙ y = 1 ˙ z = 1 x ≤ 1 x ≤ 1 − → x := 0 x ≥ 30 − → x := 0 ∧ z = 0 x = 0 ∧ y = 0 L ¬L ˙ x = 1 ˙ y = 1 ˙ z = 0
42
Problem: The symbolic representation system for data values must be expressive enough for some “interesting” linear hybrid automata. Examples:
1 x y 1 2 3 4
20 40 60 80 100 120 y 1 2 3 4 z
43
Real Vector Automata
and a separator ⋆. Example: Enc2(3.5) = 0+11 ⋆ 1(0)ω ∪ 0+11 ⋆ 0(1)ω.
{0, 1, . . . , r − 1}n ∪ {⋆}, or {0, 1, . . . , r − 1, ⋆}.
uchi automaton accepting all the base-r encodings of all the vectors in S.
44
Real Vector Automata: Properties
R, Z, +, ≤, Xr, where Xr is a base-dependent predicate.
deterministic RVA. Manipulation algorithms (∩, ∪, ×, ⊆?, ∃, . . . ) are then simple and efficient. Example:
1 1
x2 x1
45
.
6 (1,0) 10 (0,1) 13 (0,0) 1 (1,1) 7
*
(1,0) (0,1) (0,0) (1,1) 11
*
(1,0) (0,1) (0,0) (1,1) 14
*
(1,0) (0,1) (0,0) (1,1) (1,0) (0,1) (0,0) (1,1) 2
*
3 (1,1) 4 (1,0) 5 (0,0) (1,1) (1,0) (0,0) 8 (1,0) (1,1) 9 (0,1) (1,0) (1,1) (0,1) (0,1) 12 (0,0) (1,0) (0,0) (1,0) (1,0) (0,0) (1,1) 15 (0,1) (0,0) (0,1) (1,0) (1,1)
.
46
Linear Hybrid Transformations Goal: Characterize the transformations θ that label the paths of linear hybrid automata. Starting point: Time step at a location v, followed by a transition step from v to v′ along e. θ(S) = { x′ ∈ Rn | (∃ x ∈ S)(∃ x′′ ∈ Rn)(∃t ∈ R≥0)( x + t l ≤ x′′ ≤ x + t u ∧ x′′ ∈ I(v) ∧ x′′ ∈ G(e) ∧ ( x′′, x′) ∈ A(e) ∧ x′ ∈ I(v′))}, where ( l, u) ∈ R(v). Note that I(v), G(e), A(e) and I(v′) are systems of linear equalities and inequalities. One can thus eliminate the quantifiers over x′′ and t.
47
Definition: A Linear Hybrid Transformation (LHT) (P, q) is a transformation of the form θ : 2Rn → 2Rn : S →
x ∈ S)
q
with n > 0, P ∈ Zm×2n, q ∈ Zm and m ≥ 0. Property: LHT are closed under composition. They can therefore describe the transformations labeling arbitrary control paths of linear hybrid automata.
48
Iterating Linear Hybrid Transformations Goal: Develop a sufficient condition for checking whether a LHT θ is such that θ∗(S) is definable in R, Z, +, ≤ for all S definable in that theory. First restriction: The k-th image θk( x0) of a vector x0 should be definable in R, Z, +, ≤ as a function of x0 and k. It is known that the subsets of R that are definable in R, Z, +, ≤ are ultimately periodic. Second restriction: For every x0 ∈ Rn, the sequence of polyhedra { x0}, θ({ x0}), θ2({ x0}), . . . must satisfy some periodicity requirements.
49
Periodic Transformations Consider the LHT θ:
q
x → x′ : p ′′. x′ = q − p ′. x is periodic iff for every d ∈ R, the image of the plane { x′ ∈ Rn | p ′′. x′ = d} is the plane { x′ ∈ Rn | p ′′. x′ = d + δ}, where δ is independent from d.
x → x′ : p ′′. x′ ≤ q − p ′. x is periodic iff the transformation x → x′ : p ′′. x′ = q − p ′. x is periodic.
q) is periodic iff each row p ′′. x′ ≤ q − p ′. x of its linear system induces a periodic transformation.
50
Illustration: θ({ x0}) θ2({ x0}) θ3({ x0}) θ4({ x0})
51
A Periodicity Criterion Theorem: Let θ be the transformation x → x′ : p ′′. x′ = q − p ′.
transformation is periodic iff either p ′ = 0, p ′′ = 0, or p ′ = − p ′′. Proof sketch: Assume p ′′ =
{ x′ ∈ Rn | p ′′. x′ = d} is a (n − 1)-plane iff p ′ and p ′′ are colinear, i.e.,
p ′′. Rewriting into the periodicity condition, one gets λ ∈ {0, −1}. Criterion: A LHT (P, q) is periodic iff its underlying linear system is only composed of constraints of the form p. x ≤ q, p. x′ ≤ q, and p.( x′ − x) ≤ q.
52
Image Computation Problem: Given a periodic LHT θ : (P, q), and a set S ⊆ Rn definable in R, Z, +, ≤, compute θk(S) for arbitrary k > 0. Let first consider transformations in which all the constraints are of the form p.( x′ − x) ≤ q. Theorem: Let θ1 be the LHT characterized by the linear system P1( x′ − x) ≤
x′ − x) ≤ k q1, with k > 0, is equal to θk
1.
Proof sketch: For any k > 0 and x ∈ Rn, we have θk
1(
x) = { x + δ1 + δ2 + · · · + δk | (∀i ∈ [1, . . . , k])(P1 δi ≤ q1)}.
53
By convexity, if δ1, δ2, . . . , δk belong to the polyhedron P1 δi ≤ q1, so does
δ1 + δ2 + · · · + δk)/k. Each δi can thus be chosen equal to δ. We hence have θk
1(
x) = { x + δ | P1 δ ≤ k q1}.
θ({ x0}) θ2({ x0}) θ3({ x0}) θ4({ x0})
54
Generalizing to LHT with additional constraints C of the form p. x ≤ q and
x′ ≤ q is easy: Since these constraints are convex, and the trajectory x1, x2, . . . , xk of a vector x0 can always be constrained to follow a straight line, it is sufficient that x1 and xk satisfy C. Theorem: For every S ⊆ Rn and k ≥ 2, θk(S) = θ(θk−2
1
(θ(S) ∩ C) ∩ C). Note that this expression is defined in R, Z, +, ≤.
55
Reduction Step Problem: There exist non-periodic LHT θ such that for any x ∈ Rn, the sequence θ( x), θ2( x), θ3( x), . . . is ultimately periodic. Main reason: The range θ(Rn) may have a dimension smaller than n. In such a case, it it sufficient to study the transformation θ in a restricted subspace.
✁✁ ✁✁ ✁✁ ✁✁ ✂✁✂✁✂ ✂✁✂✁✂ ✂✁✂✁✂ ✂✁✂✁✂ ✄✁✄✁✄ ✄✁✄✁✄ ✄✁✄✁✄ ✄✁✄✁✄ ☎✁☎✁☎ ☎✁☎✁☎ ☎✁☎✁☎ ☎✁☎✁☎ ✆✁✆✁✆ ✆✁✆✁✆ ✆✁✆✁✆ ✆✁✆✁✆ ✝✁✝✁✝ ✝✁✝✁✝ ✝✁✝✁✝ ✝✁✝✁✝ ✞✁✞✁✞✁✞ ✞✁✞✁✞✁✞ ✞✁✞✁✞✁✞ ✞✁✞✁✞✁✞ ✞✁✞✁✞✁✞ ✞✁✞✁✞✁✞ ✞✁✞✁✞✁✞ ✞✁✞✁✞✁✞ ✞✁✞✁✞✁✞ ✟✁✟✁✟✁✟ ✟✁✟✁✟✁✟ ✟✁✟✁✟✁✟ ✟✁✟✁✟✁✟ ✟✁✟✁✟✁✟ ✟✁✟✁✟✁✟ ✟✁✟✁✟✁✟ ✟✁✟✁✟✁✟ ✟✁✟✁✟✁✟ ✠✁✠✁✠ ✠✁✠✁✠ ✠✁✠✁✠ ✠✁✠✁✠ ✡✁✡✁✡ ✡✁✡✁✡ ✡✁✡✁✡ ✡✁✡✁✡θ θ θ θ Rn
This reduction can be performed by a simple variable change operation.
56
57
Principles
T0(A0), (T0)2(A0), (T0)3(A0), . . . , where A0 represents the set of initial configurations. Approach:
union can be captured by a finite-state structure.
58
Key ideas
iterated.
pairs) automata.
successive transducers in a sequence of iterated transducers; identifying the difference between these in the form of an “increment”, and extrapolating the repetition of this increment.
transducer is “exact”.
59
Arithmetic transducers: Example Transducer for (x, x + 1) ∪ (x, x):
1 1,1 0,0 2 1,0 0,0 1,1 0,1 1,0
60
Increments: Example T 2:
3 1 1,0 2 0,0 1,1 0,0 1,1 1,0 0,1 0,0 1,1
T 8:
4 3 1,0 5 0,0 1,1 1 0,0 1,0 1,1 2 0,1 0,0 1,1 6 1,0 0,0 0,1 1,0 1,1 1,1 0,0 0,1 1,0 0,1 0,0 1,1
T 4:
4 2 1,0 3 0,0 1,1 1 0,0 1,0 1,1 0,1 0,0 1,1 1,0 0,1 0,0 1,1
T 16:
5 4 1,0 6 0,0 1,1 1 0,0 1,0 1,1 2 0,1 0,0 1,1 7 1,0 0,0 0,1 1,0 1,1 3 1,1 0,0 0,1 8 1,0 0,0 0,1 1,0 1,1 0,0 1,1 0,1 1,0 0,1 0,0 1,1
61
Sampling
i≥0T si is not necessarily equal to i≥0T i.
since
i≥0T i = i≥0T si 0 .
62
Detecting increments (1) Common parts between T si
0 and T si+1
can be identified by
f between states, based on equality
b , based on isomorphism from the
initial state.
T si
0 :
T si+1 :
Q
si+1 H
Q
si+1 I0
Esi
b
Esi
f
Q
si+1 T
Qsi
b
Qsi
f
63
Detecting increments (2) In a sequence T si
0 , T si+1
, T si+2 , . . . , repeated increments can be detected by following forwards and backwards equivalences.
T si
0 :
Q
si b
T
si+3
:
Q
si+3 H
Q
si+3 I0
T
si+2
:
Q
si+2 H
Q
si+2 I0
T
si+1
:
Q
si+1 H
Q
si+1 I0
E
si+2 b
E
si+1 b
E
si f
Q
si+1 Tf
E
si b
E
si+1 b
E
si+2 f
Q
si+3 I2
E
si+2 f
E
si+1 f
Q
si+2 Tf
E
si+1 f
Q
si+2 I1
E
si+2 f
Q
si+3 Tf
E
si+2 b
Q
si+2 T
Q
si+3 T
Q
si f
Q
si+3 I1
Q
si+1 T
64
Detecting increments (3) In order to capture the increment structure, one needs to compare the transitions between the increments. Two increments Qsi+k
Iα
and Qsi+k
Iβ
are communication equivalent iff, for each matched pair (q, q′) ∈ Qsi+k
Iα
× Qsi+k
Iβ
, and a ∈ Σ × Σ, either
Iα
and δ(q′, a) ∈ Qsi+k
Iβ
, hence leading to corresponding states by the existing isomorphism,
Tf
, or
states of respectively Qsi+k
Iα+γ and Qsi+k Iβ+γ.
65
Extrapolating increments The extrapolation is carried on by adding transitions to the head increment QI0 according to the following rule: For each state q ∈ QI0 and a ∈ Σ × Σ,
q′ (by the increment isomorphism) in each of the increments QIℓ with 0 ≤ ℓ < j.
QH QI0 QI1 QI2 QI3 a a a a . . .
66
Is it a good approximation? After having constructed the extrapolation Te∗, it remains to check whether this transducer corresponds to
i≥0T i or not. This is done by
checking that the extrapolation is safe and precise.
i≥0T i.
i≥0T i.
L(Te∗)◦L(Te∗)⊆L(Te∗).
criterion for doing this.
67
Experiments Relation |T0| |T ∗
0|
Max |T i
0|
(x, x + 1) 3 3 11 (x, x + 7) 7 9 91 (x, x + 73) 14 75 933 (((x, y), (x + 2, y − 1)) ∪ ((x, y), (x − 1, y + 2))) ∩ N2 × N2 19 70 1833 ((x, y), (x + 2, y − 1)) ∪ ((x, y), (x − 1, y + 2)) ∪ ((x, y), (x + 1, y + 1))) ∩ N2 × N2 21 31 635 ((w, x, y, z), (w + 1, x + 2, y + 3, z + 4)) 91 251 2680
68
69
finite-state models with unrealistic restrictions.
– Specific techniques are powerful, but restricted to limited frameworks. – Generic methods are promising, but still costly.
be combined with abstractions, or approximation generators (e.g., widening).
70