formal specification and verification
play

Formal Specification and Verification 10.05.2012 Viorica - PowerPoint PPT Presentation

Formal Specification and Verification 10.05.2012 Viorica Sofronie-Stokkermans e-mail: sofronie@uni-koblenz.de 1 Binary Decision Diagrams Formulae Boolean functions f F : { 0, 1 } n { 0, 1 } F ( n Prop.Var) Binary decision


  1. Formal Specification and Verification 10.05.2012 Viorica Sofronie-Stokkermans e-mail: sofronie@uni-koblenz.de 1

  2. Binary Decision Diagrams Formulae ↔ Boolean functions f F : { 0, 1 } n → { 0, 1 } F ( n Prop.Var) �→ Binary decision trees: x 0 1 y y 0 1 0 1 1 0 1 0 2

  3. Binary Decision Diagrams Formulae ↔ Boolean functions f F : { 0, 1 } n → { 0, 1 } F ( n Prop.Var) �→ Binary decision trees: x 0 1 y y 0 1 0 1 1 0 1 0 - exactly as inefficient as truth tables (2 n +1 − 1 nodes if n prop.vars.) - optimization possible: remove redundancies 3

  4. Binary Decision Diagrams Optimization: remove redundancies 1. remove duplicate leaves 2. remove unnecessary tests 3. remove duplicate nodes 4

  5. Binary Decision Diagrams Binary decision diagram (BDD): finite directed acyclic graph with: • a unique initial node • terminal nodes marked with 0 or 1 • non-terminal nodes marked with propositional variables • in each non-terminal node: two vertices (marked 0/1) Reduced BDD: Optimizations 1-3 cannot be applied. 5

  6. Binary Decision Diagrams Binary decision diagram (BDD): finite directed acyclic graph with: • a unique initial node • terminal nodes marked with 0 or 1 • non-terminal nodes marked with propositional variables • in each non-terminal node: two vertices (marked 0/1) Reduced BDD: Optimizations 1-3 cannot be applied. Problem: Variables may occur several times on a path. Solution: Ordered BDDs. 6

  7. Ordered BDDs [ P 1 , . . . , P n ] ordered list of variables (without repetitions) Let B be a BDD with variables { P 1 , . . . , P n } B has the order [ P 1 , . . . , P n ] if for every path v 1 → v 2 → · · · → v m in B , if - i < j , - v i is marked with P k i - v j ist marked with P k j then k i < k j . A ordered BDD (Notation: OBDD) is a BDD which has an order, for a certain ordered list of variables. 7

  8. Reduced OBDDs Let [ P 1 , . . . , P n ] be an order on variables. The reduced OBDD, which represents a given function f is unique. Theorem: Let B 1 , B 2 be two reduced OBDDs with the same variable ordering. If B 1 and B 2 represent the same function, then B 1 and B 2 are equal. OBDDs have a canonical form, namely the reduced OBDD. 8

  9. The role of the ordering on variables Example ( P 1 ∨ P 2 ) ∧ ( P 3 ∨ P 4 ) ∧ · · · ∧ ( P 2 n − 1 ∨ P 2 n ) [ P 1 , P 2 , . . . , P 2 n − 1 , P 2 n ]: OBDD with 2 n + 2 nodes [ P 1 , P 3 , . . . , P 2 n − 1 , P 2 , . . . , P 2 n ]: OBDD with 2 n +1 nodes 9

  10. Advantages of canonical representations • Absence of redundant variables If the value of f does not depend on the i -argument ( P i ) then no reduced OBDD contains the variable P i • Equivalence test F i �→ f i �→ B i (OBDDs with compatible variable ordering), i = 1, 2 Reduce B i , i = 1, 2. F 1 ≡ F 2 iff. B 1 and B 2 identical. 10

  11. Advantages of canonical representations • Validity test F �→ f �→ B (OBDD) F valid iff its reduced OBDD is B 1 := 1 • Entailment test F | = G iff the reduced OBDD for F ∧ ¬ G is B 0 := 0 • Satisfiability test F satisfiable iff its reduced OBDD is not B 0 . 11

  12. Operations with OBDDs • Reduce Apply reduction steps 1–3 • Apply Boolean operations • Restrict Compute OBDD for F [0/ P i ] and F [1/ P i ] • Exists E Compute OBDD for P i F ( P 1 , . . . , P n ) 12

  13. Operations with OBDDs • Reduce Apply reduction steps 1–3 • Apply Boolean operations • Restrict Compute OBDD for F [0/ P i ] and F [1/ P i ] • Exists E Compute OBDD for P i F ( P 1 , . . . , P n ) 13

  14. Reduce remove redundancies 1. remove duplicate leaves 2. remove unnecessary tests 3. remove duplicate nodes 14

  15. Reduce 1. remove duplicate leaves Only one copy of 0 and 1 necessary: x 0 1 y y 0 1 0 1 1 0 1 0 15

  16. Reduce 1. remove duplicate leaves Only one copy of 0 and 1 necessary: x x 0 1 0 1 y y y y 0 0 1 0 1 0 1 0 1 1 1 0 0 0 1 0 0 0 16

  17. Reduce 2. remove unnecessary tests x 0 1 y y 0 0 1 0 1 1 1 0 0 0 17

  18. Reduce 2. remove unnecessary tests x x 0 0 1 1 y y y 0 1 0 0 1 0 1 1 1 0 1 0 0 0 18

  19. Reduce 3. remove duplicate non-terminal nodes: z 0 1 x x 0 1 0 1 y y y y 1 1 0 0 0 0 1 1 0 1 19

  20. Reduce 3. remove duplicate non-terminal nodes: z z 0 1 0 1 x x x x 0 1 0 1 0 1 0 1 y y y y y y y y 1 1 0 1 1 0 0 0 0 0 0 0 1 1 1 1 0 1 0 1 20

  21. Reduce 3. remove duplicate non-terminal nodes: z z z 0 1 0 1 0 1 x x x x x x 1 0 0 1 0 1 0 1 0 1 0 1 y y y y y y y y y y y y 1 1 0 1 1 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 1 0 1 0 1 21

  22. Reduce 3. remove duplicate non-terminal nodes: z z z z 0 1 0 1 0 1 0 1 x x x x x x x x 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 y y y y y y y y y y y y y y y y 1 1 0 1 1 0 1 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 22

  23. Reduce 3. remove duplicate non-terminal nodes: z z z z 0 1 0 1 0 1 0 1 x x x x x x x 0 0 0 0 1 0 1 0 1 1 0 1 1 1 y y y y y y y y y y y 1 1 0 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 23

  24. Reduce The algorithm reduce traverses an OBDD B layer by layer in a bottom-up fashion, beginning with the terminal nodes. In traversing B , it assigns an integer label id ( n ) to each node n of B , in such a way that the subOBDDs with root nodes n and m denote the same boolean function iff, id ( n ) = id ( m ). 24

  25. Reduce Terminal nodes: Since reduce starts with the layer of terminal nodes, it assigns the first label (say 0) to the first 0-node it encounters. All other terminal 0-nodes denote the same function as the first 0-node and therefore get the same label (compare with reduction 1). Similarly, the 1-nodes all get the next label, say 1. 25

  26. Reduce Non-terminal nodes Now let us inductively assume that reduce has already assigned integer labels to all nodes of a layer > i (i.e. all terminal nodes and P j -nodes with j > i ). We describe how nodes of layer i (i.e. P i -nodes) are being handled. n �→ lo ( n ) node reached on branch labelled with 0 hi ( n ) node reached on branch labelled with 1 Given an P i -node n , there are three ways in which it may get its label: • If id ( lo ( n )) = id ( hi ( n )), we set id ( n ) to be that label (reduction 2) • If there is another node m s.t. n and m have same variable P i , and id ( lo ( n )) = id ( lo ( m )) and id ( hi ( n )) = id ( hi ( m )), then we set id ( n ) := id ( m ) (reduction 3) • Otherwise, we set id ( n ) to the next unused integer label. 26

  27. Operations with OBDDs • Reduce Apply reduction steps 1–3 • Apply Boolean operations • Restrict Compute OBDD for F [0/ P i ] and F [1/ P i ] • Exists E Compute OBDD for P i F ( P 1 , . . . , P n ) 27

  28. Reminder: BDDs f �→ B f (BDD associated with f ) g �→ B g (BDD associated with g ) BDD for f ∧ g : replace all 1-leaves in B f with B g BDD for f ∨ g : replace all 0-leaves in B f with B g BDD for ¬ f : replace all 1-leaves in B f with 0-leaves and all 0-leaves with 1 leaves. 28

  29. Reminder: BDDs f �→ B f (BDD associated with f ) g �→ B g (BDD associated with g ) BDD for f ∧ g : replace all 1-leaves in B f with B g BDD for f ∨ g : replace all 0-leaves in B f with B g BDD for ¬ f : replace all 1-leaves in B f with 0-leaves and all 0-leaves with 1 leaves. If applied to OBDDs, the resulting BDD is not ordered! 29

  30. Apply Idea: Use the Shannon expansion for F . F ≡ ( ¬ P ∧ F [0/ P ]) ∨ ( P ∧ F [1/ P ]) The function apply is based on the Shannon expansion for F op G : F op G = ( ¬ P i ∧ ( F [0/ P i ]op G [0/ P i ])) ∨ ( P i ∧ ( F [1/ P i ]op G [1/ P i ])). 30

  31. Apply This is used as a control structure of apply which proceeds from the roots of B F and B G downwards to construct nodes of the OBDD B F op G . Let r f be the root node of B F and r g the root node of B G . 1. If both r f , r g are terminal nodes with labels l f and l g , respectively (0 or 1), we compute the value l f op l g and let the resulting OBDD be B 0 if the value is 0 and B 1 otherwise. 31

  32. Apply This is used as a control structure of apply which proceeds from the roots of B F and B G downwards to construct nodes of the OBDD B F op G . Let r f be the root node of B F and r g the root node of B G . In the remaining cases, at least one of the root nodes is a non-terminal. 2. Suppose that both root nodes are P i -nodes. Then we create an P i -node n with - the edge labelled with 0 to apply(op, lo(r f ), lo ( r g )) - the edge labelled with 1 to apply(op, hi(r f ), hi ( r g )) 32

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend