Global Value Numbering using Random Interpretation Sumit Gulwani George C. Necula CS Department University of California, Berkeley.

Slides:



Advertisements
Similar presentations
TWO STEP EQUATIONS 1. SOLVE FOR X 2. DO THE ADDITION STEP FIRST
Advertisements

Chapter 4 Loops Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved
Assertion Checking over Combined Abstraction of Linear Arithmetic and Uninterpreted Functions Sumit Gulwani Microsoft Research, Redmond Ashish Tiwari SRI.
Join Algorithms for the Theory of Uninterpreted Functions Sumit Gulwani Ashish Tiwari George Necula UC-Berkeley SRI UC-Berkeley.
Combining Abstract Interpreters Sumit Gulwani Microsoft Research Redmond, Group Ashish Tiwari SRI RADRAD.
A Randomized Satisfiability Procedure for Arithmetic and Uninterpreted Function Symbols Sumit Gulwani George Necula EECS Department University of California,
A Polynomial-Time Algorithm for Global Value Numbering SAS 2004 Sumit Gulwani George C. Necula.
Path-Sensitive Analysis for Linear Arithmetic and Uninterpreted Functions SAS 2004 Sumit Gulwani George Necula EECS Department University of California,
Program Verification using Probabilistic Techniques Sumit Gulwani Microsoft Research Invited Talk: VSTTE Workshop August 2006 Joint work with George Necula.
2. Getting Started Heejin Park College of Information and Communications Hanyang University.
Precise Interprocedural Analysis using Random Interpretation Sumit Gulwani George Necula UC-Berkeley.
Program Analysis using Random Interpretation Sumit Gulwani UC-Berkeley March 2005.
Logical Abstract Interpretation Sumit Gulwani Microsoft Research, Redmond.
Bellwork If you roll a die, what is the probability that you roll a 2 or an odd number? P(2 or odd) 2. Is this an example of mutually exclusive, overlapping,
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Subspace Embeddings for the L1 norm with Applications Christian Sohler David Woodruff TU Dortmund IBM Almaden.
Cognitive Radio Communications and Networks: Principles and Practice By A. M. Wyglinski, M. Nekovee, Y. T. Hou (Elsevier, December 2009) 1 Chapter 12 Cross-Layer.
Combining Like Terms. Only combine terms that are exactly the same!! Whats the same mean? –If numbers have a variable, then you can combine only ones.
©2001 by Charles E. Leiserson Introduction to AlgorithmsDay 9 L6.1 Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 6 Prof. Erik Demaine.
Combining Like Terms. Only combine terms that are exactly the same!! Whats the same mean? –If numbers have a variable, then you can combine only ones.
0 - 0.
ALGEBRAIC EXPRESSIONS
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
MULTIPLICATION EQUATIONS 1. SOLVE FOR X 3. WHAT EVER YOU DO TO ONE SIDE YOU HAVE TO DO TO THE OTHER 2. DIVIDE BY THE NUMBER IN FRONT OF THE VARIABLE.
SUBTRACTING INTEGERS 1. CHANGE THE SUBTRACTION SIGN TO ADDITION
MULT. INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
Addition Facts
ALGEBRAIC EXPRESSIONS
Year 6 mental test 10 second questions Numbers and number system Numbers and the number system, fractions, decimals, proportion & probability.
Automata Theory Part 1: Introduction & NFA November 2002.
Automata Theory December 2001 NPDAPart 3:. 2 NPDA example Example: a calculator for Reverse Polish expressions Infix expressions like: a + log((b + c)/d)
Turing Machines January 2003 Part 2:. 2 TM Recap We have seen how an abstract TM can be built to implement any computable algorithm TM has components:
Tintu David Joy. Agenda Motivation Better Verification Through Symmetry-basic idea Structural Symmetry and Multiprocessor Systems Mur ϕ verification system.
LOGO Regression Analysis Lecturer: Dr. Bo Yuan
Chapter 4 Systems of Linear Equations; Matrices
Detection Chia-Hsin Cheng. Wireless Access Tech. Lab. CCU Wireless Access Tech. Lab. 2 Outlines Detection Theory Simple Binary Hypothesis Tests Bayes.
Hash Tables.
LT Codes Paper by Michael Luby FOCS ‘02 Presented by Ashish Sabharwal Feb 26, 2003 CSE 590vg.
This, that, these, those Number your paper from 1-10.
1 Chapter 4 The while loop and boolean operators Samuel Marateck ©2010.
1 Termination and shape-shifting heaps Byron Cook Microsoft Research, Cambridge Joint work with Josh Berdine, Dino Distefano, and.
Problems and Their Classes
6.4 Best Approximation; Least Squares
CRT RSA Algorithm Protected Against Fault Attacks WISTP - 5/10/07 Arnaud BOSCHER Spansion EMEA Robert NACIRI Oberthur Card Systems Emmanuel PROUFF Oberthur.
Addition 1’s to 20.
25 seconds left…...
Test B, 100 Subtraction Facts
Week 1.
Symbolic Analysis. Symbolic analysis tracks the values of variables in programs symbolically as expressions of input variables and other variables, which.
Vanderbilt Business Objects Users Group 1 Linking Data from Multiple Sources.
Complexity Analysis (Part II)
Less Than Matching Orgad Keller.
16. Mean Square Estimation
Week 10 Generalised functions, or distributions
Distributed Computing 5. Snapshot Shmuel Zaks ©
Epp, section 10.? CS 202 Aaron Bloomfield
Discrete Structures Chapter 6: Set Theory
1 Programming Languages (CS 550) Mini Language Interpreter Jeremy R. Johnson.
Environmental Data Analysis with MatLab Lecture 15: Factor Analysis.
1 ECE734 VLSI Arrays for Digital Signal Processing Loop Transformation.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 3 Loops.
1 Cover Algorithms and Their Combination Sumit Gulwani, Madan Musuvathi Microsoft Research, Redmond.
Discovering Affine Equalities Using Random Interpretation Sumit Gulwani George Necula EECS Department University of California, Berkeley.
Assertion Checking Unified Sumit Gulwani Microsoft Research, Redmond Ashish Tiwari SRI.
Precise Inter-procedural Analysis Sumit Gulwani George C. Necula using Random Interpretation presented by Kian Win Ong UC Berkeley.
September 21, 2010Neural Networks Lecture 5: The Perceptron 1 Supervised Function Approximation In supervised learning, we train an ANN with a set of vector.
Program Analysis Using Randomization Sumit Gulwani, George Necula (U.C. Berkeley)
Global Value Numbering Using Random Interpretation OSQ Retreat, May 2003 Sumit Gulwani George Necula EECS Department University of California, Berkeley.
A Polynomial-Time Algorithm for Global Value Numbering SAS 2004 Sumit Gulwani George C. Necula.
Random Interpretation Sumit Gulwani UC-Berkeley. 1 Program Analysis Applications in all aspects of software development, e.g. Program correctness Compiler.
Presentation transcript:

Global Value Numbering using Random Interpretation Sumit Gulwani George C. Necula CS Department University of California, Berkeley

2 Global Value Numbering Problem –To detect equivalences of expressions in a program –To obtain a complete algorithm under the assumptions: Conditionals are non-deterministic Operators are uninterpreted –F(e 1,e 2 ) = F(e 1,e 2 ), F=F, e 1 =e 1, e 2 =e 2 Existing algorithms –Precise but expensive –Efficient but imprecise Use randomization to obtain a precise, efficient but probabistically sound algorithm –Complements our POPL 03 algorithm, which handles only arithmetic

3 Outline Two key ideas in the algorithm –The affine join operation –K-linear interpretations Correctness of the algorithm Termination of the algorithm

4 assert(x = y); assert(z = F(y)); Example * x = (a,b) y = (a,b) z = (F(a),F(b)) F(y) = F( (a,b)) Typical algorithms treat as uninterpreted –Hence cannot verify the second assertion The randomized algorithm interprets –Similar to the randomized algorithm for linear arithmetic x := a; y := a; z := F(a); x := b; y := b; z := F(b);

5 Review: Randomized Algorithm for Linear Arithmetic a := 0; b := 1;a := 1; b := 0; c := b – a; d := 1 – 2b; assert (c + d = 0); assert (c = a + 1) c := 2a + b; d := b – 2; T T F F Between random testing and abstract interpretation Choose random values for input variables Execute both branches Combine the values of a variable at join points using a random affine combination

6 Review: The Affine Join Operation Affine combination of v 1 and v 2 w.r.t. weight w w (v 1,v 2 ) ´ w v 1 + (1-w) v 2 Affine join preserves common linear relationships (e.g. a+b=5) It does not introduce false relationships w.h.p. Unfortunately, non-linear relationships are not preserved (e.g. a (1+b) = 8) a := 2; b := 3; a := 4; b := 1; a = 7 (2,4) = -10 b = 7 (3,1) = 15 (w = 7)

7 a := 0; b := 1;a := 1; b := 0; c := b – a; d := 1 – 2b; assert (c + d = 0); assert (c = a + 1) a = -4, b = 5 c = -39, d = 39 c := 2a + b; d := b – 2; a = 1, b = 0a = 0, b = 1 a = -4, b = 5 c = -3, d = 3 a = -4, b = 5 c = 9, d = -9 T T F F w 1 = 5 w 2 = -3 Review: Example Choose a random weight for each join independently. All choices of random weights verify the first assertion Almost all choices contradict the second assertion

8 Uninterpreted Functions e := y | F(e 1,e 2 ) Choose a random interpretation for F Non-linear interpretation –E.g. F(e 1,e 2 ) = r 1 e r 2 e 2 2 –Preserves all equivalences in straight-line code –But not across join points Lets try linear interpretation

9 (Naïve) Linear Interpretation Encode F(e 1,e 2 ) = r 1 e 1 + r 2 e 2 Preserves all equivalences across a join point Introduces false equivalences in straight-line code F FF abcd e =e =F FF acbd e = E.g. e and e have same encodings even though e e Problem: too few random coefficients! Encodings e = r 1 (r 1 a+r 2 b) + r 2 (r 1 c+r 2 d) = r 1 2 (a)+r 1 r 2 (b)+r 2 r 1 (c)+r 2 2 (d) e = r 1 2 (a)+r 1 r 2 (c)+r 2 r 1 (b)+r 2 2 (d)

10 k-linear Interpretations Encode F(e 1,e 2 ) = R 1 e 1 + R 2 e 2 –Every expression evaluates to a vector of length k –R 1 and R 2 are random k £ k matrices –2k 2 random variables, k = o(n) Works since matrix multiplication is not commutative –e = R 1 2 (a) + R 1 R 2 (b) + R 2 R 1 (c) + R 2 2 (d) –e = R 1 2 (a) + R 1 R 2 (c) + R 2 R 1 (b) + R 2 2 (d) F(e 1,e 2 ) 1 F(e 1,e 2 ) k e11e11 …e1ke1k e21e21 …e2ke2k …

11 The Random Interpreter R y := e V1V1 V * True False V V1V1 V2V2 V1V1 V2V2 V V 1 = V[y à V(e)] V 1 = V V 2 = V V: Variables ! Vectors V(e): defined inductively as V(F(e 1,e 2 )) = R 1 V(e 1 ) + R 2 V(e 2 ) V j (e): the j th component of vector V(e) V j (y) = w (V 1 (y),V 2 (y)) for all y,j jj

12 Outline Two key ideas in the algorithm –The affine join operation –K-linear interpretations Correctness of the algorithm Termination of the algorithm

13 Completeness and soundness of R We compare the random interpreter R with a suitable abstract interpreter A R mimics A with high probability –R is as complete as A –R is (probabilistically) as sound as A

14 The Abstract Interpreter A * TrueFalse S S1S1 S2S2 S1S1 S2S2 S S 1 = S S 2 = S S = { e 1 =e 2 | S 1 ) e 1 =e 2, S 2 ) e 1 =e 2 } S 1 = S[y/y] [ { y = e[y/y] } S: set of symbolic equivalences y := e S1S1 S

15 Completeness Theorem If S ) e 1 = e 2, then V(e 1 ) = V(e 2 ) Proof: –Uninterpreted operators are modeled as linear functions –The affine join operation preserves linear relationships

16 Soundness Theorem If S ) e 1 = e 2, then with high probability V(e 1 ) V(e 2 ) Error probability · –n: number of function applications –d: size of set from which random values are chosen –t : number of repetitions If n = 100, d ¼ 2 32, t = 5, then error probability ·

17 Outline Two key ideas in the algorithm –The affine join operation –K-linear interpretations Correctness of the algorithm Termination of the algorithm

18 Loops and Fixed Point Computation The lattice of sets of equivalences has finite height n. Thus, the abstract interpreter A converges to a fixed point. Thus, the random interpreter R also converges (probabilistically) We can detect convergence by comparing the set of symbolic relationships implied by vectors in two successive iterations

19 Related Work Efficient but imprecise algorithms –Congruence partitioning [Rosen, Wegman, Zadeck, POPL 88] –Rewrite rules [Ruthing, Knoop, Steffen, SAS 99] - Balanced algorithms [Gargi PLDI 2002] Precise but inefficient algorithms –Abstract interpretation on uninterpreted functions [Kildall 73] Affine join operation –Random interpretation for linear arithmetic [Gulwani, Necula POPL 03]

20 Conclusion and Future Work Key ideas in the paper (e 1,e 2 ) = w e 1 + (1-w) e 2 –Linearity, Preserves equivalences across a join point F(e 1,e 2 ) = R 1 e 1 + R 2 e 2 –Vectors ) Introduce no false equivalence Random interpretation vs. deterministic algorithms –Linear arithmetic O(n 2 ) vs. O(n 4 ) [POPL 2003] –Uninterpreted functions O(n 3 ) vs. O(n 5 log n) [this talk] Future work –Inter-procedural analysis using random interpretation –Random interpretation for other theories –Combining two random interpreters