A Numerical Abstract Domain based on Expression Abstraction + Max Operator with Application in Timing Analysis Sumit Gulwani (MSR Redmond) Bhargav Gulavani.

Slides:



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

Combining Abstract Interpreters Sumit Gulwani Microsoft Research Redmond, Group Ashish Tiwari SRI RADRAD.
A Polynomial-Time Algorithm for Global Value Numbering SAS 2004 Sumit Gulwani George C. 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.
Logical Abstract Interpretation Sumit Gulwani Microsoft Research, Redmond.
Termination Proofs from Tests
Problems and Their Classes
Continuing Abstract Interpretation We have seen: 1.How to compile abstract syntax trees into control-flow graphs 2.Lattices, as structures that describe.
Semantics Static semantics Dynamic semantics attribute grammars
SPEED: Precise & Efficient Static Estimation of Symbolic Computational Complexity Sumit Gulwani MSR Redmond TexPoint fonts used in EMF. Read the TexPoint.
Approximation Algorithms Chapter 14: Rounding Applied to Set Cover.
Inferring Disjunctive Postconditions Corneliu Popeea and Wei-Ngan Chin School of Computing National University of Singapore - ASIAN
C&O 355 Lecture 4 N. Harvey TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A.
Algorithms Recurrences. Definition – a recurrence is an equation or inequality that describes a function in terms of its value on smaller inputs Example.
Program Analysis as Constraint Solving Sumit Gulwani (MSR Redmond) Ramarathnam Venkatesan (MSR Redmond) Saurabh Srivastava (Univ. of Maryland) TexPoint.
ISBN Chapter 3 Describing Syntax and Semantics.
1/22 Programs : Semantics and Verification Charngki PSWLAB Programs: Semantics and Verification Mordechai Ben-Ari Mathematical Logic for Computer.
1 of 9 ON ALMOST LYAPUNOV FUNCTIONS Daniel Liberzon University of Illinois, Urbana-Champaign, U.S.A. TexPoint fonts used in EMF. Read the TexPoint manual.
Discovering Affine Equalities Using Random Interpretation Sumit Gulwani George Necula EECS Department University of California, Berkeley.
Lifting Abstract Interpreters to Quantified Logical Domains Sumit Gulwani, MSR Bill McCloskey, UCB Ashish Tiwari, SRI 1.
Program Verification as Probabilistic Inference Sumit Gulwani Nebojsa Jojic Microsoft Research, Redmond.
Using Statically Computed Invariants Inside the Predicate Abstraction and Refinement Loop Himanshu Jain Franjo Ivančić Aarti Gupta Ilya Shlyakhter Chao.
Assertion Checking Unified Sumit Gulwani Microsoft Research, Redmond Ashish Tiwari SRI.
Interpolants [Craig 1957] G(y,z) F(x,y)
SPEED: Statically Estimating Symbolic Computational Complexity of Programs Sumit Gulwani MSR Redmond TexPoint fonts used in EMF. Read the TexPoint manual.
PSUCS322 HM 1 Languages and Compiler Design II Formal Semantics Material provided by Prof. Jingke Li Stolen with pride and modified by Herb Mayer PSU Spring.
A Polynomial-Time Algorithm for Global Value Numbering SAS 2004 Sumit Gulwani George C. Necula.
Describing Syntax and Semantics
TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A Sumit Gulwani (Microsoft Research, Redmond, USA) Symbolic Bound Computation.
Ofer Strichman, Technion Deciding Combined Theories.
C&O 355 Lecture 2 N. Harvey TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A.
From Program Verification to Program Synthesis Saurabh Srivastava * Sumit Gulwani ♯ Jeffrey S. Foster * * University of Maryland, College Park ♯ Microsoft.
Constraint-based Invariant Inference. Invariants Dictionary Meaning: A function, quantity, or property which remains unchanged Property (in our context):
Fixed Parameter Complexity Algorithms and Networks.
Reading and Writing Mathematical Proofs
Approximating Minimum Bounded Degree Spanning Tree (MBDST) Mohit Singh and Lap Chi Lau “Approximating Minimum Bounded DegreeApproximating Minimum Bounded.
C&O 355 Mathematical Programming Fall 2010 Lecture 4 N. Harvey TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A A.
Discrete Mathematics Math Review. Math Review: Exponents, logarithms, polynomials, limits, floors and ceilings* * This background review is useful for.
Asymptotic Analysis-Ch. 3
CS 363 Comparative Programming Languages Semantics.
Program Efficiency & Complexity Analysis. Algorithm Review An algorithm is a definite procedure for solving a problem in finite number of steps Algorithm.
TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A Sumit Gulwani (Microsoft Research, Redmond) The Reachability-Bound.
Program Analysis and Verification Spring 2014 Program Analysis and Verification Lecture 4: Axiomatic Semantics I Roman Manevich Ben-Gurion University.
Chapter 3 Part II Describing Syntax and Semantics.
Program Analysis and Verification Spring 2015 Program Analysis and Verification Lecture 12: Abstract Interpretation IV Roman Manevich Ben-Gurion University.
X y x-y · 4 -y-2x · 5 -3x+y · 6 x+y · 3 Given x, for what values of y is (x,y) feasible? Need: y · 3x+6, y · -x+3, y ¸ -2x-5, and y ¸ x-4 Consider the.
C&O 355 Mathematical Programming Fall 2010 Lecture 5 N. Harvey TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AA A A.
CPSC 536N Sparse Approximations Winter 2013 Lecture 1 N. Harvey TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAAAAAAAAA.
1/6/20161 CS 3343: Analysis of Algorithms Lecture 2: Asymptotic Notations.
1 First order theories (Chapter 1, Sections 1.4 – 1.5) From the slides for the book “Decision procedures” by D.Kroening and O.Strichman.
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.
Daniel Kroening and Ofer Strichman Decision Procedures An Algorithmic Point of View Deciding Combined Theories.
1 Proving program termination Lecture 5 · February 4 th, 2008 TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Big O David Kauchak cs302 Spring Administrative Assignment 1: how’d it go? Assignment 2: out soon… Lab code.
C HAPTER 3 Describing Syntax and Semantics. D YNAMIC S EMANTICS Describing syntax is relatively simple There is no single widely acceptable notation or.
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
COMP 412, FALL Type Systems C OMP 412 Rice University Houston, Texas Fall 2000 Copyright 2000, Robert Cartwright, all rights reserved. Students.
Spring 2017 Program Analysis and Verification
Analysis of Non – Recursive Algorithms
Analysis of Non – Recursive Algorithms
Spring 2017 Program Analysis and Verification
September 4, 1997 Programming Languages (CS 550) Lecture 6 Summary Operational Semantics of Scheme using Substitution Jeremy R. Johnson TexPoint fonts.
Complexity Analysis.
CS 3343: Analysis of Algorithms
CS 3343: Analysis of Algorithms
Uri Zwick – Tel Aviv Univ.
This Lecture Substitution model
Presentation transcript:

A Numerical Abstract Domain based on Expression Abstraction + Max Operator with Application in Timing Analysis Sumit Gulwani (MSR Redmond) Bhargav Gulavani (IIT Bombay, India) TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: A A

Outline Timing Analysis = Compute symbolic complexity bounds of programs in terms of inputs (assuming unit cost for statements)  Challenges in Timing Analysis Reduce Timing Analysis to Abstract Interpretation Extend linear domain with Expression Abstraction Extend linear domain with Max Operator 1

Timing Analysis Challenges Bounds for even simple programs may be –Disjunctive (i.e., they involve max operators) –Non-linear (polynomial, logarithmic, exponential) Sometimes even proving termination is hard. We would like to compute precise bounds. 2

Simple Examples may have Disjunctive Bounds. Simple(int n) x := 0; while (x<n) x++; Simple2(int n,m) Assume(n>0); x := 0; y := 0; while (x<n) if (y<m) y++ else x++; Simple3(int n, int m) Assume (n,m > 0); x := 0; y := 0; while (x<n || y<m) x++; y++; 3 Bounds Max (0,n) n + Max(0,m) Max(n,m)

Simple Examples may have Non-linear bounds. ModularMultiply(int n) for (x:=0; x<n; x++) for (y:=0; y<n; y++); ModularSquare(int n) for (x:=0; x<n; x++) for(y:=0; y<x; y++); Simple4(int n) x := 0; y := 0; while (x<n) if (y<n) y++; else y := 0; x++; 4 Bounds n2n2 n(n+1)/2 n2n2

Even proving termination may be non-trivial. while (x<n) { x := x+y; y := y+1; } Termination proof: lexicographic polyranking fns Our tool computes bound: sqrt{2n} + max(0,-2y 0 ) + 1 while (x x) x++; else z++; } Termination proof: disjunctively well-founded ranking fns. Our tool computes bound: Max(0,y-x 0 ) + Max(0,y-z 0 ) 5

We’d also like to compute precise bounds. Assume n,m>0 and initial value of x,y is 0. while (x<n || y<m) { x++; y++; } Bound is max(n,m) while (x<n && y<m) { if (*) x++; else y++; } Bound is n+m while (x<n) { y++; if (y<m) y=0 else x++; } Bound is n £ m All examples above have same termination argument: Between any two successive (not necessarily consecutive) iterations: Either x increases and is bounded by n Or y increases and is bounded by m This implies a bound of n £ m in each case In contrast, we discover precise bounds for each of these. 6

Outline Challenges in Timing Analysis  Reduce Timing Analysis to Abstract Interpretation Extend linear domain with Expression Abstraction Extend linear domain with Max Operator 7

8 while c do S ctr := 0; while c do ctr := ctr+1; S Claim: Let u be an upper bound on loop counter ctr inside the loop. Then Max(0,u) denotes an upper bound on the number of loop iterations. Reduce Timing Analysis to Abstract Interpretation

9 Example x := 0; y := n; ctr := 0; while (x < y) ctr := ctr+1; if (*) x := x+2; else y := y-2; Abstract Interpreter produces the loop invariant: 2*ctr = x + (n-y) Æ x<y Projecting out x and y yields ctr · n/2. Thus, Max{ 0, n/2 } is an upper bound on loop iterations.

Design of our Numerical domain We need to perform abstract interpretation over a numerical domain that can reason about non- linearity as well as disjunctions. Numerical Domain = Linear Arithmetic Domain (such as Polyhedra) lifted with Expression Abstraction (for non-linearity) and Max Operator (for handling disjunctions) 10

Outline Challenges in Timing Analysis Reduce Timing Analysis to Abstract Interpretation  Extend linear domain with Expression Abstraction Extend linear domain with Max Operator 11

Extend Linear domain with Expression Abstraction Choose a set of expressions S over program variables V (closed under sub-expressions) –Extended domain represents constraints over V [ S Define semantics of operators in S using directed inference rules (T, L, R) s.t. –L and R are linear inequalities over expressions in T. –If L holds, then R holds (as per the semantics of the operators used in T). {e 1,e 2,2 e 1,2 e 2 } e 1 · e 2 +c ) 2 e 1 · 2 e 2 £ 2 c {e 1,e 2,log(e 1 ),log(e 2 )} e 1 · ce 2 Æ 0 · e 1 Æ 0 · e 2 ) log(e 1 ) · log c + log(e 2 ) {e i, ee i } i  i c i e i ¸ c Æ e ¸ 0 )  i c i ee i ¸ ce 12

Transfer Functions of Extended Domain Transfer Functions for extended domain simply apply corresponding transfer function over given linear domain –after saturating the inputs (which involves adding new linear relationships using rewrite rules). Saturate(A): do A’ := A; for each inference rule (T, L, R) for each match ¾ : T ! S if A’ ) L ¾, then A’ := A’ Æ R ¾ while ( : (A ) A’) && not tired) 13

Outline Challenges in Timing Analysis Reduce Timing Analysis to Abstract Interpretation Extend linear domain with Expression Abstraction  Extend linear domain with Max Operator 14

Extend linear domain with Max Operator Choose a subset U of program variables V –Typically U is set of inputs New domain represents constraints over V-U, but with richer constant terms, constructed using (linear combinations of) max-linear expressions over U –Example: x + 2y · Max(n+m, 2n+3) Max-linear expression over U is of the form Max(e 1,..,e n ), where e i is linear over U 15

Transfer Functions of Extended Domain Transfer Functions make use of Witness Function based on Farkas lemma. Farkas Lemma Let e, e i be some linear arithmetic expressions without any constant term. If { e i · 0 } i ) e · 0, then 9 ¸ i ¸ 0 s.t. e ´  i ¸ i e i We refer to ( ¸ i ) as Witness({e i · 0} i, e · 0). Examples: Witness(y-2x · 0 Æ x · 0, y · 0) = (1,2) 16

Join Transfer Function Join(A, B): Let A be {e i · f i } i [e i : linear over V-U, f i : max-linear over U] Let B be {e i ’ · f i ’} i A s := {e i · 0} i ; B s := {e i ’ · 0} i ; C s := Join(A s,B s ); Result := { e · f’’ | (e · 0) 2 C s } where f’’ is as follows: ( ¸ i ) := Witness(A s, e · 0); f :=  i ¸ i f i ; ( ¸ i ’) := Witness(B s, e · 0); f’ :=  i ¸ i ’ f’ i ; f’’ := Max(f,f’); Correctness Proof: It can be shown that A ) e · f’’ and B ) e · f’’ Example: Let V be {y,x,n,m} and U be {n,m} Let A be y · m and B be y–2x · k Æ x · n Then, Join(A,B) is y · max(m, k+2n) 17

Experiments ProgramTime (sec) Upper BoundExpression Set Disjunction0.03Max(0,y-x 0 ) + Max(0,y-z 0 )- Sequential0.01Max(0,n,m)- Non-linear0.02sqrt(2n) + Max(0,-2y 0 )+1y 2, y 0 2, sqrt{n} ModularMultiply0.1n2n2 jn, n 2 ModularSquare0.1n(n+1)/2j 2, n 2 Log0.08log nlog(n), log(x) Fibonacci0.142n2n 2n2n MergeSort0.07n (log n) p p20.02Max(0,z 0 )- p30.22log(s)log(i), log(m), log(s) p40.16s2s2 s 2, bs, ts p50.03m+1- p60.03N 18

Related Work Worst Case Execution Time –Wilhelm, CAV 2008 (Focus on architectural details). –Our focus is on loop bounds Non-linear (polynomial inequalities) invariant generation –Sankaranarayanan et al, POPL 2004; Muller-Olm, Seidl, POPL 2004; Bagnara et al, SAS 2005 –We allow any operator but over a fixed set of expressions Inference rule based reasoning –for decision procedures (eg, Jhala, McMillan; CAV 2007) –We show how to extend ideas to abstract interpretation. Disjunctive Numerical Domains – Our algorithm finds a specific kind of disjunctive invariants using Farkas lemma. 19

Conclusion Timing Analysis using a numerical domain extended with –Expression Abstraction (to handle non-linearity) –Max Operator (to handle disjunctions) Part 2 of the HAV 2008 –Data-structures –Bonus: A different way to discover non-linear and disjunctive bounds using only a linear numerical domain, but in a CEGAR setting. 20