260 likes | 376 Views
Hardware and Petri nets. Symbolic methods for analysis and verification. Outline. Representing Boolean functions with BDDs Symbolic traversal for reachability set calculation State encoding Structural methods for efficient encoding. 1. 0. 0. 1. 1. 0. 0. 1.
E N D
Hardwareand Petri nets Symbolic methods foranalysis and verification
Outline • Representing Boolean functions with BDDs • Symbolic traversal for reachability set calculation • State encoding • Structural methods for efficient encoding
1 0 0 1 1 0 0 1 Representing Boolean functions a 1 0 b b 1 0 1 0 c c c c 1 0 1 0 1 0 1 0
0 1 1 0 Representing Boolean functions a 1 0 b b 0 1 1 0 c c 1 0 1 0
0 1 1 0 Representing Boolean functions a 1 0 b 0 1 c c 1 0 1 0
0 1 Representing Boolean functions a 1 0 b 1 0 c c 0 0 1 1
1 0 Binary Decision Diagrams • All variables appear in the same order • No isomorphic subgraphs • Canonical form • Efficient form for many functions • [Bryant,ACM Comp. Surveys,September 1992] a 1 0 b 1 0 c c 0 0 1 1 Reduced Ordered Binary Decision Diagram
p1 t2 t1 p2 p3 p4 p5 t3 t4 t7 t5 t6 p2 p7 p6 p3 p6 p5 p4 p7 t6 t4 t3 t5 p6 p7 Reachable markings p1 t1 t2 p4 p5 p2 p3 t6 t4 t5 t3 p7 p6 t7
1000000 t2 t1 0110000 0001100 t3 t4 t7 t5 t6 0010010 0000110 0001001 0100001 t6 t4 t3 t5 Seven variables: p1 p2 p3 p4 p5 p6 p7 0000011 Boolean encoding p1 t1 t2 p4 p5 p2 p3 t3 t6 t4 t5 p7 p6 t7
1000000 p1 p2 p3 (p4 p6) (p5 p7) t2 t1 Enabled(t7) = p6 p7 0110000 0001100 t3 t4 t7 t5 t6 p1 p2 p3 p4 p5 p6 p7 0010010 0000110 0001001 0100001 (toggle p1, p6 , p7) t6 t4 t3 t5 Seven variables: p1 p2 p3 p4 p5 p6 p7 0000011 p1 p2 p3 p4 p5 p6 p7 Boolean encoding
Symbolic Traversal (BFS algorithm) Reached = From = {m0 }; repeat From [ T To; New = To \ Reached; From = New; Reached = Reached New; untilNew = Ø; # iterations: sequential depth of the net
New markings #iteration Reachability Set computation • Based on BFS Image computation S0 = M0 Si+1 = Si Image (Si) S3 S2 S1 S0 Monotonic increase until fix point Si+1 = Si
Sparse encoding: 1000000 000 Seven variables: p1 p2 p3 p4 p5 p6 p7 0110000 0001100 001 100 Optimal encoding: 011 110 010 101 0010010 0000110 0001001 0100001 Three variables log2 |RG|: v1 v2 v3 111 0000011 Boolean encoding t2 t1 Very easy to derive and use Less efficient in terms of BDDs t3 t4 t7 t5 t6 t6 t4 t3 t5 But the reachability graphshould be known a priori ...
p1 p2 p3 p4 p3 p4 p1 p2 Ø Encoding for safe PNs Observation: • Not all combinations of tokens are possible. • Find relations among places to reduce the number of variables!!!
Encoding for safe PNs PN structure: Place Invariant • Set of places with a constant weighted sum of tokens k1p1+ k2p2+…..+ knpn = B • Specially efficient for safe PNs (State Machines) p1+ p2+…..+ pn = 1 • Computed by linear programming techniques
p1 p1 p1 p1 p1 t1 t1 t1 t2 t2 t2 t1 t2 t1 t2 p4 p4 p4 p4 p5 p5 p5 p2 p2 p2 p3 p3 p3 p2 p5 p3 t3 t3 t3 t6 t6 t6 t3 t4 t4 t4 t5 t5 t5 t5 t6 t4 p7 p7 p7 p6 p6 p6 p6 p7 t7 t7 t7 t7 t7 State Machine Components
00 00 p1 p1 t1 t2 t1 t2 10 01 10 01 p4 p2 p5 p3 t3 t5 t6 t4 11 11 p6 p7 t7 t7 Encoding for safe PNs Two additional variables: v3 v4 Two variables: v1 v2
0000 p1 0000 t2 t1 t1 t2 10 - - - - 10 1010 0101 p4 p5 p2 p3 - - 01 01 - - t3 t4 t7 t5 t6 t3 t6 t4 t5 1110 1101 0111 1011 p7 p6 t6 t4 t3 t5 11 - - - - 11 t7 1111 Encoding for safe PNs Four variables: v1 v2 v3 v4
t3 t2 p2 2010 3002 2104 2 t1 t2 t1 t3 t1 t3 t1 t2 p1 2 0120 1112 0214 1206 2 p4 p3 t3 t3 t2 t3 Dense encoding: 3 variables Sparse encoding: 10 variables max(p1)=3 max(p3)=2 max(p2)=3 max(p4)=8 Invariants of the PN: 010 000 001 I1: 2p1 + 4p2 - p4 = 4 I2: p1 + p2 + p3 = 3 111 100 110 011 Encoding for bounded PNs
Dense encoding: 3 variables Invariants of the PN: I1: 2p1 + 4p2 - p4 = 4 I2: p1 + p2 + p3 = 3 Encoding for bounded PNs Invariants characterize the set of all potentially reachable markings (an overestimation of the reachable markings) t3 t2 2010 3002 2104 0308 t2 t1 t3 t1 t3 t1 t2 0120 1112 0214 1206 t3 t2 t3 Dense encoding: 3 variables
p3 p4 p2 p1 p2 p2 p2 p4 p4 p4 p2 p4 p4 p4 p3 p3 p2 p4 p1 p4 p4 0 3 3 1 2 2 1 2 3 1 2 0 1 2 0 1 0 1 0 0 4 8 2 6 0 4 8 2 6 1 0 0 8 6 7 4 6 5 9 5 3 0 7 2 1 Encoding for bounded PNs 2p1 + 4p2 - p4 = 4 (8 vars) p1 + p2 + p3 = 3 3 variables 4 variables
p1 + p2 + p3 = 3 M(p1)+M(p2) p3 p1 p2 p2 p3 p2 p3 p3 p3 p3 p3 p2 p3 p3 p3 p3 1 2 3 0 1 2 3 2 1 0 1 2 3 1 2 0 1 0 2 1 0 1 0 1 0 0 0 1 3 2 2 4 0 7 4 3 1 Encoding for bounded PNs
T F T F x1 x2 x2 x3 x3 x3 x3 x2 x2 x3 x3 x1 x3 x3 T F T F T F T F T F T F T F T F T F T F T F T F p1 p3 2 0 2 1 2 3 0 0 3 0 1 2 1 1 1 0 0 0 0 1 0 1 1 2 p2 Encoding for bounded PNs 2p1 + 4p2 - p4 = 4 p3 = 3 - p1 - p2
F x1 x3 x4 x4 x3 x2 x3 x4 x4 x3 x4 x2 x4 x4 x4 x1 x2 x3 T F T T F T F T F T F T F T F T F T F F T T T T T T T T T T T T F T F T F T F T F T F T F T F F F F F F F Upper bounds for the state space 2p1 + 4p2 - p4 = 4 Characteristic function for potentially reachable states
Conclusions • Formal verification and synthesis oftensuffer from the state explosion problem • Symbolic techniques can be used to efficientlyrepresent the state space • Structural techniques are crucial to overestimateand encode the state space • Try to resist the temptation of using BDDs fromthe very beginning. Use them rationally and onlyif desperate.