Discovering Affine Equalities Using Random Interpretation Sumit Gulwani George Necula EECS Department University of California, Berkeley.

Slides:



Advertisements
Similar presentations
Assertion Checking over Combined Abstraction of Linear Arithmetic and Uninterpreted Functions Sumit Gulwani Microsoft Research, Redmond Ashish Tiwari SRI.
Advertisements

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.
Global Value Numbering using Random Interpretation Sumit Gulwani George C. Necula CS Department University of California, Berkeley.
Precise Interprocedural Analysis using Random Interpretation Sumit Gulwani George Necula UC-Berkeley.
Program Analysis using Random Interpretation Sumit Gulwani UC-Berkeley March 2005.
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Sublinear Algorithms … Lecture 23: April 20.
Extracting Randomness From Few Independent Sources Boaz Barak, IAS Russell Impagliazzo, UCSD Avi Wigderson, IAS.
An Abstract Interpretation Framework for Refactoring P. Cousot, NYU, ENS, CNRS, INRIA R. Cousot, ENS, CNRS, INRIA F. Logozzo, M. Barnett, Microsoft Research.
Principal Component Analysis Based on L1-Norm Maximization Nojun Kwak IEEE Transactions on Pattern Analysis and Machine Intelligence, 2008.
1 Cover Algorithms and Their Combination Sumit Gulwani, Madan Musuvathi Microsoft Research, Redmond.
Bounds on Code Length Theorem: Let l ∗ 1, l ∗ 2,..., l ∗ m be optimal codeword lengths for a source distribution p and a D-ary alphabet, and let L ∗ be.
Linear Obfuscation to Combat Symbolic Execution Zhi Wang 1, Jiang Ming 2, Chunfu Jia 1 and Debin Gao 3 1 Nankai University 2 Pennsylvania State University.
1 The Monte Carlo method. 2 (0,0) (1,1) (-1,-1) (-1,1) (1,-1) 1 Z= 1 If  X 2 +Y 2  1 0 o/w (X,Y) is a point chosen uniformly at random in a 2  2 square.
Machine Learning Week 2 Lecture 1.
Program Analysis as Constraint Solving Sumit Gulwani (MSR Redmond) Ramarathnam Venkatesan (MSR Redmond) Saurabh Srivastava (Univ. of Maryland) TexPoint.
Efficient Query Evaluation on Probabilistic Databases
Automated Soundness Proofs for Dataflow Analyses and Transformations via Local Rules Sorin Lerner* Todd Millstein** Erika Rice* Craig Chambers* * University.
Infinite Horizon Problems
What is an Algorithm? (And how do we analyze one?)
Program Verification as Probabilistic Inference Sumit Gulwani Nebojsa Jojic Microsoft Research, Redmond.
Complexity 18-1 Complexity Andrei Bulatov Probabilistic Algorithms.
Computational problems, algorithms, runtime, hardness
Precise Inter-procedural Analysis Sumit Gulwani George C. Necula using Random Interpretation presented by Kian Win Ong UC Berkeley.
Program Analysis Using Randomization Sumit Gulwani, George Necula (U.C. Berkeley)
Discrete Structures Chapter 2 Part B Mathematical Induction
Global Value Numbering Using Random Interpretation OSQ Retreat, May 2003 Sumit Gulwani George Necula EECS Department University of California, Berkeley.
Randomized Analysis with Repeated Conditionals for Affine Equalities Bor-Yuh Evan Chang CS263 Final Project December 4, 2002.
Randomness in Computation and Communication Part 1: Randomized algorithms Lap Chi Lau CSE CUHK.
A Polynomial-Time Algorithm for Global Value Numbering SAS 2004 Sumit Gulwani George C. Necula.
Lecture 20: April 12 Introduction to Randomized Algorithms and the Probabilistic Method.
CS 267: Automated Verification Lecture 13: Bounded Model Checking Instructor: Tevfik Bultan.
1 2 Introduction In this lecture we’ll cover: Definition of strings as functions and vice versa Error correcting codes Low degree polynomials Low degree.
Scalable Approximate Query Processing through Scalable Error Estimation Kai Zeng UCLA Advisor: Carlo Zaniolo 1.
Abstract Interpretation (Cousot, Cousot 1977) also known as Data-Flow Analysis.
Correlation testing for affine invariant properties on Shachar Lovett Institute for Advanced Study Joint with Hamed Hatami (McGill)
Reading and Writing Mathematical Proofs
1 Automatic Refinement and Vacuity Detection for Symbolic Trajectory Evaluation Orna Grumberg Technion Haifa, Israel Joint work with Rachel Tzoref.
1 Markov Decision Processes Infinite Horizon Problems Alan Fern * * Based in part on slides by Craig Boutilier and Daniel Weld.
Conformant Probabilistic Planning via CSPs ICAPS-2003 Nathanael Hyafil & Fahiem Bacchus University of Toronto.
Program Analysis and Verification Spring 2015 Program Analysis and Verification Lecture 12: Abstract Interpretation IV Roman Manevich Ben-Gurion University.
Online Social Networks and Media
1 Embedding and Similarity Search for Point Sets under Translation Minkyoung Cho and David M. Mount University of Maryland SoCG 2008.
More on Correctness. Prime Factorization Problem: Write a program that computes all the prime factors of a given number Solution (Idea): Factors are less.
13 Aug 2013 Program Verification. Proofs about Programs Why make you study logic? Why make you do proofs? Because we want to prove properties of programs.
Random Interpretation Sumit Gulwani UC-Berkeley. 1 Program Analysis Applications in all aspects of software development, e.g. Program correctness Compiler.
This Week Lecture on relational semantics Exercises on logic and relations Labs on using Isabelle to do proofs.
NPC.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
Krishnendu ChatterjeeFormal Methods Class1 MARKOV CHAINS.
PROBABILITY AND COMPUTING RANDOMIZED ALGORITHMS AND PROBABILISTIC ANALYSIS CHAPTER 1 IWAMA and ITO Lab. M1 Sakaidani Hikaru 1.
Spring 2016 Program Analysis and Verification
Introduction to Randomized Algorithms and the Probabilistic Method
Spring 2017 Program Analysis and Verification
On the Size of Pairing-based Non-interactive Arguments
Dana Moshkovitz The Institute For Advanced Study
Propositional Calculus: Boolean Algebra and Simplification
Copyright © Cengage Learning. All rights reserved.
3.5 Minimum Cuts in Undirected Graphs
Semantics In Text: Chapter 3.
The Zoo of Software Security Techniques
Totally Asynchronous Iterative Algorithms
Reinforcement Learning (2)
Reinforcement Learning (2)
Presentation transcript:

Discovering Affine Equalities Using Random Interpretation Sumit Gulwani George Necula EECS Department University of California, Berkeley

2 Probabilistically Sound Program Analysis! Sound program analysis is hard We are used to pay in terms of –Loss of completeness or precision –Complicated algorithms –Long Running Time Can we pay in terms of soundness instead? –Judgments are unsound with low probability –We can predict and control the probability of error –Can gain simplicity and efficiency

3 The Problem of Discovering Affine Equalities Discover equalities of the form 2y + 3z = 7 –Compiler Optimizations –Loop Invariants –Translation Validation There exist polynomial time deterministic algorithms [Karr 76] –involve complicated and expensive operations We present a randomized algorithm –as complete as the deterministic algorithms –but faster and simpler (almost as simple as an interpreter)

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 Example 1 Random testing will have to exercise all the 4 paths to verify the assertions Our algorithm is similar to random testing However, we execute the program once, in a way that it captures the “effect” of all the paths

5 Idea #1: The Affine Join Operation Execute both the branches Combine the values of the variables at joins using the affine join operation © w for some randomly chosen w v 1 © w v 2 ´ w £ v 1 + (1-w) £ v 2 a := 2; b := 3; a := 4; b := 1; a = 2 © 7 4 = -10 b = 3 © 7 1 = 15 (w = 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 Example 1 Choose a random weight for each join independently. All choices of random weights verify the first assertion Almost all choices contradict the second assertion.

7 Geometric Interpretation of the Affine Join operation x y x + y = 1 x = 2 (x = 0, y = 1) (x = 1, y = 0) : State before the join : State after the join satisfies all the affine relationships that are satisfied by both (e.g. x + y = 1, z = 0) Given any relationship that is not satisfied by any of (e.g. x=2), also does not satisfy it with high probability

8 Example 2 a := x + y b := ab := 2x assert (b = 2x) TF If (x = y) Idea #1 is not enough We need to make use of the conditional x=y on the true branch

9 Idea #2: The Adjust Operation Execute multiple runs of the program in parallel Sample = Collection of states at each program point “Adjust” the sample before a conditional (by taking affine joins of the states in the sample) such that –Adjustment preserves original relationships –Adjustment satisfies the equality in the conditional Use adjusted sample on the true branch

10 Geometric Interpretation of the Adjust Operation Original Point Conditional (e 2 =0) Adjusted Point (lies on e 1 =0) (lies on e 1 =0 Å e 2 =0)

11 The Randomized Interpreter R x := e S S’ e = 0 ? True False S’ S1S1 S2S2 S1S1 S2S2 S S 1 = Adjust(S’,e) S 2 = S’ S i = S 1 i © wi S 2 i S i = S’ i [x à e]

12 Completeness and soundness of R We compare the randomized interpreter R with a suitable abstract interpreter A R mimics A with high probability –R is as complete as A –R is sound with high probability

13 The Abstract Interpreter A e = 0 ? TrueFalse T’ T1T1 T2T2 T1T1 T2T2 T T 1 = T’ [ { e = 0 } T 2 = T’ T = { g=0 | T 1 ) g=0, T 2 ) g=0 } T = T’[x’/x] [ { x = e[x’/x] } Abstract Domain = Sets of affine relationships x := e T T’

14 Completeness Theorem If T ) g = 0, then S ² g = 0 Proof: –The affine join operation preserves affine relationships –And so does the adjust operation

15 Soundness Theorem If T ) g = 0, then with high probability S ² g = 0 Error probability · –b: number of branches –j: number of joins –d: size of the field –r: number of points in the sample If j = b = 10, r = 15, d ¼ 2 32, then error probability ·

16 Loops and Fixed Point Computation The lattice of sets of affine relationships has finite depth n. Thus, the abstract interpreter A converges to a fixed point. Thus, the randomized interpreter R also converges (probabilistically) We can detect convergence by comparing the ranks of the samples in two successive iterations –rank = number of linearly independent relationships

17 Related Work Abstract interpretation on sets of affine relationships [Karr76, Cousot77] –Operations are comparatively complicated and expensive Value numbering –More of syntactic flavor than semantic Random testing –Can exhibit counterexamples but doesn’t prove assertions Equivalence testing for read-once branching programs –Similar idea of affine joins

18 Conclusion and Future Work Randomization can help achieve simplicity and efficiency at the expense of making soundness probabilistic Interesting possible extensions: –Memory –Non-Linear assignments –Inequalities –Dependent conditionals