a clp heap solver for test case generation [2ex]

133
A CLP Heap Solver for Test Case Generation Elvira Albert 1 , Mar´ ıa Garc´ ıa de la Banda 2,5 , Miguel G-Zamalloa 1 , Jos´ e Miguel Rojas 3 and Peter Stuckey 4,5 (1) Complutense University of Madrid, Spain (2) Monash University, Australia (3) Technical University of Madrid, Spain (4) National ICT Australia and University of Melbourne, Australia (5) IMDEA Software, Madrid, Spain ICLP 2013 Istanbul, August 26, 2013

Upload: others

Post on 02-May-2022

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: A CLP Heap Solver for Test Case Generation [2ex]

A CLP Heap Solver for Test Case Generation

Elvira Albert1, Marıa Garcıa de la Banda2,5, MiguelG-Zamalloa1, Jose Miguel Rojas3 and Peter Stuckey4,5

(1) Complutense University of Madrid, Spain(2) Monash University, Australia

(3) Technical University of Madrid, Spain(4) National ICT Australia and University of Melbourne, Australia

(5) IMDEA Software, Madrid, Spain

ICLP 2013Istanbul, August 26, 2013

Page 2: A CLP Heap Solver for Test Case Generation [2ex]

2 11

Motivation

I Software testing – manual, expensive, time-consuming

I Automation

I Test case generation

I Symbolic execution

I Scalability is a major goalI Challenge: Efficiently handling heap-manipulating programs

I Complex dynamic data structuresI Aliasing of referencesI Explore all possible heap shapesI Path explosion problemI Outperform Lazy Initialization

Page 3: A CLP Heap Solver for Test Case Generation [2ex]

2 11

Motivation

I Software testing – manual, expensive, time-consuming

I Automation

I Test case generation

I Symbolic execution

I Scalability is a major goalI Challenge: Efficiently handling heap-manipulating programs

I Complex dynamic data structuresI Aliasing of referencesI Explore all possible heap shapesI Path explosion problemI Outperform Lazy Initialization

Page 4: A CLP Heap Solver for Test Case Generation [2ex]

2 11

Motivation

I Software testing – manual, expensive, time-consuming

I Automation

I Test case generation

I Symbolic execution

I Scalability is a major goalI Challenge: Efficiently handling heap-manipulating programs

I Complex dynamic data structuresI Aliasing of referencesI Explore all possible heap shapesI Path explosion problemI Outperform Lazy Initialization

Page 5: A CLP Heap Solver for Test Case Generation [2ex]

2 11

Motivation

I Software testing – manual, expensive, time-consuming

I Automation

I Test case generation

I Symbolic execution

I Scalability is a major goalI Challenge: Efficiently handling heap-manipulating programs

I Complex dynamic data structuresI Aliasing of referencesI Explore all possible heap shapesI Path explosion problemI Outperform Lazy Initialization

Page 6: A CLP Heap Solver for Test Case Generation [2ex]

2 11

Motivation

I Software testing – manual, expensive, time-consuming

I Automation

I Test case generation

I Symbolic execution

I Scalability is a major goal

I Challenge: Efficiently handling heap-manipulating programsI Complex dynamic data structuresI Aliasing of referencesI Explore all possible heap shapesI Path explosion problemI Outperform Lazy Initialization

Page 7: A CLP Heap Solver for Test Case Generation [2ex]

2 11

Motivation

I Software testing – manual, expensive, time-consuming

I Automation

I Test case generation

I Symbolic execution

I Scalability is a major goalI Challenge: Efficiently handling heap-manipulating programs

I Complex dynamic data structuresI Aliasing of referencesI Explore all possible heap shapesI Path explosion problemI Outperform Lazy Initialization

Page 8: A CLP Heap Solver for Test Case Generation [2ex]

2 11

Motivation

I Software testing – manual, expensive, time-consuming

I Automation

I Test case generation

I Symbolic execution

I Scalability is a major goalI Challenge: Efficiently handling heap-manipulating programs

I Complex dynamic data structures

I Aliasing of referencesI Explore all possible heap shapesI Path explosion problemI Outperform Lazy Initialization

Page 9: A CLP Heap Solver for Test Case Generation [2ex]

2 11

Motivation

I Software testing – manual, expensive, time-consuming

I Automation

I Test case generation

I Symbolic execution

I Scalability is a major goalI Challenge: Efficiently handling heap-manipulating programs

I Complex dynamic data structuresI Aliasing of references

I Explore all possible heap shapesI Path explosion problemI Outperform Lazy Initialization

Page 10: A CLP Heap Solver for Test Case Generation [2ex]

2 11

Motivation

I Software testing – manual, expensive, time-consuming

I Automation

I Test case generation

I Symbolic execution

I Scalability is a major goalI Challenge: Efficiently handling heap-manipulating programs

I Complex dynamic data structuresI Aliasing of referencesI Explore all possible heap shapes

I Path explosion problemI Outperform Lazy Initialization

Page 11: A CLP Heap Solver for Test Case Generation [2ex]

2 11

Motivation

I Software testing – manual, expensive, time-consuming

I Automation

I Test case generation

I Symbolic execution

I Scalability is a major goalI Challenge: Efficiently handling heap-manipulating programs

I Complex dynamic data structuresI Aliasing of referencesI Explore all possible heap shapesI Path explosion problem

I Outperform Lazy Initialization

Page 12: A CLP Heap Solver for Test Case Generation [2ex]

2 11

Motivation

I Software testing – manual, expensive, time-consuming

I Automation

I Test case generation

I Symbolic execution

I Scalability is a major goalI Challenge: Efficiently handling heap-manipulating programs

I Complex dynamic data structuresI Aliasing of referencesI Explore all possible heap shapesI Path explosion problemI Outperform Lazy Initialization

Page 13: A CLP Heap Solver for Test Case Generation [2ex]

3 11

Handling heap-manipulating programsLazy Initialization vs Heap Solver

m(C x,C y, C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)

m3(y.f);else

m4(y.f);}

I Standard technique to handle aliasing. Used in state-of-the-artsystems, e.g., PET (UCM&UPM) and SPF (NASA Ames)

Page 14: A CLP Heap Solver for Test Case Generation [2ex]

3 11

Handling heap-manipulating programsLazy Initialization vs Heap Solver

m(C x,C y, C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)

m3(y.f);else

m4(y.f);}

I Standard technique to handle aliasing. Used in state-of-the-artsystems, e.g., PET (UCM&UPM) and SPF (NASA Ames)

Page 15: A CLP Heap Solver for Test Case Generation [2ex]

3 11

Handling heap-manipulating programsLazy Initialization vs Heap Solver

m(C x,C y, C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)

m3(y.f);else

m4(y.f);}

I Field accesses on unknown references trigger non-determinism:1) Null 2) New reference 3) Each aliasing possibility

Page 16: A CLP Heap Solver for Test Case Generation [2ex]

3 11

Handling heap-manipulating programsLazy Initialization vs Heap Solver

m(C x,C y, C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)

m3(y.f);else

m4(y.f);}

I Field accesses on unknown references trigger non-determinism:1) Null 2) New reference 3) Each aliasing possibility

Page 17: A CLP Heap Solver for Test Case Generation [2ex]

3 11

Handling heap-manipulating programsLazy Initialization vs Heap Solver

m(C x,C y, C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)

m3(y.f);else

m4(y.f);}

I Field accesses on unknown references trigger non-determinism:1) Null 2) New reference 3) Each aliasing possibility

Page 18: A CLP Heap Solver for Test Case Generation [2ex]

3 11

Handling heap-manipulating programsLazy Initialization vs Heap Solver

m(C x,C y, C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)

m3(y.f);else

m4(y.f);}

I Field accesses on unknown references trigger non-determinism:1) Null 2) New reference 3) Each aliasing possibility

Page 19: A CLP Heap Solver for Test Case Generation [2ex]

3 11

Handling heap-manipulating programsLazy Initialization vs Heap Solver

m(C x,C y, C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)

m3(y.f);else

m4(y.f);}

I Field accesses on unknown references trigger non-determinism:1) Null 2) New reference 3) Each aliasing possibility

Page 20: A CLP Heap Solver for Test Case Generation [2ex]

3 11

Handling heap-manipulating programsLazy Initialization vs Heap Solver

m(C x,C y, C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)

m3(y.f);else

m4(y.f);}

I Field accesses on unknown references trigger non-determinism:1) Null 2) New reference 3) Each aliasing possibility

Page 21: A CLP Heap Solver for Test Case Generation [2ex]

3 11

Handling heap-manipulating programsLazy Initialization vs Heap Solver

m(C x,C y, C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)

m3(y.f);else

m4(y.f);}

I Symbolic execution quickly becomes impracticalI Redundant exploration of large number of paths

Page 22: A CLP Heap Solver for Test Case Generation [2ex]

3 11

Handling heap-manipulating programsLazy Initialization vs Heap Solver

m(C x,C y, C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)

m3(y.f);else

m4(y.f);}

I Symbolic execution quickly becomes impracticalI Redundant exploration of large number of paths

Page 23: A CLP Heap Solver for Test Case Generation [2ex]

3 11

Handling heap-manipulating programsLazy Initialization vs Heap Solver

m(C x,C y, C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)

m3(y.f);else

m4(y.f);}

I Symbolic execution quickly becomes impracticalI Redundant exploration of large number of paths

Page 24: A CLP Heap Solver for Test Case Generation [2ex]

3 11

Handling heap-manipulating programsLazy Initialization vs Heap Solver

m(C x,C y, C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)

m3(y.f);else

m4(y.f);}

I Symbolic execution quickly becomes impracticalI Redundant exploration of large number of paths

Page 25: A CLP Heap Solver for Test Case Generation [2ex]

3 11

Handling heap-manipulating programsLazy Initialization vs Heap Solver

m(C x,C y, C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)

m3(y.f);else

m4(y.f);}

I Symbolic execution quickly becomes impracticalI Redundant exploration of large number of paths

Page 26: A CLP Heap Solver for Test Case Generation [2ex]

3 11

Handling heap-manipulating programsLazy Initialization vs Heap Solver

m(C x,C y, C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)

m3(y.f);else

m4(y.f);}

I Symbolic execution quickly becomes impracticalI Redundant exploration of large number of paths

Page 27: A CLP Heap Solver for Test Case Generation [2ex]

3 11

Handling heap-manipulating programsLazy Initialization vs Heap Solver

m(C x,C y, C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)

m3(y.f);else

m4(y.f);}

I Symbolic execution quickly becomes impracticalI Redundant exploration of large number of paths

Page 28: A CLP Heap Solver for Test Case Generation [2ex]

3 11

Handling heap-manipulating programsLazy Initialization vs Heap Solver

m(C x,C y, C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)

m3(y.f);else

m4(y.f);}

I A more scalable approach than lazy initialization

Page 29: A CLP Heap Solver for Test Case Generation [2ex]

3 11

Handling heap-manipulating programsLazy Initialization vs Heap Solver

m(C x,C y, C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)

m3(y.f);else

m4(y.f);}

I A more scalable approach than lazy initialization

Page 30: A CLP Heap Solver for Test Case Generation [2ex]

3 11

Handling heap-manipulating programsLazy Initialization vs Heap Solver

m(C x,C y, C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)

m3(y.f);else

m4(y.f);}

I Avoid non-determinism as much as possible

Page 31: A CLP Heap Solver for Test Case Generation [2ex]

3 11

Handling heap-manipulating programsLazy Initialization vs Heap Solver

m(C x,C y, C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)

m3(y.f);else

m4(y.f);}

I Treatment of reference aliasing by means of disjunctions

Page 32: A CLP Heap Solver for Test Case Generation [2ex]

3 11

Handling heap-manipulating programsLazy Initialization vs Heap Solver

m(C x,C y, C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)

m3(y.f);else

m4(y.f);}

I Treatment of reference aliasing by means of disjunctions

Page 33: A CLP Heap Solver for Test Case Generation [2ex]

3 11

Handling heap-manipulating programsLazy Initialization vs Heap Solver

m(C x,C y, C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)

m3(y.f);else

m4(y.f);}

I Propagation of heap-related constraints

Page 34: A CLP Heap Solver for Test Case Generation [2ex]

3 11

Handling heap-manipulating programsLazy Initialization vs Heap Solver

m(C x,C y, C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)

m3(y.f);else

m4(y.f);}

I Support for heap assumptions to avoid certain aliasingconfigurations. E.g., acyclic(x), non-aliasing(x,z)

Page 35: A CLP Heap Solver for Test Case Generation [2ex]

3 11

Handling heap-manipulating programsLazy Initialization vs Heap Solver

m(C x,C y, C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)

m3(y.f);else

m4(y.f);}

I Implemented in PET

I Applicable to other systems

Page 36: A CLP Heap Solver for Test Case Generation [2ex]

4 11

Test Case Generation by Symbolic Execution in CLPThe PET System

I Static structural CLP-based approach

I Bounded symbolic execution

I Symbolic values (constrained variables) as input arguments

I Non-determinism at branching points involving unknown data

I Backtracking and constraint manipulation/solving

I Special built-ins to handle heap operations

Page 37: A CLP Heap Solver for Test Case Generation [2ex]

4 11

Test Case Generation by Symbolic Execution in CLPThe PET System

I Static structural CLP-based approach

I Bounded symbolic execution

I Symbolic values (constrained variables) as input arguments

I Non-determinism at branching points involving unknown data

I Backtracking and constraint manipulation/solving

I Special built-ins to handle heap operations

Page 38: A CLP Heap Solver for Test Case Generation [2ex]

4 11

Test Case Generation by Symbolic Execution in CLPThe PET System

I Static structural CLP-based approach

I Bounded symbolic execution

I Symbolic values (constrained variables) as input arguments

I Non-determinism at branching points involving unknown data

I Backtracking and constraint manipulation/solving

I Special built-ins to handle heap operations

Page 39: A CLP Heap Solver for Test Case Generation [2ex]

4 11

Test Case Generation by Symbolic Execution in CLPThe PET System

I Static structural CLP-based approach

I Bounded symbolic execution

I Symbolic values (constrained variables) as input arguments

I Non-determinism at branching points involving unknown data

I Backtracking and constraint manipulation/solving

I Special built-ins to handle heap operations

Page 40: A CLP Heap Solver for Test Case Generation [2ex]

4 11

Test Case Generation by Symbolic Execution in CLPThe PET System

I Static structural CLP-based approach

I Bounded symbolic execution

I Symbolic values (constrained variables) as input arguments

I Non-determinism at branching points involving unknown data

I Backtracking and constraint manipulation/solving

I Special built-ins to handle heap operations

Page 41: A CLP Heap Solver for Test Case Generation [2ex]

4 11

Test Case Generation by Symbolic Execution in CLPThe PET System

I Static structural CLP-based approach

I Bounded symbolic execution

I Symbolic values (constrained variables) as input arguments

I Non-determinism at branching points involving unknown data

I Backtracking and constraint manipulation/solving

I Special built-ins to handle heap operations

Page 42: A CLP Heap Solver for Test Case Generation [2ex]

4 11

Test Case Generation by Symbolic Execution in CLPThe PET System

I Static structural CLP-based approach

I Bounded symbolic execution

I Symbolic values (constrained variables) as input arguments

I Non-determinism at branching points involving unknown data

I Backtracking and constraint manipulation/solving

I Special built-ins to handle heap operations

Page 43: A CLP Heap Solver for Test Case Generation [2ex]

5 11

CLP Heap Solver - The Heap

Internal Representation

Heap ≡ 〈S,N ,RC〉

I S ::= getF (Ref ,FSig ,Var ,S) | setF (Ref ,FSig ,Data,S) | ∅I N maps fresh numeric references to new objects

I RC is a set of disequality constraints over references

Operations

I Field read access: get field(Hin,Ref,FSig,Var,Hout)

I Field write access: set field(Hin,Ref,FSig,Data,Hout)

I Reference equality: ref eq(Hin,Ref1,Ref2,Hout)

I Reference disequality: ref neq(Hin,Ref1,Ref2,Hout)

I Object creation: new object(Hin,C,Ref,Hout)

Page 44: A CLP Heap Solver for Test Case Generation [2ex]

5 11

CLP Heap Solver - The Heap

Internal Representation

Heap ≡ 〈S,N ,RC〉

I S ::= getF (Ref ,FSig ,Var ,S) | setF (Ref ,FSig ,Data,S) | ∅I N maps fresh numeric references to new objects

I RC is a set of disequality constraints over references

Operations

I Field read access: get field(Hin,Ref,FSig,Var,Hout)

I Field write access: set field(Hin,Ref,FSig,Data,Hout)

I Reference equality: ref eq(Hin,Ref1,Ref2,Hout)

I Reference disequality: ref neq(Hin,Ref1,Ref2,Hout)

I Object creation: new object(Hin,C,Ref,Hout)

Page 45: A CLP Heap Solver for Test Case Generation [2ex]

5 11

CLP Heap Solver - The Heap

Internal Representation

Heap ≡ 〈S,N ,RC〉

I S ::= getF (Ref ,FSig ,Var ,S) | setF (Ref ,FSig ,Data,S) | ∅I N maps fresh numeric references to new objects

I RC is a set of disequality constraints over references

Operations

I Field read access: get field(Hin,Ref,FSig,Var,Hout)

I Field write access: set field(Hin,Ref,FSig,Data,Hout)

I Reference equality: ref eq(Hin,Ref1,Ref2,Hout)

I Reference disequality: ref neq(Hin,Ref1,Ref2,Hout)

I Object creation: new object(Hin,C,Ref,Hout)

Page 46: A CLP Heap Solver for Test Case Generation [2ex]

5 11

CLP Heap Solver - The Heap

Internal Representation

Heap ≡ 〈S,N ,RC〉

I S ::= getF (Ref ,FSig ,Var ,S) | setF (Ref ,FSig ,Data,S) | ∅I N maps fresh numeric references to new objects

I RC is a set of disequality constraints over references

Operations

I Field read access: get field(Hin,Ref,FSig,Var,Hout)

I Field write access: set field(Hin,Ref,FSig,Data,Hout)

I Reference equality: ref eq(Hin,Ref1,Ref2,Hout)

I Reference disequality: ref neq(Hin,Ref1,Ref2,Hout)

I Object creation: new object(Hin,C,Ref,Hout)

Page 47: A CLP Heap Solver for Test Case Generation [2ex]

5 11

CLP Heap Solver - The Heap

Internal Representation

Heap ≡ 〈S,N ,RC〉

I S ::= getF (Ref ,FSig ,Var ,S) | setF (Ref ,FSig ,Data,S) | ∅I N maps fresh numeric references to new objects

I RC is a set of disequality constraints over references

Operations

I Field read access: get field(Hin,Ref,FSig,Var,Hout)

I Field write access: set field(Hin,Ref,FSig,Data,Hout)

I Reference equality: ref eq(Hin,Ref1,Ref2,Hout)

I Reference disequality: ref neq(Hin,Ref1,Ref2,Hout)

I Object creation: new object(Hin,C,Ref,Hout)

Page 48: A CLP Heap Solver for Test Case Generation [2ex]

5 11

CLP Heap Solver - The Heap

Internal Representation

Heap ≡ 〈S,N ,RC〉

I S ::= getF (Ref ,FSig ,Var ,S) | setF (Ref ,FSig ,Data,S) | ∅I N maps fresh numeric references to new objects

I RC is a set of disequality constraints over references

Operations

I Field read access: get field(Hin,Ref,FSig,Var,Hout)

I Field write access: set field(Hin,Ref,FSig,Data,Hout)

I Reference equality: ref eq(Hin,Ref1,Ref2,Hout)

I Reference disequality: ref neq(Hin,Ref1,Ref2,Hout)

I Object creation: new object(Hin,C,Ref,Hout)

Page 49: A CLP Heap Solver for Test Case Generation [2ex]

6 11

CLP Heap Solver - How does the it work?Running example

Java program

m(C x,C y,C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-set field(Hin,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

Page 50: A CLP Heap Solver for Test Case Generation [2ex]

6 11

CLP Heap Solver - How does the it work?Running example

Java program

m(C x,C y,C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-set field(Hin,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

Page 51: A CLP Heap Solver for Test Case Generation [2ex]

6 11

CLP Heap Solver - How does the it work?Running example

Java program

m(C x,C y,C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-set field(Hin,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

Page 52: A CLP Heap Solver for Test Case Generation [2ex]

6 11

CLP Heap Solver - How does the it work?Running example

Java program

m(C x,C y,C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-set field(Hin,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

Page 53: A CLP Heap Solver for Test Case Generation [2ex]

6 11

CLP Heap Solver - How does the it work?Running example

Java program

m(C x,C y,C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-set field(Hin,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

Page 54: A CLP Heap Solver for Test Case Generation [2ex]

6 11

CLP Heap Solver - How does the it work?Running example

Java program

m(C x,C y,C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-set field(Hin,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

Page 55: A CLP Heap Solver for Test Case Generation [2ex]

6 11

CLP Heap Solver - How does the it work?Running example

Java program

m(C x,C y,C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-set field(Hin,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

Page 56: A CLP Heap Solver for Test Case Generation [2ex]

6 11

CLP Heap Solver - How does the it work?Running example

Java program

m(C x,C y,C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-set field(Hin,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

Page 57: A CLP Heap Solver for Test Case Generation [2ex]

6 11

CLP Heap Solver - How does the it work?Running example

Java program

m(C x,C y,C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-set field(Hin,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

Page 58: A CLP Heap Solver for Test Case Generation [2ex]

6 11

CLP Heap Solver - How does the it work?Running example

Java program

m(C x,C y,C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-set field(Hin,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

Page 59: A CLP Heap Solver for Test Case Generation [2ex]

6 11

CLP Heap Solver - How does the it work?Running example

Java program

m(C x,C y,C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-set field(Hin,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

Page 60: A CLP Heap Solver for Test Case Generation [2ex]

6 11

CLP Heap Solver - How does the it work?Running example

Java program

m(C x,C y,C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-set field(Hin,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

Page 61: A CLP Heap Solver for Test Case Generation [2ex]

6 11

CLP Heap Solver - How does the it work?Running example

Java program

m(C x,C y,C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-set field(Hin,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

Page 62: A CLP Heap Solver for Test Case Generation [2ex]

6 11

CLP Heap Solver - How does the it work?Running example

Java program

m(C x,C y,C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-set field(Hin,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

Page 63: A CLP Heap Solver for Test Case Generation [2ex]

6 11

CLP Heap Solver - How does the it work?Running example

Java program

m(C x,C y,C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-set field(Hin,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

Page 64: A CLP Heap Solver for Test Case Generation [2ex]

6 11

CLP Heap Solver - How does the it work?Running example

Java program

m(C x,C y,C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-set field(Hin,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

Page 65: A CLP Heap Solver for Test Case Generation [2ex]

6 11

CLP Heap Solver - How does the it work?Running example

Java program

m(C x,C y,C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-set field(Hin,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

Page 66: A CLP Heap Solver for Test Case Generation [2ex]

6 11

CLP Heap Solver - How does the it work?Running example

Java program

m(C x,C y,C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-set field(Hin,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

Page 67: A CLP Heap Solver for Test Case Generation [2ex]

7 11

CLP Heap Solver - How does the it work?Example featuring object creation

Java program

m(C x,C y,C z){

x = new C();x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-new object(Hin,X,C,H1),set field(H1,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

Page 68: A CLP Heap Solver for Test Case Generation [2ex]

7 11

CLP Heap Solver - How does the it work?Example featuring object creation

Java program

m(C x,C y,C z){

x = new C();x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-new object(Hin,X,C,H1),set field(H1,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

N

Cf:

X=0

Page 69: A CLP Heap Solver for Test Case Generation [2ex]

7 11

CLP Heap Solver - How does the it work?Example featuring object creation

Java program

m(C x,C y,C z){

x = new C();x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-new object(Hin,X,C,H1),set field(H1,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

N

Cf:1

X=0

Page 70: A CLP Heap Solver for Test Case Generation [2ex]

7 11

CLP Heap Solver - How does the it work?Example featuring object creation

Java program

m(C x,C y,C z){

x = new C();x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-new object(Hin,X,C,H1),set field(H1,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

N

Cf:1

X=0

Page 71: A CLP Heap Solver for Test Case Generation [2ex]

7 11

CLP Heap Solver - How does the it work?Example featuring object creation

Java program

m(C x,C y,C z){

x = new C();x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-new object(Hin,X,C,H1),set field(H1,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

N

Cf:1

X=0

Page 72: A CLP Heap Solver for Test Case Generation [2ex]

7 11

CLP Heap Solver - How does the it work?Example featuring object creation

Java program

m(C x,C y,C z){

x = new C();x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-new object(Hin,X,C,H1),set field(H1,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

N

Cf:1

X=0

Page 73: A CLP Heap Solver for Test Case Generation [2ex]

7 11

CLP Heap Solver - How does the it work?Example featuring object creation

Java program

m(C x,C y,C z){

x = new C();x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-new object(Hin,X,C,H1),set field(H1,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

N

Cf:1

X=0

Page 74: A CLP Heap Solver for Test Case Generation [2ex]

7 11

CLP Heap Solver - How does the it work?Example featuring object creation

Java program

m(C x,C y,C z){

x = new C();x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-new object(Hin,X,C,H1),set field(H1,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

N

Cf:1

X=0

Page 75: A CLP Heap Solver for Test Case Generation [2ex]

7 11

CLP Heap Solver - How does the it work?Example featuring object creation

Java program

m(C x,C y,C z){

x = new C();x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-new object(Hin,X,C,H1),set field(H1,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

N

Cf:1

X=0

Page 76: A CLP Heap Solver for Test Case Generation [2ex]

7 11

CLP Heap Solver - How does the it work?Example featuring object creation

Java program

m(C x,C y,C z){

x = new C();x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-new object(Hin,X,C,H1),set field(H1,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

N

Cf:1

X=0

Page 77: A CLP Heap Solver for Test Case Generation [2ex]

7 11

CLP Heap Solver - How does the it work?Example featuring object creation

Java program

m(C x,C y,C z){

x = new C();x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-new object(Hin,X,C,H1),set field(H1,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

N

Cf:1

X=0

Page 78: A CLP Heap Solver for Test Case Generation [2ex]

7 11

CLP Heap Solver - How does the it work?Example featuring object creation

Java program

m(C x,C y,C z){

x = new C();x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-new object(Hin,X,C,H1),set field(H1,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

N

Cf:1

X=0

Page 79: A CLP Heap Solver for Test Case Generation [2ex]

7 11

CLP Heap Solver - How does the it work?Example featuring object creation

Java program

m(C x,C y,C z){

x = new C();x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-new object(Hin,X,C,H1),set field(H1,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

N

Cf:1

X=0

Page 80: A CLP Heap Solver for Test Case Generation [2ex]

7 11

CLP Heap Solver - How does the it work?Example featuring object creation

Java program

m(C x,C y,C z){

x = new C();x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-new object(Hin,X,C,H1),set field(H1,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

N

Cf:1

X=0

Page 81: A CLP Heap Solver for Test Case Generation [2ex]

7 11

CLP Heap Solver - How does the it work?Example featuring object creation

Java program

m(C x,C y,C z){

x = new C();x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-new object(Hin,X,C,H1),set field(H1,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

N

Cf:1

X=0

Page 82: A CLP Heap Solver for Test Case Generation [2ex]

7 11

CLP Heap Solver - How does the it work?Example featuring object creation

Java program

m(C x,C y,C z){

x = new C();x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-new object(Hin,X,C,H1),set field(H1,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

N

Cf:1

X=0

Page 83: A CLP Heap Solver for Test Case Generation [2ex]

7 11

CLP Heap Solver - How does the it work?Example featuring object creation

Java program

m(C x,C y,C z){

x = new C();x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x==z)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-new object(Hin,X,C,H1),set field(H1,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),if([X,Y,Z],[],H6,Hout).

if([X,Y,Z],[],H6,Hout) :-ref eq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([X,Y,Z],[],H6,Hout) :-ref neq(H6,X,Z,H7),get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

N

Cf:1

X=0

Page 84: A CLP Heap Solver for Test Case Generation [2ex]

8 11

CLP Heap Solver - How does the it work?Example for back-propagation

Java program

m(C x,C y,C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x.f==1)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-set field(Hin,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),get field(H6,X,f,Xf2,H7),if([Xf2,Y],[],H7,Hout).

if([Xf2,Y],[],H7,Hout) :-Xf2 #= 1,get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([Xf2,Y],[],H7,Hout) :-Xf2 #\= 1,get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

Page 85: A CLP Heap Solver for Test Case Generation [2ex]

8 11

CLP Heap Solver - How does the it work?Example for back-propagation

Java program

m(C x,C y,C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x.f==1)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-set field(Hin,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),get field(H6,X,f,Xf2,H7),if([Xf2,Y],[],H7,Hout).

if([Xf2,Y],[],H7,Hout) :-Xf2 #= 1,get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([Xf2,Y],[],H7,Hout) :-Xf2 #\= 1,get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

Page 86: A CLP Heap Solver for Test Case Generation [2ex]

8 11

CLP Heap Solver - How does the it work?Example for back-propagation

Java program

m(C x,C y,C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x.f==1)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-set field(Hin,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),get field(H6,X,f,Xf2,H7),if([Xf2,Y],[],H7,Hout).

if([Xf2,Y],[],H7,Hout) :-Xf2 #= 1,get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([Xf2,Y],[],H7,Hout) :-Xf2 #\= 1,get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

Page 87: A CLP Heap Solver for Test Case Generation [2ex]

8 11

CLP Heap Solver - How does the it work?Example for back-propagation

Java program

m(C x,C y,C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x.f==1)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-set field(Hin,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),get field(H6,X,f,Xf2,H7),if([Xf2,Y],[],H7,Hout).

if([Xf2,Y],[],H7,Hout) :-Xf2 #= 1,get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([Xf2,Y],[],H7,Hout) :-Xf2 #\= 1,get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

Page 88: A CLP Heap Solver for Test Case Generation [2ex]

8 11

CLP Heap Solver - How does the it work?Example for back-propagation

Java program

m(C x,C y,C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x.f==1)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-set field(Hin,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),get field(H6,X,f,Xf2,H7),if([Xf2,Y],[],H7,Hout).

if([Xf2,Y],[],H7,Hout) :-Xf2 #= 1,get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([Xf2,Y],[],H7,Hout) :-Xf2 #\= 1,get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

Page 89: A CLP Heap Solver for Test Case Generation [2ex]

8 11

CLP Heap Solver - How does the it work?Example for back-propagation

Java program

m(C x,C y,C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x.f==1)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-set field(Hin,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),get field(H6,X,f,Xf2,H7),if([Xf2,Y],[],H7,Hout).

if([Xf2,Y],[],H7,Hout) :-Xf2 #= 1,get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([Xf2,Y],[],H7,Hout) :-Xf2 #\= 1,get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

Page 90: A CLP Heap Solver for Test Case Generation [2ex]

8 11

CLP Heap Solver - How does the it work?Example for back-propagation

Java program

m(C x,C y,C z){

x.f = 1;z.f = -5;y.f = x.f+1;m2();if (x.f==1)m3(y.f);

elsem4(y.f);

}

CLP-translation

m([X,Y,Z],[],Hin,Hout) :-set field(Hin,X,f,1,H2),set field(H2,Z,f,-5,H3),get field(H3,X,f,Xf,H4),Yf #= Xf+1,set field(H4,Y,f,Yf,H5),m2([],[],H5,H6),get field(H6,X,f,Xf2,H7),if([Xf2,Y],[],H7,Hout).

if([Xf2,Y],[],H7,Hout) :-Xf2 #= 1,get field(H7,Y,f,Yf,H8),m3([Yf],[],H8,Hout).

if([Xf2,Y],[],H7,Hout) :-Xf2 #\= 1,get field(H7,Y,f,Yf,H8),m4([Yf],[],H8,Hout).

Heap Updates

S

Page 91: A CLP Heap Solver for Test Case Generation [2ex]

9 11

Experimental Results

I 12 benchmarks from net.datastructures Java library

I Loops iterated at most one time per run

I Constraint system solved to obtain actual test cases

Method C N1 T1 N2 T2 N3 T3

DLL.add 139 33 36 200 177 33 42Seq.removeAt 213 36 42 89 116 37 50Seq.replaceAt 187 36 41 39 47 37 27PQ.insert 399 101 160 3602 10672 101 182PQ.remove 193 12 11 86 68 12 15BST.addAll 293 379 2019 919 - 379 2535BST.find 269 62 108 184 285 62 98BST.findAll 428 330 2385 1165 - 330 2538BST.insert 426 970 2527 8365 - 970 3924BST.remove 516 203 615 2745 5587 203 725HPQ.insert 349 61 283 135 638 95 163HPQ.remove 469 80 1814 2021 - 146 2378

Number of paths

0 2 4 6 8 10 12

0

2,000

4,000

6,000

8,000 No AliasingLazy Initialization

Heap-Solver

Total TCG time

0 2 4 6 8 10 12

0

2,000

4,000

6,000No Aliasing

Lazy InitializationHeap-Solver

I Handling reference aliasing efficiently is paramount

I The more complex the program, the bigger the gains

Page 92: A CLP Heap Solver for Test Case Generation [2ex]

9 11

Experimental Results

I 12 benchmarks from net.datastructures Java library

I Loops iterated at most one time per run

I Constraint system solved to obtain actual test cases

Method C N1 T1 N2 T2 N3 T3

DLL.add 139 33 36 200 177 33 42Seq.removeAt 213 36 42 89 116 37 50Seq.replaceAt 187 36 41 39 47 37 27PQ.insert 399 101 160 3602 10672 101 182PQ.remove 193 12 11 86 68 12 15BST.addAll 293 379 2019 919 - 379 2535BST.find 269 62 108 184 285 62 98BST.findAll 428 330 2385 1165 - 330 2538BST.insert 426 970 2527 8365 - 970 3924BST.remove 516 203 615 2745 5587 203 725HPQ.insert 349 61 283 135 638 95 163HPQ.remove 469 80 1814 2021 - 146 2378

Number of paths

0 2 4 6 8 10 12

0

2,000

4,000

6,000

8,000 No AliasingLazy Initialization

Heap-Solver

Total TCG time

0 2 4 6 8 10 12

0

2,000

4,000

6,000No Aliasing

Lazy InitializationHeap-Solver

I Handling reference aliasing efficiently is paramount

I The more complex the program, the bigger the gains

Page 93: A CLP Heap Solver for Test Case Generation [2ex]

9 11

Experimental Results

I 12 benchmarks from net.datastructures Java library

I Loops iterated at most one time per run

I Constraint system solved to obtain actual test cases

Method C N1 T1 N2 T2 N3 T3

DLL.add 139 33 36 200 177 33 42Seq.removeAt 213 36 42 89 116 37 50Seq.replaceAt 187 36 41 39 47 37 27PQ.insert 399 101 160 3602 10672 101 182PQ.remove 193 12 11 86 68 12 15BST.addAll 293 379 2019 919 - 379 2535BST.find 269 62 108 184 285 62 98BST.findAll 428 330 2385 1165 - 330 2538BST.insert 426 970 2527 8365 - 970 3924BST.remove 516 203 615 2745 5587 203 725HPQ.insert 349 61 283 135 638 95 163HPQ.remove 469 80 1814 2021 - 146 2378

Number of paths

0 2 4 6 8 10 12

0

2,000

4,000

6,000

8,000 No AliasingLazy Initialization

Heap-Solver

Total TCG time

0 2 4 6 8 10 12

0

2,000

4,000

6,000No Aliasing

Lazy InitializationHeap-Solver

I Handling reference aliasing efficiently is paramount

I The more complex the program, the bigger the gains

Page 94: A CLP Heap Solver for Test Case Generation [2ex]

9 11

Experimental Results

I 12 benchmarks from net.datastructures Java library

I Loops iterated at most one time per run

I Constraint system solved to obtain actual test cases

Method C N1 T1 N2 T2 N3 T3

DLL.add 139 33 36 200 177 33 42Seq.removeAt 213 36 42 89 116 37 50Seq.replaceAt 187 36 41 39 47 37 27PQ.insert 399 101 160 3602 10672 101 182PQ.remove 193 12 11 86 68 12 15BST.addAll 293 379 2019 919 - 379 2535BST.find 269 62 108 184 285 62 98BST.findAll 428 330 2385 1165 - 330 2538BST.insert 426 970 2527 8365 - 970 3924BST.remove 516 203 615 2745 5587 203 725HPQ.insert 349 61 283 135 638 95 163HPQ.remove 469 80 1814 2021 - 146 2378

Number of paths

0 2 4 6 8 10 12

0

2,000

4,000

6,000

8,000 No AliasingLazy Initialization

Heap-Solver

Total TCG time

0 2 4 6 8 10 12

0

2,000

4,000

6,000No Aliasing

Lazy InitializationHeap-Solver

I Handling reference aliasing efficiently is paramount

I The more complex the program, the bigger the gains

Page 95: A CLP Heap Solver for Test Case Generation [2ex]

9 11

Experimental Results

I 12 benchmarks from net.datastructures Java library

I Loops iterated at most one time per run

I Constraint system solved to obtain actual test cases

Method C N1 T1 N2 T2 N3 T3

DLL.add 139 33 36 200 177 33 42Seq.removeAt 213 36 42 89 116 37 50Seq.replaceAt 187 36 41 39 47 37 27PQ.insert 399 101 160 3602 10672 101 182PQ.remove 193 12 11 86 68 12 15BST.addAll 293 379 2019 919 - 379 2535BST.find 269 62 108 184 285 62 98BST.findAll 428 330 2385 1165 - 330 2538BST.insert 426 970 2527 8365 - 970 3924BST.remove 516 203 615 2745 5587 203 725HPQ.insert 349 61 283 135 638 95 163HPQ.remove 469 80 1814 2021 - 146 2378

Number of paths

0 2 4 6 8 10 12

0

2,000

4,000

6,000

8,000 No AliasingLazy Initialization

Heap-Solver

Total TCG time

0 2 4 6 8 10 12

0

2,000

4,000

6,000No Aliasing

Lazy InitializationHeap-Solver

I Handling reference aliasing efficiently is paramount

I The more complex the program, the bigger the gains

Page 96: A CLP Heap Solver for Test Case Generation [2ex]

9 11

Experimental Results

I 12 benchmarks from net.datastructures Java library

I Loops iterated at most one time per run

I Constraint system solved to obtain actual test cases

Method C N1 T1 N2 T2 N3 T3

DLL.add 139 33 36 200 177 33 42Seq.removeAt 213 36 42 89 116 37 50Seq.replaceAt 187 36 41 39 47 37 27PQ.insert 399 101 160 3602 10672 101 182PQ.remove 193 12 11 86 68 12 15BST.addAll 293 379 2019 919 - 379 2535BST.find 269 62 108 184 285 62 98BST.findAll 428 330 2385 1165 - 330 2538BST.insert 426 970 2527 8365 - 970 3924BST.remove 516 203 615 2745 5587 203 725HPQ.insert 349 61 283 135 638 95 163HPQ.remove 469 80 1814 2021 - 146 2378

Number of paths

0 2 4 6 8 10 12

0

2,000

4,000

6,000

8,000 No AliasingLazy Initialization

Heap-Solver

Total TCG time

0 2 4 6 8 10 12

0

2,000

4,000

6,000No Aliasing

Lazy InitializationHeap-Solver

I Handling reference aliasing efficiently is paramount

I The more complex the program, the bigger the gains

Page 97: A CLP Heap Solver for Test Case Generation [2ex]

9 11

Experimental Results

I 12 benchmarks from net.datastructures Java library

I Loops iterated at most one time per run

I Constraint system solved to obtain actual test cases

Method C N1 T1 N2 T2 N3 T3

DLL.add 139 33 36 200 177 33 42Seq.removeAt 213 36 42 89 116 37 50Seq.replaceAt 187 36 41 39 47 37 27PQ.insert 399 101 160 3602 10672 101 182PQ.remove 193 12 11 86 68 12 15BST.addAll 293 379 2019 919 - 379 2535BST.find 269 62 108 184 285 62 98BST.findAll 428 330 2385 1165 - 330 2538BST.insert 426 970 2527 8365 - 970 3924BST.remove 516 203 615 2745 5587 203 725HPQ.insert 349 61 283 135 638 95 163HPQ.remove 469 80 1814 2021 - 146 2378

Number of paths

0 2 4 6 8 10 12

0

2,000

4,000

6,000

8,000 No AliasingLazy Initialization

Heap-Solver

Total TCG time

0 2 4 6 8 10 12

0

2,000

4,000

6,000No Aliasing

Lazy InitializationHeap-Solver

I Handling reference aliasing efficiently is paramount

I The more complex the program, the bigger the gains

Page 98: A CLP Heap Solver for Test Case Generation [2ex]

10 11

Conclusions

I Novel approach to TCG for heap-manipulating programsI As effective as previous approaches

I No loss of precision

I More efficient and scalableI Applicable to other TCG tools

I In the paperI Formalization of heap representation and operationsI Extension to handle arraysI Support for heap assumptions: non-aliasing(a,b), acyclic(a),

non-sharing(a,b)I Implementation details and experimental evaluation

Page 99: A CLP Heap Solver for Test Case Generation [2ex]

10 11

Conclusions

I Novel approach to TCG for heap-manipulating programs

I As effective as previous approachesI No loss of precision

I More efficient and scalableI Applicable to other TCG tools

I In the paperI Formalization of heap representation and operationsI Extension to handle arraysI Support for heap assumptions: non-aliasing(a,b), acyclic(a),

non-sharing(a,b)I Implementation details and experimental evaluation

Page 100: A CLP Heap Solver for Test Case Generation [2ex]

10 11

Conclusions

I Novel approach to TCG for heap-manipulating programsI As effective as previous approaches

I No loss of precision

I More efficient and scalableI Applicable to other TCG tools

I In the paperI Formalization of heap representation and operationsI Extension to handle arraysI Support for heap assumptions: non-aliasing(a,b), acyclic(a),

non-sharing(a,b)I Implementation details and experimental evaluation

Page 101: A CLP Heap Solver for Test Case Generation [2ex]

10 11

Conclusions

I Novel approach to TCG for heap-manipulating programsI As effective as previous approaches

I No loss of precision

I More efficient and scalableI Applicable to other TCG tools

I In the paperI Formalization of heap representation and operationsI Extension to handle arraysI Support for heap assumptions: non-aliasing(a,b), acyclic(a),

non-sharing(a,b)I Implementation details and experimental evaluation

Page 102: A CLP Heap Solver for Test Case Generation [2ex]

10 11

Conclusions

I Novel approach to TCG for heap-manipulating programsI As effective as previous approaches

I No loss of precision

I More efficient and scalable

I Applicable to other TCG tools

I In the paperI Formalization of heap representation and operationsI Extension to handle arraysI Support for heap assumptions: non-aliasing(a,b), acyclic(a),

non-sharing(a,b)I Implementation details and experimental evaluation

Page 103: A CLP Heap Solver for Test Case Generation [2ex]

10 11

Conclusions

I Novel approach to TCG for heap-manipulating programsI As effective as previous approaches

I No loss of precision

I More efficient and scalableI Applicable to other TCG tools

I In the paperI Formalization of heap representation and operationsI Extension to handle arraysI Support for heap assumptions: non-aliasing(a,b), acyclic(a),

non-sharing(a,b)I Implementation details and experimental evaluation

Page 104: A CLP Heap Solver for Test Case Generation [2ex]

10 11

Conclusions

I Novel approach to TCG for heap-manipulating programsI As effective as previous approaches

I No loss of precision

I More efficient and scalableI Applicable to other TCG tools

I In the paper

I Formalization of heap representation and operationsI Extension to handle arraysI Support for heap assumptions: non-aliasing(a,b), acyclic(a),

non-sharing(a,b)I Implementation details and experimental evaluation

Page 105: A CLP Heap Solver for Test Case Generation [2ex]

10 11

Conclusions

I Novel approach to TCG for heap-manipulating programsI As effective as previous approaches

I No loss of precision

I More efficient and scalableI Applicable to other TCG tools

I In the paperI Formalization of heap representation and operations

I Extension to handle arraysI Support for heap assumptions: non-aliasing(a,b), acyclic(a),

non-sharing(a,b)I Implementation details and experimental evaluation

Page 106: A CLP Heap Solver for Test Case Generation [2ex]

10 11

Conclusions

I Novel approach to TCG for heap-manipulating programsI As effective as previous approaches

I No loss of precision

I More efficient and scalableI Applicable to other TCG tools

I In the paperI Formalization of heap representation and operationsI Extension to handle arrays

I Support for heap assumptions: non-aliasing(a,b), acyclic(a),non-sharing(a,b)

I Implementation details and experimental evaluation

Page 107: A CLP Heap Solver for Test Case Generation [2ex]

10 11

Conclusions

I Novel approach to TCG for heap-manipulating programsI As effective as previous approaches

I No loss of precision

I More efficient and scalableI Applicable to other TCG tools

I In the paperI Formalization of heap representation and operationsI Extension to handle arraysI Support for heap assumptions: non-aliasing(a,b), acyclic(a),

non-sharing(a,b)

I Implementation details and experimental evaluation

Page 108: A CLP Heap Solver for Test Case Generation [2ex]

10 11

Conclusions

I Novel approach to TCG for heap-manipulating programsI As effective as previous approaches

I No loss of precision

I More efficient and scalableI Applicable to other TCG tools

I In the paperI Formalization of heap representation and operationsI Extension to handle arraysI Support for heap assumptions: non-aliasing(a,b), acyclic(a),

non-sharing(a,b)I Implementation details and experimental evaluation

Page 109: A CLP Heap Solver for Test Case Generation [2ex]

Thanks!

Page 110: A CLP Heap Solver for Test Case Generation [2ex]

12 11

Extra ExampleField read and write accesses

Mutually inclusive rules are generated for read-accesses

int a = x.f;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),get field(H1,Y,f,Yf,H2),get field(H2,Z,f,Zf,H3),

Mutually exclusive rules are generated for write-accesses

Page 111: A CLP Heap Solver for Test Case Generation [2ex]

12 11

Extra ExampleField read and write accesses

Mutually inclusive rules are generated for read-accesses

int a = x.f;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),get field(H1,Y,f,Yf,H2),get field(H2,Z,f,Zf,H3),

Mutually exclusive rules are generated for write-accesses

Page 112: A CLP Heap Solver for Test Case Generation [2ex]

12 11

Extra ExampleField read and write accesses

Mutually inclusive rules are generated for read-accesses

int a = x.f;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),get field(H1,Y,f,Yf,H2),get field(H2,Z,f,Zf,H3),

Mutually exclusive rules are generated for write-accesses

Page 113: A CLP Heap Solver for Test Case Generation [2ex]

12 11

Extra ExampleField read and write accesses

Mutually inclusive rules are generated for read-accesses

int a = x.f;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),get field(H1,Y,f,Yf,H2),get field(H2,Z,f,Zf,H3),

Mutually exclusive rules are generated for write-accesses

Page 114: A CLP Heap Solver for Test Case Generation [2ex]

12 11

Extra ExampleField read and write accesses

Mutually inclusive rules are generated for read-accesses

int a = x.f;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),get field(H1,Y,f,Yf,H2),get field(H2,Z,f,Zf,H3),

Mutually exclusive rules are generated for write-accesses

Page 115: A CLP Heap Solver for Test Case Generation [2ex]

12 11

Extra ExampleField read and write accesses

Mutually inclusive rules are generated for read-accesses

int a = x.f;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),get field(H1,Y,f,Yf,H2),get field(H2,Z,f,Zf,H3)

Mutually exclusive rules are generated for write-accesses

Page 116: A CLP Heap Solver for Test Case Generation [2ex]

12 11

Extra ExampleField read and write accesses

Mutually inclusive rules are generated for read-accesses

int a = x.f;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),get field(H1,Y,f,Yf,H2),get field(H2,Z,f,Zf,H3)

Mutually exclusive rules are generated for write-accesses

Page 117: A CLP Heap Solver for Test Case Generation [2ex]

12 11

Extra ExampleField read and write accesses

Mutually inclusive rules are generated for read-accesses

int a = x.f;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),get field(H1,Y,f,Yf,H2),get field(H2,Z,f,Zf,H3)

Mutually exclusive rules are generated for write-accesses

Page 118: A CLP Heap Solver for Test Case Generation [2ex]

12 11

Extra ExampleField read and write accesses

Mutually inclusive rules are generated for read-accesses

int a = x.f;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),get field(H1,Y,f,Yf,H2),get field(H2,Z,f,Zf,H3)

Mutually exclusive rules are generated for write-accesses

Page 119: A CLP Heap Solver for Test Case Generation [2ex]

12 11

Extra ExampleField read and write accesses

Mutually inclusive rules are generated for read-accesses

int a = x.f;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),get field(H1,Y,f,Yf,H2),get field(H2,Z,f,Zf,H3)

Mutually exclusive rules are generated for write-accesses

int a = x.f;w.f = a;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),set field(H1,W,f,Wf,H2),get field(H2,Y,f,Yf,H3),get field(H3,Z,f,Zf,H4),

Page 120: A CLP Heap Solver for Test Case Generation [2ex]

12 11

Extra ExampleField read and write accesses

Mutually inclusive rules are generated for read-accesses

int a = x.f;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),get field(H1,Y,f,Yf,H2),get field(H2,Z,f,Zf,H3)

Mutually exclusive rules are generated for write-accesses

int a = x.f;w.f = a;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),set field(H1,W,f,Wf,H2),get field(H2,Y,f,Yf,H3),get field(H3,Z,f,Zf,H4),

Page 121: A CLP Heap Solver for Test Case Generation [2ex]

12 11

Extra ExampleField read and write accesses

Mutually inclusive rules are generated for read-accesses

int a = x.f;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),get field(H1,Y,f,Yf,H2),get field(H2,Z,f,Zf,H3)

Mutually exclusive rules are generated for write-accesses

int a = x.f;w.f = a;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),set field(H1,W,f,Wf,H2),get field(H2,Y,f,Yf,H3),get field(H3,Z,f,Zf,H4),

Page 122: A CLP Heap Solver for Test Case Generation [2ex]

12 11

Extra ExampleField read and write accesses

Mutually inclusive rules are generated for read-accesses

int a = x.f;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),get field(H1,Y,f,Yf,H2),get field(H2,Z,f,Zf,H3)

Mutually exclusive rules are generated for write-accesses

int a = x.f;w.f = a;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),set field(H1,W,f,Wf,H2),get field(H2,Y,f,Yf,H3),get field(H3,Z,f,Zf,H4),

Page 123: A CLP Heap Solver for Test Case Generation [2ex]

12 11

Extra ExampleField read and write accesses

Mutually inclusive rules are generated for read-accesses

int a = x.f;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),get field(H1,Y,f,Yf,H2),get field(H2,Z,f,Zf,H3)

Mutually exclusive rules are generated for write-accesses

int a = x.f;w.f = a;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),set field(H1,W,f,Wf,H2),get field(H2,Y,f,Yf,H3),get field(H3,Z,f,Zf,H4),

Page 124: A CLP Heap Solver for Test Case Generation [2ex]

12 11

Extra ExampleField read and write accesses

Mutually inclusive rules are generated for read-accesses

int a = x.f;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),get field(H1,Y,f,Yf,H2),get field(H2,Z,f,Zf,H3)

Mutually exclusive rules are generated for write-accesses

int a = x.f;w.f = a;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),set field(H1,W,f,Wf,H2),get field(H2,Y,f,Yf,H3),get field(H3,Z,f,Zf,H4),

Page 125: A CLP Heap Solver for Test Case Generation [2ex]

12 11

Extra ExampleField read and write accesses

Mutually inclusive rules are generated for read-accesses

int a = x.f;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),get field(H1,Y,f,Yf,H2),get field(H2,Z,f,Zf,H3)

Mutually exclusive rules are generated for write-accesses

int a = x.f;w.f = a;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),set field(H1,W,f,Wf,H2),get field(H2,Y,f,Yf,H3),get field(H3,Z,f,Zf,H4),

Page 126: A CLP Heap Solver for Test Case Generation [2ex]

12 11

Extra ExampleField read and write accesses

Mutually inclusive rules are generated for read-accesses

int a = x.f;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),get field(H1,Y,f,Yf,H2),get field(H2,Z,f,Zf,H3)

Mutually exclusive rules are generated for write-accesses

int a = x.f;w.f = a;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),set field(H1,W,f,Wf,H2),get field(H2,Y,f,Yf,H3),get field(H3,Z,f,Zf,H4)

Page 127: A CLP Heap Solver for Test Case Generation [2ex]

12 11

Extra ExampleField read and write accesses

Mutually inclusive rules are generated for read-accesses

int a = x.f;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),get field(H1,Y,f,Yf,H2),get field(H2,Z,f,Zf,H3)

Mutually exclusive rules are generated for write-accesses

int a = x.f;w.f = a;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),set field(H1,W,f,Wf,H2),get field(H2,Y,f,Yf,H3),get field(H3,Z,f,Zf,H4)

Page 128: A CLP Heap Solver for Test Case Generation [2ex]

12 11

Extra ExampleField read and write accesses

Mutually inclusive rules are generated for read-accesses

int a = x.f;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),get field(H1,Y,f,Yf,H2),get field(H2,Z,f,Zf,H3)

Mutually exclusive rules are generated for write-accesses

int a = x.f;w.f = a;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),set field(H1,W,f,Wf,H2),get field(H2,Y,f,Yf,H3),get field(H3,Z,f,Zf,H4)

Page 129: A CLP Heap Solver for Test Case Generation [2ex]

12 11

Extra ExampleField read and write accesses

Mutually inclusive rules are generated for read-accesses

int a = x.f;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),get field(H1,Y,f,Yf,H2),get field(H2,Z,f,Zf,H3)

Mutually exclusive rules are generated for write-accesses

int a = x.f;w.f = a;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),set field(H1,W,f,Wf,H2),get field(H2,Y,f,Yf,H3),get field(H3,Z,f,Zf,H4)

Page 130: A CLP Heap Solver for Test Case Generation [2ex]

12 11

Extra ExampleField read and write accesses

Mutually inclusive rules are generated for read-accesses

int a = x.f;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),get field(H1,Y,f,Yf,H2),get field(H2,Z,f,Zf,H3)

Mutually exclusive rules are generated for write-accesses

int a = x.f;w.f = a;int b = y.f;int c = z.f;

get field(H0,X,f,Xf,H1),set field(H1,W,f,Wf,H2),get field(H2,Y,f,Yf,H3),get field(H3,Z,f,Zf,H4)

Page 131: A CLP Heap Solver for Test Case Generation [2ex]

13 11

Heap Operations

get field(Hin,Ref,FSig,Var{R},Hout)

(Ref 7→ O) ∈ NVar ← O[FSig ]

〈S,N ,RC〉; 〈S,N ,RC〉

(Ref 7→ O) /∈ N 〈R, dom(Var)〉 ← ψ(S,Ref ,FSig ,Var , true)S′ ← getF (Ref ,FSig ,Var ,S)

〈S,N ,RC〉; 〈S′,N ,RC〉

where ψ(S,Ref ,FSig ,Var , ϕ) =

〈{ϕ→ Var = F} , dom(F )〉 (F fresh) S = ∅

〈{ϕ→ Var = F} , dom(F )〉 S = [g |s]etF (Ref ,FSig ,F ,Si )

〈{ϕ ∧ Ref = Ref i → Var = F} ∪ Ri , dom(F ) ∪ Di 〉 S = getF (Ref i ,FSig ,F ,Si )where 〈Ri ,Di 〉 = ψ(Si ,Ref ,FSig ,Var , ϕ)

〈{ϕ ∧ Ref = Ref i → Var = F} ∪ Ri , dom(F ) ∪ Di 〉 S = setF (Ref i ,FSig ,F ,Si )where 〈Ri ,Di 〉 = ψ(Si ,Ref ,FSig ,Var , ϕ ∧ Ref 6= Ref i )

ψ(Si ,Ref ,FSig ,Var , ϕ) S = [g |s]etF (Ref i ,FSig ,F ,Si )

Page 132: A CLP Heap Solver for Test Case Generation [2ex]

14 11

Heap Operations

set field(Hin,Ref,FSig,Data,Hout)

(Ref 7→ O) ∈ NN ′ ← N [Ref 7→ O[FSig 7→ Data]]

〈S,N ,RC〉; 〈S,N ′,RC〉

(Ref 7→ O) /∈ NS′ ← setF (Ref ,FSig ,Data,S)

〈S,N ,RC〉; 〈S′,N ,RC〉

new object(Hin,C,Ref,Hout)

new(Ref ) createObject(C ,O) N ′ = N ∪ {Ref 7→ O}

〈S,N ,RC〉; 〈S,N ′,RC〉

Page 133: A CLP Heap Solver for Test Case Generation [2ex]

15 11

Heap Operations

ref eq(Hin,Ref1,Ref2,Hout)

t ≡ Ref 1 = Ref 2 S′ ← propagate(S, t)

〈S,N ,RC〉; 〈S′,N ,RC〉

propagate(S, t): ∀getF (Ref ,FSig , Var , ) in S, ∀r ∈ R:

(I) If t ∈ lhs(r), remove t from lhs(r), if new lhs(r) ≡ true, add rhs(r) toconstraint store

(II) If ¬t ∈ lhs(r), then lhs(r) can never hold, remove r from R

ref neq(Hin,Ref1,Ref2,Hout)

t ≡ Ref 1 6= Ref 2 S′ ← propagate(S, t) RC′ = RC ∪ {t}

〈S,N ,RC〉; 〈S′,N ,RC′〉