An Accurate Join for Zonotopes, Preserving Affine Input/Output Relations Eric Goubault, Tristan Le Gall and Sylvie Putot CEA, LIST - LMeASI NSAD’12
Motivation Static Analysis of Numerical Programs ◮ Goal : to find numerical invariants, to give an upper bound for numerical errors ◮ Problems : ◮ infinite domains ⇒ symbolic representation ◮ precision, difference between real numbers arithmetics and floating-point arithmetics ◮ infinite loops, numerical drift (e.g. Patriot missile) Numerical Abstract Domains ◮ Classical ones : Intervals, convex polyhedra ◮ Recent ones : Octagons, linear templates ◮ In Fluctuat : Affine sets (zonotopes) 2 / 19
Motivation Static Analysis of Numerical Programs ◮ Goal : to find numerical invariants, to give an upper bound for numerical errors ◮ Problems : ◮ infinite domains ⇒ symbolic representation ◮ precision, difference between real numbers arithmetics and floating-point arithmetics ◮ infinite loops, numerical drift (e.g. Patriot missile) Numerical Abstract Domains ◮ Classical ones : Intervals, convex polyhedra ◮ Recent ones : Octagons, linear templates ◮ In Fluctuat : Affine sets (zonotopes) We present a new, accurate join operator for zonotopes 2 / 19
Outline Presentation of the abstract domain A new join operator Experiments 3 / 19
Zonotopes (1) : Symbolic Representation and Concretization Symbolic representation ◮ Each variable = linear sum of noise symbols : ˆ x = 20 − 4 ε 1 + 2 ε 3 + 3 ε 4 ◮ Noise symbols are shared variables, whose range is [ − 1 , 1] ◮ Alternative definition : Minkowski sum of vectors defined by the coefficients of the noise symbols An affine set and its concretization y 15 The gray zonotope is the concretization of the affine set (ˆ x , ˆ y ), with x = 20 − 4 ε 1 + 2 ε 3 + 3 ε 4 , ˆ 10 y = 10 − 2 ε 1 + ε 2 − ε 4 , ˆ t A and = � 20 � − 4 0 2 3 5 x 10 − 2 1 0 − 1 10 15 20 25 30 4 / 19
Zonotopes (2) : Partial order Functional Order, Augmented Space ◮ Partial order on affine sets is a functional order Example ˆ x = 2 + ǫ and ˆ x = 2 − ǫ (concretization : [1 , 3]) ǫ x 5 / 19
Zonotopes (2) : Partial order Functional Order, Augmented Space ◮ Partial order on affine sets is a functional order ◮ Functional order � = geometrical order of the concretization in R p Example ˆ x = 2 + ǫ and ˆ x = 2 − ǫ (concretization : [1 , 3]) ǫ x 5 / 19
Zonotopes (2) : Partial order Functional Order, Augmented Space ◮ Partial order on affine sets is a functional order ◮ Functional order � = geometrical order of the concretization in R p ◮ Functional order = geometrical order in augmentend space R p + n Example ˆ x = 2 + ǫ and ˆ x = 2 − ǫ (concretization : [1 , 3]) ǫ x 5 / 19
Zonotopes (3) : Semantics of + and × Consider two affines sets ˆ x = 2 + 3 ǫ 1 − 2 ǫ 2 and ˆ y = 3 + 2 ǫ 2 Addition x + y ◮ Exact operation � x + y = 5 + 3 ǫ 1 Multiplication x × y ◮ Exact operation x × y = 6 + 9 ǫ 1 + (4 − 6) ǫ 2 + 6 ǫ 1 ǫ 2 − 4 ǫ 2 � 2 6 / 19
Zonotopes (3) : Semantics of + and × Consider two affines sets ˆ x = 2 + 3 ǫ 1 − 2 ǫ 2 and ˆ y = 3 + 2 ǫ 2 Addition x + y ◮ Exact operation � x + y = 5 + 3 ǫ 1 Multiplication x × y ◮ Exact operation x × y = 6 + 9 ǫ 1 + (4 − 6) ǫ 2 + 6 ǫ 1 ǫ 2 − 4 ǫ 2 � 2 ◮ Second-order terms range in [ − 10 , 2 . 25] = − 3 . 875 + 6 . 125 η 1 � x × y = 2 . 125 + 9 ǫ 1 − 2 ǫ 2 + 6 . 125 η 1 6 / 19
Zonotopes (4) : Advantages and Drawbacks Advantages ◮ Relational lattice, cheap linear assignments ◮ Non-linear assignments (Taylor, 1st order) Drawbacks ◮ Meet ◮ Join 7 / 19
Zonotopes (4) : Advantages and Drawbacks Advantages ◮ Relational lattice, cheap linear assignments ◮ Non-linear assignments (Taylor, 1st order) Drawbacks / improvements ◮ Meet : constrained affine sets ◮ Join 7 / 19
Zonotopes (4) : Advantages and Drawbacks Advantages ◮ Relational lattice, cheap linear assignments ◮ Non-linear assignments (Taylor, 1st order) Drawbacks / improvements ◮ Meet : constrained affine sets ◮ Join : global join 7 / 19
Example (1) Example of join double x1 := [1,3] ; double x2 := [1,3] ; double x3 ; if (random()) { x1 = x1 + 2 ; x2 = x2 + 2 ; } x3 = x2 - x1 ; Affine sets : ˆ = 2 + ǫ 1 ˆ = 4 + ǫ 1 x 1 x 1 ˆ = 2 + ǫ 2 ˆ = 4 + ǫ 2 x 2 and x 2 x 3 ˆ = ⊤ x 3 ˆ = ⊤ 8 / 19
Example (2) x 2 5 3 1 x 1 0 1 3 5 9 / 19
Example (2) x 2 5 3 1 x 1 0 1 3 5 ◮ Componentwise join (one dimension at a time) ˆ = 3 + ǫ 1 + η 1 x 1 ˆ = 3 + ǫ 2 + η 2 x 2 ˆ = x 3 ⊤ 9 / 19
Example (2) x 2 5 3 1 x 1 0 1 3 5 ◮ Componentwise join (one dimension at a time) ◮ Common affine relation : x 1 − x 2 = ǫ 1 − ǫ 2 9 / 19
Example (2) x 2 5 3 1 x 1 0 1 3 5 ◮ Componentwise join (one dimension at a time) ◮ Common affine relation : x 1 − x 2 = ǫ 1 − ǫ 2 ◮ Global join 9 / 19
Main idea Goal : to preserve affine relations ◮ Two affine sets X and Y , p variables x 1 . . . x p , n + 1 noise symbols ε 0 , . . . , ε n ◮ An affine relation : α 1 x 1 + · · · + α p x p = β 0 ε 0 + β 1 ε 1 + · · · + β n ε n ◮ Our goal : to find an upper bound Z that preserves common affine relations 10 / 19
Main idea Goal : to preserve affine relations ◮ Two affine sets X and Y , p variables x 1 . . . x p , n + 1 noise symbols ε 0 , . . . , ε n ◮ An affine relation : α 1 x 1 + · · · + α p x p = β 0 ε 0 + β 1 ε 1 + · · · + β n ε n ◮ Our goal : to find an upper bound Z that preserves common affine relations Issues 1. How to discover common affine relations ? 2. How to reduce the size of the problem ? 3. How to rebuild the affine sets with the help of the affine relations ? 10 / 19
Geometrical intuition Augmented space ◮ Program variables + noise symbols : vector space, dimension p + n + 1 ◮ Functional order = geometrical order ◮ A relation defines an hyperplane containing the zonotope. 11 / 19
Geometrical intuition Augmented space ◮ Program variables + noise symbols : vector space, dimension p + n + 1 ◮ Functional order = geometrical order ◮ A relation defines an hyperplane containing the zonotope. General algorithm Assume we have k relations, defining the variables x 1 , . . . , x k , we compute X ⊔ G Y : 1. Existential quantification : X > k and Y > k (elimination of x 1 , . . . , x k ) 2. Componentwise join Z > k = X > k ⊔ Y > k 3. Reconstruction (intersection with hyperplanes) Any relation true for both X and Y is also true for Z . 11 / 19
Discovery of common affine relations Algorithm to find affine relations 1. The value of each variable is replaced by its expression (linear sum of noise symbol) 2. The coefficients of noise symbols must be equal in both affine sets X and Y 3. One equation per noise symbol, then we solve them by a Gauss reduction to obtain the coefficients α i , then the coefficients β i 4. Solutions belong to a vector space (finite dimension) Example Affine sets X and Y : x 1 = 2 + ǫ 1 x 1 = 4 + ǫ 1 x 2 = 2 + ǫ 2 and x 2 = 4 + ǫ 2 = ⊤ = ⊤ x 3 x 3 We are looking for a relation : α 1 x 1 + α 2 x 2 = β 0 + β 1 ǫ 1 + β 2 ǫ 2 12 / 19
Discovery of common affine relations (2) Affine sets X and Y : x 1 = 2 + ǫ 1 x 1 = 4 + ǫ 1 x 2 = 2 + ǫ 2 and x 2 = 4 + ǫ 2 x 3 = ⊤ x 3 = ⊤ Example (cont.) 1. We replace x 1 and x 2 by their expressions : α 1 (2 + ǫ 1 ) + α 2 (2 + ǫ 2 ) = β 0 + β 1 ǫ 1 + β 2 ǫ 2 and : α 1 (4 + ǫ 1 ) + α 2 (4 + ǫ 2 ) = β 0 + β 1 ǫ 1 + β 2 ǫ 2 13 / 19
Discovery of common affine relations (2) Affine sets X and Y : x 1 = 2 + ǫ 1 x 1 = 4 + ǫ 1 x 2 = 2 + ǫ 2 and x 2 = 4 + ǫ 2 x 3 = ⊤ x 3 = ⊤ Example (cont.) 1. We replace x 1 and x 2 by their expressions : α 1 (2 + ǫ 1 ) + α 2 (2 + ǫ 2 ) = β 0 + β 1 ǫ 1 + β 2 ǫ 2 and : α 1 (4 + ǫ 1 ) + α 2 (4 + ǫ 2 ) = β 0 + β 1 ǫ 1 + β 2 ǫ 2 2. The coefficients of the noise symbols must be equal ; we get the equations : 2 α 1 + 2 α 2 = 4 α 1 + 4 α 2 , and β 0 = 0, β 1 = α 1 , β 2 = α 2 13 / 19
Discovery of common affine relations (2) Affine sets X and Y : x 1 = 2 + ǫ 1 x 1 = 4 + ǫ 1 x 2 = 2 + ǫ 2 and x 2 = 4 + ǫ 2 x 3 = ⊤ x 3 = ⊤ Example (cont.) 1. We replace x 1 and x 2 by their expressions : α 1 (2 + ǫ 1 ) + α 2 (2 + ǫ 2 ) = β 0 + β 1 ǫ 1 + β 2 ǫ 2 and : α 1 (4 + ǫ 1 ) + α 2 (4 + ǫ 2 ) = β 0 + β 1 ǫ 1 + β 2 ǫ 2 2. The coefficients of the noise symbols must be equal ; we get the equations : 2 α 1 + 2 α 2 = 4 α 1 + 4 α 2 , and β 0 = 0, β 1 = α 1 , β 2 = α 2 3. Example of solution : α 1 = 1 , α 2 = − 1 , β 0 = 0 , β 1 = 1 , β 2 = − 1 13 / 19
Discovery of common affine relations (2) Affine sets X and Y : x 1 = 2 + ǫ 1 x 1 = 4 + ǫ 1 x 2 = 2 + ǫ 2 and x 2 = 4 + ǫ 2 x 3 = ⊤ x 3 = ⊤ Example (cont.) 1. We replace x 1 and x 2 by their expressions : α 1 (2 + ǫ 1 ) + α 2 (2 + ǫ 2 ) = β 0 + β 1 ǫ 1 + β 2 ǫ 2 and : α 1 (4 + ǫ 1 ) + α 2 (4 + ǫ 2 ) = β 0 + β 1 ǫ 1 + β 2 ǫ 2 2. The coefficients of the noise symbols must be equal ; we get the equations : 2 α 1 + 2 α 2 = 4 α 1 + 4 α 2 , and β 0 = 0, β 1 = α 1 , β 2 = α 2 3. Example of solution : α 1 = 1 , α 2 = − 1 , β 0 = 0 , β 1 = 1 , β 2 = − 1 4. Relation : x 1 = x 2 + ε 1 − ε 2 13 / 19
Recommend
More recommend