Functional synthesis for linear arithmetic and sets

  • Viktor Kuncak
  • Mikaël Mayer
  • Ruzica Piskac
  • Philippe Suter
Synthesis

Abstract

Synthesis of program fragments from specifications can make programs easier to write and easier to reason about. To integrate synthesis into programming languages, synthesis algorithms should behave in a predictable way—they should succeed for a well-defined class of specifications. To guarantee correctness and applicability to software (and not just hardware), these algorithms should also support unbounded data types, such as numbers and data structures. To obtain appropriate synthesis algorithms, we propose to generalize decision procedures into predictable and complete synthesis procedures. Such procedures are guaranteed to find the code that satisfies the specification if such code exists. Moreover, we identify conditions under which synthesis will statically decide whether the solution is guaranteed to exist and whether it is unique. We demonstrate our approach by starting from a quantifier elimination decision procedure for Boolean algebra of set with Presburger arithmetic and transforming it into a synthesis procedure. Our procedure also works in the presence of parametric coefficients. We establish results on the size and the efficiency of the synthesized code. We show that such procedures are useful as a language extension with implicit value definitions, and we show how to extend a compiler to support such definitions. Our constructs provide the benefits of synthesis to programmers, without requiring them to learn new concepts, give up a deterministic execution model, or provide code skeletons.

Keywords

Software synthesis Complete synthesis procedures Decision procedures Linear integer arithmetic 

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Anand, S., Godefroid, P., Tillmann, N.: Demand-driven compositional symbolic execution. In: Tools and Algorithms for the Construction and Analysis of Systems (2008)Google Scholar
  2. 2.
    Asarin, E., Maler, O., Pnueli, A.: Symbolic controller synthesis for discrete and timed systems. In: Hybrid Systems II, pp. 1–20 (1995)Google Scholar
  3. 3.
    Banerjee U.K.: Dependence Analysis for Supercomputing. Kluwer, Norwell (1988)CrossRefGoogle Scholar
  4. 4.
    Boigelot B., Jodogne S., Wolper P.: An effective decision procedure for linear arithmetic over the integers and reals. ACM Trans. Comput. Log. 6(3), 614–633 (2005)MathSciNetCrossRefGoogle Scholar
  5. 5.
    Bradley A.R., Manna Z.: The Calculus of Computation. Springer, Berlin (2007)MATHGoogle Scholar
  6. 6.
    Bryant R.E.: Graph-based algorithms for Boolean function manipulation. IEEE Trans. Comput. C-35(8), 677–691 (1986)CrossRefGoogle Scholar
  7. 7.
    Barrett C., Shikanian I., Tinelli C.: An abstract decision procedure for satisfiability in the theory of recursive data types. Electron. Notes Theor. Comput. Sci. 174(8), 23–37 (2007)CrossRefGoogle Scholar
  8. 8.
    Cormen T.H., Leiserson C.E., Rivest R.L., Stein C.: Introduction to Algorithms, 2nd edn. MIT Press and McGraw-Hill, Cambridge (2001)MATHGoogle Scholar
  9. 9.
    Cooper D.C.: Theorem proving in arithmetic without multiplication. In: Meltzer, B., Michie, D. (eds) Machine Intelligence, vol. 7, pp. 91–100. Edinburgh University Press, Edinburgh (1972)Google Scholar
  10. 10.
    de Moura, L., Bjørner, N.: Z3: an efficient SMT solver. In: TACAS (2008)Google Scholar
  11. 11.
    Dewar R.B.K., Grand A., Liu S.-C., Schwartz J.T., Schonberg E.: Programming by refinement, as exemplified by the SETL representation sublanguage. ACM Trans. Program. Lang. Syst. (TOPLAS) 1(1), 27–49 (1979). doi:10.1145/357062.357064 CrossRefMATHGoogle Scholar
  12. 12.
    Dijkstra E.W.: A Discipline of Programming. Prentice-Hall, Inc., Englewood Cliffs (1976)MATHGoogle Scholar
  13. 13.
    Emir, B., Odersky, M., Williams, J.: Matching objects with patterns. In: ECOOP (2007)Google Scholar
  14. 14.
    Eisenbrand F., Shmonin G.: Parametric integer programming in fixed dimension. Math. Oper. Res. 33(4), 839–850 (2008)MathSciNetCrossRefMATHGoogle Scholar
  15. 15.
    Ford, D., Havas, G.: A new algorithm and refined bounds for extended gcd computation. In: ANTS, pp. 145–150 (1996)Google Scholar
  16. 16.
    Flanagan, C., Leino, K.R.M., Lilibridge, M., Nelson, G., Saxe, J.B., Stata, R.: Extended static checking for Java. In: PLDI (2002)Google Scholar
  17. 17.
    Ferrante, J., Rackoff, C.W.: The Computational Complexity of Logical Theories. Lecture Notes in Mathematics, vol. 718. Springer, Berlin (1979)Google Scholar
  18. 18.
    Feferman S., Vaught R.L.: The first order properties of products of algebraic systems. Fundam. Math. 47, 57–103 (1959)MathSciNetMATHGoogle Scholar
  19. 19.
    Ganzinger, H., Hagen, G., Nieuwenhuis, R., Oliveras, A., Cesare, T.: DPLL(T): fast decision procedures. In: CAV, pp. 175–188 (2004)Google Scholar
  20. 20.
    Ginsburg S., Spanier E.: Bounded algol-like languages. Trans. Am. Math. Soc. 113(2), 333–368 (1964)MathSciNetMATHGoogle Scholar
  21. 21.
    Ginsburg S., Spanier E.: Semigroups, Presburger formulas and languages. Pac. J. Math. 16(2), 285–296 (1966)MathSciNetCrossRefMATHGoogle Scholar
  22. 22.
    Hamza, J., Jobstmann, B., Kuncak, V.: Synthesis for regular specifications over unbounded domains. In: FMCAD, pp. 101–109 (2010)Google Scholar
  23. 23.
    Hodges W.: Model Theory. Encyclopedia of Mathematics and its Applications, vol. 42. Cambridge University Press, London (1993)Google Scholar
  24. 24.
    Jacobs, S.: Hierarchic decision procedures for verification. PhD thesis, Universität des Saarlandes (2010)Google Scholar
  25. 25.
    Jobstmann, B., Bloem, R.: Optimizations for LTL synthesis. In: FMCAD (2006)Google Scholar
  26. 26.
    Jones, S.P. et al.: Haskell 98 language and libraries: the revised report (2010)Google Scholar
  27. 27.
    Jones, N.D., Gomard, C.K., Sestoft, P.: Partial evaluation and automatic program generation (available on the Web) (1993)Google Scholar
  28. 28.
    Jobstmann, B., Galler, S., Weiglhofer, M., Bloem, R.: Anzu: a tool for property synthesis. In: CAV. LNCS, vol. 4590 (2007)Google Scholar
  29. 29.
    Jaffar J., Maher M.J.: Constraint logic programming: a survey. J. Log. Program. 19/20, 503–581 (1994)MathSciNetCrossRefGoogle Scholar
  30. 30.
    Köksal, A.S., Kuncak, V., Suter, P.: Scala to the power of Z3: integrating SMT and programming. In: CADE, pp. 400–406 (2011)Google Scholar
  31. 31.
    Klaedtke, F.: On the automata size for Presburger arithmetic. Technical Report 186, Institute of Computer Science at Freiburg University (2003)Google Scholar
  32. 32.
    Klarlund, N., Møller, A.: MONA version 1.4 user manual. BRICS Notes Series NS-01-1, Department of Computer Science, University of Aarhus (2001)Google Scholar
  33. 33.
    Kuncak V., Nguyen H.H., Rinard M.: Deciding Boolean algebra with Presburger arithmetic. J. Autom. Reason. 36(3), 213–236 (2006)MathSciNetCrossRefMATHGoogle Scholar
  34. 34.
    Kuncak, V., Piskac, R., Suter, P.: Ordered sets in the calculus of data structures. In: CSL, pp. 34–48 (2010)Google Scholar
  35. 35.
    Kuncak, V., Piskac, R., Suter, P., Wies, T.: Building a calculus of data structures. In:VMCAI. LNCS, vol. 5944 (2010)Google Scholar
  36. 36.
    Kuncak, V., Rinard, M.: Towards efficient satisfiability checking for Boolean Algebra with Presburger Arithmetic. In: CADE-21. LNCS, vol. 4603 (2007)Google Scholar
  37. 37.
    Klarlund, N., Schwartzbach, M.I.: Graph types. In: POPL, Charleston, SC (1993)Google Scholar
  38. 38.
    Kukula, J.H., Shiple, T.R.: Building circuits from relations. In: CAV (2000)Google Scholar
  39. 39.
    McPeak, S., Necula, G.C.: Data structure specifications via local equality axioms. In: CAV, pp. 476–490 (2005)Google Scholar
  40. 40.
    Monniaux, D.P.: Automatic modular abstractions for linear constraints. In: Proceedings of the 36th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 140–151 (2009)Google Scholar
  41. 41.
    Moskal, M.: Satisfiability modulo software. PhD thesis, University of Wrocław (2009)Google Scholar
  42. 42.
    Manna Z., Waldinger R.J.: Toward automatic program synthesis. Commun. ACM 14(3), 151–165 (1971)CrossRefMATHGoogle Scholar
  43. 43.
    Manna Z., Waldinger R.: A deductive approach to program synthesis. ACM Trans. Program. Lang. Syst. 2(1), 90–121 (1980)CrossRefMATHGoogle Scholar
  44. 44.
    Nipkow, T.: Linear quantifier elimination. In: IJCAR (2008)Google Scholar
  45. 45.
    Oppen, D.C.: Reasoning about recursively defined data structures. In: POPL, pp. 151–157 (1978)Google Scholar
  46. 46.
    Odersky M., Spoon L., Venners B.: Programming in Scala: A Comprehensive Step-by-Step Guide. Artima Press, Walnut Creek (2008)Google Scholar
  47. 47.
    Piskac, R., Kuncak, V.: Decision procedures for multisets with cardinality constraints. In: VMCAI. LNCS, vol. 4905 (2008)Google Scholar
  48. 48.
    Piskac, R., Kuncak, V.: Linear arithmetic with stars. In: CAV. LNCS, vol. 5123 (2008)Google Scholar
  49. 49.
    Piterman, N., Pnueli, A., Sa’ar, Y.: Synthesis of reactive(1) designs. In: VMCAI (2006)Google Scholar
  50. 50.
    Pnueli, A., Rosner, R.: On the synthesis of a reactive module. In: POPL (1989)Google Scholar
  51. 51.
    Pugh W.: A practical algorithm for exact array dependence analysis. Commun. ACM 35(8), 102–114 (1992)CrossRefGoogle Scholar
  52. 52.
    Schrijver A.: Theory of Linear and Integer Programming. Wiley, New York (1998)MATHGoogle Scholar
  53. 53.
    Suter, P., Dotta, M., Kuncak, V.: Decision procedures for algebraic data types with abstractions. In: POPL (2010)Google Scholar
  54. 54.
    Syme D., Granicz A., Cisternino A.: Expert F#. Apress, New York (2007)CrossRefGoogle Scholar
  55. 55.
    Srivastava, S., Gulwani, S., Foster, J.S.: From program verification to program synthesis. In: POPL (2010)Google Scholar
  56. 56.
    Sharir M.: Some observations concerning formal differentiation of set theoretic expressions. Trans. Program. Lang. Syst. 4(2), 196–226 (1982)MathSciNetCrossRefMATHGoogle Scholar
  57. 57.
    Solar-Lezama, A., Arnold, G., Tancau, L., Bodík, R., Saraswat, V.A., Seshia, S.A.: Sketching stencils. In: PLDI (2007)Google Scholar
  58. 58.
    Solar-Lezama, A., Jones, C.G., Bodík, R.: Sketching concurrent data structures. In: PLDI (2008)Google Scholar
  59. 59.
    Solar-Lezama, A., Tancau, L., Bodík, R., Seshia, S.A., Saraswat, V.A.: Combinatorial sketching for finite programs. In: ASPLOS (2006)Google Scholar
  60. 60.
    Sekar R.C., Ramesh R., Ramakrishnan I.V.: Adaptive pattern matching. SIAM J. Comput. 24, 1207–1234 (1995)MathSciNetCrossRefMATHGoogle Scholar
  61. 61.
    Vechev, M.T., Yahav, E., Bacon, D.F., Rinetzky, N.: Cgcexplorer: a semi-automated search procedure for provably correct concurrent collectors. In: PLDI, pp. 456–467 (2007)Google Scholar
  62. 62.
    Vechev, M.T., Yahav, E., Yorsh, G.: Inferring synchronization under limited observability. In: TACAS (2009)Google Scholar
  63. 63.
    Weispfenning, V.: Complexity and uniformity of elimination in Presburger arithmetic. In: Proceedings of the International Symposium on Symbolic and Algebraic Computation, pp. 48–53 (1997)Google Scholar
  64. 64.
    Wintersteiger, C.M., Hamadi, Y., de Moura, L.: Efficiently solving quantified bit-vector formulas. In: FMCAD, pp. 239–246 (2010)Google Scholar
  65. 65.
    Wies, T., Piskac, R., Kuncak, V.: Combining theories with shared set operations. In: FroCoS: Frontiers in Combining Systems (2009)Google Scholar
  66. 66.
    Yessenov, K., Piskac, R., Kuncak, V.: Collections, cardinalities, and relations. In: VMCAI. LNCS, vol. 5944 (2010)Google Scholar
  67. 67.
    Zarba, C.G.: A quantifier elimination algorithm for a fragment of set theory involving the cardinality operator. In: 18th International Workshop on Unification (2004)Google Scholar
  68. 68.
    Zarba C.G.: Combining sets with cardinals. J. Autom. Reason. 34(1), 1–29 (2005)MathSciNetCrossRefMATHGoogle Scholar
  69. 69.
    Zee, K., Kuncak, V., Rinard, M.: Full functional verification of linked data structures. In: PLDI (2008)Google Scholar

Copyright information

© Springer-Verlag 2011

Authors and Affiliations

  • Viktor Kuncak
    • 1
  • Mikaël Mayer
    • 1
  • Ruzica Piskac
    • 1
  • Philippe Suter
    • 1
  1. 1.School of Computer and Communication Sciences (I&C)Swiss Federal Institute of Technology (EPFL)LausanneSwitzerland

Personalised recommendations