27
Difference Bound Matrices Lecture #19 of Advanced Model Checking Joost-Pieter Katoen Lehrstuhl 2: Software Modeling & Veriļ¬cation E-mail: [email protected] July 14, 2014 c JPK

Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

  • Upload
    others

  • View
    9

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

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

Page 2: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

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

Page 3: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

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

Page 4: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

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

Page 5: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

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

Page 6: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

Advanced model checking

Zone successor: example

cĀ© JPK 5

Page 7: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

Advanced model checking

Zone predecessor: example

cĀ© JPK 6

Page 8: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

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

Page 9: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

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

Page 10: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

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

Page 11: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

Advanced model checking

Example of k-normalization

cĀ© JPK 10

Page 12: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

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

Page 13: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

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

Page 14: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

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

Page 15: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

Advanced model checking

Example

all clock constraints in the above DBM are of the form (c,ļæ½)

cĀ© JPK 14

Page 16: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

Advanced model checking

The need for canonicity

cĀ© JPK 15

Page 17: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

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

Page 18: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

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

Page 19: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

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

Page 20: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

Advanced model checking

Example

cĀ© JPK 19

Page 21: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

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

Page 22: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

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

Page 23: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

Advanced model checking

Example

cĀ© JPK 22

Page 24: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

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

Page 25: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

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

Page 26: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

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

Page 27: Difference Bound Matrices - RWTH Aachen Universitymoves.rwth-aachen.de/wp-content/uploads/SS14/amc14/slides/amc14_lec18.pdfDifference Bound Matrices Lecture #19 of Advanced Model Checking

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