Upload
others
View
9
Download
0
Embed Size (px)
Citation preview
Difference Bound MatricesLecture #19 of Advanced Model Checking
Joost-Pieter Katoen
Lehrstuhl 2: Software Modeling & Verification
E-mail: [email protected]
July 14, 2014
cĀ© JPK
Advanced model checking
Symbolic reachability analysis
ā¢ Use a symbolic representation of timed automata configurations
ā needed as there are infinitely many configurationsā example: state regions ćļæ½, [Ī·]ć
ā¢ For set z of clock valuations and edge e = ļæ½g:Ī±,DāŖā ļæ½ā² let:
Poste(z) = { Ī·ā² ā Rnļæ½0 | āĪ· ā z, d ā Rļæ½0. Ī·+d |= g ā§ Ī·ā² = reset D in (Ī·+d) }
Pree(z) = { Ī· ā Rnļæ½0 | āĪ·ā² ā z, d ā Rļæ½0. Ī·+d |= g ā§ Ī·ā² = reset D in (Ī·+d) }
ā¢ Intuition:
ā Ī·ā² ā Poste(z) if for some Ī· ā z and delay d, (ļæ½, Ī·)dā . . . eāā (ļæ½ā², Ī·ā²)
ā Ī· ā Pree(z) if for some Ī·ā² ā z and delay d, (ļæ½, Ī·)dā . . . eāā (ļæ½ā², Ī·ā²)
cĀ© JPK 1
Advanced model checking
Zones
ā¢ Clock constraints are conjunctions of constraints of the form:
ā x āŗ c and xāy āŗ c for āŗ ā {<,ļæ½,=,ļæ½, > }, and c ā Z
ā¢ A zone is a set of clock valuations satisfying a clock constraint
ā a clock zone for g is the maximal set of clock valuations satisfying g
ā¢ Clock zone of g: [[ g ]] = { Ī· ā Eval(C) | Ī· |= g }
ā¢ The state zone of s = ćļæ½, Ī·ć is ćļæ½, zć with Ī· ā z
ā¢ For zone z and edge e, Poste(z) and Pree(z) are zones
state zones will be used as symbolic representations for configurations
cĀ© JPK 2
Advanced model checking
Operations on zonesā¢ Future of z:
ā āāz = { Ī·+d | Ī· ā z ā§ d ā Rļæ½0 }
ā¢ Past of z:
ā āāz = { Ī·ād | Ī· ā z ā§ d ā Rļæ½0 }
ā¢ Intersection of two zones:
ā z ā© zā² = { Ī· | Ī· ā z ā§ Ī· ā zā² }
ā¢ Clock reset in a zone:
ā reset D in z = { reset D in Ī· | Ī· ā z }
ā¢ Inverse clock reset of a zone:
ā resetā1 D in z = { Ī· | reset D in Ī· ā z }
cĀ© JPK 3
Advanced model checking
Symbolic successors and predecessors
Recall that for edge e = ļæ½g:Ī±,DāŖā ļæ½ā² we have:
Poste(z) = { Ī·ā² ā Rnļæ½0 | āĪ· ā z, d ā Rļæ½0. Ī·+d |= g ā§ Ī·ā² = reset D in (Ī·+d) }
Pree(z) = { Ī· ā Rnļæ½0 | āĪ·ā² ā z, d ā Rļæ½0. Ī·+d |= g ā§ Ī·ā² = reset D in (Ī·+d) }
This can also be expressed symbolically using operations on zones:
Poste(z) = reset D in (āāz ā© [[ g ]])
and
Pree(z) =āāāāāāāāāāāāāāāāāāāāāāāāāāāresetā1 D in (z ā© [[D = 0 ]]) ā© [[ g ]]
cĀ© JPK 4
Advanced model checking
Zone successor: example
cĀ© JPK 5
Advanced model checking
Zone predecessor: example
cĀ© JPK 6
Advanced model checking
Abstract forward reachabilityLet Ī³ associate sets of valuations to sets of valuations
Abstract forward symbolic transition system of TA is defined by:
(ļæ½, z)ā (ļæ½ā², zā²) z = Ī³(z)
(ļæ½, z)ā Ī³ (ļæ½ā², Ī³(zā²))
Iterative forward reachability analysis computation schemata:
T0 = { (ļæ½0, Ī³(z0)) | āx ā C. z0(x) = 0 }T1 = T0 āŖ { (ļæ½ā², zā²) | ā(ļæ½, z) ā T0 such that (ļæ½, z)ā Ī³ (ļæ½ā², zā²) }. . . . . .
Tk+1 = Tk āŖ { (ļæ½ā², zā²) | ā(ļæ½, z) ā Tk such that (ļæ½, z)ā Ī³ (ļæ½ā², zā²) }. . . . . .
with inclusion check and termination criteria as before
cĀ© JPK 7
Advanced model checking
Criteria on the abstraction operator
ā¢ Finiteness: { Ī³(z) | Ī³ defined on z } is finite
ā¢ Correctness: Ī³ is sound wrt. reachability
ā¢ Completeness: Ī³ is complete wrt. reachability
ā¢ Effectiveness: Ī³ is defined on zones, and Ī³(z) is a zone
cĀ© JPK 8
Advanced model checking
k-Normalization [Daws & Yovine, 1998]
Let k ā N.
ā¢ A k-bounded zone is described by a k-bounded clock constraint
ā e.g., zone z = (x ļæ½ 3)ā§ (y ļæ½ 5)ā§ (xā y ļæ½ 4) is not 2-boundedā but zone zā² = (x ļæ½ 2)ā§ (y ā x ļæ½ 2) is 2-boundedā note that: z ā zā²
ā¢ Let normk(z) be the smallest k-bounded zone containing zone z
cĀ© JPK 9
Advanced model checking
Example of k-normalization
cĀ© JPK 10
Advanced model checking
Facts about k-normalization [Bouyer, 2003]
ā¢ Finiteness: normk(Ā·) is a finite abstraction operator
ā¢ Correctness: normk(Ā·) is sound wrt. reachability
provided k is the maximal constant appearing in the constraints of TA
ā¢ Completeness: normk(Ā·) is complete wrt. reachability
since z ā normk(z), so normk(Ā·) is an over-approximation
ā¢ Effectiveness: normk(z) is a zone
this will be made clear in the sequel when considering zone representations
cĀ© JPK 11
Advanced model checking
Representing zones
ā¢ Let 0 be a clock with constant value 0; let C0 = C āŖ {0 }
ā¢ Any zone z over C can be written as:
ā conjunction of constraints xā y < n or xā y ļæ½ n for n ā Z, x, y ā C0
ā when xā y ļæ½ n and xā y ļæ½ m take only xā y ļæ½ min(n,m)
ā this yields at most |C0|Ā·|C0| constraints
ā¢ Example:
xā 0 < 20 ā§ y ā 0 ļæ½ 20 ā§ y ā x ļæ½ 10 ā§ xā y ļæ½ ā10
ā¢ Store each such constraint in a matrix
ā this yields a difference bound matrix [Berthomieu & Menasche, 1983]
cĀ© JPK 12
Advanced model checking
Difference bound matrices
ā¢ Zone z over C is represented by DBM Z of cardinality |C+1|Ā·|C+1|ā for C = { x1, . . . , xn }, let C0 = { x0 } āŖ C with x0 = 0, and:
Z(i, j) = (c,āŗ) if and only if xi ā xj āŗ c
ā so, rows are used for lower, and columns for upper bounds on clock differences
ā¢ Definition of DBM Z for zone z:
ā Z(i, j) := (c,āŗ) for each bound xi ā xj āŗ c in z
ā Z(i, j) :=ā (= no bound) if clock difference xi ā xj is unbounded in z
ā Z(0, i) := (0,ļæ½), i.e., 0ā xi ļæ½ 0, or: all clocks are non-negativeā Z(i, i) := (0,ļæ½), i.e., each clock is at most itself
cĀ© JPK 13
Advanced model checking
Example
all clock constraints in the above DBM are of the form (c,ļæ½)
cĀ© JPK 14
Advanced model checking
The need for canonicity
cĀ© JPK 15
Advanced model checking
Canonical DBMs
ā¢ A zone z is in canonical form if and only if:
ā no constraint in z can be strengthened without reducing [[ z ]] = { Ī· | Ī· ā z }
ā¢ For each zone z:
ā there exists a zone z ā² such that [[ z ]] = [[ zā² ]], and zā² is in canonical formā moreover, zā² is unique
how to obtain the canonical form of a zone?
cĀ© JPK 16
Advanced model checking
Turning a DBM into canonical form
ā¢ Represent zone z by a weighted digraph Gz = (V,E,w) where
ā V = C0 is the set of verticesā (xi, xj) ā E whenever xj ā xi ļæ½ c is a constraint in z
ā w(xi, xj) = (c,ļæ½) whenever xj ā xi ļæ½ c is a constraint in z
ā¢ DBMs are thus (transposed) adjacency matrices of the weighteddigraph
ā¢ Observe: deriving bounds = adding weights along paths
ā¢ Zone z is in canonical form if and only if DBM Z satisfies:
ā Z(i, j) ļæ½ Z(i, k) + Z(k, j) for any xi, xj, xk ā C0
cĀ© JPK 17
Advanced model checking
Operations on DBM entries
Let ā {<,ļæ½ }.
ā¢ Comparison of DBM entries:
ā (c,ļæ½) <āā (c,ļæ½) < (cā²,ļæ½ā²) if c < cā²
ā (c,<) < (c,ļæ½) but (c,ļæ½) ļæ½< (c,<)
ā¢ Addition of DBM entries:
ā c +ā =āā (c,ļæ½) + (cā²,ļæ½) = (c+cā²,ļæ½)
ā (c,<) + (cā²,ļæ½) = (c+cā², <)
cĀ© JPK 18
Advanced model checking
Example
cĀ© JPK 19
Advanced model checking
Computing canonical DBMs
Deriving the tightest constraint on a pair of clocks in a zone
is equivalent to finding the shortest path between their vertices
ā¢ apply Floyd-Warshallās all-pairs shortest-path algorithm
ā¢ its worst-case time complexity lies in O(|C0|3)
ā¢ efficiency improvement:
ā let all frequently used operations preserve canonicity
cĀ© JPK 20
Advanced model checking
Minimal constraint systems
ā¢ A (canonical) zone may contain many redundant constraints
ā e.g., in xāy < 2, yāz < 5, and xāz < 7, constraint xāz < 7 is redundant
ā¢ Reduce memory usageā consider minimal constraint systems
ā e.g., xāy ļæ½ 0, y ā z ļæ½ 0, z ā x ļæ½ 0, xā0 ļæ½ 3, and 0āx < ā2is a minimal representation of a zone in canonical form with 12 constraints
ā¢ For each zone: ā a unique and equivalent minimal constraint system
ā¢ Determining minimal representations of canonical zones:
ā xi(n,ļæ½)āāāāāxj is redundant if a path from xi to xj has weight at most (n,ļæ½)
ā fact: it suffices to consider alternative paths of length two only
complexity in O(|C0|3); zero cycles require a special treatment
cĀ© JPK 21
Advanced model checking
Example
cĀ© JPK 22
Advanced model checking
DBM operations: checking properties
ā¢ Nonemptiness: is [[Z ]] = ā ?
ā Z = ā if xi ā xj ļæ½ c and xj ā xi ļæ½ā² cā² and (c,ļæ½) < (cā²,ļæ½ā²)ā search for negative cycles in the graph representation of Z, orā mark Z when upper bound is set to value < its corresponding lower bound
ā¢ Inclusion test: is [[Z ]] ā [[Zā² ]]?
ā for DBMs in canonical form, test whether Z(i, j) ļæ½ Zā²(i, j), for all i, j ā C0
ā¢ Satisfaction: does Z |= g?
ā check whether [[Zā§ g ]] = [[Z ]] ā© [[ g ]] = ā
cĀ© JPK 23
Advanced model checking
DBM operations: delays
ā¢ Future: determineāāZ
ā remove the upper bounds on any clock, i.e.,
āāZ (i, 0) =ā and
āāZ (i, j) = Z(i, j) for j ļæ½= 0
ā Z is canonical impliesāāZ is canonical
ā¢ Past: determineāāZ
ā set the lower bounds on all individual clocks to (0,ļæ½)āāZ (0, i) = (0,ļæ½) and
āāZ (i, j) = Z(i, j) for j ļæ½= 0
ā Z is canonical does not implyāāZ is canonical
cĀ© JPK 24
Advanced model checking
Final DBM operations
ā¢ Conjunction: [[Z ]]ā§ (xi ā xj n)
ā if (n,ļæ½) < Z(i, j) then Z(i, j) := (n,ļæ½) else do nothingā put Z into canonical form (in timeO(|C0|2) using that only Z(i, j) changed)
ā¢ Clock reset: xi := d in Z
ā Z(i, j) := (d,ļæ½) + Z(0, j) and Z(j, i) := Z(j, 0) + (ād,ļæ½)
ā¢ k-Normalization: normk(Z)
ā remove all bounds xāy ļæ½ m for which (m,ļæ½) > (k,ļæ½), andā set all bounds xāy ļæ½ m with (m,ļæ½) < (āk,<) to (āk,<)
ā put the DBM back into canonical form (Floyd-Warshall)
cĀ© JPK 25
Advanced model checking
k-Normalization of DBMs
remove all upper bounds higher than k and lower all lower bounds exceeding āk to āk
cĀ© JPK 26