Verifying Programs with BDDs Topics Representing Boolean functions with Binary Decision Diagrams Application to program verification class-bdd.ppt 15-213.

Slides:



Advertisements
Similar presentations
Model Checking Lecture 4. Outline 1 Specifications: logic vs. automata, linear vs. branching, safety vs. liveness 2 Graph algorithms for model checking.
Advertisements

Representing Boolean Functions for Symbolic Model Checking Supratik Chakraborty IIT Bombay.
BDDs & Theorem Proving Binary Decision Diagrams Dr. Eng. Amr T. Abdel-Hamid NETW 703 Winter 2012 Network Protocols Lectures are based on slides by: K.
Lecture 24 MAS 714 Hartmut Klauck
Planning based on Model Checking Dept. of Information Systems and Applied CS Bamberg University Seminar Paper Svetlana Balinova.
Chapter 2 Logic Circuits.
SYMBOLIC MODEL CHECKING: STATES AND BEYOND J.R. Burch E.M. Clarke K.L. McMillan D. L. Dill L. J. Hwang Presented by Rehana Begam.
CS420 lecture one Problems, algorithms, decidability, tractability.
1 Don´t Care Minimization of *BMDs: Complexity and Algorithms Christoph Scholl Marc Herbstritt Bernd Becker Institute of Computer Science Albert-Ludwigs-University.
Class Presentation on Binary Moment Diagrams by Krishna Chillara Base Paper: “Verification of Arithmetic Circuits using Binary Moment Diagrams” by.
ECE 667 Synthesis & Verification - Boolean Functions 1 ECE 667 Spring 2013 ECE 667 Spring 2013 Synthesis and Verification of Digital Circuits Boolean Functions.
Department of Electrical and Computer Engineering M.A. Basith, T. Ahmad, A. Rossi *, M. Ciesielski ECE Dept. Univ. Massachusetts, Amherst * Univ. Bretagne.
Spring 07, Feb 13 ELEC 7770: Advanced VLSI Design (Agrawal) 1 ELEC 7770 Advanced VLSI Design Spring 2007 Binary Decision Diagrams Vishwani D. Agrawal James.
DATE-2002TED1 Taylor Expansion Diagrams: A Compact Canonical Representation for Symbolic Verification M. Ciesielski, P. Kalla, Z. Zeng B. Rouzeyre Electrical.
1 Introduction to Linear and Integer Programming Lecture 9: Feb 14.
ECE Synthesis & Verification1 ECE 667 Spring 2011 Synthesis and Verification of Digital Systems Verification Introduction.
ECE Synthesis & Verification - Lecture 18 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Word-level.
Boolean Functions and their Representations
A New Approach to Structural Analysis and Transformation of Networks Alan Mishchenko November 29, 1999.
Analysis of Algorithms CS 477/677
Taylor Expansion Diagrams (TED): Verification EC667: Synthesis and Verification of Digital Systems Spring 2011 Presented by: Sudhan.
Chapter 11: Limitations of Algorithmic Power
Automated Formal Verification of Software Randal E. Bryant Carnegie Mellon University.
Decision Structures Truth TableDecision Tree –Vertex represents decision –Follow green (dashed) line for value 0 –Follow red (solid) line for value 1 –Function.
ECE Synthesis & Verification - Lecture 10 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Binary.
 2001 CiesielskiBDD Tutorial1 Decision Diagrams Maciej Ciesielski Electrical & Computer Engineering University of Massachusetts, Amherst, USA
ENGG3190 Logic Synthesis “Binary Decision Diagrams” BDDs Winter 2014 S. Areibi School of Engineering University of Guelph.
IT University of Copenhagen Lecture 8: Binary Decision Diagrams 1. Classical Boolean expression representations 2. If-then-else Normal Form (INF) 3. Binary.
CS 267: Automated Verification Lecture 13: Bounded Model Checking Instructor: Tevfik Bultan.
Propositional Calculus Math Foundations of Computer Science.
Digitaalsüsteemide verifitseerimise kursus1 Formal verification: BDD BDDs applied in equivalence checking.
1 CHAPTER 4: PART I ARITHMETIC FOR COMPUTERS. 2 The MIPS ALU We’ll be working with the MIPS instruction set architecture –similar to other architectures.
Systems Architecture I1 Propositional Calculus Objective: To provide students with the concepts and techniques from propositional calculus so that they.
Binary Decision Diagrams (BDDs)
Analysis of Algorithms
Logic Circuits Chapter 2. Overview  Many important functions computed with straight-line programs No loops nor branches Conveniently described with circuits.
CS 267: Automated Verification Lecture 6: Binary Decision Diagrams Instructor: Tevfik Bultan.
Program Efficiency & Complexity Analysis. Algorithm Review An algorithm is a definite procedure for solving a problem in finite number of steps Algorithm.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View BDDs.
MA/CSSE 474 Theory of Computation Decision Problems DFSMs.
Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
Integrating high-level constructs into programming languages Language extensions to make programming more productive Underspecified programs –give assertions,
Umans Complexity Theory Lectures Lecture 1a: Problems and Languages.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View BDDs.
- 1 -  P. Marwedel, Univ. Dortmund, Informatik 12, 05/06 Universität Dortmund Validation - Formal verification -
Verification & Validation By: Amir Masoud Gharehbaghi
Computer Systems 1 Fundamentals of Computing Simplifying Boolean Expressions.
Lecture 3 Combinational Circuits
R. Johnsonbaugh Discrete Mathematics 5 th edition, 2001 Chapter 9 Boolean Algebras and Combinatorial Circuits.
1 Class Presentation on Binary Moment Diagrams by Krishna Chillara Base Paper: “Verification of Arithmetic Circuits with Binary Moment Diagrams” by Randal.
CS357 Lecture 13: Symbolic model checking without BDDs Alex Aiken David Dill 1.
Test complexity of TED operations Use canonical property of TED for - Software Verification - Algorithm Equivalence check - High Level Synthesis M ac iej.
Binary Decision Diagrams Prof. Shobha Vasudevan ECE, UIUC ECE 462.
Algorithmic Foundations COMP108 COMP108 Algorithmic Foundations Algorithm efficiency Prudence Wong.
Algorithmic Foundations COMP108 COMP108 Algorithmic Foundations Algorithm efficiency Prudence Wong
Software Testing.
Analysis of Algorithms
COMP108 Algorithmic Foundations Algorithm efficiency
ECE 667 Synthesis and Verification of Digital Systems
Propositional Calculus: Boolean Algebra and Simplification
Software Testing (Lecture 11-a)
Binary Decision Diagrams
Automatic Verification of Industrial Designs
NP-Complete Problems.
A logic function f in n inputs x1, x2, ...xn and
Binary Decision Diagrams
A logic function f in n inputs x1, x2, ...xn and
Verifying Programs with BDDs Sept. 22, 2006
10 Design Verification and Test
Presentation transcript:

Verifying Programs with BDDs Topics Representing Boolean functions with Binary Decision Diagrams Application to program verification class-bdd.ppt “The course that gives CMU its Zip!” , S’08

– 2 – Verification Example Do these functions produce identical results? How could you find out? How about exhaustive testing? int abs(int x) { int mask = x>>31; return (x ^ mask) + ~mask + 1; } int test_abs(int x) { return (x < 0) ? -x : x; }

– 3 – More Examples int addXY(int x, int y) { return x+y; } int addYX(int x, int y) { return y+x; } ?=?= int mulXY(int x, int y) { return x*y; } int mulYX(int x, int y) { return y*x; } ?=?=

– 4 – How Can We Verify Programs? Testing Exhaustive testing not generally feasible Currently, programs only tested over small fraction of possible cases Formal Verification Mathematical “proof” that code is correct Did Pythagoras show that a 2 + b 2 = c 2 by testing? a b c

– 5 – Bit-Level Program Verification View computer word as 32 separate bit values Each output becomes Boolean function of inputs abs x0x0 x1x1 x2x2 x 31 y0y0 y1y1 y2y2 y 31 x0x0 x1x1 x2x2 x 31 yiyi abs i int abs(int x) { int mask = x>>31; return (x ^ mask) + ~mask + 1; }

– 6 – Extracting Boolean Representation Do these functions produce identical results? int bitOr(int x, int y) { return ~(~x & ~y); } int test_bitOr(int x, int y) { return x | y; } y xv1 =~x v2 =~y v3 =v1 & v2 v4 =~v3 v5 =x | y t =v4 == v5 Straight-Line Evaluation

– 7 – Tabular Function Representation List every possible function valueComplexity Function with n variables

– 8 – Algebraic Function Representation f(x 1, x 2, x 3 ) = (x 1 + x 2 ) · x 3 Boolean AlgebraComplexity Representation Determining properties of function E.g., deciding whether two expressions are equivalent x 1 · x 3 x 2 · x 3

– 9 – Tree Representation Truth TableDecision Tree Vertex represents decision Follow green (dashed) line for value 0 Follow red (solid) line for value 1 Function value determined by leaf valueComplexity

– 10 – Ordered Binary Decision Diagrams Initial TreeReduced Graph Canonical representation of Boolean function Two functions equivalent if and only if graphs isomorphic Can be tested in linear time Desirable property: simplest form is canonical. (x 1 + x 2 ) · x 3

– 11 – Example Functions Constants Unique unsatisfiable function Unique tautology Variable Treat variable as function Odd Parity Linear representation Typical Function (x 1 + x 2 ) · x 4 No vertex labeled x 3  independent of x 3 Many subgraphs shared

– 12 – More Complex Functions Functions Add 4-bit words a and b Get 4-bit sum S Carry output bit Cout Shared Representation Graph with multiple roots 31 nodes for 4-bit adder 571 nodes for 64-bit adder Linear growth!

– 13 – Symbolic Execution (3-bit word size) x x2x2 10 x1x1 10 x0x0 10 y y2y2 10 y1y1 10 y0y0 10 v1 =~x x2x2 01 x1x1 01 x0x0 01 v2 =~y y2y2 01 y1y1 01 y0y0 01

– 14 – Symbolic Execution (cont.) v3 =v1 & v2 x2x2 y2y2 01 x1x1 y1y1 01 x0x0 y0y0 01 v4 =~v3 x2x2 y2y2 10 x1x1 y1y1 10 x0x0 y0y0 10 v5 =x | y x2x2 y2y2 10 x1x1 y1y1 10 x0x0 y0y0 10 t =v4 == v5 1

– 15 – Counterexample Generation Find values of x & y for which these programs produce different results int bitOr(int x, int y) { return ~(~x & ~y); } int bitXor(int x, int y) { return x ^ y; } y xv1 =~x v2 =~y v3 =v1 & v2 v4 =~v3 v5 =x ^ y t =v4 == v5 Straight-Line Evaluation

– 16 – Symbolic Execution v4 =~v3 x2x2 y2y2 10 x1x1 y1y1 10 x0x0 y0y0 10 v5 =x ^ y x2x2 y2y2 10 y2y2 x1x1 y1y1 10 y1y1 x0x0 y0y0 10 y0y0 t =v4 == v5 x2x2 y2y2 x1x1 y1y1 x0x0 y0y0 01 x = 111 y = 001

– 17 – Performance: Good int addXY(int x, int y) { return x+y; } int addYX(int x, int y) { return y+x; }

– 18 – Performance: Bad int mulXY(int x, int y) { return x*y; } int mulYX(int x, int y) { return y*x; }

– 19 – Why Is Multiplication Slow? Multiplication function intractable for BDDs Exponential growth, regardless of variable orderingBitsAddMult Multiplication-4 Add-4 Node Counts

– 20 – What if Multiplication were Easy? int factorK(int x, int y) { int K = XXXX...X; int rangeOK = 1 < x && x <= y; int factorOK = x*y == K; return !(rangeOK && factorOK); } int one(int x, int y) { return 1; }

– 21 – Dealing with Conditionals During Evaluation, Keep Track of: Current Context: Under what condition would code be evaluated Definedness (for each variable) Has it been assigned a value int abs(int x) { int r; if (x < 0) r = -x; else r = x; return r; } t1 = x<0 x v1 = -x r = v1 v2 = r r = x 1 1 t1 1 !t t t1?v1:0 t1?v1:x Context r defined r value

– 22 – Dealing with Loops Unroll Turn into bounded sequence of conditionals Default limit = 33 Signal runtime error if don’t complete within limit int ilog2(unsigned x) { int r = -1; while (x) { r++; x >>= 1; } return r; } int ilog2(unsigned x) { int r = -1; if (x) { r++; x >>= 1; } else return r; if (x) { r++; x >>= 1; } else return r;... if (x) { r++; x >>= 1; } else return r; error(); } Unrolled

– 23 – Evaluation Strengths Provides 100% guarantee of correctness Performance very good for simple arithmetic functionsWeaknesses Important integer functions have exponential blowup Not practical for programs that build and operate on large data structures

– 24 – Some History Origins Lee 1959, Akers 1976 Idea of representing Boolean function as BDD Hopcroft, Fortune, Schmidt 1978 Recognized that ordered BDDs were like finite state machines Polynomial algorithm for equivalence Bryant 1986 Proposed as useful data structure + efficient algorithms McMillan 1987 Developed symbolic model checking Method for verifying complex sequential systems Bryant 1991 Proved that multiplication has exponential BDD No matter how variables are ordered