• Ingen resultater fundet

Symbolic Model Checking

N/A
N/A
Info
Hent
Protected

Academic year: 2022

Del "Symbolic Model Checking"

Copied!
71
0
0

Indlæser.... (se fuldtekst nu)

Hele teksten

(1)

Binary Decision Diagrams

1

Randal Bryant ’86

Symbolic Model Checking

Ken McMillan ’90

(2)

2

Combinatorial Circuits

(3)

3

Combinatorial Problems

Sudoku Eight Queen

(4)

4

Control Programs

A Train Simulator, visualSTATE (VVS)

1421 machines 11102 transitions 2981 inputs 2667 outputs 3204 local states

Declare state sp.: 10^476

BUGS ?

“Ideal” pr

esent

ation: 1

bit/s tate will c

learly NO

T work!

(5)

5

Reduced Ordered Binary Decision Diagrams [Bryant’86]

• Compact represetation of boolean functions allowing effective manipulation (satifiability, validity,….)

or

• Compact representation of sets over finite

universe allowing effective manipulations.

(6)

6

Binary Decision Diagrams

[Randal Bryant’86]

A sho rt rev iew

(7)

7

If-Then-Else Normal Form

(8)

8

Shannon Expansion

(9)

9

Binary Decision Trees

Variable is set to 0 Variable is set to 1 Each path determines a partial (set of) truth assignments.

Result of the boolean expression under the given assigment

found in value of terminal.

(10)

10

Orderedness & Redundant TESTS

(11)

11

Orderedness & Reducedness

x

y z

x x

x

x<y x<z

(12)

12

ROBDDs formally

(13)

13

Reduced Ordered Binary Decision Diagrams

Iben

Edges to 0 implicit

(14)

14

Ordering DOES matter

(15)

15

Canonicity of ROBDDs

(16)

16

Build

Complexity ??

(17)

17

APPLY operation

(18)

18

APPLY example

(19)

19

APPLY operation

with dynamic programming

(20)

20

Other operations

(21)

21

Constraint Solving

using BDDs

(22)

22

4 x 4 Sudoku

288 solutions !

1

2

3

4

(23)

23

Encoding

1

2

3

4

Boolean variables x

i,j,k

for all i, j, k ∈ {1,2,3,4}.

Idea:

x

i,j,k

= 1 ; if the number k is in

position (i,j) in the solution 0 ; otherwise

1 2 3 4

1 2 3 4

x

2,2,2

=1

x

4,4,4

=1

x

2,2,1

=0

(24)

24

Constraints

Precisely one value in each position i, j:

x

1,j,1

+ x

i,j,2

+ x

i,j,3

+ x

i,j,4

= 1 for each i, j

Each value k appears in each row i exactly ones:

x

i,1,k

+ x

i,2,k

+ x

i,3,k

+ x

i,4,k

= 1 for each i, k

Each value k appears in each colomn j exactly ones:

x

1,j,k

+ x

2,j,k

+ x

3,j,k

+ x

4,j,k

= 1 for each j, k

Each value k appears in each 2x2 box exactly ones:

x

1,1,k

+ x

1,2,k

+ x

2,1,k

+ x

2,2,k

= 1 (e.g.)

1 2

3 4

1 2 3 4

1 2 3 4

(25)

25

Solving Sudoku

1 2 3 4

1 2 3 4

1 2

3 4

1 2 3 4

1 2 3 4

(26)

26

ROBDDs and Verification

[…,McMillan’90,…..,VVS’97]

(27)

27

ROBDD encoding of transition system

00

10

01

11

Trans(x1,x2,y1,y2):=

!x1 & !x2 & !y1 & y2 + !x1 & !x2 & y1 & y2 + x1 & !x2 & !y1 & y2 + x1 & !x2 & y1 & y2 + x1 & x2 & y1 & !y2;

Encoding of states using binary variables (here x1 and x2 ).

Encoding of transition relation using source and target variables

(here x1, x2, y1 , and y2 )

(28)

28

ROBDD representation (cont.)

Trans(x1,x2,y1,y2):=

!x1 & !x2 & !y1 & y2 + !x1 & !x2 & y1 & y2 + x1 & !x2 & !y1 & y2 + x1 & !x2 & y1 & y2 + x1 & x2 & y1 & !y2;

00

10

01

11

(29)

29

ROBDD for parallel composition

00

10

01

11

00

10

01

11

Trans(x,y,u,v) =

(

ATrans(x,y) & v=u

)

+

(

BTrans(u,v) & y=x

)

ATrans(x,y)

BTrans(u,v)

Asynchronous composition

Synchronous composition

Trans(x,y,u,v) =

(

ATrans(x,y) & BTrans(u,v)

)

Which ordering to choose?

(30)

30

Ordering?

23 nodes

x1,x2,y1,y2,u1,u2,v1,v2 45 nodes

x1,x2,u1,u2, y1,y2 ,v1,v2

20 nodes

x1,y1,x2,y2,u1,v1,u2,v2

Polynomial size BDDs guaranteed in size of argument BDDs

[Enders,Filkorn, Taubner’91]

(31)

31

Reach1

Reach1

Reach(x) := Init(x);

REPEAT

Old(x) := Reach(x);

New(y) := Exists x.(Reach(x) & Trans(x,y));

Reach(x) := Old(x) + New(x) UNTIL Old(x) = Reach(x)

Reachable States

00

10

01

11

Reach0 Reach2

Relational Product:

May be constructed without building

intermediate (often large)

&-BDD.

(32)

32

A MUTEX Algorithm

Clarke & Emerson

P1 :: while True do

T1 : wait(turn=1) C1 : turn:=0

endwhile

||

P2 :: while True do

T2 : wait(turn=0) C2 : turn:=1

endwhile

P1 :: while True do

T1 : wait(turn=1) C1 : turn:=0

endwhile

||

P2 :: while True do

T2 : wait(turn=0) C2 : turn:=1

endwhile

Mutual Exclusion Program

(33)

33

Global Transition System

I1 I2 t=0

T1 I2 t=0

T1 T2 t=0

I1 T2 t=0

I1 C2 t=0

T1 C2 t=0

C1 I2

t=1 T1 T2

t=1

C1 T2 t=1

T1 I2 t=1

I1 T2 t=1 I1 I2

t=1

(34)

34

A MUTEX Algorithm

Clarke & Emerson

vars x1 x2;

vars y1 y2;

vars u1 u2;

vars v1 v2;

vars t s;

ATrans := (!x1 & !x2 & !y1 & y2 & (s=t)) + (!x1 & x2 & !y1 & y2 & !t & !s) + (!x1 & x2 & y1 & !y2 & t & s) + (x1 & !x2 & !y1 & !y2 & !s);

BTrans := (!u1 & !u2 & !v1 & v2 & (s=t)) + (!u1 & u2 & !v1 & v2 & t & s) + (!u1 & u2 & v1 & !v2 & !t & !s) + (u1 & !u2 & !v1 & !v2 & s);

TT := (ATrans & (u1=v1) & (u2=v2)) + (BTrans & (x1=y1) & (x2=y2));

00

01

10

(35)

35

BDDs for Transition Relations

ATrans

TT

(36)

36

Reachable States

Reach(x) := Init(x);

REPEAT

Old(x) := Reach(x);

New(y) := Exists x.(Reach(x) & Trans(x,y));

Reach(x) := Old(x) + New(x) UNTIL Old(x) = Reach(x)

(37)

37

Reachable States

Reach(x) := Init(x);

REPEAT

Old(x) := Reach(x);

New(y) := Exists x.(Reach(x) & Trans(x,y));

Reach(x) := Old(x) + New(x) UNTIL Old(x) = Reach(x)

(38)

38

Reachable States

Reach(x) := Init(x);

REPEAT

Old(x) := Reach(x);

New(y) := Exists x.(Reach(x) & Trans(x,y));

Reach(x) := Old(x) + New(x) UNTIL Old(x) = Reach(x)

Reach

Reach &

x1 & !x2 &

u1 & !u2 MUTEX ?

(39)

39

Bisimulation

00

10

01

11

00

10

01

11

Bis(x,u):= 1;

REPEAT

Old(x,u) := Bis(x,u);

Bis(x,u) :=

Forall y. Trans(x,y) =>

(Exists v. Trans(u,v) & Bis(y,v))

&

Forall v. Trans(u,v) =>

(Exists y. Trans(x,y) & Bis(y,v));

UNTIL Bis(x,u)=Old(x,u) vars x (y)

vars u (v)

(40)

40

Bisimulation (cont.)

00

10

01

11

3 equivalence classes

= 6 pairs in final bisimulation

Bis

0

Bis

1

Bis

2

(41)

41

Model Checking

p p

q

p,q

0 1

3

2

vars x1 x2;

vars y1 y2;

Trans(x1,x2,y1,y2) :=

!x1 & !x2 & !y1 & y2 + !x1 & !x2 & y1 & y2 + ………… ;

P(x1,x2) := !x1 & !x2 + !x1 & x2

+ x1 & !x2;

Q(x1,x2) := ……… ;

(42)

42

Model Checking

p p

q

p,q

0 1

3

2

EX P

Exists y1,y2.

Trans(x1,x2,y1,y2) &

P(y1,y2);

(43)

43

Model Checking

p p

q

p,q

0 1

3

2

EX P

Exists y1,y2.

Trans(x1,x2,y1,y2) &

P(y1,y2);

(44)

44

Model Checking

p p

q

p,q

0 1

3

2

AX P

Forall y1,y2.

Trans(x1,x2,y1,y2) =>

P(y1,y2);

(45)

45

Model Checking

p p

q

p,q

0 1

3

2

AX P

Forall y1,y2.

Trans(x1,x2,y1,y2) =>

P(y1,y2);

(46)

46

Model Checking

p p

q

p,q

0 1

3

2

AG P

A(x1,x2) = P(x1,x2) &

Forall y1,y2.

Trans(x1,x2,y1,y2) =>

A(y1,y2);

max fixpoint

(47)

47

Model Checking

p p

q

p,q

0 1

3

2

AG P

A(x1,x2) = P(X1,x2) &

Forall y1,y2.

Trans(x1,x2,y1,y2) =>

A(y1,y2);

max fixpoint

(48)

48

Model Checking

p p

q

p,q

0 1

3

2

A( P UNTIL Q )

U(x1,x2) = Q(x1,x2) + { P(x1,x2) &

Forall y1,y2.

Trans(x1,x2,y1,y2) =>

U(y1,y2) };

min fixpoint

(49)

49

Model Checking

p p

q

p,q

0 1

3

2

A( P UNTIL Q )

U(x1,x2) = Q(X1,x2) + { P(x1,x2) &

Forall y1,y2.

Trans(x1,x2,y1,y2) =>

U(y1,y2) };

min fixpoint

(50)

50

Partitioned Transition Relation

T(xu,yv) =

(

ATrans(x,y) & v=u

)

+

(

BTrans(u,v) & y=x

)

T(xu,yv) =

ATrans(x,y)

& BTrans(u,v)

Exists yv. (T(xu,yv) & S(yv)) Relational Product

Asynchronous Synchronous

Exists y. ATrans(x,y) & S(yu) +

Exists v. BTrans(u,v) & S(xv)

LARGE

Exists yv.

Atrans(x,y)

& Btrans(u,v) & S(yv) Exists y.

Atrans(x,y)

& (Exists v. Btrans(u,v) & S(yv))

(51)

51

visualSTATE

CIT project VVS (w DTU)

Beologic’s Products: salesPLUSsalesPLUS visualSTATEvisualSTATE

1980-95: Independent division of B&0 1995- : Independent company

B&O, 2M Invest,

Danish Municipal Pension Ins. Fund 1998: BAAN

2000: IAR Systems A/S Customers:

ABB B&O

Daimler-Benz Ericson DIAX ESA/ESTEC FORD

Grundfos LEGO PBS

Siemens ……. (approx. 200)

Verification Problems:

• 1.400 components

• 10400 states

Our techniques has reduced

verification by an order of magnitude (from 14 days to 6 sec)

•Embedded Systems

•Simple Model

•Verification of Std. Checks

•Explicit Representation (STATEEXPLOSION)

•Code Generation

(52)

52

visualSTATE

Embedded World

Nürnberg, 2005

(53)

53

Control Programs

A Train Simulator, visualSTATE (VVS)

1421 machines 11102 transitions 2981 inputs 2667 outputs 3204 local states

Declare state sp.: 10^476

BUGS ?

“Ideal” pr

esent

ation: 1

bit/s tate will c

learly NO

T work!

(54)

54

Experimental Breakthroughs

Patented

State Space St-of-Art ComBack

System Mach.

Declared Reach

Checks Visual

ST Sec MB Sec MB

VCR 7 10^5 1279 50 <1 <1 6 <1 7

JVC 8 10^4 352 22 <1 <1 6 <1 6

HI-FI 9 10^7 1416384 120 1200 1.0 6 3.9 6

Motor 12 10^7 34560 123 32 <1 6 2,0

AVS 12 10^7 1438416 173 3780 6.7 6 5.7 6

Video 13 10^8 1219440 122 --- 1.1 6 1.5 6

Car 20 10^11 9.2 10^9 83 --- 3.8 9 1.8 6

N6 14 10^10 6399552 443 --- 32.3 7 218 6

N5 25 10^12 5.0 10^10 269 --- 56.2 7 9.1 6

N4 23 10^13 3.7 10^8 132 --- 622 7 6.3 6

Train1 373 10^136 --- 1335 --- --- --- 25.9 6

Train2 1421 10^476 --- 4708 --- --- --- 739 11

Machine: 166 MHz Pentium PC with 32 MB RAM

---: Out of memory, or did not terminate after 3 hours.

(55)

55

Experimental Breakthroughs

Patented

State Space St-of-Art ComBack

System Mach.

Declared Reach

Checks Visual

ST Sec MB Sec MB

VCR 7 10^5 1279 50 <1 <1 6 <1 7

JVC 8 10^4 352 22 <1 <1 6 <1 6

HI-FI 9 10^7 1416384 120 1200 1.0 6 3.9 6

Motor 12 10^7 34560 123 32 <1 6 2,0

AVS 12 10^7 1438416 173 3780 6.7 6 5.7 6

Video 13 10^8 1219440 122 --- 1.1 6 1.5 6

Car 20 10^11 9.2 10^9 83 --- 3.8 9 1.8 6

N6 14 10^10 6399552 443 --- 32.3 7 218 6

N5 25 10^12 5.0 10^10 269 --- 56.2 7 9.1 6

N4 23 10^13 3.7 10^8 132 --- 622 7 6.3 6

Train1 373 10^136 --- 1335 --- --- --- 25.9 6

Train2 1421 10^476 --- 4708 --- --- --- 739 11

Machine: 166 MHz Pentium PC with 32 MB RAM

---: Out of memory, or did not terminate after 3 hours.

Ou r te ch niq ue ha ve re du ce d v eri fica tio n tim e b y s ev era l o rde rs of ma gn itu de

(eg . F rom 14 da ys to 6 s ec )

(56)

56

Compositional Backwards Reachability

[ TACAS’98 ]

(57)

57

Example

The Small Train

Train Gate Signal

l t

r

STOP

BW FW

t l,t r

r

DOWN DOWN t

l

UP

DOWN

GR

RED d

RED u g re

(58)

58

State-Event Model

visualSTATE

n synchronously combined machines

Mi = (Si,si0,Ti) where

TiSi× E × Gi× M(O)× Si

Input Events

Guards on other machines

locations Syntax

Semantics

(s1,…,sn) e , ∪ oiÆ (s1’,…,sn’) iff

si - e,gi,oi Æ si with

gi(s1,…,sn)=true or

si= si and oi=Ø and whenever si - e, gi Æ

then gi(s1,…,sn)=false Output

i=1..n

(59)

59

Small Train (cont)

Train Gate

Signal

DOWN

UP

STOP

BW

FW GR

RED

STOP

BW FW

t

l,t r

t

r

l

DOWN DOWN

UP

DOW N

GR

RED d

RED

u g re

(60)

60

Small Train (cont)

Train Gate

Signal

DOWN

UP

STOP

BW

FW GR

RED re d

l

r

STOP

BW FW

t

l,t r

t

r

l

DOWN DOWN

UP

DOW N

GR

RED d

RED

u g re

(61)

61

Generic Checks

visualSTATE offers checks for a number of predefined properties:

• Reachability of states

• Firing of transitions

• Input without interpretation

• Output without generation

• Conflicting Rules

• Local Deadlock

• Global Deadlock

Not a single CHECK but several thousands!

Reachability

(62)

62

Guard dependencies

Let

g

1

, g

2

, g

3

, …, g

N

(N big)

be the guards we want to show reachable If

g

i

⇒ g

j

(e.g. g

i

=DOWN ∧ UP, g

j

=DOWN) then it suffices to show that g

i

reachable, i.e. there is a

reachable global state satisfying g

i

.

Sort g

1

, g

2

, g

3

, …, g

N

according to size and check only if NOT implied by a previously shown reachable guard Î

40-70-90 % reduction.

(63)

63

Machine Dependencies

STOP

BW FW

t

l,t r

t

r

l

DOWN DOWN

UP

DOWN

GR

RED d

RED

u g re

A guard g in machie M

i

that depends on/refers to a state in M

j

introduces a dependency from M

i

to M

j

TRAIN GATE SIGNAL

Backwards statespace iterations can be restricted to

dependency closed sets, e.g. DC(GATE) = {GATE,SIGNAL}

(64)

64

Compositional Backwards

STOP

BW FW

t

l,t r

t

r

l

DOWN DOWN

UP

DOW N

GR

RED d

RED

u g re

Is FW reachable ?

IDEA:

Compute backward reachable states as much as possible with minimal set of machines.

Increase set of considered machines when necessary!

Consider TRAIN

FW BW

STOP

TRAIN

(65)

65

Compositional Backwards

STOP

BW FW

t

l,t r

t

r

l

DOWN DOWN

UP

DOW N

GR

RED d

RED

u g re

Is FW reachable ?

IDEA:

Compute backward reachable states as much as possible with minimal set of machines.

Increase set of considered machines when necessary!

Consider TRAIN

FW BW

STOP

TRAIN

DO

WN DO

WN

Ignoring INPUT event

(66)

66

Compositional Backwards

STOP

BW FW

t

l,t r

t

r

l

DOWN DOWN

UP

DOW N

GR

RED d

RED

u g re

Is FW reachable ?

IDEA:

Compute backward reachable states as much as possible with minimal set of machines.

Increase set of considered machines when necessary!

Consider TRAIN

FW BW

STOP

TRAIN

DO

WN DO

WN

Ignoring INPUT event

(67)

67

Compositional Backwards

STOP

BW FW

t

l,t r

t

r

l

DOWN DOWN

UP

DOW N

GR

RED d

RED

u g re

Include GATE !

FW BW

TRAIN

RED

Ignoring

transtions with source in

(68)

68

Compositional Backwards

STOP

BW FW

t

l,t r

t

r

l

DOWN DOWN

UP

DOW N

GR

RED d

RED

u g re

Include GATE !

FW BW

TRAIN

RED

Ignoring

transtions with source in

Any state projecting to

can reach a state projecting to

(69)

69

Compositional Backwards

STOP

BW FW

t

l,t r

t

r

l

DOWN DOWN

UP

DOW N

GR

RED d

RED

u g re

Include SIGNAL !

Train Gate

Signal

DOWN

UP

STOP

BW

FW GR

RED

Thus FW is

reachable !

(70)

70

Hierarchical Systems

IDEA

Reuse already known reachability

properties of superstates to conclude

reachability of substates !

[ TACAS’99 ]

(71)

71

Experimental results

Referencer

RELATEREDE DOKUMENTER

Concrete Composite Types From these one can form type expressions: finite sets, infinite sets, Cartesian products, lists, maps, etc. Let A, B and C be any type names or

(Note that for limit sets of geometrically finite Kleinian groups with parabolic elements the weak singu- larity spectra of the Patterson measure was derived in [22] (see also

Lecture: Symbolic methods for finite-state model checking 2.+3. Exercise class: Circuit

Second, we consider continuous-time Markov chains (CTMCs), frequently used in performance analysis, which model continuous real time and probabilistic choice: one can specify the

Def.: The decision diagrams obtained by above rules are called reduced ordered binary decision diagrams (ROBDDs).. May expect good performance if many substructures

an alternative path of no greater weight THUS Remove all redundant edges.. An edge is REDUNDANT if there exists an alternative path of no

In order to integrate the approach just described with the lazy intruder, there is, however, one subtlety that we must address: we have assumed that all constraint sets are well

• linear in the size of the formula, given a fixed Kripke structure,. • linear in the size of the Kripke structure, given a