1 / 133

Solvers: Equality and Arrays Lecture 4 2012

Solvers: Equality and Arrays Lecture 4 2012. Nikolaj Bjørner Microsoft Research DTU Winter course January 5 th 2012. Plan. The theory of Un-interpreted functions The Theory of Arrays. Key Takeaways :. Theory of equality, un-interpreted functions and arrays

berny
Télécharger la présentation

Solvers: Equality and Arrays Lecture 4 2012

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Solvers: Equality and Arrays Lecture 4 2012 Nikolaj Bjørner Microsoft Research DTU Winter course January 5th2012

  2. Plan • The theory of Un-interpreted functions • The Theory of Arrays

  3. Key Takeaways: • Theory of equality, un-interpreted functions and arrays • Saturation-based decision procedures • A common pattern • Connections with algorithms used in program analysis • Inference rule formulation • Datalog formulation • A reduction approach to decision procedures • The theory of array reduces to theory of equalities/functions

  4. Deciding Equality

  5. E - The theory of equality Reflexivity: t = t Symmetry: t = s  s = t Transitivity: t = s  s= u t = u Congruence: t1= s1 ..  tn =sn  f(t1, …, tn) = f(s1, …, sn) E – the (infinite) conjunction of these axioms

  6. Congruence Closure • E-satisfiability can be decided with a simple algorithm known as congruence closure. • Congruence closure creates a finite quotient for DC(E + L). • E – Equality axioms • L – Literals: extra equalities in input

  7. Deciding Equality a = b, b = c, d = e, b = s, d = t, a e, a s a b c d e s t

  8. Deciding Equality a = b, b = c, d = e, b = s, d = t, a e, a s a b c d e s t

  9. Deciding Equality a = b, b = c, d = e, b = s, d = t, a e, a s a,b c d e s t

  10. Deciding Equality a = b, b = c, d = e, b = s, d = t, a e, a s a,b c d e s t

  11. Deciding Equality a = b, b = c, d = e, b = s, d = t, a e, a s a,b,c d e s t

  12. Deciding Equality a = b,b = c, d = e, b = s, d = t, a e, a s a,b,c d e s t

  13. Deciding Equality a = b,b = c, d = e, b = s, d = t, a e, a s a,b,c d,e s t

  14. Deciding Equality a = b,b = c, d = e, b = s, d = t, a e, a s a,b,c d,e s t

  15. Deciding Equality a = b,b = c, d = e, b = s, d = t, a e, a s a,b,c,s d,e t

  16. Deciding Equality a = b,b = c, d = e, b = s, d = t, a e, a s a,b,c,s d,e t

  17. Deciding Equality a = b,b = c, d = e, b = s, d = t, a e, a s a,b,c,s d,e,t

  18. Deciding Equality a = b,b = c, d = e, b = s, d = t, a e, a s a,b,c,s d,e,t

  19. Deciding Equality a = b,b = c, d = e, b = s, d = t, a e, a s a,b,c,s d,e,t Unsatisfiable

  20. Deciding Equality a = b,b = c, d = e, b = s, d = t, a e a,b,c,s d,e,t Model construction

  21. Deciding Equality a = b,b = c, d = e, b = s, d = t, a e a,b,c,s 1 2 d,e,t Model construction • |M| = {1 ,2} (universe, aka domain)

  22. Deciding Equality a = b,b = c, d = e, b = s, d = t, a e a,b,c,s 1 2 d,e,t Model construction • |M| = {1 ,2} (universe, aka domain) • M(a) = 1 (assignment)

  23. Deciding Equality a = b,b = c, d = e, b = s, d = t, a e a,b,c,s 1 2 d,e,t Alternative notation: • aM = 1 Model construction • |M| = {1 ,2} (universe, aka domain) • M(a) = 1 (assignment)

  24. Deciding Equality a = b,b = c, d = e, b = s, d = t, a e a,b,c,s 1 2 d,e,t Model construction • |M| = {1 ,2} (universe, aka domain) • M(a) = M(b) = M(c) = M(s) = 1 • M(d) = M(e) = M(t) = 2

  25. Deciding Equality:Termination, Soundness, Completeness • Termination: easy • Soundness • Invariant: all constants in a “ball” are known to be equal. • The “ball” merge operation is justified by: • Transitivity and Symmetry rules. • Completeness • We can build a model if an inconsistency was not detected. • Proof template (by contradiction): • Build a candidate model. • Assume a literal was not satisfied. • Find contradiction.

  26. Deciding Equality:Termination, Soundness, Completeness • Completeness • We can build a model if an inconsistency was not detected. • Instantiating the template for our procedure: • Assume some literal c = d is not satisfied by our model. • That is, M(c) ≠ M(d). • This is impossible, c and d must be in the same “ball”. c,d,… i M(c) = M(d) = i

  27. Deciding Equality:Termination, Soundness, Completeness • Completeness • We can build a model if an inconsistency was not detected. • Instantiating the template for our procedure: • Assume some literal c ≠ d is not satisfied by our model. • That is, M(c) = M(d). • Key property: we only check the disequalities after we processed all equalities. • This is impossible, c and d must be in the different “balls” c,… d,… i j M(c) = i M(d) = j

  28. Deciding Equality + (uninterpreted) Functions a = b,b = c, d = e, b = s, d = t, f(a, g(d))  f(b, g(e)) Congruence Rule: • x1 = y1, …, xn = yn implies f(x1, …, xn) = f(y1, …, yn)

  29. Deciding Equality + (uninterpreted) Functions a = b,b = c, d = e, b = s, d = t, f(a, g(d))  f(b, g(e)) First Step: “Naming” subterms Congruence Rule: • x1 = y1, …, xn = yn implies f(x1, …, xn) = f(y1, …, yn)

  30. Deciding Equality + (uninterpreted) Functions a = b,b = c, d = e, b = s, d = t, f(a, v1)  f(b, g(e)) v1  g(d) First Step: “Naming” subterms Congruence Rule: • x1 = y1, …, xn = yn implies f(x1, …, xn) = f(y1, …, yn)

  31. Deciding Equality + (uninterpreted) Functions a = b,b = c, d = e, b = s, d = t, f(a, v1)  f(b, g(e)) v1  g(d) First Step: “Naming” subterms Congruence Rule: • x1 = y1, …, xn = yn implies f(x1, …, xn) = f(y1, …, yn)

  32. Deciding Equality + (uninterpreted) Functions a = b,b = c, d = e, b = s, d = t, f(a, v1)  f(b, v2) v1  g(d), v2  g(e) First Step: “Naming” subterms Congruence Rule: • x1 = y1, …, xn = yn implies f(x1, …, xn) = f(y1, …, yn)

  33. Deciding Equality + (uninterpreted) Functions a = b,b = c, d = e, b = s, d = t, f(a, v1)  f(b, v2) v1  g(d), v2  g(e) First Step: “Naming” subterms Congruence Rule: • x1 = y1, …, xn = yn implies f(x1, …, xn) = f(y1, …, yn)

  34. Deciding Equality + (uninterpreted) Functions a = b,b = c, d = e, b = s, d = t, v3  f(b, v2) v1  g(d), v2  g(e), v3 f(a, v1) First Step: “Naming” subterms Congruence Rule: • x1 = y1, …, xn = yn implies f(x1, …, xn) = f(y1, …, yn)

  35. Deciding Equality + (uninterpreted) Functions a = b,b = c, d = e, b = s, d = t, v3 f(b, v2) v1  g(d), v2  g(e), v3  f(a, v1) First Step: “Naming” subterms Congruence Rule: • x1 = y1, …, xn = yn implies f(x1, …, xn) = f(y1, …, yn)

  36. Deciding Equality + (uninterpreted) Functions a = b,b = c, d = e, b = s, d = t, v3 v4 v1  g(d), v2  g(e), v3  f(a, v1) , v4  f(b, v2) First Step: “Naming” subterms Congruence Rule: • x1 = y1, …, xn = yn implies f(x1, …, xn) = f(y1, …, yn)

  37. Deciding Equality + (uninterpreted) Functions a = b,b = c, d = e, b = s, d = t, v3 v4 v1  g(d), v2  g(e), v3  f(a, v1) , v4  f(b, v2) a,b,c,s d,e,t v2 v4 v1 v3 Congruence Rule: • x1 = y1, …, xn = yn implies f(x1, …, xn) = f(y1, …, yn)

  38. Deciding Equality + (uninterpreted) Functions a = b,b = c, d = e, b = s, d = t, v3 v4 v1  g(d), v2  g(e), v3  f(a, v1) , v4  f(b, v2) a,b,c,s d,e,t v2 v4 v1 v3 Congruence Rule: • x1 = y1, …, xn = yn implies f(x1, …, xn) = f(y1, …, yn) • d = e implies g(d) = g(e)

  39. Deciding Equality + (uninterpreted) Functions a = b,b = c, d = e, b = s, d = t, v3 v4 v1  g(d), v2  g(e), v3  f(a, v1) , v4  f(b, v2) a,b,c,s d,e,t v2 v4 v1 v3 Congruence Rule: • x1 = y1, …, xn = yn implies f(x1, …, xn) = f(y1, …, yn) • d = e implies v1= v2

  40. Deciding Equality + (uninterpreted) Functions We say: • v1 and v2 are congruent. a = b,b = c, d = e, b = s, d = t, v3 v4 v1 g(d), v2  g(e), v3  f(a, v1) , v4  f(b, v2) a,b,c,s v1,v2 d,e,t v4 v3 Congruence Rule: • x1 = y1, …, xn = yn implies f(x1, …, xn) = f(y1, …, yn) • d = e implies v1= v2

  41. Deciding Equality + (uninterpreted) Functions a = b,b = c, d = e, b = s, d = t, v3 v4 v1  g(d), v2  g(e), v3  f(a, v1) , v4  f(b, v2) a,b,c,s v1,v2 d,e,t v4 v3 Congruence Rule: • x1 = y1, …, xn = yn implies f(x1, …, xn) = f(y1, …, yn) • a = b, v1= v2implies f(a, v1) = f(b, v2)

  42. Deciding Equality + (uninterpreted) Functions a = b,b = c, d = e, b = s, d = t, v3 v4 v1  g(d), v2  g(e), v3  f(a, v1) , v4 f(b, v2) a,b,c,s v1,v2 d,e,t v4 v3 Congruence Rule: • x1 = y1, …, xn = yn implies f(x1, …, xn) = f(y1, …, yn) • a = b, v1= v2implies v3 = v4

  43. Deciding Equality + (uninterpreted) Functions a = b,b = c, d = e, b = s, d = t, v3 v4 v1  g(d), v2  g(e), v3  f(a, v1) , v4 f(b, v2) a,b,c,s v1,v2 v3,v4 d,e,t Congruence Rule: • x1 = y1, …, xn = yn implies f(x1, …, xn) = f(y1, …, yn) • a = b, v1= v2implies v3 = v4

  44. Deciding Equality + (uninterpreted) Functions a = b,b = c, d = e, b = s, d = t, v3  v4 v1  g(d), v2  g(e), v3  f(a, v1) , v4  f(b, v2) a,b,c,s v1,v2 v3,v4 d,e,t Unsatisfiable Congruence Rule: • x1 = y1, …, xn = yn implies f(x1, …, xn) = f(y1, …, yn)

  45. Deciding Equality + (uninterpreted) Functions a = b,b = c, d = e, b = s, d = t, a v4, v2  v3 v1  g(d), v2  g(e), v3  f(a, v1) , v4  f(b, v2) Changing the problem a,b,c,s v1,v2 v3,v4 d,e,t Congruence Rule: • x1 = y1, …, xn = yn implies f(x1, …, xn) = f(y1, …, yn)

  46. Deciding Equality + (uninterpreted) Functions a = b,b = c, d = e, b = s, d = t, a v4, v2  v3 v1  g(d), v2  g(e), v3  f(a, v1) , v4  f(b, v2) a,b,c,s v1,v2 v3,v4 d,e,t Congruence Rule: • x1 = y1, …, xn = yn implies f(x1, …, xn) = f(y1, …, yn)

  47. Deciding Equality + (uninterpreted) Functions a = b,b = c, d = e, b = s, d = t, a v4, v2  v3 v1  g(d), v2  g(e), v3  f(a, v1) , v4  f(b, v2) a,b,c,s v1,v2 v3,v4 d,e,t Congruence Rule: • x1 = y1, …, xn = yn implies f(x1, …, xn) = f(y1, …, yn)

  48. Deciding Equality + (uninterpreted) Functions a = b,b = c, d = e, b = s, d = t, a v4, v2  v3 v1  g(d), v2  g(e), v3  f(a, v1) , v4  f(b, v2) a,b,c,s v1,v2 1 2 3 4 v3,v4 d,e,t Model construction: • |M| = {1 ,2 ,3 ,4} • M(a) = M(b) = M(c) = M(s) = 1 • M(d) = M(e) = M(t) = 2 • M(v1) = M(v2) = 3 • M(v3) = M(v4) = 4

  49. Deciding Equality + (uninterpreted) Functions a = b,b = c, d = e, b = s, d = t, a v4, v2  v3 v1  g(d), v2  g(e), v3  f(a, v1) , v4  f(b, v2) a,b,c,s v1,v2 1 2 3 4 v3,v4 d,e,t Model construction: • |M| = {1 ,2 ,3 ,4} • M(a) = M(b) = M(c) = M(s) = 1 • M(d) = M(e) = M(t) = 2 • M(v1) = M(v2) = 3 • M(v3) = M(v4) = 4 Missing: Interpretation for f and g.

  50. Deciding Equality + (uninterpreted) Functions • Building the interpretation for function symbols • M(g) is a mapping from |M| to |M| • Defined as: M(g)(i) = j if there is v  g(a) s.t. M(a) = i M(v) = j = k, otherwise (k is an arbitrary element) • Is M(g) well-defined?

More Related