Verifying Programs with BDDs Sept. 22, 2006

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.
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 & Verification - Lecture 18 1 ECE 697B (667) Spring 2006 ECE 697B (667) Spring 2006 Synthesis and Verification of Digital Systems Word-level.
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.
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.
Propositional Calculus Math Foundations of Computer Science.
Digitaalsüsteemide verifitseerimise kursus1 Formal verification: BDD BDDs applied in equivalence checking.
Combinational Logic Design CS341 Digital Logic and Computer Organization F2003.
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
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,
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.
Verification & Validation By: Amir Masoud Gharehbaghi
Computer Systems 1 Fundamentals of Computing Simplifying Boolean Expressions.
Verifying Programs with BDDs Topics Representing Boolean functions with Binary Decision Diagrams Application to program verification class-bdd.ppt
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.
Algorithmic Foundations COMP108 COMP108 Algorithmic Foundations Algorithm efficiency Prudence Wong.
White-Box Testing Statement coverage Branch coverage Path coverage
IT 60101: Lecture #121 Foundation of Computing Systems Lecture 13 Trees: Part VIII.
1 Proving Properties of Recursive Functions and Data Structures CS 270 Math Foundations of CS Jeremy Johnson.
Algorithmic Foundations COMP108 COMP108 Algorithmic Foundations Algorithm efficiency Prudence Wong
P & NP.
Analysis of Algorithms
COMP108 Algorithmic Foundations Algorithm efficiency
Computer Architecture CST 250
NP-Completeness Yin Tat Lee
ECE 667 Synthesis and Verification of Digital Systems
Propositional Calculus: Boolean Algebra and Simplification
LPSAT: A Unified Approach to RTL Satisfiability
Binary Decision Diagrams
Automatic Verification of Industrial Designs
Week 7: Gates and Circuits: PART II
Chapter 11 Limitations of Algorithm Power
NP-Complete Problems.
A logic function f in n inputs x1, x2, ...xn and
XOR Function Logic Symbol  Description  Truth Table 
Binary Decision Diagrams
A logic function f in n inputs x1, x2, ...xn and
CSE 589 Applied Algorithms Spring 1999
10 Design Verification and Test
Presentation transcript:

Verifying Programs with BDDs Sept. 22, 2006 15-213 “The course that gives CMU its Zip!” Verifying Programs with BDDs Sept. 22, 2006 Topics Representing Boolean functions with Binary Decision Diagrams Application to program verification 15-213, F’06 class08-bdd.ppt

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

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; } ? =

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 a2 + b2 = c2 by testing? a c b

Bit-Level Program Verification int abs(int x) { int mask = x>>31; return (x ^ mask) + ~mask + 1; } abs x0 x1 x2 • x31 y0 y1 y2 y31 x0 x1 x2 • x31 yi absi View computer word as 32 separate bit values Each output becomes Boolean function of inputs

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

Tabular Function Representation List every possible function value Complexity Function with n variables

Algebraic Function Representation x2 · x3 x1 · x3 f(x1, x2, x3) = (x1 + x2) · x3 Boolean Algebra Complexity Representation Determining properties of function E.g., deciding whether two expressions are equivalent

Tree Representation Truth Table Decision Tree Complexity Vertex represents decision Follow green (dashed) line for value 0 Follow red (solid) line for value 1 Function value determined by leaf value Complexity

Ordered Binary Decision Diagrams Initial Tree Reduced Graph (x1 + x2) · x3 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.

Example Functions Constants Variable Typical Function Odd Parity Unique unsatisfiable function Unique tautology Variable Treat variable as function Typical Function (x1 + x2 ) · x4 No vertex labeled x3 independent of x3 Many subgraphs shared Odd Parity Linear representation

More Complex 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!

Symbolic Execution (3-bit word size) x y v1 = ~x v2 = ~y 1 1 1 1 x2 x1 x1 x0 y y2 1 y1 y0 v1 = ~x x2 1 x1 x0 v2 = ~y y2 1 y1 y0

Symbolic Execution (cont.) v3 = v1 & v2 x2 y2 1 x1 y1 x0 y0 v4 = ~v3 x2 y2 1 x1 y1 x0 y0 v5 = x | y x2 y2 1 x1 y1 x0 y0 t = v4 == v5 1

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

Symbolic Execution v4 = ~v3 t = v4 == v5 v5 = x ^ y x = 111 y = 001 1 x1 y1 x0 y0 t = v4 == v5 x2 y2 x1 y1 x0 y0 1 x = 111 y = 001 v5 = x ^ y x2 y2 1 x1 y1 x0 y0

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

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

Why Is Multiplication Slow? Multiplication function intractable for BDDs Exponential growth, regardless of variable ordering Node Counts Bits Add Mult 4 21 155 8 41 14560 Add-4 Multiplication-4

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; }

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

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

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

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