Lecture 10 Abstract Interpretation using Fixpoints.

Slides:



Advertisements
Similar presentations
Completeness and Expressiveness
Advertisements

Abstract Interpretation Part II
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.
Lecture 11: Datalog Tuesday, February 6, Outline Datalog syntax Examples Semantics: –Minimal model –Least fixpoint –They are equivalent Naive evaluation.
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
Tutorial on Widening (and Narrowing) Hongseok Yang Seoul National University.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 13.
Review of topics Final exam : -May 2nd to May 7 th - Projects due on May 7th.
1 Basic abstract interpretation theory. 2 The general idea §a semantics l any definition style, from a denotational definition to a detailed interpreter.
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.
Programming Language Semantics Denotational Semantics Chapter 5 Based on a lecture by Martin Abadi.
Abstractions. Outline Informal intuition Why do we need abstraction? What is an abstraction and what is not an abstraction A framework for abstractions.
Discrete Mathematics Lecture 4: Sequences and Mathematical Induction
Discrete Mathematics Lecture 4 Harper Langston New York University.
From last time: reaching definitions For each use of a variable, determine what assignments could have set the value being read from the variable Information.
Discrete Structures Chapter 2 Part B Mathematical Induction
Abstract Interpretation Part I Mooly Sagiv Textbook: Chapter 4.
Administrative stuff Office hours: After class on Tuesday.
¹ -Calculus Based on: “Model Checking”, E. Clarke and O. Grumberg (ch. 6, 7) “Symbolic Model Checking: 10^20 States and Beyond”, Burch, Clark, et al “Introduction.
Data Flow Analysis Compiler Design Nov. 8, 2005.
1 Systematic Domain Design Some Remarks. 2 Best (Conservative) interpretation abstract representation Set of states concretization Abstract semantics.
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 Program Analysis Systematic Domain Design Mooly Sagiv Tel Aviv University Textbook: Principles.
Software Verification Bertrand Meyer Chair of Software Engineering Lecture 2: Axiomatic semantics.
Prof. Aiken CS 294 Lecture 21 Abstract Interpretation Part 2.
Lecture 4 Discrete Mathematics Harper Langston. Algorithms Algorithm is step-by-step method for performing some action Cost of statements execution –Simple.
Programming Language Semantics Denotational Semantics Chapter 5 Part III Based on a lecture by Martin Abadi.
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.
Abstract Interpretation (Cousot, Cousot 1977) also known as Data-Flow Analysis.
Lecture 9. Arithmetic and geometric series and mathematical induction
MIT Foundations of Dataflow Analysis Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology.
Solving fixpoint equations
Continuity ( Section 1.8) Alex Karassev. Definition A function f is continuous at a number a if Thus, we can use direct substitution to compute the limit.
Program Analysis and Verification Spring 2014 Program Analysis and Verification Lecture 11: Abstract Interpretation III Roman Manevich Ben-Gurion University.
The Integers. The Division Algorithms A high-school question: Compute 58/17. We can write 58 as 58 = 3 (17) + 7 This forms illustrates the answer: “3.
Chapter 2 Mathematical preliminaries 2.1 Set, Relation and Functions 2.2 Proof Methods 2.3 Logarithms 2.4 Floor and Ceiling Functions 2.5 Factorial and.
Program Analysis and Verification Spring 2015 Program Analysis and Verification Lecture 9: Abstract Interpretation I Roman Manevich Ben-Gurion University.
Reading and Writing Mathematical Proofs Spring 2015 Lecture 4: Beyond Basic Induction.
Lecture 11 Abstract Interpretation on Control-Flow Graphs.
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.
Program Analysis and Verification Spring 2015 Program Analysis and Verification Lecture 13: Abstract Interpretation V Roman Manevich Ben-Gurion University.
Program Analysis and Verification
Web Science & Technologies University of Koblenz ▪ Landau, Germany Models of Definite Programs.
Program Analysis and Verification
1 Numeric Abstract Domains Mooly Sagiv Tel Aviv University Adapted from Antoine Mine.
Introduction to Real Analysis Dr. Weihu Hong Clayton State University 11/11/2008.
Semilattices presented by Niko Simonson, CSS 548, Autumn 2012 Semilattice City, © 2009 Nora Shader.
Chaotic Iterations Mooly Sagiv Tel Aviv University Textbook: Principles of Program Analysis.
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.
Abstractions Eric Feron. Outline Principles of abstraction Motivating example Abstracting variables Abstracting functions Abstracting operators Recommended.
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.
Fixpoints and Reachability
Models of Definite Programs
Spring 2016 Program Analysis and Verification
Introductory Material
Program Analysis and Verification
Software analysis SET seminar.
Chapter 15 Multiple Integrals
Continuity Alex Karassev.
Background material.
Background material.
Models of Definite Programs
Introductory Material
Presentation transcript:

Lecture 10 Abstract Interpretation using Fixpoints

Notation Partial order: Least upper bound: lub, sup, Greatest lower bound: glb, inf, Least fixpoint: lfp Complete lattice: always exist

Tarski’s fixpoint theorem (A, ) complete lattice G : A  A monotonic function Postfixp = { x | G(x) x } Then G has least fixpoint, lfp(G) and it’s Postfixp So, if G(x) x then x Postfixp, so lfp(G) x Let G be also -continuous. Then { G n ( ) | n 0 } = lfp(G)

Fixpoints for Recursive Definitions Given monotonic G in complete lattice, If G(P) P then lfp(G) P Natural numbers: lfp under adding successors: G(P) = {0} {x+1|x P} lfp(G) = {0,1,2, … }(natural numbers) Take a property PP(x), let P = {x | PP(x)} What does G(P) P mean? {0} U {x+1|x P} P 0 P x P  x+1 P If so, we get that all natural numbers are in P

Structural Recursion Trees = lfp(G) where G(P) = { Leaf } U { Node(t1,x,t2) | t1  P, t2  P} To prove all trees satisfy property, prove for the set P of trees satisfying property that G(P)  P. { Leaf } U { Node(t1,x,t2) | t1  P /\ t2  P}  P Structural induction! Every inductively defined set is given as lfp(G) for some G, and this gives us an induction principle.

Concrete post Init,Good  S r  SxS Goal: show sp(Init,r*)  Good Approach: find I  S such that sp(Init,r*)  I  Good Define post : 2 S  2 S post(P) = Init U sp(P,r) – post is monotonic function on complete lattice 2 S so it has a least fixpoint. This is sp(Init,r*) – Consequence: if post(P)  P, then sp(Init,r*)  P – Remark: post is also  -continuous and join morphism: post(UC)=U{post(x)|x  C} so this is also equal to U{ post n ({}) | n ≥ 0} Strategy: find P such that post(P)  P and then check that P  Good

Example k=1; while(k < 100) { k=k+3 }; assert(k <= 255) k=1; loop {assume(k =100); assert(k <= 255) r = {(k,k’) | (k < 100 /\ k’ = k + 3) } Approximating sp({1},r*) post(P) = {1} U sp(P,r) = {1} U {k+3|k  P, k < 100} post n ({}): {}, {1}, {1,4}, …, {1,…,97},{1,…,97,100}, {1,…,97,100}

Approximate post Let apost be approximation of post, that is, post(P)  apost(P) for all sets P (e.g. take interval enclosing a set) If we find P such that apost(P)  P, then post(P)  apost(P)  P Summary: all we need is – apost that approximes post – a postfix point P of apost, ideally as small as possible, hoping to be able to prove P  Good

Domain: Representation of Invariants apost will work only on certain invariants (e.g. only intervals) Represent these invariants as another set A. Define concretization  : A  2 S post# : A  A  (post#(a)) = apost(  (a)) Then post(P)  apost(P) becomes post(  (a))   (post#(a)) This is the soundness condition.

Postfixpoint in Abstract Domain We have found a postfixpoint  (a) if  (post#(a))   (a) How to effectively check if this inclusion holds? Define an ordering on domain that is computable and satisfies: a1 a2   (a1)   (a2) If post#(a) a, then  (post#(a))   (a)  is monotonic. We need postfixpoint of  Define such that it is ordering, the nicer ordering the better (e.g. complete lattice).

Interval Approximation post(P) = {1} U {k+3|k  P /\ k < 100} post#(  ) = [1,1] post#([a,b]) = [min(1,a+3),min(b+3,102)] Soundness: post([a,b])  post#([a,b]) {1}U{k+3|a ≤ k ≤ b, k < 100}  [min(1,a+3),min(b+3,102)] (post#) n (  ): , [1,1], [1,4], …, [1,97], lfp(post#) = [1,102] We proved automatically sp({1},r*)  [1,102]

How to define post# ? One way: Galois comes to rescue Suppose  s.t. ( ,  ) is Galois connection. Then post(  (a))   (post#(a)) is equivalent to (  on right =  on left)  (post(  (a)) post#(a) So we can define: post#(a) =  (post(  (a)) Note: such post# is monotonic

Finding fixpoint of post# Compute post# iteration: (post#) n (  ) If for some n (post#) n (  )= (post#) n+1 (  ) then for this n lfp(post#) = (post#) n (  ) To help make this happen make post# monotonic design domain so post# iteration terminates in finitely many steps

Partial Order on Intervals

Interval Domain A A = , intervals w/ finite and infinite bounds Partial order a1, a2  A

Galois Connection: Monotonicity  : A  2 S  ([L,U]) = {x | L ≤ x ≤ U}  : 2 S  A  (c) = [min(c),max(c)] Prove ,  are monotonic

Galois Connection Condition  : A  2 S  ([L,U]) = {x | L ≤ x ≤ U}  : 2 S  A  (c) = [min(c),max(c)] Galois connection condition c   (a)   (c) a Prove it for case where c is bounded, a is [L,U]

Multiple variables Wish to track interval for each variable We track not [L,U] but ([L1,U1],[L2,U2]) If program state is (x,y), define  (([L1,U1],[L2,U2])) = {(x,y) | }  (p) = ([L1,U1],[L2,U2]) L1 = U1 = L2 = U2 =

Product of Partial Orders (A i, ≤ i ) partial orders for i  J (A, ≤) given by A = {f : J  U i  J A i,  i. f(i)  A i } f,g  A ordered by f ≤ g   i. f(i) ≤ i g(i) Then (A, ≤) is a partial order. Moreover: If (A i, ≤ i ) all have lub, then so does (A, ≤). If (A i, ≤ i ) all have glb, then so does (A, ≤).