Functional synthesis for linear arithmetic and sets

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.

This is a preview of subscription content, log in to check access.

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)

  2. 2

    Asarin, E., Maler, O., Pnueli, A.: Symbolic controller synthesis for discrete and timed systems. In: Hybrid Systems II, pp. 1–20 (1995)

  3. 3

    Banerjee U.K.: Dependence Analysis for Supercomputing. Kluwer, Norwell (1988)

    Google 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)

    MathSciNet  Article  Google Scholar 

  5. 5

    Bradley A.R., Manna Z.: The Calculus of Computation. Springer, Berlin (2007)

    Google Scholar 

  6. 6

    Bryant R.E.: Graph-based algorithms for Boolean function manipulation. IEEE Trans. Comput. C-35(8), 677–691 (1986)

    Article  Google 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)

    Article  Google 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)

    Google 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)

  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

    Article  MATH  Google Scholar 

  12. 12

    Dijkstra E.W.: A Discipline of Programming. Prentice-Hall, Inc., Englewood Cliffs (1976)

    Google Scholar 

  13. 13

    Emir, B., Odersky, M., Williams, J.: Matching objects with patterns. In: ECOOP (2007)

  14. 14

    Eisenbrand F., Shmonin G.: Parametric integer programming in fixed dimension. Math. Oper. Res. 33(4), 839–850 (2008)

    MathSciNet  Article  MATH  Google Scholar 

  15. 15

    Ford, D., Havas, G.: A new algorithm and refined bounds for extended gcd computation. In: ANTS, pp. 145–150 (1996)

  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)

  17. 17

    Ferrante, J., Rackoff, C.W.: The Computational Complexity of Logical Theories. Lecture Notes in Mathematics, vol. 718. Springer, Berlin (1979)

  18. 18

    Feferman S., Vaught R.L.: The first order properties of products of algebraic systems. Fundam. Math. 47, 57–103 (1959)

    MathSciNet  MATH  Google Scholar 

  19. 19

    Ganzinger, H., Hagen, G., Nieuwenhuis, R., Oliveras, A., Cesare, T.: DPLL(T): fast decision procedures. In: CAV, pp. 175–188 (2004)

  20. 20

    Ginsburg S., Spanier E.: Bounded algol-like languages. Trans. Am. Math. Soc. 113(2), 333–368 (1964)

    MathSciNet  MATH  Google Scholar 

  21. 21

    Ginsburg S., Spanier E.: Semigroups, Presburger formulas and languages. Pac. J. Math. 16(2), 285–296 (1966)

    MathSciNet  Article  MATH  Google Scholar 

  22. 22

    Hamza, J., Jobstmann, B., Kuncak, V.: Synthesis for regular specifications over unbounded domains. In: FMCAD, pp. 101–109 (2010)

  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)

  25. 25

    Jobstmann, B., Bloem, R.: Optimizations for LTL synthesis. In: FMCAD (2006)

  26. 26

    Jones, S.P. et al.: Haskell 98 language and libraries: the revised report (2010)

  27. 27

    Jones, N.D., Gomard, C.K., Sestoft, P.: Partial evaluation and automatic program generation (available on the Web) (1993)

  28. 28

    Jobstmann, B., Galler, S., Weiglhofer, M., Bloem, R.: Anzu: a tool for property synthesis. In: CAV. LNCS, vol. 4590 (2007)

  29. 29

    Jaffar J., Maher M.J.: Constraint logic programming: a survey. J. Log. Program. 19/20, 503–581 (1994)

    MathSciNet  Article  Google 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)

  31. 31

    Klaedtke, F.: On the automata size for Presburger arithmetic. Technical Report 186, Institute of Computer Science at Freiburg University (2003)

  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)

  33. 33

    Kuncak V., Nguyen H.H., Rinard M.: Deciding Boolean algebra with Presburger arithmetic. J. Autom. Reason. 36(3), 213–236 (2006)

    MathSciNet  Article  MATH  Google Scholar 

  34. 34

    Kuncak, V., Piskac, R., Suter, P.: Ordered sets in the calculus of data structures. In: CSL, pp. 34–48 (2010)

  35. 35

    Kuncak, V., Piskac, R., Suter, P., Wies, T.: Building a calculus of data structures. In:VMCAI. LNCS, vol. 5944 (2010)

  36. 36

    Kuncak, V., Rinard, M.: Towards efficient satisfiability checking for Boolean Algebra with Presburger Arithmetic. In: CADE-21. LNCS, vol. 4603 (2007)

  37. 37

    Klarlund, N., Schwartzbach, M.I.: Graph types. In: POPL, Charleston, SC (1993)

  38. 38

    Kukula, J.H., Shiple, T.R.: Building circuits from relations. In: CAV (2000)

  39. 39

    McPeak, S., Necula, G.C.: Data structure specifications via local equality axioms. In: CAV, pp. 476–490 (2005)

  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)

  41. 41

    Moskal, M.: Satisfiability modulo software. PhD thesis, University of Wrocław (2009)

  42. 42

    Manna Z., Waldinger R.J.: Toward automatic program synthesis. Commun. ACM 14(3), 151–165 (1971)

    Article  MATH  Google Scholar 

  43. 43

    Manna Z., Waldinger R.: A deductive approach to program synthesis. ACM Trans. Program. Lang. Syst. 2(1), 90–121 (1980)

    Article  MATH  Google Scholar 

  44. 44

    Nipkow, T.: Linear quantifier elimination. In: IJCAR (2008)

  45. 45

    Oppen, D.C.: Reasoning about recursively defined data structures. In: POPL, pp. 151–157 (1978)

  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)

  48. 48

    Piskac, R., Kuncak, V.: Linear arithmetic with stars. In: CAV. LNCS, vol. 5123 (2008)

  49. 49

    Piterman, N., Pnueli, A., Sa’ar, Y.: Synthesis of reactive(1) designs. In: VMCAI (2006)

  50. 50

    Pnueli, A., Rosner, R.: On the synthesis of a reactive module. In: POPL (1989)

  51. 51

    Pugh W.: A practical algorithm for exact array dependence analysis. Commun. ACM 35(8), 102–114 (1992)

    Article  Google Scholar 

  52. 52

    Schrijver A.: Theory of Linear and Integer Programming. Wiley, New York (1998)

    Google Scholar 

  53. 53

    Suter, P., Dotta, M., Kuncak, V.: Decision procedures for algebraic data types with abstractions. In: POPL (2010)

  54. 54

    Syme D., Granicz A., Cisternino A.: Expert F#. Apress, New York (2007)

    Google Scholar 

  55. 55

    Srivastava, S., Gulwani, S., Foster, J.S.: From program verification to program synthesis. In: POPL (2010)

  56. 56

    Sharir M.: Some observations concerning formal differentiation of set theoretic expressions. Trans. Program. Lang. Syst. 4(2), 196–226 (1982)

    MathSciNet  Article  MATH  Google Scholar 

  57. 57

    Solar-Lezama, A., Arnold, G., Tancau, L., Bodík, R., Saraswat, V.A., Seshia, S.A.: Sketching stencils. In: PLDI (2007)

  58. 58

    Solar-Lezama, A., Jones, C.G., Bodík, R.: Sketching concurrent data structures. In: PLDI (2008)

  59. 59

    Solar-Lezama, A., Tancau, L., Bodík, R., Seshia, S.A., Saraswat, V.A.: Combinatorial sketching for finite programs. In: ASPLOS (2006)

  60. 60

    Sekar R.C., Ramesh R., Ramakrishnan I.V.: Adaptive pattern matching. SIAM J. Comput. 24, 1207–1234 (1995)

    MathSciNet  Article  MATH  Google 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)

  62. 62

    Vechev, M.T., Yahav, E., Yorsh, G.: Inferring synchronization under limited observability. In: TACAS (2009)

  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)

  64. 64

    Wintersteiger, C.M., Hamadi, Y., de Moura, L.: Efficiently solving quantified bit-vector formulas. In: FMCAD, pp. 239–246 (2010)

  65. 65

    Wies, T., Piskac, R., Kuncak, V.: Combining theories with shared set operations. In: FroCoS: Frontiers in Combining Systems (2009)

  66. 66

    Yessenov, K., Piskac, R., Kuncak, V.: Collections, cardinalities, and relations. In: VMCAI. LNCS, vol. 5944 (2010)

  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)

  68. 68

    Zarba C.G.: Combining sets with cardinals. J. Autom. Reason. 34(1), 1–29 (2005)

    MathSciNet  Article  MATH  Google Scholar 

  69. 69

    Zee, K., Kuncak, V., Rinard, M.: Full functional verification of linked data structures. In: PLDI (2008)

Download references

Author information

Affiliations

Authors

Corresponding author

Correspondence to Viktor Kuncak.

Additional information

R. Piskac was supported by the EPFL School of Computer and Communication Sciences and in part by the Swiss National Foundation Grant SCOPES IZ73Z0_127979. P. Suter was supported by the Swiss National Science Foundation Grant 200021_120433.

Rights and permissions

Reprints and Permissions

About this article

Cite this article

Kuncak, V., Mayer, M., Piskac, R. et al. Functional synthesis for linear arithmetic and sets. Int J Softw Tools Technol Transfer 15, 455–474 (2013). https://doi.org/10.1007/s10009-011-0217-7

Download citation

Keywords

  • Software synthesis
  • Complete synthesis procedures
  • Decision procedures
  • Linear integer arithmetic