Presentation is loading. Please wait.

Presentation is loading. Please wait.

Non-Termination of Affine Loops Kevin Durant, Corina Pasareanu, Willem Visser Stellenbosch University and NASA/CMU.

Similar presentations


Presentation on theme: "Non-Termination of Affine Loops Kevin Durant, Corina Pasareanu, Willem Visser Stellenbosch University and NASA/CMU."— Presentation transcript:

1 Non-Termination of Affine Loops Kevin Durant, Corina Pasareanu, Willem Visser Stellenbosch University and NASA/CMU

2 public String preserveTags(String body) {…}

3 Infinite loops are the worst kind of error, since it is input driven and therefore can reappear frequently, in fact infinitely often!

4 Symbolic String Analysis (Almost) All Java String operations covered Mixed Integer and String constraints Automata and SMT (bitvector) back-ends Part of Symbolic PathFinder M.Sc. by Gideon Redelinghuys Collaborators – Jaco Geldenhuys (Stellenbosch)

5 Infinite Loop? while (x > 0) (x,y) = (x+y+2,-x); Try (2,-3)

6 We only consider affine transformations on loop variables and simple loop conditions such as x>0 and x>=0

7 x,y are inputs while (x >= 0) { x := x – y; } Infinite Loop?

8 x,y are inputs while (x >= 0) { assert(‘x > x); x := x – y; } Ranking functions

9 Use ranking functions for non-termination!

10 x,y are inputs while (x >= 0) { assert(‘x > x); x := x – y; } Ranking functions ‘x <= x … {c /\ wp(s,‘x <= x)} s {c /\ wp(s,‘x <= x)}

11 x,y are inputs while (x >= 0) { assert(‘x > x); x := x – y; } Inductive? {x >= 0 /\ wp(x:=x-y,‘x <= x)} x := x - y {x >= 0/\ wp(x:=x-y,‘x <= x)} wp(x:=x-y,’x<=x) = {x <= x-y} {x >= 0 /\ y <= 0} x := x - y {x >= 0 /\ y <= 0}

12 So how about just… while (c) { s; } {c /\ wp(s,!rr)} s {c /\ wp(s,!rr)}

13 x,y are inputs while (x >= 0) { assert(‘x > x); x := x + y; y := 1 – y; }

14 x,y are inputs while (x >= 0) { assert(‘x > x); x := x + y; y := 1 – y; } {x >= 0 /\ wp(x:=x+y;y:=1-y,‘x <= x)} x := x – y; y := 1 – y; {x >= 0/\ wp(x:=x+y;y:=1-y,‘x <= x)} wp(x:=x+y;y:=1-y,’x<=x) = {x <= x+(1-y)} {x >= 0 /\ y <= 1} x:=x+y;y:=1-y; {x >= 0 /\ y <= 1}

15 ‘x <= x … ‘x <= x … N while (c) { s; } {c /\ wp(s n,!rr)} s n {c /\ wp(s n,!rr)}

16 while (x 0 > 0) { f(x) = Ax+b; } We conjecture that if there is an infinite loop then there exist n such that for all x for which the following is true you will loop infinitely x 0 > 0 /\ f 1 (x) > 0 /\ … /\ f 2n-1 (x) > 0 /\ x 0 ≤ f n (x) => f n (x) ≤ f 2n (x) Can we derive n from the number of variables in x? For 1 variable n = 2For 2 variables n >= 6 For 3 variables there is no n

17 Infinite Loop and no “n” while (x > 0) { x = 5x+y+z, y = 4y+3z, z = -3y+4z; }

18 Implementation JavaPathFinder Symbolic PathFinder SPF AffineLoopListener Model Checker for Java Open Source http://babelfish.arc.nasa.gov/trac/jpf Symbolic Execution extension for JPF called jpf-symbc Custom Listener on SPF Tries n = 0..6

19 To Do Study how many loops can be handled? Combine with abstraction Nested Loops?


Download ppt "Non-Termination of Affine Loops Kevin Durant, Corina Pasareanu, Willem Visser Stellenbosch University and NASA/CMU."

Similar presentations


Ads by Google