Top Banner
Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci. Dept., Univ. of
51

Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Jan 01, 2016

Download

Documents

Adela Owen
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: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Symbolic Implementationof the Best Transformer

Thomas RepsUniversity of Wisconsin

Joint work with M. Sagiv and G. Yorsh (Tel-Aviv)[TR-1468, Comp. Sci. Dept., Univ. of Wisconsin]

Page 2: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Who Cares?

• New approach to using symbolic techniques in abstract interpretation– For shape analysis

– For other abstract domains

• What does it mean to harness a decision procedure for use in static analysis?

Page 3: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Abstract

Abstract Interpretation

Concrete

Sets of storesDescriptors ofsets of stores

T#T

Page 4: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Abstract

Abstract Interpretation

Concrete

Sets of storesDescriptors ofsets of stores

T#T

Page 5: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Abstract

Best Abstract Transformer

Concrete

Sets of storesDescriptors ofsets of stores

T#T

Page 6: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Best Abstract Transformers

• For each abstract domain, there is a best transformer for each program statement– Best possible precision for that abstraction

• For predicate-abstraction domains, implementation of best transformer is known– Uses theorem prover

• Our work: implement best transformers for non-predicate-abstraction domains– Also uses theorem prover

Page 7: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Symbolic Operations: Three Value-Spaces

FormulasConcreteValues

AbstractValues

TT

Page 8: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Symbolic Operations: Three Value-Spaces

Formulas AbstractValues

T

T#

ConcreteValues

Page 9: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Symbolic Operations: Three Value-Spaces

FormulasConcreteValues

AbstractValues

u1

xu

x

...x

Page 10: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Required Primitive OperationsAbstraction

(S) = sS (s)

( ) = { }

Symbolic concretization

( ) = v1,v2 : nodeu1(v1) nodeu (v2) v1 ≠ v2

v : nodeu1(v) nodeu (v) . . .

Theorem prover returning a satisfying structure (store)

S For shape analysis, SPASS is mostly satisfactory

u1

xu

xu1

xu

Page 11: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Constant-Propagation Domain

(Var ZT), where ZT =

T

. . . -2 -1 0 1 2 . . .

Examples: , [x0, y43, z0], [xT, yT, z0], [xT, yT, z T]

Infinite cardinality, but finite height

Page 12: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Three Value-Spaces

Formulas AbstractValues

ConcreteValues

[x0, y0, z0]

[x0, y1, z0]

[x0, y2, z0]

(x = 0) (z = 0)

[x0, yT, z0]

Page 13: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Three Value-Spaces

Formulas AbstractValues

ConcreteValues

[x0, y0, z0]

[x0, y1, z0]

[x0, y2, z0]

[x0, y2, z0]

(x = 0) (z = 0)

Page 14: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Required Primitive OperationsAbstraction

(S) = sS (s)

([x 0, y 2, z 0]) = [x0, y2, z0]

Symbolic concretization

([x0, yT, z0]) = (x = 0) (z = 0)

Theorem prover returning a satisfying structure (store)

S [x 0, y 2, z 0] (x = 0) (z = 0)

Page 15: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Required Primitive OperationsAbstraction

(S) = sS (s)

([x 0, y 2, z 0]) = [x0, y2, z0]

Symbolic concretization

([x0, yT, z0]) = (x = 0) (z = 0)

Theorem prover returning a satisfying structure (store)

S [x 0, y 2, z 0] (z = 0) (x = y*z)

Page 16: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Constant Propagation

x = y * z[x3, y4, z1]

[x’4, y’4, z’1]

T[x = y * z] λe.e[x e(y)*e(z)]

T[x := y*z] =df (x’ = y * z) (y’ = y) (z’ = z)

(x’ = y * z) (y’ = y) (z’ = z)[x3, y4, z1, x’4, y’4, z’1]

Page 17: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Constant Propagation

x = y * z[x3, yT, z1]

[x’T, y’T, z’1]

T#[x = y * z] λe.e[x e(y) # e(z)]

Page 18: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Three Value-Spaces

Formulas AbstractValues

ConcreteValues

(z = 0)

[x’0,y’T,z’0]α (x’ = 0) (z’ = 0)

T[x := y*z]

αT [xT,yT,z0]

Page 19: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Remainder of the Talk

() – best abstract value that represents

• Best = T – best abstract transformer

Page 20: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Idea Behind Procedure CP()

FormulasConcreteValues

AbstractValues

ans

Page 21: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Idea Behind Procedure CP()

FormulasConcreteValues

AbstractValues

S

S

(S)

ans

Page 22: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Idea Behind Procedure CP()

FormulasConcreteValues

AbstractValues

S

S

(S)

(ans)

(ans)

(ans)

ans

Page 23: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Idea Behind Procedure CP()

1

FormulasConcreteValues

AbstractValues

S1

(ans)

1 (ans)

(ans)

S 1

ans

(S)

Page 24: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Idea Behind Procedure CP()

2

FormulasConcreteValues

AbstractValues

2

S 2

S

(S)

ans

2 = 1 (ans)

Page 25: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

(ans)

S 2

Idea Behind Procedure CP()

2

FormulasConcreteValues

AbstractValues

2

2 (ans)

S

(S)

ans

(ans)

Page 26: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Idea Behind Procedure CP()

5 = false

FormulasConcreteValues

AbstractValues

ans

(ans)

(ans), (ans)

Page 27: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Procedure

(formula ) { ans := := while ( is satisfiable) { Select a store S such that S ans := ans (S) := (ans) } return ans}

Page 28: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Procedure CP()

(z = 0) (x = y * z)

FormulasConcreteValues

AbstractValues

S

ans

[x0,y43,z0]

[x0, y43, z0]

Page 29: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Procedure CP()

FormulasConcreteValues

AbstractValues

(x = 0) (y = 43) (z = 0)

(ans)

(ans)

ans

S

(z = 0) (x = y * z)

[x0,y43,z0]

[x0, y43, z0]

Page 30: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Procedure CP()

(z = 0) (x = y * z) (y 43)

FormulasConcreteValues

AbstractValues

S

[x0,y46,z0]

[x0, y43, z0]

[x0, y46, z0]

Page 31: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Procedure CP()

(z = 0) (x = y * z) (y 43)

FormulasConcreteValues

AbstractValues

S

[x0, yT, z0]

ans

(x = 0) (z = 0)

(x = 0) (z = 0)

Page 32: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

(a)T

The Idea Behind Best = T

FormulasT AbstractValues

(a)

(a)

a

Page 33: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

(a)T

The Idea Behind Best = T

FormulasT AbstractValues

(a)

(a)

a

Page 34: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

(a)T

The Idea Behind Best = T

FormulasT AbstractValues

(a)

(a)

a

ans

Page 35: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

(a)T

The Idea Behind Best = T

FormulasT AbstractValues

(a)

(a)

a

ans

Page 36: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Procedure Best

Best(two-store-formula T, abs-store a) { ans’ := ’ := (a) T while ( is satisfiable) { Select a store pair (S,S ’) such that (S,S ’) ans’ := ans’ ’(S ’) := ’(ans’) } return ans’}

Page 37: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Best((x’ = y * z) (y’ = y) (z’ = z), [xT, yT, z0])

Initialization:

ans’ := ’ := (z = 0) (x’ = y * z) (y’ = y) (z’ = z)

Iteration 1:

(S,S ’) := [x 5, y 17, z 0,

x’ 0, y’ 17, z’ 0]

Page 38: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

(a)T

The Idea Behind Best = T

FormulasT

AbstractValues

(a)

(a)

a

[x5, y17, z0]

[ x’0, y’17, z’0]

Page 39: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Best((x’ = y * z) (y’ = y) (z’ = z), [xT, yT, z0])

Initialization:

ans’ := ’ := (z = 0) (x’ = y * z) (y’ = y) (z’ = z)

Iteration 1:

(S,S ’) := [x 5, y 17, z 0,

x’ 0, y’ 17, z’ 0]

ans’ := [x’0, y’17, z’0] ’(ans’) = (x’= 0) (y’= 17) (z’= 0)

:= (z = 0) (x’ = y*z) (y’ = y) (z’ = z) (y’ 17)

Page 40: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Best((x’ = y * z) (y’ = y) (z’ = z), [xT, yT, z0])

Iteration 2: (S,S ’) := [x 12, y 99, z 0,

x’ 0, y’ 99, z’ 0] ans’ := [x’0, y’17, z’0] [x’0, y’99, z’0]

= [x’0, y’T, z’0] ’(ans’) = (x’= 0) (z’= 0) := (z = 0) (x’ = y * z) (y’ = y) (z’ = z)

(y’ 17) ((x’ 0) (z’ 0)) = false

Iteration 3: is unsatisfiable

Return value: [x’0, y’T, z’0]

Page 41: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Best(y = x next, )u1

xu

r[x] r[x]

u4

x

r[x]r[x]r[x]r[x]

u1 u2 u3

x’

r[x]’,r[y]’r[x]’,r[y]’r[x]’,r[y]’r[x]’

y’

u2

xu

r[x],r[y] r[x],r[y]

u1

r[x]

y

. . . (y’(v) v1: x(v1) n(v1,v)) . . .

Page 42: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Predicate Abstractiony := 3x := 4*y + 1

B1 B2 B3 B4 B5 B6

[x 13, y 3]

{ B1 (y = 1), B2 (y = 3), B3 (y = 4), B4 (x = 1), B5 (x = 3), B6 (x = 4) }

y = 3 x {1, 3, 4}

[x 13, y 3]

Page 43: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Three Value-Spaces

Formulas AbstractValues

ConcreteValues

(y ≠ 1) (y = 3) (y ≠ 4) (x ≠ 1) (x ≠ 3) (x ≠ 4)

(B1, B2,B3, B4,B5,B6)

[x5, y3]

[x0, y3]

[x17, y3]

Page 44: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Three Value-Spaces

Formulas AbstractValues

ConcreteValues

(y ≠ 1) (y = 3) (y ≠ 4) (x ≠ 1) (x ≠ 3) (x ≠ 4)

(B1, B2,B3, B4,B5,B6)

(B1, B2,B3,B6)

α (y ≠ 1) (y = 3) (y ≠ 4) (x ≠ 4)

T[x := x+1]

αT

Page 45: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Predicate Abstraction

• Abstract values(B1, B2, B3, B4, B5, B6)

• Apply , which performs symbolically(y ≠ 1) (y = 3) (y ≠ 4) (x ≠ 1) (x ≠ 3) (x ≠ 4)

• Apply T, which implements α T

Page 46: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

α PA: Most-Precise Abstract Value[Predicate Abstraction]

Formulas AbstractValues

ConcreteValues

(y = 3) (x = 4*y + 1)

(B1, B2,B3, B4,B5,B6)

αPA

Page 47: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

α PA: Most-Precise Abstract Value[Predicate Abstraction]

PA() =

false

j = 1

k Bj if j is valid

Bj if j is valid

true otherwise

if isunsatisfiable

otherwise

PA((y = 3) (x = 4*y + 1)) = B1, B2, B3, B4, B5, B6

(y = 3) (x = 4*y + 1) (y = 1)

(y = 3) (x = 4*y + 1) (y = 3)

(y = 3) (x = 4*y + 1) (y = 4)

Page 48: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

α PA: Most-Precise Abstract Value[Predicate Abstraction]

PA() =

false

j = 1

k Bj if j is valid

Bj if j is valid

true otherwise

if isunsatisfiable

otherwise

(y = 3) (x = 4*y + 1) (x = 1)

(y = 3) (x = 4*y + 1) (x = 3)

(y = 3) (x = 4*y + 1) (x = 4)

PA((y = 3) (x = 4*y + 1)) = B1, B2, B3, B4, B5, B6

Page 49: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Procedure PA vs. General

ConcreteValues

Formulas AbstractValues

PA

i

FormulasConcreteValues

AbstractValues

i

S i

S

ansi = ansi-1 (S)

ansi-1 (ansi-1)

Page 50: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.

Conclusions

• Requirements– Finite-height abstract domain– Theorem prover that returns a satisfying structure (store)

(S) = sS (S)– Symbolic-concretization operation ()

() – best abstract value that represents • Best(T,a) – best abstract transformer

– Best(T1; T2; . . .; Tk, a) – best abstract transformer for a basic block

Page 51: Symbolic Implementation of the Best Transformer Thomas Reps University of Wisconsin Joint work with M. Sagiv and G. Yorsh (Tel-Aviv) [TR-1468, Comp. Sci.