1 Basic abstract interpretation theory. 2 The general idea §a semantics l any definition style, from a denotational definition to a detailed interpreter.

Slides:



Advertisements
Similar presentations
Modeling issues Book: chapters 4.12, 5.4, 8.4, 10.1.
Advertisements

An Abstract Interpretation Framework for Refactoring P. Cousot, NYU, ENS, CNRS, INRIA R. Cousot, ENS, CNRS, INRIA F. Logozzo, M. Barnett, Microsoft Research.
Continuing Abstract Interpretation We have seen: 1.How to compile abstract syntax trees into control-flow graphs 2.Lattices, as structures that describe.
1 A simple abstract interpreter to compute Sign s.
1 PROPERTIES OF A TYPE ABSTRACT INTERPRETATER. 2 MOTIVATION OF THE EXPERIMENT § a well understood case l type inference in functional programming à la.
1 How to transform an analyzer into a verifier. 2 OUTLINE OF THE LECTURE a verification technique which combines abstract interpretation and Park’s fixpoint.
Inferring Disjunctive Postconditions Corneliu Popeea and Wei-Ngan Chin School of Computing National University of Singapore - ASIAN
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
Tutorial on Widening (and Narrowing) Hongseok Yang Seoul National University.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 13.
ISBN Chapter 3 Describing Syntax and Semantics.
Comp 205: Comparative Programming Languages Semantics of Imperative Programming Languages denotational semantics operational semantics logical semantics.
Foundations of Data-Flow Analysis. Basic Questions Under what circumstances is the iterative algorithm used in the data-flow analysis correct? How precise.
Software Testing and Quality Assurance
CSE 231 : Advanced Compilers Building Program Analyzers.
Worklist algorithm Initialize all d i to the empty set Store all nodes onto a worklist while worklist is not empty: –remove node n from worklist –apply.
Abstractions. Outline Informal intuition Why do we need abstraction? What is an abstraction and what is not an abstraction A framework for abstractions.
Data Flow Analysis Compiler Design October 5, 2004 These slides live on the Web. I obtained them from Jeff Foster and he said that he obtained.
Abstract Interpretation Part I Mooly Sagiv Textbook: Chapter 4.
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.
Administrative stuff Office hours: After class on Tuesday.
Data Flow Analysis Compiler Design Nov. 8, 2005.
Recap: Reaching defns algorithm From last time: reaching defns worklist algo We want to avoid using structure of the domain outside of the flow functions.
1 Combining verification and analysis. 2 CONCLUSIONS ON VERIFICATION  denotational abstract interpreters have the extra-value of being easily transformed.
1 Abstraction and Approximation via Abstract Interpretation: a systematic approach to program analysis and verification Giorgio Levi Dipartimento di Informatica,
1 Program Analysis Systematic Domain Design Mooly Sagiv Tel Aviv University Textbook: Principles.
Prof. Aiken CS 294 Lecture 21 Abstract Interpretation Part 2.
*Department of Computing Science University of Newcastle upon Tyne **Institut für Informatik, Universität Augsburg Canonical Prefixes of Petri Net Unfoldings.
Describing Syntax and Semantics
Programming Language Semantics Denotational Semantics Chapter 5 Part III Based on a lecture by Martin Abadi.
1 Program Analysis Mooly Sagiv Tel Aviv University Textbook: Principles of Program Analysis.
1 Tentative Schedule u Today: Theory of abstract interpretation u May 5 Procedures u May 15, Orna Grumberg u May 12 Yom Hatzamaut u May.
Lecture 9 Illustrations Lattices. Fixpoints Abstract Interpretation.
MIT Foundations of Dataflow Analysis Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology.
1 Iterative Program Analysis Abstract Interpretation Mooly Sagiv Tel Aviv University Textbook:
CSI 3125, Axiomatic Semantics, page 1 Axiomatic semantics The assignment statement Statement composition The "if-then-else" statement The "while" statement.
Constraint Satisfaction Problems (CSPs) CPSC 322 – CSP 1 Poole & Mackworth textbook: Sections § Lecturer: Alan Mackworth September 28, 2012.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Lecture 10 Abstract Interpretation using Fixpoints.
Universidad Nacional de ColombiaUniversidad Nacional de Colombia Facultad de IngenieríaFacultad de Ingeniería Departamento de Sistemas- 2002Departamento.
CS 267: Automated Verification Lecture 3: Fixpoints and Temporal Properties Instructor: Tevfik Bultan.
Semantics In Text: Chapter 3.
Program Analysis and Verification Spring 2015 Program Analysis and Verification Lecture 12: Abstract Interpretation IV Roman Manevich Ben-Gurion University.
2004 Hawaii Inter Conf Comp Sci1 Specifying and Proving Object- Oriented Programs Arthur C. Fleck Computer Science Department University of Iowa.
Lecture 5 1 CSP tools for verification of Sec Prot Overview of the lecture The Casper interface Refinement checking and FDR Model checking Theorem proving.
Predicate Abstraction. Abstract state space exploration Method: (1) start in the abstract initial state (2) use to compute reachable states (invariants)
Program Analysis and Verification Spring 2015 Program Analysis and Verification Lecture 13: Abstract Interpretation V Roman Manevich Ben-Gurion University.
1 Iterative Program Analysis Abstract Interpretation Mooly Sagiv Tel Aviv University Textbook:
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
Operational Semantics Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Data Flow Analysis II AModel Checking and Abstract Interpretation Feb. 2, 2011.
Semilattices presented by Niko Simonson, CSS 548, Autumn 2012 Semilattice City, © 2009 Nora Shader.
Iterative Dataflow Problems Taken largely from notes of Alex Aiken (UC Berkeley) and Martin Rinard (MIT) Dataflow information used in optimization Several.
Abstraction and Abstract Interpretation. Abstraction (a simplified view) Abstraction is an effective tool in verification Given a transition system, we.
1 Abstract interpretation Giorgio Levi Dipartimento di Informatica, Università di Pisa
Lub and glb Given a poset (S, · ), and two elements a 2 S and b 2 S, then the: –least upper bound (lub) is an element c such that a · c, b · c, and 8 d.
DFA foundations Simone Campanoni
Spring 2017 Program Analysis and Verification
Fixpoints and Reachability
Axiomatic Number Theory and Gödel’s Incompleteness Theorems
Combining Abstract Interpreters
Symbolic Implementation of the Best Transformer
Iterative Program Analysis Abstract Interpretation
Lecture 5 Floyd-Hoare Style Verification
Axiomatic semantics Points to discuss: The assignment statement
Data Flow Analysis Compiler Design
Predicate Transformers
((a)) A a and c C ((c))
I.4 Polyhedral Theory (NW)
I.4 Polyhedral Theory.
Presentation transcript:

1 Basic abstract interpretation theory

2 The general idea §a semantics l any definition style, from a denotational definition to a detailed interpreter assigning meanings to programs on a suitable concrete domain (concrete computations domain) §an abstract domain modeling some properties of concrete computations and forgetting about the remaining information (abstract computations domain) §we derive an abstract semantics, which allows us to “execute” the program on the abstract domain to compute its abstract meaning, i.e., the modeled property

3 Concrete and Abstract Domains §two complete partial orders l the partial orders reflect precision smaller is better   concrete domain ( P(C), , , C, ,  ) l has the structure of a powerset we will see later why   abstract domain ( A, ,  bottom, top, lub, glb ) l each abstract value is a description of “a set of” concrete values

4 The Sign Abstract Domain   concrete domain ( P ( Z ), , C, ,  ) sets of integers   abstract domain ( Sign, ,  bot, top, lub, glb )

5 Concretization   concrete domain ( P(C), , , C, ,  )   abstract domain ( A, ,  bottom, top, lub, glb ) §the meaning of abstract values is defined by a concretization function  : A   P(C)  a  A,  (a) is the set of concrete computations described by a l that’s why the concrete domain needs to be a powerset §the concretization function must be monotonic  a 1,a 2  A, a 1  a 2 implies  (a 1 )   (a 2 ) l concretization preserves relative precision

6 Abstraction   concrete domain ( P(C), , C, ,  ),   abstract domain ( A,  bottom, top, lub, glb )  every element of P(C) should have a unique “best” (most precise) description in A this is possible if and only if A is a Moore family closed under glb l in such a case, we can define an abstraction function  : P(C)  A  c  P(C),  (c) is the best abstract description of c l the abstraction function must be monotonic  c 1,c 2  P(C), c 1  c 2 implies  (c 1 )   (c 2 ) l abstraction preserves relative precision

7 The example of Sign  Sign  (x) = , if x= bot l {y|y>0}, if x= + l {y|y  0}, if x= 0+ l {0}, if x= 0 {y|y  0}, if x= 0- l {y|y<0}, if x= - Z, if x= top  Sign  y) = glb of bot, if y=  -, if y  {y|y<0} 0-, if y  {y|y  0} 0, if y  {0} 0+, if y  {y|y  0} +, if y  {y|y  0} top, if y  Z

8 Galois connection Galois connection (insertion)  c  P(C). c  c   a  A.  a    a (  a  A.  a    a)  mutually determine each other ( P(C), , C, ,  ) ( A,  bottom, top, lub, glb )  : A   P(C) (concretization)  : P(C)  A (abstraction)  monotonic  there may be loss of information (approximation) in describing an element of P(C) by an element of A

9 Concrete semantics  the concrete semantics is defined as the least or (greatest) fixpont of a concrete semantic evaluation function F defined on the domain C l this does not necessarily mean that the semantic definition style is denotational!  F is defined in terms of primitive semantic operations f i on C  the abstract semantic evaluation function is obtained by replacing in F each concrete operation f i by a suitable abstract operation  however, since the actual concrete domain is P(C), we need first to lift the concrete semantics lfp F to a collecting semantics defined on P(C)

10 Collecting semantics  lifting lfp F to the powerset (to get the collecting semantics) is simply a conceptual operation collecting semantics = { lfp F }  we don’t need to define a brand new collecting semantic evaluation function on P(C) we just need to reason in terms of liftings of all the primitive operations (and of F ), while designing the abstract operations and establishing their properties §in the following, by abuse of notation, we will use the same notation for the standard and the collecting (“conceptually” lifted) operations

11 Abstract operations: local correctness  an abstract operator f i  defined on A is locally correct wrt a concrete operator f i if  x 1,..,x n  P(C)  f i  x 1,..,x n )  f i   x 1 ,..,  x n  l the concrete computation step is more precise than the concretization of the “corresponding” abstract computation step l a very weak requirement, which is satisfied, for example, by an abstract operator which always computes the worst abstract value top l the real issue in the design of abstract operations is therefore precision

12 Abstract operations: optimality and completeness §correctness  x 1,..,x n  P(C)  f i  x 1,..,x n )  f i   x 1 ,..,  x n  §optimality  y 1,..,y n  A . f i   y 1,..,y n )  f i   y 1 ,..,  y n  the most precise abstract operator f i  correct wrt f i l a theoretical bound and basis for the design, rather then an implementable definition §completeness (exactness or absolute precision)  x 1,..,x n  P(C)   f i  x 1,..,x n ))  f i   x 1 ,..,  x n  no loss of information,  the abstraction of the concrete computation step is exactly the same as the result of the corresponding abstract computation step

13 Abstract operations on Sign : Times Sign

14 Abstract operations on Sign : Plus Sign

15 The Sign example  Times and Plus are the usual operations lifted to P(Z)  both Times Sign and Plus Sign are optimal (hence correct)  Times Sign is also complete (no approximation)  Plus Sign is necessarily incomplete   Sign ( Times ({2},{-3})) = Times Sign (  Sign ({2}),  Sign ({-3}))   Sign ( Plus ({2},{-3}))  Plus Sign (  Sign ({2}),  Sign ({-3}))

16 From local to global correctness §the composition of locally correct abstract operations is locally correct wrt the composition of concrete operations l composition does not preserve optimality, i.e., the composition of optimal operators may be less precise than the optimal abstract version of the composition  if we obtain F   (abstract semantic evaluation function) by replacing in F every concrete semantic operation by a corresponding (locally correct) abstract operation, the local correctness property still holds  x  P(C)   F  x)  F   x))) §local correctness implies global correctness, i.e., correctness of the abstract semantics wrt the concrete one lfp F  lfp  F   gfp F  gfp  F    ( lfp F )   lfp  F   ( gfp F )   gfp  F  §the abstraction of the concrete semantics is more precise than the abstract semantics

17  ( lfp F )  lfp F  : why computing lfp F  ?  lfp F cannot be computed in finitely many steps  steps are in general required  lfp F   can be computed in finitely many steps, if the abstract domain is finite or at least noetherian l does not contain infinite increasing chains l interesting for static program analysis, where the fixpoint computation must terminate l most program properties considered in static analysis are undecidable l we accept a loss of precision (safe approximation) in order to make the analysis feasible

18 Where does the approximation come from? §incomplete abstract operators §more execution paths in the abstract semantics l the abstract state has no information to allow deterministic choices l conditionals, pattern matching, etc. §the set of resulting abstract states is transformed into a single abstract state by an abstract lub operation

19 Approximation in abstract Sign computations §concrete state [x={3}] §if x>2 then y:=3 else y:=-5; §concrete state [x={3}, y={3}] abstract state [x=+] if x>2 then y:=3 else y:=-5; –the abstract guard “can be both true and false” –we need to abstractly execute both paths –the resulting abstract states are “merged” by performing a lub on Sign abstract state [x=+,y=top]

20 Approximation in type analysis §the following ML expression is not typed by the ML’s type inference algorithm, because it always performs a lub operation in the conditional if true then 3 else true even when the guard is valid or unsatisfiable in the abstract state

21 Applications of Abstract Interpretation §comparative semantics l a technique to reason about semantics at different level of abstraction non-noetherian abstract domain abstraction without approximation (completeness)  ( lfp F )  lfp F  §static analysis = effective computation of the abstract semantics l if the abstract domain is noetherian and the abstract operations are computationally feasible l if the abstract domain is non-noetherian or if the fixpoint computation is too complex use widening operators –which effectively compute an (upper) approximation of lfp F  »one example later

22 The abstract interpretation framework  ( P(C), , C, ,  ) (concrete domain )  ( A,  bottom, top, lub, glb ) (abstract domain )  : A   P(C) monotonic (concretization function)  : P(C)  A monotonic (abstraction function)  x  P(C)  x  x   y  A.  y    y (Galois connection)   f i   f i   |  x 1,..,x n  P(C)  f i  x 1,..,x n )  f i   x 1 ,..,  x n  (local correctness) §critical choices l the abstract domain to model the property l the (possibly optimal) correct abstract operations

23 Other approaches and extensions §there exist weaker versions of abstract interpretation l without Galois connections (e.g., concretization function only) l based on approximation operators (widening, narrowing) l without explicit abstract domain (closure operators) §the theory provides also several results on abstract domain design l how to combine domains l how to improve the precision of a domain l how to transform an abstract domain into a complete one l …... l we will look at some of these results in the last lecture