Binary Decision Diagrams

Similar documents
Reduced Ordered Binary Decision Diagrams

Decision Procedures for Satisfiability and Validity in Propositional Logic

Binary Decision Diagrams

Binary Decision Diagrams

Propositional Logic: Models and Proofs

Comp487/587 - Boolean Formulas

The Maze Generation Problem is NP-complete

Boolean decision diagrams and SAT-based representations

Symbolic Model Checking with ROBDDs

Propositional and Predicate Logic - II

Overview. Discrete Event Systems Verification of Finite Automata. What can finite automata be used for? What can finite automata be used for?

Binary Decision Diagrams Boolean Functions

Reduced Ordered Binary Decision Diagrams

CTL Model Checking. Wishnu Prasetya.

Binary Decision Diagrams. Graphs. Boolean Functions

Propositional Fragments for Knowledge Compilation and Quantified Boolean Formulae

Basing Decisions on Sentences in Decision Diagrams

Computational Logic. Davide Martinenghi. Spring Free University of Bozen-Bolzano. Computational Logic Davide Martinenghi (1/30)

SAT based BDD solver for Quantified Boolean Formulas

Tecniche di Verifica. Introduction to Propositional Logic

Propositional Calculus: Formula Simplification, Essential Laws, Normal Forms

A brief introduction to Logic. (slides from

2.5.2 Basic CNF/DNF Transformation

Binary Decision Diagrams

Propositional and First Order Reasoning

EECS 219C: Computer-Aided Verification Boolean Satisfiability Solving III & Binary Decision Diagrams. Sanjit A. Seshia EECS, UC Berkeley

Chapter 2 Combinational Logic Circuits

BDD Based Upon Shannon Expansion

Propositional Logic. Methods & Tools for Software Engineering (MTSE) Fall Prof. Arie Gurfinkel

Binary Decision Diagrams

Propositional and Predicate Logic. jean/gbooks/logic.html

Quantified Boolean Formulas: Complexity and Expressiveness

Design and Analysis of Algorithms

CS 395T Computational Learning Theory. Scribe: Mike Halcrow. x 4. x 2. x 6

CS250: Discrete Math for Computer Science. L6: CNF and Natural Deduction for PropCalc

Clause/Term Resolution and Learning in the Evaluation of Quantified Boolean Formulas

Section 1.2 Propositional Equivalences. A tautology is a proposition which is always true. A contradiction is a proposition which is always false.

Part 1: Propositional Logic

On the Relative Efficiency of DPLL and OBDDs with Axiom and Join

Propositional Logic. Testing, Quality Assurance, and Maintenance Winter Prof. Arie Gurfinkel

02 Propositional Logic

Boolean Algebra. Philipp Koehn. 9 September 2016

Knowledge base (KB) = set of sentences in a formal language Declarative approach to building an agent (or other system):

Solvers for the Problem of Boolean Satisfiability (SAT) Will Klieber Aug 31, 2011

Exercises 1 - Solutions

Lecture 2: Proof of Switching Lemma

LOGIC PROPOSITIONAL REASONING

This is an author-deposited version published in : Eprints ID : 16897

Propositional Logic: Evaluating the Formulas

A Collection of Problems in Propositional Logic

13th International Conference on Relational and Algebraic Methods in Computer Science (RAMiCS 13)

Conjunctive Normal Form and SAT

Exercises - Solutions

Formal Verification Methods 1: Propositional Logic

NP-Completeness Part II

Version January Please send comments and corrections to

CS 512, Spring 2017, Handout 10 Propositional Logic: Conjunctive Normal Forms, Disjunctive Normal Forms, Horn Formulas, and other special forms

Classical Propositional Logic

Reduced Ordered Binary Decision Diagram with Implied Literals: A New knowledge Compilation Approach

SAT Modulo ODE: A Direct SAT Approach to Hybrid Systems

Binary decision diagrams for security protocols

COMP219: Artificial Intelligence. Lecture 20: Propositional Reasoning

NP-Completeness Part II

Binary Decision Diagrams

Lecture 8. MINDNF = {(φ, k) φ is a CNF expression and DNF expression ψ s.t. ψ k and ψ is equivalent to φ}

De Morgan s a Laws. De Morgan s laws say that. (φ 1 φ 2 ) = φ 1 φ 2, (φ 1 φ 2 ) = φ 1 φ 2.

NP-Completeness Part II

Safety and Reliability of Embedded Systems

Toda s Theorem: PH P #P

Design and Analysis of Algorithms

NP-Complete Problems. More reductions

Propositional Calculus - Semantics (3/3) Moonzoo Kim CS Dept. KAIST

First-Order Logic First-Order Theories. Roopsha Samanta. Partly based on slides by Aaron Bradley and Isil Dillig

CDM. Algorithms for Propositional Logic

Maximum 3-SAT as QUBO

Worst-Case Upper Bound for (1, 2)-QSAT

Chapter 2. Reductions and NP. 2.1 Reductions Continued The Satisfiability Problem (SAT) SAT 3SAT. CS 573: Algorithms, Fall 2013 August 29, 2013

Lecture #14: NP-Completeness (Chapter 34 Old Edition Chapter 36) Discussion here is from the old edition.

CS156: The Calculus of Computation

CSE 555 HW 5 SAMPLE SOLUTION. Question 1.

Foundations of Databases

Mathematical Logic Propositional Logic - Tableaux*

Model Checking for Propositions CS477 Formal Software Dev Methods

Conjunctive Normal Form and SAT

Logic and Computer Design Fundamentals. Chapter 2 Combinational Logic Circuits. Part 1 Gate Circuits and Boolean Equations

Language of Propositional Logic

1 First-order logic. 1 Syntax of first-order logic. 2 Semantics of first-order logic. 3 First-order logic queries. 2 First-order query evaluation

Boolean Algebra and Logic Gates

Non-Deterministic Time

Correctness of Dijkstra s algorithm

Solutions to Homework I (1.1)

Advanced Topics in Theoretical Computer Science

Exact Equations. M(x,y) + N(x,y) y = 0, M(x,y) dx + N(x,y) dy = 0. M(x,y) + N(x,y) y = 0

NP Completeness. CS 374: Algorithms & Models of Computation, Spring Lecture 23. November 19, 2015

This lecture covers Chapter 7 of HMU: Properties of CFLs

Computational Boolean Algebra. Pingqiang Zhou ShanghaiTech University

NP and Computational Intractability

Implementing Semantic Merging Operators using Binary Decision Diagrams

On the satisfiability problem for a 4-level quantified syllogistic and some applications to modal logic

Chapter 2 Combinational

Transcription:

Binar Decision Diagrams Ma 3, 2004 1

Overview Boolean functions Possible representations Binar decision trees Binar decision diagrams Ordered binar decision diagrams Reduced ordered binar decision diagrams Operations on ordered binar decision diagrams Validit, satisfiabilit, function equivalence Function composition operations 2

Boolean functions A boolean function maps boolean inputs (0s and 1s) to a boolean result (0 or 1). Basic functions: 0 = 1, 1 = 0 (complementation). + = 0 = = 0 (disjunction, like addition). = 1 = = 1 (conjunction, like multiplication). = 1 (eclusive or). Comple functions: h(,, ) = + ( ) Function composition: h = f + g Goal: represent models and CTL formulas. 3

Representing boolean functions Goal: efficientl implement useful operations: Validit Satisfiabilit Equivalence of functions Approaches: Truth tables. Propositional formulas. Propositional formulas in a canonical form. (e.g. CNF, DNF) 4

Binar decision trees Truth-table representation: ( + ) 1 1 1 1 1 1 0 0 1 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 Tree representation: 0 0 Evaluation: Use the dotted edge if the variable is 0. Use the solid edge if the variable is 1. Structure depends on the input/output relation, not on the formula definition. 5

Problems Trees no more efficient than truth tables. Tree structure depends on the variable ordering: 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 1 Repeated variables can create unreachable edges. 6

Binar decision diagrams (BDDs) BDDs: Trees with sharing (DAGs). Reduction: Eliminate redundant information from a BDD. Share redundant subgraphs. 7

Reduction rules Multiple 0 s and 1 s clearl redundant. Eample: 0 0 becomes: 8

Reduction rules, contd. If a node has the same child at both outgoing edges, the node is redundant. If two nodes represent the same variable and have the same descendants, one is redundant. 9

Variable ordering Reduction opportunities depend on variable ordering. Eamples: 0 0 0 0 0 1 10

Summar Reduction rules: Coalescing duplicate terminal nodes. Removal of redundant tests. Coalescing duplicate non-terminals. No rules introduce terminals, so the first rule can be applied all at once. Otherwise, one application can make opportunities for others: = The rules are confluent. 11

Operations on BDDs Desirable predicates: Validit Satisfiabilit Equivalence of functions Desirable operations: f f + g f g f g 12

Predicates Validit: Is the result alwas 1? Satisfiabilit: Is the result ever 1? Ideall: Validit: check for absence of 0. Satisfiabilit: check for presence of 1. Problem: Repeated variables impl that some edges might be unreachable. Eample: BDD for + : Solution: Evaluate on all inputs (truth-table approach). 13

Equivalence of functions Ideall: Check whether BDDs have the same structure. Problem: structure sensitive to: Variable ordering Repeated variables Redundant nodes Solution: Evaluate both functions on all inputs (again, the truth-table solution). 14

Operations f: interchange 0 s and 1 s. f + g: If 1 reached in f, return 1. Otherwise, check g. Replace the 0 nodes of B f b B g. : : 1 0 + : 1 1 0 f g: If 0 reached in f, return 0. Otherwise, check g. Replace the 1 nodes of B f b B g. Calculations efficient, but variables occur multipl in resulting paths. 15

Ordered BDDs (OBDDs) Problems with BDDs: Repeated variables cause inaccessible edges. Structure depends on variable ordering. Solution: Require a fied order for all paths. Ordered: [,, ]: Not ordered: 0 0 0 1 0 0 0 1 An BDD can be converted to an order. 16

Properties of OBDDs No duplication implies no inaccessible edges. Validit: absence of 0. Satisfiabilit: presence of 1. Implication: f g f g (f g). Check f g for validit. Equivalentl, check that f g has no 1 (alwas false). 17

Properties of reduced OBDDs Absence of redundant variables: A reduced OBDD contains no redundant variables. Eample: OBDD: non-obdd: Equivalence of functions: Reduced OBDDs must be identical. Compleit linear in OBDD sie. 18

Properties of reduced OBDDs, contd. Validit: Reduced OBDD equivalent to 1. Satisfiabilit: Reduced OBDD not equivalent to 0. Implication: f g iff reduced OBDD of f g is equivalent to 0. Constant time operations. 19

OBDDs and variable ordering Variable ordering affects reduced OBDD sie, which affects manipulation costs. ( 1 + 2 ) ( 3 + 4 ) ( 5 + 6 ) [ 1, 2, 3, 4, 5, 6 ] : [ 1, 3, 5, 2, 4, 6 ] : 1 2 3 4 5 6 1 3 3 5 5 5 5 2 2 2 2 4 4 6 1 0 For ( 1 + 2 ) ( 3 + 4 )... ( 2n 1 + 2n ): [ 1, 2,..., 2n ] 2n + 2 nodes. [ 1, 3,..., 2n 1, 2, 4,... 2n ] 2 n+1 nodes. Problem: the same ordering must be used for all functions. 20

Reduction for OBDDs Efficient bottom-up algorithm. Idea: label nodes, giving redundant nodes the same label. Labeling allows efficient comparison of subgraphs. Terminolog: l(n): the child at the dotted edge of n. h(n): the child at the solid edge of n. 21

Labeling algorithm 1. Label all 0 s with 1, all 1 s with 1. 2. If l(n) = h(n), label n with l(n). 3. If there is a node m with the same variable such that l(n) = l(m) and h(n) = h(m), label n with m s label. 4. Otherwise, pick a fresh label for n. 4 3 2 0 2 2 2 00 00 01 01 01 Appl reduction rules, bottom-up. If two children have the same label, the are the same. 22

Compleit Visit each node: O(n) Check whether children identical: O(1) Search for a predecessor with the same variable and the same children. B first sorting: O(log n) 23

Boolean functions Goal: combine OBDDs so that the result is an OBDD. Operations: f + g, f g, f g. Observation: f op g trivial if f and g are constant functions. Eample: f = 0, g = 1 f + g = 0 + 1 = 0 Inductive strateg: Compute f op g on n variables in terms of f op g on n 1 variables. Eventuall reach a constant function. 24

Shannon epansion Law of the ecluded middle: = 0 or = 1. f[0/], f[1/] have fewer variables than f. Idea: redefine f in terms of f[0/] and f[1/]: + combines, but f[0/] + f[1/] is wrong. Drop the component that does not use s value. α: = 0 drop α. = 1 keep α. α: = 0 keep α. = 1 drop α. f = f[0/] + f[1/] f op g = (f op g)[0/] + (f op g)[1/] = (f[0/] op g[0/]) + (f[1/] op g[1/]) 25

Implementing appl(op, B f, B g ) f op g = (f[0/] op g[0/])+ (f[1/] op g[1/]) Construct OBDDs for f[0/], f[1/] from an OBDD for f. If is at the root: f[0/]: the target of the dotted edge. f[1/]: the target of the solid edge. Inductive algorithm eliminates all variables, so choose the root each time. OBDDs, so f and g variables in the same order. 26

appl algorithm Cases: Both roots are terminals: Appl op directl. Both roots associated with : app(op, l(r f ), l(r g )) app(op, h(r f ), h(r g )) Incompatible roots: deferred. These rules are sufficient if all paths contain all variables. Result: a full binar tree. Reduction required. 27

Connection to Shannon epansion f op g = f[0/] op g[0/] + f[1/] op g[1/] BDDs: : 1 0 : f[0/] op g[0/] : f[1/] op g[1/] : app(op, l(r f ), l(r g )) 0 0 app(op, h(r f ), h(r g )) Final sum: app(op, l(r f ), l(r g )) 0 app(op, h(r f ), h(r g )) 28

Eample Compute product: : 1 a : 1 b 2 a 3 a 0 4 a 1 5 a 2 b 3 b 0 4 b 1 5 b 29

Completing the appl algorithm Remaining cases: One root a variable, the other a constant. The two roots represent different variables. OBDD propert: If the variable earlier in the ordering is not the root of one tree, it is not in that tree. Idea: Rules: r f < r g : op op app(op, l(r f ), r g ) app(op, h(r f ), r g ) r g < r f : app(op, r f, l(r g )) app(op, r f, h(r g )) 30

Eample Compute product: 1 a 3 a 0 4 a 1 5 a 1 b 3 b 2 b 0 4 b 1 5 b 31

Compleit Observation: appl algorithm often creates a full binar tree. 2 n nodes, for n variables. Problems: Repeated computations. Distinct computations give the same result. Memoisation addresses the first problem. Onl compute each app(op, n, m) once. Compleit O( B f B g ). 32

Quantifiers (.f)( 1,..., n ) = 1 iff: f returns 1 for these values when = 0, or f returns 1 for these values when = 1. Encoding:.f = f[0/] + f[1/] (.f)( 1,..., n ) = 1 iff: f returns 1 for these values when = 0, and f returns 1 for these values when = 1. Encoding:.f = f[0/] f[1/] 33

Computing restrict(c,, B) For appl, is alwas the root variable. f[0/] is the left child of the root. f[1/] is the right child of the root. For restrict, can be an variable. For each, connect all incoming edges to c child. Eample: ( ) : [0/] : 34

Implementing quantification.f = app(+, restrict(0,, B f ), restrict(1,, B f )).f = app(, restrict(0,, B f ), restrict(1,, B f )) Eample, d.f: a b c d e Restrictions: a a b c e b c e Sum: b l + b r = b c l + c r = c a 0 + 0 = 0 e l + e r = e 1 + 1 = 1 0 + e r = e 35

Improving efficienc Most of the tree is not affected b restrictions. Thus most of the tree is duplicated in the result (e.g. b l + b r ). More efficient approach: replace quantified node b the sum of the children. Eample: b a c d e a b c e Nested quantification NP-complete. 36

Compleit summar input time compleit reduce B O( B log B ) appl Br f, Br g O( Br f Br g ) restrict Br O( Br log Br ) eists Br NP-complete Br: a reduced OBDD. 37

Comparison with other approaches Compact Sat. Val. Prop. formulas + DNF formulas 0 + CNF formulas 0 + Truth tables Reduced OBDDs + + + + Prop. formulas + + + DNF formulas + CNF formulas + Truth tables Reduced OBDDs 0 0 + 38