Chair of Software Engineering From Program slicing to Abstract Interpretation Dr. Manuel Oriol.

Slides:



Advertisements
Similar presentations
Precise Interprocedural Analysis using Random Interpretation Sumit Gulwani George Necula UC-Berkeley.
Advertisements

Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
DATAFLOW TESTING DONE BY A.PRIYA, 08CSEE17, II- M.s.c [C.S].
Compilation 2011 Static Analysis Johnni Winther Michael I. Schwartzbach Aarhus University.
CS107 Introduction to Computer Science Lecture 2.
Finding bugs: Analysis Techniques & Tools Comparison of Program Analysis Techniques CS161 Computer Security Cho, Chia Yuan.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
1 Program Slicing Purvi Patel. 2 Contents Introduction What is program slicing? Principle of dependences Variants of program slicing Slicing classifications.
Basic Control Structures Control order of execution of statements sequential selection iteration - Repeat some action while a certain condition is true.
What is an Algorithm? (And how do we analyze one?)
Example – calculating interest until the amount doubles using a for loop: will calculate up to 1000 years, if necessary if condition decides when to terminate.
CS 536 Spring Global Optimizations Lecture 23.
Chair of Software Engineering Fundamentals of Program Analysis Dr. Manuel Oriol.
4/25/08Prof. Hilfinger CS164 Lecture 371 Global Optimization Lecture 37 (From notes by R. Bodik & G. Necula)
Abstract Interpretation Part I Mooly Sagiv Textbook: Chapter 4.
1 Program Analysis Mooly Sagiv Tel Aviv University Textbook: Principles of Program Analysis.
Software Testing and Quality Assurance
Pointer and Shape Analysis Seminar Mooly Sagiv Schriber 317 Office Hours Thursday
Prof. Fateman CS 164 Lecture 221 Global Optimization Lecture 22.
Program Analysis Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
CHAPTER 10 Recursion. 2 Recursive Thinking Recursion is a programming technique in which a method can call itself to solve a problem A recursive definition.
Week 7 - Programming II Today – more features: – Loop control – Extending if/else – Nesting of loops Debugging tools Textbook chapter 7, pages
Cormac Flanagan University of California, Santa Cruz Hybrid Type Checking.
Prof. Bodik CS 164 Lecture 16, Fall Global Optimization Lecture 16.
Handouts Software Testing and Quality Assurance Theory and Practice Chapter 5 Data Flow Testing
Software Testing and QA Theory and Practice (Chapter 4: Control Flow Testing) © Naik & Tripathy 1 Software Testing and Quality Assurance Theory and Practice.
Writing algorithms using the while-statement. Previously discussed Syntax of while-statement:
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering.
Topics in Software Dynamic White-box Testing Part 2: Data-flow Testing
Objectives Understand the basic concepts and definitions relating to testing, like error, fault, failure, test case, test suite, test harness. Explore.
Data-Flow Analysis. Approaches Static Analysis Inspections Dependence analysis Symbolic execution Software Verification Data flow analysis Concurrency.
Presented By Dr. Shazzad Hosain Asst. Prof., EECS, NSU
Introduction Algorithms and Conventions The design and analysis of algorithms is the core subject matter of Computer Science. Given a problem, we want.
Type Systems CS Definitions Program analysis Discovering facts about programs. Dynamic analysis Program analysis by using program executions.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Technology and Science, Osaka University Dependence-Cache.
1 Program Slicing Amir Saeidi PhD Student UTRECHT UNIVERSITY.
1 Program Testing (Lecture 14) Prof. R. Mall Dept. of CSE, IIT, Kharagpur.
1 Introduction to Software Testing. Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Chapter 1 2.
Reasoning about programs March CSE 403, Winter 2011, Brun.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 2.
Java Basics Hussein Suleman March 2007 UCT Department of Computer Science Computer Science 1015F.
An Undergraduate Course on Software Bug Detection Tools and Techniques Eric Larson Seattle University March 3, 2006.
Scientific Debugging. Errors in Software Errors are unexpected behaviors or outputs in programs As long as software is developed by humans, it will contain.
1/6/20161 CS 3343: Analysis of Algorithms Lecture 2: Asymptotic Notations.
1 Software Testing & Quality Assurance Lecture 13 Created by: Paulo Alencar Modified by: Frank Xu.
Fundamentals of Informatics Lecture 12 The Halting Problem Bas Luttik.
1 Iterative Program Analysis Abstract Interpretation Mooly Sagiv Tel Aviv University Textbook:
Data Flow Analysis II AModel Checking and Abstract Interpretation Feb. 2, 2011.
Engineering Computing I Chapter 3 Control Flow. Chapter 3 - Control Flow The control-flow of a language specify the order in which computations are performed.
Mid-Year Review. Coding Problems In general, solve the coding problems by doing it piece by piece. Makes it easier to think about Break parts of code.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
Chapter 15 Running Time Analysis. Topics Orders of Magnitude and Big-Oh Notation Running Time Analysis of Algorithms –Counting Statements –Evaluating.
Abstraction and Abstract Interpretation. Abstraction (a simplified view) Abstraction is an effective tool in verification Given a transition system, we.
CS223: Software Engineering Lecture 26: Software Testing.
Phoenix Based Dynamic Slicing Debugging Tool Eric Cheng Lin Xu Matt Gruskin Ravi Ramaseshan Microsoft Phoenix Intern Team (Summer '06)
Software Testing and QA Theory and Practice (Chapter 5: Data Flow Testing) © Naik & Tripathy 1 Software Testing and Quality Assurance Theory and Practice.
Software Testing.
Textbook: Principles of Program Analysis
SwE 455 Program Slicing.
Mark Weiser University of Maryland, College Park IEEE CHI, 1981
Program Slicing Baishakhi Ray University of Virginia
Software Testing (Lecture 11-a)
Lecture 5 Floyd-Hoare Style Verification
Abstract Interpretation
C. M. Overstreet Old Dominion University Spring 2006
Abstract Interpretation
The Zoo of Software Security Techniques
C. M. Overstreet Old Dominion University Fall 2005
C. M. Overstreet Old Dominion University Fall 2007
Software Testing and QA Theory and Practice (Chapter 5: Data Flow Testing) © Naik & Tripathy 1 Software Testing and Quality Assurance Theory and Practice.
Presentation transcript:

Chair of Software Engineering From Program slicing to Abstract Interpretation Dr. Manuel Oriol

2 Topics  Program Slicing  Static  Dynamic  Abstract Interpretation  Soundness  Completeness

3 Program slicing A technique for analyzing programs regarding to a specific criterion. More specifically, the analysis is meant to find the statements that participate to a result.

4 Intuition What are the statements leading to the value of b at the end? a := 1 b := 5 if (b > 3) then Result := b else a := 2 end b := a

5 Key Idea: static slicing criteria Slicing criterion: (S, {variables}) A statement, a point in the program The set of variables that matter

6 The static slice The set of statements that lead to the state of the variables at the chosen statement. Example: i := 3 fact := 1 from i := 1 until i > 10 loop fact :=fact *i last_i := i-- Middle io.put ("last I:" +last_i ) i := i + 1 end (end,i)? (end,fact)? (middle,i)?

7 Key Idea: dynamic slicing criteria Slicing criterion: (x, S q, {variables}) Input of the program The set of variables that matter Statement S in q th position

8 The dynamic slice The set of statements that lead to the state of the variables at the chosen statement given input x. Example: n := io.read_int i := 3 fact := 1 from i := 1 until i > n loop fact :=fact *i last_i := i -- Middle io.put ("last I:“ + last_i ) i := i + 1 end (10,end 1,i)? (0,end 1,fact)? (5,middle 2,i)?

9 Application: Debugging  Simpler: Easier to understand what’s wrong  Remove statements: Detect dead code  By comparing to an intended behavior: detects bugs in the behavior

10 Other Applications  Software maintenance  Testing  Optimizations

11 Abstract interpretation A technique for analyzing the programs by modeling their values and operations. It is an execution that one can make to prove facts.

12 Intuition Set of values: V::= integers Expressions: e::= e * e | i ∈ V Language: eval: e -> integers eval(i) = i eval(e1*e2) = eval(e1) x eval(e2) How can we decide on the sign of the evaluated expressions?

13 Key Idea: the Abstraction! State Abstract State State Abstract State next α α How is this called? Homomorphism γ α: abstraction function γ: concretization function

14 Abstraction Set of values: V::= integers Expressions: e::= e * e | i ∈ V Language: eval: e -> integers eval(i) = i eval(e1*e2) = eval(e1) * eval(e2) Set of abstract values: AV::= {+, -, 0} Expressions: e::= e * e | ai ∈ AV Language: aeval: e -> AV aeval(i>0) = + aeval(i<0) = - aeval(i=0) = 0 aeval(e1*e2) = aeval(e1)* aeval(e2) where +*- = - +*+=+ -*-=+ 0*av=0 av*0=0 Adding unary minus?

15 If only the world would be so great… State Abstract State State Abstract State next α α How is this called? Semi-Homomorphism ⊆

16 Abstraction Set of values: V::= integers Expressions: e::= e * e | -e | e + e | i ∈ V Language: eval: e -> integers eval(i) = i eval(-e)=-eval(e) eval(e1*e2) = eval(e1) * eval(e2) eval(e1+e2) = eval(e1) + eval(e2) Set of abstract values: AV::= {+, -, 0, T} Expressions: e::= e * e | -e | e + e | av ∈ AV Language: aeval: e -> AV aeval(integer) = … as before aeval(e1*e2) = … as before aeval(-e) = … easy ;) aeval(e1+e2) = aeval(e1)+ aeval(e2) where = T = = - 0+av=av av+0=av

17 Abstraction complete? Set of values: V::= integers Expressions: e::= e * e | -e | e + e | e/e | i ∈ V Language: eval: e -> integers eval(i) = i eval(-e)=-eval(e) eval(e1*e2) = eval(e1) * eval(e2) eval(e1+e2) = eval(e1) + eval(e2) eval(e1/e2) = eval(e1) / eval(e2) Set of abstract values: AV::= {+, -, 0, T, ⊥ } Expressions: e::= e * e | -e | e + e | e/e | av ∈ AV Language: aeval: e -> AV aeval(integer) = … as before aeval(e1*e2) = … as before aeval(-e) = … easy ;) aeval(e1/e2) = aeval(e1)/ aeval(e2) where av/0 = ⊥ av+ ⊥ = ⊥ …

18 Significance of the results?  It is sound! (the results are correct)  It is far from complete!!!!! (the results loose too much information)

19 Condition for Soundness It should be a Galois insertion: γ and α monotonic (x ⊆ y => f(x) ⊆ f(y)) for all S: S ⊆ γ ( α(S) ) α ( γ( av ) ) = av

20 Monotonic Functions In the example: for α: (S, ⊆ ) → (AV, ≤ ) for γ:(av,≤) → (S, ⊆ ) T ⊥

21 Exercise Prove that the expression is divisible by 3. Set of abstract values: AV::= {true,false,T,  } Expressions: e::= e * e | -e | e + e | e/e | ai ∈ AV Language: aeval: e -> AV aeval(3) = yes aeval(e1*e2) = yes iff aeval(e1)=yes or aeval(e2)=yes aeval(-e) = … easy ;) aeval(e1+e2) = aeval(e1) and aeval(e2) aeval(e1/e2) = true if aeval(e1) and not aeval (e2)

22 Presenting it… Usually presented through the definition of transitions… Prove that this program does not try to access a value outside the array’s definition, a of size 10 (from 1 to 10) j := 0 from i := 1 until i > 50 loop j :=j + (45 - a.item (i ) + a.item (2*i )) i :=i + 1 end

23 Using abstract interpretation…  What abstraction would you use to compute the call graph of a program?  What abstraction would you use to optimize the tests within a program?

24 Problems  How would you verify that loops terminate?  Is it sound? Is it complete?  How would you verify that a password read on the keyboard is not sent through a socket?  Is it sound? Is it complete?

25 Applications to Trusted Components  Dataflow Analysis?  Program Slicing?  Abstract Interpretation?

26 Conclusions  Program Slicing  Static  Dynamic  Abstract Interpretation  Soundness  Completeness