on intervals and bounds in bit vector arithmetic
play

on intervals and bounds in bit-vector arithmetic Mikol Janota and - PowerPoint PPT Presentation

on intervals and bounds in bit-vector arithmetic Mikol Janota and Christoph M. Wintersteiger Microsoft Research, Cambridge, UK Janota, Wintersteiger On Intervals and Bounds in Bit-vector Arithmetic 1 / 10 fixed bit-width , wraps


  1. on intervals and bounds in bit-vector arithmetic Mikoláš Janota and Christoph M. Wintersteiger Microsoft Research, Cambridge, UK Janota, Wintersteiger On Intervals and Bounds in Bit-vector Arithmetic 1 / 10

  2. • fixed bit-width • , wraps around • negative numbers via 2’s complement s • Example: x 8 8 1 8 8 y 8 8 3 8 • x 8 0 x 7 f y 8 0 x 80 what are bit vectors? • numbers as in computer (roughly) Janota, Wintersteiger On Intervals and Bounds in Bit-vector Arithmetic 2 / 10

  3. • , wraps around • negative numbers via 2’s complement s • Example: x 8 8 1 8 8 y 8 8 3 8 • x 8 0 x 7 f y 8 0 x 80 what are bit vectors? • numbers as in computer (roughly) • fixed bit-width Janota, Wintersteiger On Intervals and Bounds in Bit-vector Arithmetic 2 / 10

  4. • negative numbers via 2’s complement s • Example: x 8 8 1 8 8 y 8 8 3 8 • x 8 0 x 7 f y 8 0 x 80 what are bit vectors? • numbers as in computer (roughly) • fixed bit-width • + , × wraps around Janota, Wintersteiger On Intervals and Bounds in Bit-vector Arithmetic 2 / 10

  5. s • Example: x 8 8 1 8 8 y 8 8 3 8 • x 8 0 x 7 f y 8 0 x 80 what are bit vectors? • numbers as in computer (roughly) • fixed bit-width • + , × wraps around • negative numbers via 2’s complement Janota, Wintersteiger On Intervals and Bounds in Bit-vector Arithmetic 2 / 10

  6. • x 8 0 x 7 f y 8 0 x 80 what are bit vectors? • numbers as in computer (roughly) • fixed bit-width • + , × wraps around • negative numbers via 2’s complement • Example: ( x 8 + 8 1 8 ) ≤ s 8 ( y 8 × 8 3 8 ) Janota, Wintersteiger On Intervals and Bounds in Bit-vector Arithmetic 2 / 10

  7. what are bit vectors? • numbers as in computer (roughly) • fixed bit-width • + , × wraps around • negative numbers via 2’s complement • Example: ( x 8 + 8 1 8 ) ≤ s 8 ( y 8 × 8 3 8 ) • x 8 = 0 x 7 f , y 8 = 0 x 80 Janota, Wintersteiger On Intervals and Bounds in Bit-vector Arithmetic 2 / 10

  8. • Exponential in bit-width and losing “domain” knowledge. • It is important to apply preprocessing before sending to SAT. • Example: x m 0 m x m • Example: x m 4 m x m 3 0 0 2 how do we solve bit-vectors? • Bit-blasting — convert everything to propositional form (SAT). Janota, Wintersteiger On Intervals and Bounds in Bit-vector Arithmetic 3 / 10

  9. • It is important to apply preprocessing before sending to SAT. • Example: x m 0 m x m • Example: x m 4 m x m 3 0 0 2 how do we solve bit-vectors? • Bit-blasting — convert everything to propositional form (SAT). • Exponential in bit-width and losing “domain” knowledge. Janota, Wintersteiger On Intervals and Bounds in Bit-vector Arithmetic 3 / 10

  10. • Example: x m 0 m x m • Example: x m 4 m x m 3 0 0 2 how do we solve bit-vectors? • Bit-blasting — convert everything to propositional form (SAT). • Exponential in bit-width and losing “domain” knowledge. • It is important to apply preprocessing before sending to SAT. Janota, Wintersteiger On Intervals and Bounds in Bit-vector Arithmetic 3 / 10

  11. • Example: x m 4 m x m 3 0 0 2 how do we solve bit-vectors? • Bit-blasting — convert everything to propositional form (SAT). • Exponential in bit-width and losing “domain” knowledge. • It is important to apply preprocessing before sending to SAT. • Example: ( x m + 0 m ) = x m Janota, Wintersteiger On Intervals and Bounds in Bit-vector Arithmetic 3 / 10

  12. how do we solve bit-vectors? • Bit-blasting — convert everything to propositional form (SAT). • Exponential in bit-width and losing “domain” knowledge. • It is important to apply preprocessing before sending to SAT. • Example: ( x m + 0 m ) = x m • Example: ( x m × 4 m ) = x [ m − 3 : 0 ] + + 0 2 Janota, Wintersteiger On Intervals and Bounds in Bit-vector Arithmetic 3 / 10

  13. u c 2 1. c 1 w x w x u c 2 2. c 1 w x u c 2 3. c 1 w x s c 1 4. x s x 5. c 1 • conjunction C i C i , where C i is one of the following with x a bit-vector variable and c 1 c 2 constants. problem • inequalities with multiple variables and addition are NP-complete Janota, Wintersteiger On Intervals and Bounds in Bit-vector Arithmetic 4 / 10

  14. u c 2 1. c 1 w x w x u c 2 2. c 1 w x u c 2 3. c 1 w x s c 1 4. x s x 5. c 1 problem • inequalities with multiple variables and addition are NP-complete • conjunction ∧ ¬ C i ∧ ∧ C i , where C i is one of the following with x a bit-vector variable and c 1 , c 2 constants. Janota, Wintersteiger On Intervals and Bounds in Bit-vector Arithmetic 4 / 10

  15. u c 2 2. c 1 w x u c 2 3. c 1 w x s c 1 4. x s x 5. c 1 problem • inequalities with multiple variables and addition are NP-complete • conjunction ∧ ¬ C i ∧ ∧ C i , where C i is one of the following with x a bit-vector variable and c 1 , c 2 constants. 1. ( c 1 + w x ) ≤ u ( c 2 + w x ) Janota, Wintersteiger On Intervals and Bounds in Bit-vector Arithmetic 4 / 10

  16. u c 2 3. c 1 w x s c 1 4. x s x 5. c 1 problem • inequalities with multiple variables and addition are NP-complete • conjunction ∧ ¬ C i ∧ ∧ C i , where C i is one of the following with x a bit-vector variable and c 1 , c 2 constants. 1. ( c 1 + w x ) ≤ u ( c 2 + w x ) 2. c 1 ≤ u ( c 2 + w x ) Janota, Wintersteiger On Intervals and Bounds in Bit-vector Arithmetic 4 / 10

  17. s c 1 4. x s x 5. c 1 problem • inequalities with multiple variables and addition are NP-complete • conjunction ∧ ¬ C i ∧ ∧ C i , where C i is one of the following with x a bit-vector variable and c 1 , c 2 constants. 1. ( c 1 + w x ) ≤ u ( c 2 + w x ) 2. c 1 ≤ u ( c 2 + w x ) 3. ( c 1 + w x ) ≤ u c 2 Janota, Wintersteiger On Intervals and Bounds in Bit-vector Arithmetic 4 / 10

  18. s x 5. c 1 problem • inequalities with multiple variables and addition are NP-complete • conjunction ∧ ¬ C i ∧ ∧ C i , where C i is one of the following with x a bit-vector variable and c 1 , c 2 constants. 1. ( c 1 + w x ) ≤ u ( c 2 + w x ) 2. c 1 ≤ u ( c 2 + w x ) 3. ( c 1 + w x ) ≤ u c 2 4. x ≤ s c 1 Janota, Wintersteiger On Intervals and Bounds in Bit-vector Arithmetic 4 / 10

  19. problem • inequalities with multiple variables and addition are NP-complete • conjunction ∧ ¬ C i ∧ ∧ C i , where C i is one of the following with x a bit-vector variable and c 1 , c 2 constants. 1. ( c 1 + w x ) ≤ u ( c 2 + w x ) 2. c 1 ≤ u ( c 2 + w x ) 3. ( c 1 + w x ) ≤ u c 2 4. x ≤ s c 1 5. c 1 ≤ s x Janota, Wintersteiger On Intervals and Bounds in Bit-vector Arithmetic 4 / 10

  20. u • x 100 8 x 200 true false true 0 56 156 0/256 u • x 200 8 x 100 false true false 0 56 156 0/256 inequalities • ( 0 < s 8 x ) ∧ ( 200 < u 8 x ) ... UNSAT 0 < s 200 < u 8 x 8 x 0 128 200 0/256 Janota, Wintersteiger On Intervals and Bounds in Bit-vector Arithmetic 5 / 10

  21. u • x 200 8 x 100 false true false 0 56 156 0/256 inequalities • ( 0 < s 8 x ) ∧ ( 200 < u 8 x ) ... UNSAT 0 < s 200 < u 8 x 8 x 0 128 200 0/256 • ( x + 100 < u 8 x + 200 ) true false true 0 56 156 0/256 Janota, Wintersteiger On Intervals and Bounds in Bit-vector Arithmetic 5 / 10

  22. inequalities • ( 0 < s 8 x ) ∧ ( 200 < u 8 x ) ... UNSAT 0 < s 200 < u 8 x 8 x 0 128 200 0/256 • ( x + 100 < u 8 x + 200 ) true false true 0 56 156 0/256 • ( x + 200 < u 8 x + 100 ) false true false 0 56 156 0/256 Janota, Wintersteiger On Intervals and Bounds in Bit-vector Arithmetic 5 / 10

  23. translation Expression Condition Interval c 1 + w x ≤ u c 2 + w x c 1 ≤ c 2 ∽ [ − c 2 ; − c 1 − 1 ] c 1 + w x ≤ u c 2 + w x c 1 > c 2 [ − c 1 ; − c 2 − 1 ] c 1 ≤ u c 2 + w x c 1 < c 2 ∽ [ − c 2 ; c 1 − c 2 − 1 ] c 1 ≤ u c 2 + w x c 1 ≥ c 2 [ c 1 − c 2 ; − c 2 − 1 ] c 1 + w x ≤ u c 2 c 1 ≤ c 2 ∽ [ c 2 − c 1 + 1 ; − c 1 − 1 ] c 1 + w x ≤ u c 2 c 1 > c 2 [ − c 1 ; − c 1 + c 2 ] x ≤ s c 1 ∽ [ c 1 + 1 ; 2 w − 1 − 1 ] c 1 < 2 w − 1 x ≤ s c 1 c 1 ≥ 2 w − 1 [ 2 w − 1 ; c 1 ] c 1 ≤ s x [ c 1 ; 2 w − 1 − 1 ] c 1 < 2 w − 1 c 1 ≤ s x ∽ [ 2 w − 1 ; c 1 − 1 ] c 1 ≥ 2 w − 1 Janota, Wintersteiger On Intervals and Bounds in Bit-vector Arithmetic 6 / 10

  24. computing the envelope 1 P ← { [ a ; b ] | [ a ; b ] ∈ I} ; // positive intervals 2 l ← P = ∅ ? 0 : min { a | [ a ; b ] ∈ P} ; // lower bound 3 h ← P = ∅ ? 2 w − 1 : max { b | [ a ; b ] ∈ P} ; // upper bound 4 N ← { ∽ [ a ; b ] | ∽ [ a ; b ] ∈ I} ; // negative intervals 5 N ← sort N by first element; 6 p , l ′ , h ′ ← l , l , l − 1; 7 for ∽ [ a ; b ] ∈ N ∪ ∽ [ 2 w ; 2 w ] do if p > h then break ; // space exhausted 8 if b < p then continue ; // redundant interval 9 if p < a then // satisfiable portion 10 if h ′ > l ′ then l ′ ← p ; // first satisfiable point 11 h ′ ← a − 1; // update upper bound 12 p ← b + 1; // move onto next portion 13 14 return [ l ′ ; h ′ ] Janota, Wintersteiger On Intervals and Bounds in Bit-vector Arithmetic 7 / 10

  25. evaluation Table 1: Conflict count. Example Avg. Med Min Max (1) unsat 26 36 3 100 (2) redundant 31 25 7 89 (2) reduced 29 37 3 92 (3) unique 21 40 0 123 Janota, Wintersteiger On Intervals and Bounds in Bit-vector Arithmetic 8 / 10

Recommend


More recommend