semantics and verification 2005
play

Semantics and Verification 2005 Lecture 13 boolean expressions and - PowerPoint PPT Presentation

Boolean Logic Binary Decision Diagrams Algorithms on ROBDDs Semantics and Verification 2005 Lecture 13 boolean expressions and normal forms binary decision diagrams (BDDs) algorithms on BDDs Lecture 13 Semantics and Verification 2005


  1. Boolean Logic Binary Decision Diagrams Algorithms on ROBDDs Semantics and Verification 2005 Lecture 13 boolean expressions and normal forms binary decision diagrams (BDDs) algorithms on BDDs Lecture 13 Semantics and Verification 2005

  2. Boolean Logic Boolean Functions Binary Decision Diagrams Boolean Expressions Algorithms on ROBDDs Normal Forms Boolean Functions Let B = { 0 , 1 } . 1 ... true, 0 ... false Boolean Function of Arity n f : B n → B Boolean functions are often described using truth tables. f ( x 1 , x 2 , x 3 ) x 1 x 2 x 3 0 0 0 1 0 0 1 0 0 1 0 0 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 0 1 1 1 1 Problem: arity n gives truth table of size θ (2 n ). Lecture 13 Semantics and Verification 2005

  3. Boolean Logic Boolean Functions Binary Decision Diagrams Boolean Expressions Algorithms on ROBDDs Normal Forms Boolean Expressions Let x 1 , x 2 , . . . , x n be boolean variables. Abstract Syntax for Boolean Expressions ( x ranges over variables) t , t 1 , t 2 ::= 0 | 1 | x | ¬ t | t 1 ∧ t 2 | t 1 ∨ t 2 | t 1 ⇒ t 2 | t 1 ⇔ t 2 Truth Assignment v : { x 1 , . . . , x n } → B Function v is often written as [ v ( x 1 ) / x 1 , v ( x 2 ) / x 2 , . . . , v ( x n ) / x n ]. Example: boolean expression: ¬ ( x 1 ∧ x 2 ) ⇒ ( ¬ x 1 ∨ x 4 ) truth assignment: [1 / x 1 , 0 / x 2 , 1 / x 3 , 1 / x 4 ] Lecture 13 Semantics and Verification 2005

  4. Boolean Logic Boolean Functions Binary Decision Diagrams Boolean Expressions Algorithms on ROBDDs Normal Forms Evaluation of Boolean Expressions A boolean expression t defines a boolean function f t : B n → B by the following (structural) rules: t 1 t 2 t 1 ∧ t 2 t 1 t 2 t 1 ∨ t 2 t ¬ t 0 0 0 0 0 0 0 1 0 1 0 0 1 1 1 0 1 0 0 1 0 1 1 1 1 1 1 1 t 1 ⇒ t 2 t 1 ⇔ t 2 t 1 t 2 t 1 t 2 0 0 1 0 0 1 0 1 1 0 1 0 1 0 0 1 0 0 1 1 1 1 1 1 Lecture 13 Semantics and Verification 2005

  5. Boolean Logic Boolean Functions Binary Decision Diagrams Boolean Expressions Algorithms on ROBDDs Normal Forms Terminology Equivalent Boolean Expressions Boolean expressions t 1 and t 2 are equivalent iff f t 1 = f t 2 , i.e., they yield the same truth value for all truth assignments. Example: ¬ ( x 1 ∧ x 2 ) is equivalent to ¬ x 1 ∨ ¬ x 2 Tautology A boolean expression t is a tautology if it yields true for all truth assignment. Satisfiability A boolean expression t is satisfiable if it yields true for at least one truth assignment. Lecture 13 Semantics and Verification 2005

  6. Boolean Logic Boolean Functions Binary Decision Diagrams Boolean Expressions Algorithms on ROBDDs Normal Forms Conjunctive Normal Form (CNF) Definitions Literal is a boolean variable or its negation. Clause is a disjunction of literals. A boolean expression if CNF is a conjunction of clauses. Example: ( x 1 ∨ ¬ x 3 ) ∧ ( ¬ x 1 ∨ x 2 ∨ x 3 ) ∧ ( x 2 ∨ ¬ x 3 ) Theorem For any boolean expression there is an equivalent one in CNF. Cook’s Theorem Satisfiability of boolean expressions (in CNF) is NP-complete. Lecture 13 Semantics and Verification 2005

  7. Boolean Logic Boolean Functions Binary Decision Diagrams Boolean Expressions Algorithms on ROBDDs Normal Forms Combinatorial Circuits Are these two circuits equivalent? co-NP-hard problem! Lecture 13 Semantics and Verification 2005

  8. Boolean Logic Boolean Functions Binary Decision Diagrams Boolean Expressions Algorithms on ROBDDs Normal Forms Representations of Boolean Functions Problems over Boolean Expressions are Hard Many problems related to boolean expressions are hard from the theoretical point of view (NP-complete or co-NP-complete). Our Aim We are looking for compact representation and efficient manipulation with boolean expressions for real-life examples. We will have a look at Binary Decision Diagrams (BDDs) [Randal E. Bryant’86]. Lecture 13 Semantics and Verification 2005

  9. Boolean Logic Boolean Functions Binary Decision Diagrams Boolean Expressions Algorithms on ROBDDs Normal Forms If-Then-Else Operator Let t , t 1 and t 2 be boolean expressions. Syntax t → t 1 , t 2 Semantics If-Then-Else operator t → t 1 , t 2 is equivalent to ( t ∧ t 1 ) ∨ ( ¬ t ∧ t 2 ) . t t 1 t 2 t → t l , t 2 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 Lecture 13 Semantics and Verification 2005

  10. Boolean Logic Boolean Functions Binary Decision Diagrams Boolean Expressions Algorithms on ROBDDs Normal Forms If-Then-Else Normal Form Definition A boolean expression is in If-Then-Else normal form (INF) iff it is given by the following abstract syntax t , t 1 , t 2 ::= 0 | 1 | x → t 1 , t 2 where x ranges over boolean variables. Example: x 1 → ( x 2 → 1 , 0) , 0 (equivalent to x 1 ∧ x 2 ) Boolean expressions in INF can be drawn as decision trees. Lecture 13 Semantics and Verification 2005

  11. Boolean Logic Shannon’s Expansion Law Binary Decision Diagrams Definition Algorithms on ROBDDs Canonicity of ROBDDs Shannon’s Expansion Law Let t be a boolean expression and x a variable. We define boolean expressions t [0 / x ] where every occurrence of x in t is replaced with 0, and t [1 / x ] where every occurrence of x in t is replaced with 1. Shannon’s Expansion Law Let x be an arbitrary boolean variable. Any boolean expressions t is equivalent to x → t [1 / x ] , t [0 / x ] . Corollary For any boolean expression there is an equivalent one in INF. Lecture 13 Semantics and Verification 2005

  12. Boolean Logic Shannon’s Expansion Law Binary Decision Diagrams Definition Algorithms on ROBDDs Canonicity of ROBDDs Binary Decision Diagrams Let the set of boolean variables be { x 1 , . . . , x n } . Binary Decision Diagram (BDD) A BDD is a rooted, directed, acyclic graph ( V , E ) such that 0 , 1 ∈ V (representing false and true) and the nodes 0 and 1 have no outgoing edges every node v ∈ V � { 0 , 1 } has exactly two successors low ( v ) ∈ V and high ( v ) ∈ V every node v ∈ V � { 0 , 1 } has a label var ( v ) ∈ { x 1 , . . . , x n } . Assume a given total ordering < on boolean variables. Ordered BDD A BDD is ordered if on all paths from the root the variables respect the ordering < . Lecture 13 Semantics and Verification 2005

  13. Boolean Logic Shannon’s Expansion Law Binary Decision Diagrams Definition Algorithms on ROBDDs Canonicity of ROBDDs Reduced Ordered BDDs (ROBDDs) Reduced BDD A BDD is reduced iff for all nodes u , v ∈ V � { 0 , 1 } : 1 low ( u ) � = high ( u ) 2 low ( u ) = low ( v ) and high ( u ) = high ( v ) and var ( u ) = var ( v ) implies that u = v . ROBDD with a root node u describes a boolean expression t u according to the following (inductive) definition: t 0 def = 0 t 1 def = 1 t u def = var ( u ) → t high ( u ) , t low ( u ) Lecture 13 Semantics and Verification 2005

  14. Boolean Logic Shannon’s Expansion Law Binary Decision Diagrams Definition Algorithms on ROBDDs Canonicity of ROBDDs Canonicity of ROBDDs Canonicity Lemma For any boolean function f : B n → B and a given ordering of variables x 1 < x 2 < · · · < x n there is exactly one ROBDD with root u which describes the function f , i,e. t u [ v 1 / x 1 , . . . , v n / x n ] = f ( v 1 , . . . , v n ) for all ( v 1 , . . . , v n ) ∈ B n . Consequences: A given ROBDD with root u is tautology iff u = 1. A given ROBDD with root u is satisfiable iff u � = 0. Lecture 13 Semantics and Verification 2005

  15. Boolean Logic Shannon’s Expansion Law Binary Decision Diagrams Definition Algorithms on ROBDDs Canonicity of ROBDDs Ordering of Variables (Exponential Difference in Size) ( x 1 ⇔ x 2 ) ∧ ( x 3 ⇔ x 4 ) ∧ ( x 5 ⇔ x 6 ) ∧ ( x 7 ⇔ x 8 ) x1 x1 x2 x2 x3 x3 x5 x5 x5 x5 x3 x4 x4 x7 x7 x7 x7 x7 x7 x7 x7 x5 x2 x2 x2 x2 x2 x2 x2 x2 x2 x2 x2 x2 x2 x2 x2 x2 x6 x6 x4 x4 x4 x4 x4 x4 x4 x4 x6 x6 x6 x6 x7 x8 x8 x8 x8 1 1 x 1 < x 2 < · · · < x 8 x 1 < x 3 < x 5 < x 7 < x 2 < x 4 < x 6 < x 8 Lecture 13 Semantics and Verification 2005

  16. � � � � � � � Boolean Logic Representation of ROBDDs in Memory Binary Decision Diagrams Building ROBDDs Algorithms on ROBDDs Operations on ROBDDs Representing ROBDDs in Memory – Array Implementation Table T : Assume x 1 < x 2 < x 3 . ���� ���� u �→ ( var ( u ) , low ( u ) , high ( u )) x 1 � 6 u var low high ����� � � � � 0 4 - - � � ���� ���� ���� ���� � � 1 4 - - x 2 x 2 � 4 � 5 2 3 0 1 � � ����� � � � � 3 3 1 0 � � � � � � ���� ���� ���� ���� � � 4 2 0 2 � � x 3 x 3 � 2 3 5 2 2 3 ���������������������� � � � � � � � � � � 6 1 4 5 � � � � � Inverse table H : 0 1 ( var , low , high ) �→ u . Example: T (4) = (2 , 0 , 2), H (1 , 4 , 5) = 6, and H (3 , 0 , 2) = undef . Lecture 13 Semantics and Verification 2005

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