Simple, efficient but unsound (can’t prove absence of bugs)
Abstract Interpretation:
Class of deterministic program analyses
Interpret (analyze) an abstraction (approximation) of program
Sound but usually complicated, expensive
Random Interpretation:
Class of randomized program analyses
Almost as simple, efficient as random testing
Almost as sound as abstract interpretation
5.
Example 1 a := 0; b := i; a := i-2; b := 2; c := b – a; d := i – 2b; assert(c+d = 0); assert(c = a+i) c := 2a + b; d := b – 2i; True False False True * *
6.
Example 1: Random Testing a := 0; b := i; a := i-2; b := 2; c := b – a; d := i – 2b; assert(c+d = 0); assert(c = a+i) c := 2a + b; d := b – 2i; True False False True * *
Need to test blue path to falsify second assertion.
Chances of choosing blue path from set of all 4 paths are small.
Hence, random testing is unsound.
7.
Example 1: Abstract Interpretation a+b=i a+b=i, c=-d a=i-2, b=2 a+b=i c=2a+b, d=b-2i a+b=i c=b-a, d=i-2b a=0, b=i a := 0; b := i; a := i-2; b := 2; c := b – a; d := i – 2b; assert(c+d = 0); assert(c = a+i) c := 2a + b; d := b – 2i; True False False True * *
Computes invariant at each program point.
Operations are usually complicated and expensive.
8.
Example 1: Random Interpretation a := 0; b := i; a := i-2; b := 2; c := b – a; d := i – 2b; assert(c+d = 0); assert(c = a+i) c := 2a + b; d := b – 2i; True False False True * *
Affine join preserves common linear relationships (a+b=5)
It does not introduce false relationships w.h.p.
Unfortunately, non-linear relationships are not preserved (e.g. a £ (1+b) = 8)
w = 5 w = 7 a = 5 (2,4) = -6 b = 5 (3,1) = 11 a = 2 b = 3 a = 4 b = 1 a = 7 (2,4) = -10 b = 7 (3,1) = 15
14.
Geometric Interpretation of Affine Join a b a + b = 5 b = 2 (a = 2, b = 3) (a = 4, b = 1) : State before the join : State after the join satisfies all the affine relationships that are satisfied by both (e.g. a + b = 5) Given any relationship that is not satisfied by any of (e.g. b=2), also does not satisfy it with high probability
15.
i=3, a=0, b=3 i=3 a := 0; b := i; a := i-2; b := 2; c := b – a; d := i – 2b; assert (c+d = 0); assert (c = a+i) i=3, a=-4, b=7 i=3, a=-4, b=7 c=23, d=-23 c := 2a + b; d := b – 2i; i=3, a=1, b=2 i=3, a=-4, b=7 c=-1, d=1 i=3, a=-4, b=7 c=11, d=-11 False False w 1 = 5 w 2 = 2 True True * * Example 1
Choose a random weight for each join independently.
All choices of random weights verify first assertion
Introduces false equivalences in straight-line code.
E.g. e and e’ have same encodings even though e e’
Problem: Scalar multiplication is commutative.
Solution: Choose r 1 and r 2 to be random matrices and evaluate expressions to vectors
Encodings e = r 1 ( r 1 a+ r 2 b) + r 2 ( r 1 c+ r 2 d) = r 1 2 (a)+ r 1 r 2 (b)+ r 2 r 1 (c)+ r 2 2 (d) e’ = r 1 2 (a)+ r 1 r 2 (c)+ r 2 r 1 (b)+ r 2 2 (d) F F F a b c d e = F F F a c b d e’ =
27.
Example a := 0; b := i; a := i-2; b := 2; c := b – a; d := i – 2b; assert (c + d = 0); assert (c = a + i) c := 2a + b; d := b – 2i; True False False
Be the first to comment