Top Banner
« A Tutorial on Abstract Interpretation » Patrick Cousot École normale supérieure 45 rue d’Ulm 75230 Paris cedex 05, France [email protected] www.di.ens.fr/ ~ cousot VMCAI’05 Industrial Day VMCAI’05 Industrial Day, Paris, France, January 20, 2005 1 ľ P. Cousot
168

«ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

May 27, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

« A Tutorial onAbstract Interpretation »

Patrick CousotÉcole normale supérieure

45 rue d’Ulm75230 Paris cedex 05, France

[email protected]/~cousot

VMCAI’05 Industrial Day

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 1 — ! P. Cousot

Page 2: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Static analysisby abstract interpretation

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 2 — ! P. Cousot

Page 3: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example of static analysis (input){n0>=0}n := n0;

{n0=n,n0>=0}i := n;

{n0=i,n0=n,n0>=0}while (i <> 0 ) do

{n0=n,i>=1,n0>=i}j := 0;

{n0=n,j=0,i>=1,n0>=i}while (j <> i) do

{n0=n,j>=0,i>=j+1,n0>=i}j := j + 1

{n0=n,j>=1,i>=j,n0>=i}od;

{n0=n,i=j,i>=1,n0>=i}i := i - 1

{i+1=j,n0=n,i>=0,n0>=i+1}od

{n0=n,i=0,n0>=0}

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 3 — ! P. Cousot

Page 4: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example of static analysis (output){n0>=0}n := n0;

{n0=n,n0>=0}i := n;

{n0=i,n0=n,n0>=0}while (i <> 0 ) do

{n0=n,i>=1,n0>=i}j := 0;

{n0=n,j=0,i>=1,n0>=i}while (j <> i) do

{n0=n,j>=0,i>=j+1,n0>=i}j := j + 1

{n0=n,j>=1,i>=j,n0>=i}od;

{n0=n,i=j,i>=1,n0>=i}i := i - 1

{i+1=j,n0=n,i>=0,n0>=i+1}od

{n0=n,i=0,n0>=0}

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 3 — ! P. Cousot

Page 5: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example of static analysis (safety){n0>=0}n := n0;

{n0=n,n0>=0}i := n; n0 must be initially nonnegative

(otherwise the program does notterminate properly)

{n0=i,n0=n,n0>=0}while (i <> 0 ) do

{n0=n,i>=1,n0>=i}j := 0;

{n0=n,j=0,i>=1,n0>=i}while (j <> i) do

{n0=n,j>=0,i>=j+1,n0>=i}j := j + 1 j < n0 so no upper overflow

{n0=n,j>=1,i>=j,n0>=i}od;

{n0=n,i=j,i>=1,n0>=i}i := i - 1 i > 0 so no lower overflow

{i+1=j,n0=n,i>=0,n0>=i+1}od

{n0=n,i=0,n0>=0}

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 3 — ! P. Cousot

Page 6: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Static analysis by abstract interpretation

Verification: define and prove automatically a property ofthe possible behaviors of a complex computer pro-gram (example: program semantics);

Abstraction: the reasoning/calculus can be done on an ab-straction of these behaviors dealing only with thoseelements of the behaviors related to the consideredproperty;

Theory: abstract interpretation.

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 4 — ! P. Cousot

Page 7: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example of static analysis

Verification: absence of runtime errors;Abstraction: polyhedral abstraction (a!ne inequalities);Theory: abstract interpretation.

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 5 — ! P. Cousot

Page 8: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

A very informal introductionto the principles ofabstract interpretation

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 6 — ! P. Cousot

Page 9: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Semantics

The concrete semantics of a program formalizes (is amathematical model of) the set of all its possible execu-tions in all possible execution environments.

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 7 — ! P. Cousot

Page 10: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: Possible behaviors

x(t)

t

!"##$%&'()*+,'-)"*$'#

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 8 — ! P. Cousot

Page 11: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Undecidability

– The concrete mathematical semantics of a program isan “tinfinite” mathematical object, not computable;– All non trivial questions on the concrete program se-mantics are undecidable.Example: termination– Assume termination(P) would always terminates andreturns true i" P always terminates on all input data;– The following program yields a contradiction

P ” while termination(P) do skip od.

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 9 — ! P. Cousot

Page 12: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: Safety properties

The safety properties of a program express that no possi-ble execution in any possible execution environment canreach an erroneous state.

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 10 — ! P. Cousot

Page 13: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: Safety property

x(t)

t

."*%$//'0(1"0'

!"##$%&'()*+,'-)"*$'#

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 11 — ! P. Cousot

Page 14: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Safety proofs

– A safety proof consists in proving that the intersectionof the program concrete semantics and the forbiddenzone is empty;– Undecidable problem (the concrete semantics is notcomputable);– Impossible to provide completely automatic answerswith finite computer resources and neither human in-teraction nor uncertainty on the answer 1.

1 e.g. probabilistic answer.

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 12 — ! P. Cousot

Page 15: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Test/debugging

– consists in considering a subset of the possible execu-tions;– not a correctness proof;– absence of coverage is the main problem.

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 13 — ! P. Cousot

Page 16: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: Property test/simulation

x(t)

t

2'#)("3(+(3'4()*+,'-)"*$'#

."*%$//'0(1"0'

!"##$%&'()*+,'-)"*$'#

5**"*(666

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 14 — ! P. Cousot

Page 17: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Abstract interpretation

– consists in considering an abstract semantics, that isto say a superset of the concrete semantics of the pro-gram;– hence the abstract semantics covers all possible con-crete cases;– correct: if the abstract semantics is safe (does not in-tersect the forbidden zone) then so is the concrete se-mantics

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 15 — ! P. Cousot

Page 18: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: Abstract interpretation

x(t)

t

7%#)*+-)$"0("3()8'()*+,'-)"*$'#

."*%$//'0(1"0'

!"##$%&'()*+,'-)"*$'#

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 16 — ! P. Cousot

Page 19: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Formal methods

Formal methods are abstract interpretations, which dif-fer in the way to obtain the abstract semantics:– “model checking”:- the abstract semantics is given manually by the user;- in the form of a finitary model of the program exe-cution;- can be computed automatically, by techniques rele-vant to static analysis.

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 17 — ! P. Cousot

Page 20: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

– “deductive methods”:- the abstract semantics is specified by verification con-ditions;- the user must provide the abstract semantics in theform of inductive arguments (e.g. invariants);- can be computed automatically by methods relevantto static analysis.

– “static analysis”: the abstract semantics is computedautomatically from the program text according to pre-defined abstractions (that can sometimes be tailoredautomatically/manually by the user).

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 18 — ! P. Cousot

Page 21: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Required properties of the abstract semantics

– sound so that no possible error can be forgotten;– precise enough (to avoid false alarms);– as simple/abstract as possible (to avoid combinatorialexplosion phenomena).

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 19 — ! P. Cousot

Page 22: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: The most abstract correctand precise semantics

x(t)

t

."*%$//'0(1"0'

!"##$%&'()*+,'-)"*$'#

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 20 — ! P. Cousot

Page 23: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: Erroneous abstraction — I

x(t)

t

5**"0'"9#()*+,'-)"*:(+%#)*+-)$"0

."*%$//'0(1"0'

!"##$%&'()*+,'-)"*$'#

5**"*(666

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 21 — ! P. Cousot

Page 24: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: Erroneous abstraction — II

x(t)

t

5**"0'"9#()*+,'-)"*:(+%#)*+-)$"0

."*%$//'0(1"0'

!"##$%&'()*+,'-)"*$'#

5**"*(666

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 22 — ! P. Cousot

Page 25: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: Imprecision ) false alarms

x(t)

t

;<=*'-$#'()*+,'-)"*:(+%#)*+-)$"0

."*%$//'0(1"0'

!"##$%&'()*+,'-)"*$'#

.+&#'(+&+*<

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 23 — ! P. Cousot

Page 26: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Abstract domains

Standard abstractions– that serve as a basis for the design of static analyzers:- abstract program data,- abstract program basic operations;- abstract program control (iteration, procedure, con-currency, . . . );

– can be parametrized to allow for manual adaptationto the application domains.

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 24 — ! P. Cousot

Page 27: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: Standard abstractionby intervals

x(t)

t

;<=*'-$#'()*+,'-)"*:(+%#)*+-)$"0(%:($0)'*>+&#

."*%$//'0(1"0'

!"##$%&'()*+,'-)"*$'#

.+&#'(+&+*<#

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 25 — ! P. Cousot

Page 28: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: A more refined abstraction

x(t)

t

?'3$0'<'0)("3($0)'*>+&#

."*%$//'0(1"0'

!"##$%&'()*+,'-)"*$'#

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 26 — ! P. Cousot

Page 29: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

A very informal introductionto static analysisalgorithms

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 27 — ! P. Cousot

Page 30: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Standard operational semantics

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 28 — ! P. Cousot

Page 31: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Standard semantics

– Start from a standard operational semantics that de-scribes formally:- states that is data values of program variables,- transitions that is elementary computation steps;– Consider traces that is successions of states correspond-ing to executions described by transitions (possibly in-finite).

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 29 — ! P. Cousot

Page 32: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: Small-steps transitionsemantics

x(t)

t

!"##$%&'(/$#-*')'(

)*+,'-)"*$'#

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 30 — ! P. Cousot

Page 33: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Small-steps transition semantics ofan assignment

int x;...l:

x := x + 1;l’:

fl : x = v ! l0 : x = v + 1 j v 2 [min_int; max_int` 1]g[ fl : x = max_int! l0 : x = ˙g (runtime error)

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 31 — ! P. Cousot

Page 34: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Small-steps transition semantics ofa loop

l1:x := 1;

l2:while x < 10 do

l3:x := x + 1

l4:od

l5:

l1 : : : :l1 : x = `1l1 : x = 0l1 : x = 1l1 : : : :

3

777775

&!%

l2 : x = 1

l2 : x = 1! l3 : x = 1l3 : x = 1! l4 : x = 2l4 : x = 2! l3 : x = 2l3 : x = 2! l4 : x = 3: : :l4 : x = 10! l5 : x = 10

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 32 — ! P. Cousot

Page 35: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Trace semantics of loop

l1:x := 1;

l2:while x < 10 do

l3:x := x + 1

l4:od

l5:l1 : : : :l1 : x = `1l1 : x = 0l1 : x = 1l1 : : : :

3

777775

&!%

l2 : x = 1! l3 : x = 1! l4 : x = 2!

l3 : x = 2! l4 : x = 3 : : :! l4 : x = 10! l5 : x = 10VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 33 — ! P. Cousot

Page 36: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Transition systems

– hS; t!i where:- S is a set of states/vertices/. . .

- t! 2 }(SˆS) is a transition relation/set of arcs/. . .

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 34 — ! P. Cousot

Page 37: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Collecting semanticsin fixpoint form

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 35 — ! P. Cousot

Page 38: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Collecting semantics

– consider all traces simultaneously;– collecting semantics:- sets of states that describe data values of programvariables on all possible trajectories;- set of states transitions that is simultaneous elemen-tary computation steps on all possible trajectories;

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 36 — ! P. Cousot

Page 39: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: sets of states

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 37 — ! P. Cousot

Page 40: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: set of states transitions

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 38 — ! P. Cousot

Page 41: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Reachable states of a transitionsystem

I

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 39 — ! P. Cousot

Page 42: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Reachable states in fixpoint form

F (X) = I [ fs0 j 9s 2 X : s t! s0g

R = lfp„

; F

=+1[

n=0

Fn(;) where f0(x) = xfn+1(x) = f(fn(x))

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 40 — ! P. Cousot

Page 43: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example of fixpoint iterationfor reachable states lfp

„; –X

. I [ fs0 j 9s 2 X : s t! s0g

I

F ! " F ! " F ! " F ! "# $ %@ A B 0

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 41 — ! P. Cousot

Page 44: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example of fixpoint iterationfor reachable states lfp

„; –X

. I [ fs0 j 9s 2 X : s t! s0g

!

F ! " F ! " F ! " F ! "# $ %@ A B 0

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 41 — ! P. Cousot

Page 45: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example of fixpoint iterationfor reachable states lfp

„; –X

. I [ fs0 j 9s 2 X : s t! s0g

!

F ! " F ! " F ! " F ! "# $ %@ A B 0

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 41 — ! P. Cousot

Page 46: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example of fixpoint iterationfor reachable states lfp

„; –X

. I [ fs0 j 9s 2 X : s t! s0g

!

F ! " F ! " F ! " F ! "# $ %@ A B 0

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 41 — ! P. Cousot

Page 47: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example of fixpoint iterationfor reachable states lfp

„; –X

. I [ fs0 j 9s 2 X : s t! s0g

!

F ! " F ! " F ! " F ! "# $ %@ A B 0

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 41 — ! P. Cousot

Page 48: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Abstraction by Galois connections

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 42 — ! P. Cousot

Page 49: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Abstracting sets (i.e. properties)

– Choose an abstract domain, replacing sets of objects(states, traces, . . . ) S by their abstraction ¸(S)– The abstraction function ¸ maps a set of concrete ob-jects to its abstract interpretation;– The inverse concretization function ‚ maps an abstractset of objects to concrete ones;– Forget no concrete objects: (abstraction from above)S „ ‚(¸(S)).

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 43 — ! P. Cousot

Page 50: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Interval abstraction ¸

!

"

!!"

#

$$

fx : [1; 99]; y : [2; 77]g

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 44 — ! P. Cousot

Page 51: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Interval concretization ‚

!

"

!!"

#

$$

fx : [1; 99]; y : [2; 77]g

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 45 — ! P. Cousot

Page 52: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

The abstraction ¸ is monotone

!

"

!!"

#

%&

&!''

("

!)

fx : [33; 89]; y : [48; 61]gv

fx : [1; 99]; y : [2; 90]g

X „ Y ) ¸(X) v ¸(Y )

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 46 — ! P. Cousot

Page 53: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

The concretization ‚ is monotone

fx : [33; 89]; y : [48; 61]gv

fx : [1; 99]; y : [2; 90]g

X v Y ) ‚(X) „ ‚(Y )

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 47 — ! P. Cousot

Page 54: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

The ‚ ‹ ¸ composition is extensive

!

"

!!"

#

$$

fx : [1; 99]; y : [2; 77]g

X „ ‚ ‹ ¸(X)

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 48 — ! P. Cousot

Page 55: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

The ¸ ‹ ‚ composition is reductive

!

"

!!"

#

$$

fx : [1; 99]; y : [2; 77]g==v

fx : [1; 99]; y : [2; 77]g

¸ ‹ ‚(Y ) ==v Y

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 49 — ! P. Cousot

Page 56: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Correspondance between concrete andabstract properties

– The pair h¸; ‚i is a Galois connection:

h}(S); „i ` ! `¸‚hD; vi

– h}(S); „i ``!! ``¸

‚hD; vi when ¸ is onto (equivalently

¸ ‹ ‚ = 1 or ‚ is one-to-one).

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 50 — ! P. Cousot

Page 57: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Galois connection

hD;„i ` ! `¸‚hD;vi

i" 8x; y 2 D : x „ y =) ¸(x) v ¸(y)

^ 8x; y 2 D : x v y =) ‚(x) „ ‚(y)^ 8x 2 D : x „ ‚(¸(x))

^ 8y 2 D : ¸(‚(y)) v x

i" 8x 2 D; y 2 D : ¸(x) v y () x „ ‚(y)

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 51 — ! P. Cousot

Page 58: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: Interval abstraction

x(t)

t;0)'*>+&(4$)8(#=9*$"9#(#)+)'#

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 52 — ! P. Cousot

Page 59: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: Abstract transitions

x(t)

t;0)'*>+&()*+0#$)$"0

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 53 — ! P. Cousot

Page 60: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Interval transition semantics ofassignments

int x;...l:

x := x + 1;l’:

fl : x 2 [‘; h]! l0 : x 2 [l+ 1;min(h+ 1; max_int)] [f˙ j h = max_intg j ‘ » hg

where [‘; h] = ; when h < ‘.

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 54 — ! P. Cousot

Page 61: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Function abstraction#

$

#

*+,-./0- 123/45

6250.7-7 123/45

F] = ¸ ‹ F ‹ ‚i:e: F ] = ! ‹ F

hP; „i ` ! `¸‚hQ; vi )

hP mon7 ! P; _„i `` ` ` `! ` ` ` ``–F .¸‹F ‹‚

–F ] . ‚‹F]‹¸hQ mon7 ! Q; _vi

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 55 — ! P. Cousot

Page 62: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Set of traces to trace of intervalsabstraction

Set of traces:

¸1 #

Trace of sets:

¸2 #

Trace of intervals

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 56 — ! P. Cousot

Page 63: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Set of traces to reachable statesabstraction

Set of traces:

¸1 #

Trace of sets:

¸3 #

Reachable states

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 57 — ! P. Cousot

Page 64: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Composition of Galois Connections

The composition of Galois connections:

hL; »i ` ! `¸1

‚1 hM; vi

and:

hM; vi ` ! `¸2

‚2 hN; —i

is a Galois connection:

hL; »i `` `! ` ``¸2‹¸1

‚1‹‚2 hN; —i

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 58 — ! P. Cousot

Page 65: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Abstract semantics in fixpoint form

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 59 — ! P. Cousot

Page 66: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of sets of statesin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 60 — ! P. Cousot

Page 67: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of sets of statesin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 60 — ! P. Cousot

Page 68: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of sets of statesin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 60 — ! P. Cousot

Page 69: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of sets of statesin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 60 — ! P. Cousot

Page 70: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of sets of statesin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 60 — ! P. Cousot

Page 71: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of sets of statesin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 60 — ! P. Cousot

Page 72: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of sets of statesin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 60 — ! P. Cousot

Page 73: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of sets of statesin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 60 — ! P. Cousot

Page 74: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of sets of statesin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 60 — ! P. Cousot

Page 75: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of sets of statesin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 60 — ! P. Cousot

Page 76: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of sets of statesin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 60 — ! P. Cousot

Page 77: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of sets of statesin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 60 — ! P. Cousot

Page 78: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of sets of statesin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 60 — ! P. Cousot

Page 79: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of sets of statesin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 60 — ! P. Cousot

Page 80: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of intervalsin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 61 — ! P. Cousot

Page 81: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of intervalsin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 61 — ! P. Cousot

Page 82: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of intervalsin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 61 — ! P. Cousot

Page 83: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of intervalsin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 61 — ! P. Cousot

Page 84: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of intervalsin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 61 — ! P. Cousot

Page 85: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of intervalsin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 61 — ! P. Cousot

Page 86: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of intervalsin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 61 — ! P. Cousot

Page 87: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of intervalsin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 61 — ! P. Cousot

Page 88: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of intervalsin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 61 — ! P. Cousot

Page 89: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of intervalsin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 61 — ! P. Cousot

Page 90: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of intervalsin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 61 — ! P. Cousot

Page 91: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of intervalsin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 61 — ! P. Cousot

Page 92: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of intervalsin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 61 — ! P. Cousot

Page 93: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of intervalsin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 61 — ! P. Cousot

Page 94: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: traces of intervalsin fixpoint form

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 61 — ! P. Cousot

Page 95: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Approximate fixpoint abstraction

F

F]

Concrete domain

Abstract domain

F F F F FF

F] F

] F]

F]

â Approximationrelation

?

?]

v

F] = ¸ ‹ F ‹ ‚ ) ¸(lfpF ) v lfpF]

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 62 — ! P. Cousot

Page 96: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

approximate/exact fixpoint abstraction

Exact Abstraction:

¸(lfpF ) = lfpF]

Approximate Abstraction:

¸(lfpF ) @] lfpF]

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 63 — ! P. Cousot

Page 97: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Convergence accelerationby widening/narrowing

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 64 — ! P. Cousot

Page 98: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: upward iterationwith widening

x(t)

t

;0$)$+&(#)+)'#

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 65 — ! P. Cousot

Page 99: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: upward iterationwith widening

x(t)

t;0)'*>+&()*+0#$)$"0

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 65 — ! P. Cousot

Page 100: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: upward iterationwith widening

x(t)

t;0)'*>+&()*+0#$)$"0(4$)8(4$/'0$0C

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 65 — ! P. Cousot

Page 101: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: upward iterationwith widening

x(t)

t

;0)'*>+&()*+0#$)$"0(4$)8(4$/'0$0C

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 65 — ! P. Cousot

Page 102: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: stability of theupward iteration

x(t)

t

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 66 — ! P. Cousot

Page 103: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Convergence acceleration with widening

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 67 — ! P. Cousot

Page 104: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Widening operatorA widening operator

!2 Lˆ L 7! L is such that:

– Correctness:- 8x; y 2 L : ‚(x) v ‚(x

!y)

- 8x; y 2 L : ‚(y) v ‚(x!y)

– Convergence:- for all increasing chains x0 v x1 v . . . , the in-creasing chain defined by y0 = x0, . . . , yi+1 =yi

!xi+1, . . . is not strictly increasing.

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 68 — ! P. Cousot

Page 105: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Fixpoint approximation with wideningThe upward iteration sequence with widening:– X0 = ?- (infimum)– Xi+1 = Xi if F (Xi) v Xi

= Xi!F (Xi) otherwise

is ultimately stationary and its limit A is a sound upperapproximation of lfp

?-F :lfp?-F v A

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 69 — ! P. Cousot

Page 106: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Interval widening– L = f?g[f[‘; u] j ‘; u 2 Z[f`1g^u 2 Z[fg^‘ » ug– The widening extrapolates unstable bounds to infinity:

?!X = X

X!? = X

[‘0; u0]![‘1; u1] = [if ‘1 < ‘0 then `1 else ‘0;

if u1 > u0 then +1 else u0]

Not monotone. For example [0; 1] v [0; 2] but [0; 1]!

[0; 2] = [0; +1] 6v [0; 2] = [0; 2]![0; 2]

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 70 — ! P. Cousot

Page 107: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Interval analysis (1975)Program to be analyzed:

x := 1;1:

while x < 10000 do2:

x := x + 13:

od;4:

8>>><

>>>:

X1 = [1; 1]X2 = (X1 [X3) \ [`1; 9999]X3 = X2 ˘ [1; 1]X4 = (X1 [X3) \ [10000;+1]

8>>><

>>>:

X1 = [1; 1]X2 = (X1 [X3) \ [`1; 9999]X3 = X2 ˘ [1; 1]X4 = (X1 [X3) \ [10000;+1]

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 71 — ! P. Cousot

Page 108: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Interval analysis (1975)Equations (abstract interpretation of the semantics):

x := 1;1:

while x < 10000 do2:

x := x + 13:

od;4:

8>>><

>>>:

X1 = [1; 1]X2 = (X1 [X3) \ [`1; 9999]X3 = X2 ˘ [1; 1]X4 = (X1 [X3) \ [10000;+1]

8>>><

>>>:

X1 = [1; 1]X2 = (X1 [X3) \ [`1; 9999]X3 = X2 ˘ [1; 1]X4 = (X1 [X3) \ [10000;+1]

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 72 — ! P. Cousot

Page 109: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Interval analysis (1975)Resolution by chaotic increasing iteration:

x := 1;1:

while x < 10000 do2:

x := x + 13:

od;4:

8>>><

>>>:

X1 = [1; 1]X2 = (X1 [X3) \ [`1; 9999]X3 = X2 ˘ [1; 1]X4 = (X1 [X3) \ [10000;+1]

8>>><

>>>:

X1 = ;X2 = ;X3 = ;X4 = ;

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 73 — ! P. Cousot

Page 110: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Interval analysis (1975)Increasing chaotic iteration:

x := 1;1:

while x < 10000 do2:

x := x + 13:

od;4:

8>>><

>>>:

X1 = [1; 1]X2 = (X1 [X3) \ [`1; 9999]X3 = X2 ˘ [1; 1]X4 = (X1 [X3) \ [10000;+1]

8>>><

>>>:

X1 = [1; 1]X2 = ;X3 = ;X4 = ;

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 74 — ! P. Cousot

Page 111: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Interval analysis (1975)Increasing chaotic iteration:

x := 1;1:

while x < 10000 do2:

x := x + 13:

od;4:

8>>><

>>>:

X1 = [1; 1]X2 = (X1 [X3) \ [`1; 9999]X3 = X2 ˘ [1; 1]X4 = (X1 [X3) \ [10000;+1]

8>>><

>>>:

X1 = [1; 1]X2 = [1; 1]X3 = ;X4 = ;

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 74 — ! P. Cousot

Page 112: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Interval analysis (1975)Increasing chaotic iteration:

x := 1;1:

while x < 10000 do2:

x := x + 13:

od;4:

8>>><

>>>:

X1 = [1; 1]X2 = (X1 [X3) \ [`1; 9999]X3 = X2 ˘ [1; 1]X4 = (X1 [X3) \ [10000;+1]

8>>><

>>>:

X1 = [1; 1]X2 = [1; 1]X3 = [2; 2]X4 = ;

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 74 — ! P. Cousot

Page 113: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Interval analysis (1975)Increasing chaotic iteration:

x := 1;1:

while x < 10000 do2:

x := x + 13:

od;4:

8>>><

>>>:

X1 = [1; 1]X2 = (X1 [X3) \ [`1; 9999]X3 = X2 ˘ [1; 1]X4 = (X1 [X3) \ [10000;+1]

8>>><

>>>:

X1 = [1; 1]X2 = [1; 2]X3 = [2; 2]X4 = ;

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 74 — ! P. Cousot

Page 114: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Interval analysis (1975)Increasing chaotic iteration: convergence !

x := 1;1:

while x < 10000 do2:

x := x + 13:

od;4:

8>>><

>>>:

X1 = [1; 1]X2 = (X1 [X3) \ [`1; 9999]X3 = X2 ˘ [1; 1]X4 = (X1 [X3) \ [10000;+1]

8>>><

>>>:

X1 = [1; 1]X2 = [1; 2]X3 = [2; 3]X4 = ;

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 74 — ! P. Cousot

Page 115: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Interval analysis (1975)Increasing chaotic iteration: convergence !!

x := 1;1:

while x < 10000 do2:

x := x + 13:

od;4:

8>>><

>>>:

X1 = [1; 1]X2 = (X1 [X3) \ [`1; 9999]X3 = X2 ˘ [1; 1]X4 = (X1 [X3) \ [10000;+1]

8>>><

>>>:

X1 = [1; 1]X2 = [1; 3]X3 = [2; 3]X4 = ;

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 74 — ! P. Cousot

Page 116: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Interval analysis (1975)Increasing chaotic iteration: convergence !!!

x := 1;1:

while x < 10000 do2:

x := x + 13:

od;4:

8>>><

>>>:

X1 = [1; 1]X2 = (X1 [X3) \ [`1; 9999]X3 = X2 ˘ [1; 1]X4 = (X1 [X3) \ [10000;+1]

8>>><

>>>:

X1 = [1; 1]X2 = [1; 3]X3 = [2; 4]X4 = ;

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 74 — ! P. Cousot

Page 117: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Interval analysis (1975)Increasing chaotic iteration: convergence !!!!

x := 1;1:

while x < 10000 do2:

x := x + 13:

od;4:

8>>><

>>>:

X1 = [1; 1]X2 = (X1 [X3) \ [`1; 9999]X3 = X2 ˘ [1; 1]X4 = (X1 [X3) \ [10000;+1]

8>>><

>>>:

X1 = [1; 1]X2 = [1; 4]X3 = [2; 4]X4 = ;

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 74 — ! P. Cousot

Page 118: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Interval analysis (1975)Increasing chaotic iteration: convergence !!!!!

x := 1;1:

while x < 10000 do2:

x := x + 13:

od;4:

8>>><

>>>:

X1 = [1; 1]X2 = (X1 [X3) \ [`1; 9999]X3 = X2 ˘ [1; 1]X4 = (X1 [X3) \ [10000;+1]

8>>><

>>>:

X1 = [1; 1]X2 = [1; 4]X3 = [2; 5]X4 = ;

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 74 — ! P. Cousot

Page 119: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Interval analysis (1975)Increasing chaotic iteration: convergence !!!!!!

x := 1;1:

while x < 10000 do2:

x := x + 13:

od;4:

8>>><

>>>:

X1 = [1; 1]X2 = (X1 [X3) \ [`1; 9999]X3 = X2 ˘ [1; 1]X4 = (X1 [X3) \ [10000;+1]

8>>><

>>>:

X1 = [1; 1]X2 = [1; 5]X3 = [2; 5]X4 = ;

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 74 — ! P. Cousot

Page 120: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Interval analysis (1975)Increasing chaotic iteration: convergence !!!!!!!

x := 1;1:

while x < 10000 do2:

x := x + 13:

od;4:

8>>><

>>>:

X1 = [1; 1]X2 = (X1 [X3) \ [`1; 9999]X3 = X2 ˘ [1; 1]X4 = (X1 [X3) \ [10000;+1]

8>>><

>>>:

X1 = [1; 1]X2 = [1; 5]X3 = [2; 6]X4 = ;

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 74 — ! P. Cousot

Page 121: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Interval analysis (1975)Convergence speed-up by widening:

x := 1;1:

while x < 10000 do2:

x := x + 13:

od;4:

8>>><

>>>:

X1 = [1; 1]X2 = (X1 [X3) \ [`1; 9999]X3 = X2 ˘ [1; 1]X4 = (X1 [X3) \ [10000;+1]

8>>><

>>>:

X1 = [1; 1]X2 = [1;+1] ( wideningX3 = [2; 6]X4 = ;

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 75 — ! P. Cousot

Page 122: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Interval analysis (1975)Decreasing chaotic iteration:

x := 1;1:

while x < 10000 do2:

x := x + 13:

od;4:

8>>><

>>>:

X1 = [1; 1]X2 = (X1 [X3) \ [`1; 9999]X3 = X2 ˘ [1; 1]X4 = (X1 [X3) \ [10000;+1]

8>>><

>>>:

X1 = [1; 1]X2 = [1;+1]X3 = [2;+1]X4 = ;

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 76 — ! P. Cousot

Page 123: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Interval analysis (1975)Decreasing chaotic iteration:

x := 1;1:

while x < 10000 do2:

x := x + 13:

od;4:

8>>><

>>>:

X1 = [1; 1]X2 = (X1 [X3) \ [`1; 9999]X3 = X2 ˘ [1; 1]X4 = (X1 [X3) \ [10000;+1]

8>>><

>>>:

X1 = [1; 1]X2 = [1; 9999]X3 = [2;+1]X4 = ;

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 76 — ! P. Cousot

Page 124: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Interval analysis (1975)Decreasing chaotic iteration:

x := 1;1:

while x < 10000 do2:

x := x + 13:

od;4:

8>>><

>>>:

X1 = [1; 1]X2 = (X1 [X3) \ [`1; 9999]X3 = X2 ˘ [1; 1]X4 = (X1 [X3) \ [10000;+1]

8>>><

>>>:

X1 = [1; 1]X2 = [1; 9999]X3 = [2;+10000]X4 = ;

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 76 — ! P. Cousot

Page 125: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Interval analysis (1975)Final solution:

x := 1;1:

while x < 10000 do2:

x := x + 13:

od;4:

8>>><

>>>:

X1 = [1; 1]X2 = (X1 [X3) \ [`1; 9999]X3 = X2 ˘ [1; 1]X4 = (X1 [X3) \ [10000;+1]

8>>><

>>>:

X1 = [1; 1]X2 = [1; 9999]X3 = [2;+10000]X4 = [+10000;+10000]

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 77 — ! P. Cousot

Page 126: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Interval analysis (1975)Result of the interval analysis:

x := 1;1: {x = 1}

while x < 10000 do2: {x 2 [1; 9999]}

x := x + 13: {x 2 [2;+10000]}

od;4: {x = 10000}

8>>><

>>>:

X1 = [1; 1]X2 = (X1 [X3) \ [`1; 9999]X3 = X2 ˘ [1; 1]X4 = (X1 [X3) \ [10000;+1]

8>>><

>>>:

X1 = [1; 1]X2 = [1; 9999]X3 = [2;+10000]X4 = [+10000;+10000]

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 78 — ! P. Cousot

Page 127: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example: Interval analysis (1975)Checking absence of runtime errors with interval analysis:

x := 1;1: {x = 1}

while x < 10000 do2: {x 2 [1; 9999]}

x := x + 13: {x 2 [2;+10000]}

od;4: {x = 10000}

8>>><

>>>:

X1 = [1; 1]X2 = (X1 [X3) \ [`1; 9999]X3 = X2 ˘ [1; 1]X4 = (X1 [X3) \ [10000;+1]

8>>><

>>>:

no overflowX2 = [1; 9999]X3 = [2;+10000]X4 = [+10000;+10000]

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 79 — ! P. Cousot

Page 128: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Refinement of abstractions

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 80 — ! P. Cousot

Page 129: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Approximations of an [in]finite set of points:from above

x

y

f: : : ; h19; 77i; : : : ;h20; 03i; : : :g

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 81 — ! P. Cousot

Page 130: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Approximations of an [in]finite set of points:from above

x

y

?

?

??

?

?

??

?

?

f: : : ; h19; 77i; : : : ;

h20; 03i; h?; ?i; : : :g

From Below: dual 2 + combinations.

2 Trivial for finite states (liveness model-checking), more di!cult for infinite states (variant functions).

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 82 — ! P. Cousot

Page 131: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

E"ective computable approximations of an[in]finite set of points; Signs 3

x

y!x – 0y – 0

3 P. Cousot & R. Cousot. Systematic design of program analysis frameworks. ACM POPL’79, pp. 269–282,1979.

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 83 — ! P. Cousot

Page 132: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

E"ective computable approximations of an[in]finite set of points; Intervals 4

x

y!x 2 [19; 77]y 2 [20; 03]

4 P. Cousot & R. Cousot. Static determination of dynamic properties of programs. Proc. 2nd Int. Symp. onProgramming, Dunod, 1976.

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 84 — ! P. Cousot

Page 133: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

E"ective computable approximations of an[in]finite set of points; Octagons 5

x

y

8>>><

>>>:

1 » x » 9x+ y » 771 » y » 9x` y » 99

5 A. Miné. A New Numerical Abstract Domain Based on Di!erence-Bound Matrices. PADO ’2001.LNCS 2053, pp. 155–172. Springer 2001. See the The Octagon Abstract Domain Library onhttp://www.di.ens.fr/~mine/oct/

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 85 — ! P. Cousot

Page 134: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

E"ective computable approximations of an[in]finite set of points; Polyhedra 6

x

y!19x+ 77y » 200420x+ 03y – 0

6 P. Cousot & N. Halbwachs. Automatic discovery of linear restraints among variables of a program. ACMPOPL, 1978, pp. 84–97.

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 86 — ! P. Cousot

Page 135: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

E"ective computable approximations of an[in]finite set of points; Simple

congruences 7

x

y!x = 19 mod 77y = 20 mod 99

7 Ph. Granger. Static Analysis of Arithmetical Congruences. Int. J. Comput. Math. 30, 1989, pp. 165–190.

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 87 — ! P. Cousot

Page 136: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

E"ective computable approximations of an[in]finite set of points; Linear

congruences 8

x

y!1x+ 9y = 7 mod 82x` 1y = 9 mod 9

8 Ph. Granger. Static Analysis of Linear Congruence Equalities among Variables of a Program.TAPSOFT ’91, pp. 169–192. LNCS 493, Springer, 1991.

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 88 — ! P. Cousot

Page 137: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

E"ective computable approximations of an[in]finite set of points; Trapezoidal lin-

ear congruences 9

x

y

!1x+ 9y 2 [0; 77] mod 102x` 1y 2 [0; 99] mod 11

9 F. Masdupuy. Array Operations Abstraction Using Semantic Analysis of Trapezoid Congruences. ACMICS ’92.

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 89 — ! P. Cousot

Page 138: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Refinement of iterates

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 90 — ! P. Cousot

Page 139: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: Refinement requiredby false alarms

x(t)

t

."*%$//'0(1"0'

.+&#'(+&+*<#

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 91 — ! P. Cousot

Page 140: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: Partitionning

x(t)

t

!"##$%&'(/$#-*')'(

)*+,'-)"*$'#

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 92 — ! P. Cousot

Page 141: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: partitionned upward itera-tion with widening

x(t)

t

!"##$%&'(/$#-*')'(

)*+,'-)"*$'#

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 93 — ! P. Cousot

Page 142: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: partitionned upward itera-tion with widening

x(t)

t

!"##$%&'(/$#-*')'(

)*+,'-)"*$'#

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 93 — ! P. Cousot

Page 143: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: partitionned upward itera-tion with widening

x(t)

t

!"##$%&'(/$#-*')'(

)*+,'-)"*$'#

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 93 — ! P. Cousot

Page 144: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: partitionned upward itera-tion with widening

x(t)

t

!"##$%&'(/$#-*')'(

)*+,'-)"*$'#

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 93 — ! P. Cousot

Page 145: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: partitionned upward itera-tion with widening

x(t)

t

!"##$%&'(/$#-*')'(

)*+,'-)"*$'#

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 93 — ! P. Cousot

Page 146: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: partitionned upward itera-tion with widening

x(t)

t

!"##$%&'(/$#-*')'(

)*+,'-)"*$'#

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 93 — ! P. Cousot

Page 147: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: partitionned upward itera-tion with widening

x(t)

t

!"##$%&'(/$#-*')'(

)*+,'-)"*$'#

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 93 — ! P. Cousot

Page 148: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: partitionned upward itera-tion with widening

x(t)

t

!"##$%&'(/$#-*')'(

)*+,'-)"*$'#

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 93 — ! P. Cousot

Page 149: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: partitionned upward itera-tion with widening

x(t)

t

!"##$%&'(/$#-*')'(

)*+,'-)"*$'#

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 93 — ! P. Cousot

Page 150: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: partitionned upward itera-tion with widening

x(t)

t

!"##$%&'(/$#-*')'(

)*+,'-)"*$'#

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 93 — ! P. Cousot

Page 151: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: partitionned upward itera-tion with widening

x(t)

t

!"##$%&'(/$#-*')'(

)*+,'-)"*$'#

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 93 — ! P. Cousot

Page 152: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Graphic example: safety verification

x(t)

t

!"##$%&'(/$#-*')'(

)*+,'-)"*$'#

."*%$//'0(1"0'

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 94 — ! P. Cousot

Page 153: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Examples of partitionnings

– sets of control states: attach local information to pro-gram points instead of global information for the wholeprogram/procedure/loop– sets of data states:- case analysis (test, switches)– fixpoint iterates:- widening with threshold set

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 95 — ! P. Cousot

Page 154: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Interval widening with threshold set

– The threshold set T is a finite set of numbers (plus+1 and `1),– [a; b]

!T [a0; b0] = [if a0 < a then maxf‘ 2 T j ‘ » a0g

else a;if b0 > b then minfh 2 T j h – b0g

else b] :– Examples (intervals):- sign analysis: T = f`1; 0;+1g;- strict sign analysis: T = f`1;`1; 0;+1;+1g;

– T is a parameter of the analysis.

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 96 — ! P. Cousot

Page 155: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Combinations of abstractions

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 97 — ! P. Cousot

Page 156: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Forward/reachability analysis

II

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 98 — ! P. Cousot

Page 157: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Backward/ancestry analysis

IIF

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 99 — ! P. Cousot

Page 158: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Iterated forward/backward analysis

IF

I

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 100 — ! P. Cousot

Page 159: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example of iterated forward/backward analysisArithmetical mean of two integers x and y:{x>=y}

while (x <> y) do{x>=y+2}

x := x - 1;{x>=y+1}

y := y + 1{x>=y}

od{x=y}

Necessarily x – y for proper termination

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 101 — ! P. Cousot

Page 160: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Example of iterated forward/backward analysisAdding an auxiliary counter k decremented in the loopbody and asserted to be null on loop exit:{x=y+2k,x>=y}

while (x <> y) do{x=y+2k,x>=y+2}

k := k - 1;{x=y+2k+2,x>=y+2}

x := x - 1;{x=y+2k+1,x>=y+1}

y := y + 1{x=y+2k,x>=y}

od{x=y,k=0}

assume (k = 0){x=y,k=0}

Moreover the di"er-ence of x and y mustbe even for proper ter-mination

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 102 — ! P. Cousot

Page 161: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Bibliography

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 103 — ! P. Cousot

Page 162: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Seminal papers– Patrick Cousot & Radhia Cousot. Abstract interpretation: aunified lattice model for static analysis of programs by con-struction or approximation of fixpoints. In 4th Symp. on Prin-ciples of Programming Languages, pages 238—252. ACM Press,1977.– Patrick Cousot & Nicolas Halbwachs. Automatic discovery oflinear restraints among variables of a program. In 5th Symp.on Principles of Programming Languages, pages 84—97. ACMPress, 1978.– Patrick Cousot & Radhia Cousot. Systematic design of pro-gram analysis frameworks. In 6th Symp. on Principles of Pro-gramming Languages pages 269—282. ACM Press, 1979.

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 104 — ! P. Cousot

Page 163: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Recent surveys– Patrick Cousot. Interprétation abstraite. Technique et ScienceInformatique, Vol. 19, Nb 1-2-3. Janvier 2000, Hermès, Paris,France. pp. 155-164.– Patrick Cousot. Abstract Interpretation Based Formal Meth-ods and Future Challenges. In Informatics, 10 Years Back —10 Years Ahead, R. Wilhelm (Ed.), LNCS 2000, pp. 138-156,2001.– Patrick Cousot & Radhia Cousot. Abstract InterpretationBased Verification of Embedded Software: Problems and Per-spectives. In Proc. 1st Int. Workshop on Embedded Software,EMSOFT 2001, T.A. Henzinger & C.M. Kirsch (Eds.), LNCS2211, pp. 97–113. Springer, 2001.

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 105 — ! P. Cousot

Page 164: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Conclusion

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 106 — ! P. Cousot

Page 165: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Theoretical applications of abstract interpretation

– Static Program Analysis [POPL ’77,78,79] inluding Data-flow Analysis [POPL ’79,00], Set-based Analysis [FPCA ’95],etc– Syntax Analysis [TCS 290(1) 2002]– Hierarchies of Semantics (including Proofs) [POPL ’92, TCS277(1–2) 2002]– Typing [POPL ’97]– Model Checking [POPL ’00]– Program Transformation [POPL ’02]– Software watermarking [POPL ’04]VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 107 — ! P. Cousot

Page 166: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Practical applications of abstractinterpretation

– Program analysis and manipulation: a small rate of falsealarms is acceptable- AiT: worst case execution time – Christian Ferdi-nand

– Program verification: no false alarms is acceptable- TVLA: A system for generating abstract interpreters– Mooly Sagiv- Astrée: verification of absence of run-time errors –Laurent Mauborgne

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 108 — ! P. Cousot

Page 167: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

Industrial applications of abstractinterpretation

– Both to Program analysis and verification– Experience with the industrial use of abstract interpre-tation-based static analysis tools – Jean Souyris (Air-bus France)

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 109 — ! P. Cousot

Page 168: «ATutorialon Abstract Interpretationhomepage.cs.uiowa.edu/~tinelli/classes/seminar/Cousot--A Tutorial on AI.pdfStatic analysis by abstract interpretation VMCAI’05 Industrial Day,

THE END

More references at URL www.di.ens.fr/~cousot.

VMCAI’05 Industrial Day, Paris, France, January 20, 2005 — 110 — ! P. Cousot