skip to main content
research-article
Open Access
Artifacts Available
Artifacts Evaluated & Functional

Program synthesis with algebraic library specifications

Published:10 October 2019Publication History
Skip Abstract Section

Abstract

A key challenge in program synthesis is synthesizing programs that use libraries, which most real-world software does. The current state of the art is to model libraries with mock library implementations that perform the same function in a simpler way. However, mocks may still be large and complex, and must include many implementation details, both of which could limit synthesis performance. To address this problem, we introduce JLibSketch, a Java program synthesis tool that allows library behavior to be described with algebraic specifications, which are rewrite rules for sequences of method calls, e.g., encryption followed by decryption (with the same key) is the identity. JLibSketch implements rewrite rules by compiling JLibSketch problems into problems for the Sketch program synthesis tool. More specifically, after compilation, library calls are represented by abstract data types (ADTs), and rewrite rules manipulate those ADTs. We formalize compilation and prove it sound and complete if the rewrite rules are ordered and non-unifiable. We evaluated JLibSketch by using it to synthesize nine programs that use libraries from three domains: data structures, cryptography, and file systems. We found that algebraic specifications are, on average, about half the size of mocks. We also found that algebraic specifications perform better than mocks on seven of the nine programs, sometimes significantly so, and perform equally well on the last two programs. Thus, we believe that JLibSketch takes an important step toward synthesis of programs that use libraries.

Skip Supplemental Material Section

Supplemental Material

a132-mariano

Presentation at OOPSLA '19

References

  1. Nada Amin, K. Rustan M. Leino, and Tiark Rompf. 2014. Computing with an SMT Solver. In Tests and Proofs, Martina Seidl and Nikolai Tillmann (Eds.). Springer International Publishing, Cham, 20–35.Google ScholarGoogle Scholar
  2. Franz Baader and Tobias Nipkow. 1998. Term rewriting and all that. Cambridge University Press, University Press, Cambridge, UK.Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Clark Barrett, Christopher L. Conway, Morgan Deters, Liana Hadarean, Dejan Jovanović, Tim King, Andrew Reynolds, and Cesare Tinelli. 2011. CVC4. In Proceedings of the 23rd International Conference on Computer Aided Verification (CAV ’11) (Lecture Notes in Computer Science), Ganesh Gopalakrishnan and Shaz Qadeer (Eds.), Vol. 6806. Springer, Berlin, 171–177. http://www.cs.stanford.edu/~barrett/pubs/BCD+11.pdf Snowbird, Utah.Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. James Bornholt and Emina Torlak. 2017. Synthesizing memory models from framework sketches and litmus tests. ACM SIGPLAN Notices 52, 6 (2017), 467–481.Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. James Bornholt, Emina Torlak, Dan Grossman, and Luis Ceze. 2016. Optimizing synthesis with metasketches. In ACM SIGPLAN Notices, Vol. 51. ACM, New York, NY, USA, 775–788.Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Luca Cardelli, Milan Češka, Martin Fränzle, Marta Kwiatkowska, Luca Laurenti, Nicola Paoletti, and Max Whitby. 2017. Syntax-guided optimal synthesis for chemical reaction networks. In International Conference on Computer Aided Verification. Springer, Berlin, Heidelberg, 375–395.Google ScholarGoogle ScholarCross RefCross Ref
  7. Alvin Cheung, Armando Solar-Lezama, and Samuel Madden. 2012. Using program synthesis for social recommendations. In 21st ACM International Conference on Information and Knowledge Management, CIKM’12, Maui, HI, USA, October 29 -November 02, 2012, Xue-wen Chen, Guy Lebanon, Haixun Wang, and Mohammed J. Zaki (Eds.). ACM, Hawaii, USA, 1732–1736. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Loris D’Antoni, Roopsha Samanta, and Rishabh Singh. 2016. Qlose: Program repair with quantitative objectives. In International Conference on Computer Aided Verification. Springer, Berlin, Heidelberg, 383–401.Google ScholarGoogle ScholarCross RefCross Ref
  9. Leonardo de Moura and Nikolaj Bjørner. 2007. Efficient E-Matching for SMT Solvers. In Automated Deduction - CADE-21, 21st International Conference on Automated Deduction, Bremen, Germany, July 17-20, 2007, Proceedings. Springer Berlin Heidelberg, Berlin, Heidelberg, 183–198.Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Nachum Dershowitz and Jean-Pierre Jouannaud. 1990. Rewrite Systems. In Handbook of Theoretical Computer Science, Volume B: Formal Models and Sematics (B). Elsevier, Cambridge, MA, USA, 243–320.Google ScholarGoogle Scholar
  11. Francisco Durán and José Meseguer. 2010. A Church-Rosser Checker Tool for Conditional Order-Sorted Equational Maude Specifications. In Rewriting Logic and Its Applications, Peter Csaba Ölveczky (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg, 69–85.Google ScholarGoogle Scholar
  12. Yu Feng, Ruben Martins, Yuepeng Wang, Isil Dillig, and Thomas W Reps. 2017. Component-based synthesis for complex APIs. ACM SIGPLAN Notices 52, 1 (2017), 599–612.Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Carlo Ghezzi, Andrea Mocci, and Mattia Monga. 2007. Efficient recovery of algebraic specifications for stateful components. In Ninth international workshop on Principles of software evolution: in conjunction with the 6th ESEC/FSE joint meeting. ACM, ACM, New York, NY, USA, 98–105.Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Sumit Gulwani, Susmit Jha, Ashish Tiwari, and Ramarathnam Venkatesan. 2011. Synthesis of Loop-free Programs. In Proceedings of the 32Nd ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI ’11). ACM, New York, NY, USA, Article 1, 12 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Johannes Henkel and Amer Diwan. 2003. Discovering algebraic specifications from Java classes. In European Conference on Object-Oriented Programming. Springer, Springer Berlin Heidelberg, Berlin, Heidelberg, 431–456.Google ScholarGoogle ScholarCross RefCross Ref
  16. Johannes Henkel, Christoph Reichenbach, and Amer Diwan. 2007. Discovering documentation for Java container classes. IEEE Transactions on Software Engineering 33, 8 (2007), 526–543.Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Johannes Henkel, Christoph Reichenbach, and Amer Diwan. 2008. Developing and debugging algebraic specifications for Java classes. ACM Transactions on Software Engineering and Methodology (TOSEM) 17, 3 (2008), 14.Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Jinru Hua and Sarfraz Khurshid. 2017. EdSketch: execution-driven sketching for Java. In Proceedings of the 24th ACM SIGSOFT International SPIN Symposium on Model Checking of Software. ACM, New York, NY, USA, 162–171.Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Gérard Huet. 1980. Confluent Reductions: Abstract Properties and Applications to Term Rewriting Systems: Abstract Properties and Applications to Term Rewriting Systems. J. ACM 27, 4, Article 1 (Oct. 1980), 25 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Jeevana Priya Inala, Nadia Polikarpova, Xiaokang Qiu, Benjamin S. Lerner, and Armando Solar-Lezama. 2017. Synthesis of Recursive ADT Transformations from Reusable Templates. In Tools and Algorithms for the Construction and Analysis of Systems, Axel Legay and Tiziana Margaria (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 247–263.Google ScholarGoogle Scholar
  21. P. Z. Ingerman. 1961. Thunks: A Way of Compiling Procedure Statements with Some Comments on Procedure Declarations. Commun. ACM 4, 1, Article 1 (Jan. 1961), 4 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Jinseong Jeon, Xiaokang Qiu, Jonathan Fetter-Degges, Jeffrey S. Foster, and Armando Solar-Lezama. 2016. Synthesizing framework models for symbolic execution. In Proceedings of the 38th International Conference on Software Engineering, ICSE 2016, Austin, TX, USA, May 14-22, 2016. IEEE, Austin, TX, USA, 156–167. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Jinseong Jeon, Xiaokang Qiu, Armando Solar-Lezama, and Jeffrey S. Foster. 2015a. Adaptive Concretization for Parallel Program Synthesis. In Computer Aided Verification (CAV) (Lecture Notes in Computer Science), Vol. 9207. Springer International Publishing, Cham, 377–394.Google ScholarGoogle Scholar
  24. Jinseong Jeon, Xiaokang Qiu, Armando Solar-Lezama, and Jeffrey S. Foster. 2015b. JSketch: Sketching for Java. In European Software Engineering Conference and Foundations of Software Engineering (ESEC/FSE), Tool Demo Track. ACM, Bergamo, Italy, Article 1, 4 pages.Google ScholarGoogle Scholar
  25. D. E. Knuth and P. B. Bendix. 1970. Simple Word Problems in Universal Algebras. In Computational Problems in Abstract Algebras, J. Leech (Ed.). Pergamon Press, Oxford, 263–297.Google ScholarGoogle Scholar
  26. Tim Lindholm, Frank Yellin, Gilad Bracha, and Alex Buckley. 2016. The Java Virtual Machine Specification, Java SE 8 Edition. Pearson Education, Redwood City, CA , U.S.A.Google ScholarGoogle Scholar
  27. Christof Löding, P. Madhusudan, and Lucas Peña. 2017. Foundations for natural proofs and quantifier instantiation. Proceedings of the ACM on Programming Languages 2, POPL (Dec 2017), 1–30. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Yoad Lustig and Moshe Y. Vardi. 2013. Synthesis from component libraries. International Journal on Software Tools for Technology Transfer 15, 5 (01 Oct 2013), 603–618. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. David Mandelin, Lin Xu, Rastislav Bodík, and Doug Kimelman. 2005. Jungloid mining: helping to navigate the API jungle. In ACM Sigplan Notices, Vol. 40. ACM, New York, 48–61.Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. H. B. Mann and D. R. Whitney. 1947. On a Test of Whether one of Two Random Variables is Stochastically Larger than the Other. The Annals of Mathematical Statistics 18, 1 (1947), 50–60. http://www.jstor.org/stable/2236101Google ScholarGoogle ScholarCross RefCross Ref
  31. M. H. A. Newman. 1942. On Theories with a Combinatorial Definition of "Equivalence". Annals of Mathematics 43, 2 (1942), 223–243. http://www.jstor.org/stable/1968867Google ScholarGoogle ScholarCross RefCross Ref
  32. Tung Thanh Nguyen, Hoan Anh Nguyen, Nam H. Pham, Jafar M. Al-Kofahi, and Tien N. Nguyen. 2009. Graph-based Mining of Multiple Object Usage Patterns. In Proceedings of the the 7th Joint Meeting of the European Software Engineering Conference and the ACM SIGSOFT Symposium on The Foundations of Software Engineering (ESEC/FSE ’09). ACM, New York, NY, USA, Article 1, 10 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Andreas Raabe and Rastislav Bodik. 2009. Synthesizing hardware from sketches. In 2009 46th ACM/IEEE Design Automation Conference. IEEE, San Francisco, California, USA, 623–624.Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Andrew Reynolds, Jasmin Christian Blanchette, Simon Cruanes, and Cesare Tinelli. 2016. Model finding for recursive functions in SMT. In International Joint Conference on Automated Reasoning. Springer, Berlin, 133–151.Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Kensen Shi, Jacob Steinhardt, and Percy Liang. 2019. FrAngel: component-based synthesis with control structures. Proceedings of the ACM on Programming Languages 3, POPL (2019), 73.Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Rishabh Singh, Sumit Gulwani, and Armando Solar-Lezama. 2013. Automated feedback generation for introductory programming assignments. Acm Sigplan Notices 48, 6 (2013), 15–26.Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Rohit Singh, Rishabh Singh, Zhilei Xu, Rebecca Krosnick, and Armando Solar-Lezama. 2014. Modular Synthesis of Sketches Using Models. In Verification, Model Checking, and Abstract Interpretation - 15th International Conference, VMCAI 2014, San Diego, CA, USA, January 19-21, 2014, Proceedings. Springer Berlin Heidelberg, Berlin, Heidelberg, 395–414.Google ScholarGoogle Scholar
  38. Calvin Smith and Aws Albarghouthi. 2019. Program Synthesis with Equivalence Reduction. In International Conference on Verification, Model Checking, and Abstract Interpretation. Springer, Berlin, Heidelberg, 24–47.Google ScholarGoogle Scholar
  39. Armando Solar-Lezama. 2013. Program sketching. STTT 15, 5-6 (2013), 475–495. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Armando Solar-Lezama. 2016. The Sketch Programmers Manual. MIT. Version 1.7.5.Google ScholarGoogle Scholar
  41. Armando Solar-Lezama, Gilad Arnold, Liviu Tancau, Rastislav Bodik, Vijay Saraswat, and Sanjit Seshia. 2007. Sketching Stencils. In PLDI ’07: Proceedings of the 2007 ACM SIGPLAN conference on Programming language design and implementation, Vol. 42. ACM, New York, NY, USA, 167–178. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Armando Solar-Lezama, Christopher Grant Jones, and Rastislav Bodik. 2008. Sketching concurrent data structures. In ACM SIGPLAN Notices, Vol. 43. ACM, New York, NY, USA, 136–148.Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. Armando Solar-Lezama, Liviu Tancau, Rastislav Bodik, Vijay Saraswat, and Sanjit Seshia. 2006. Combinatorial Sketching for Finite Programs. In ASPLOS ’06. ACM Press, San Jose, CA, USA, Article 1, 12 pages.Google ScholarGoogle Scholar
  44. Philippe Suter, Ali Sinan Köksal, and Viktor Kuncak. 2011. Satisfiability Modulo Recursive Programs. In Static Analysis -18th International Symposium, SAS 2011, Venice, Italy, September 14-16, 2011. Proceedings. Springer Berlin Heidelberg, Berlin, Heidelberg, 298–315.Google ScholarGoogle Scholar
  45. Emina Torlak and Rastislav Bodik. 2014. A Lightweight Symbolic Virtual Machine for Solver-aided Host Languages. In PLDI’14. ACM, Edinburgh, UK, 530–541.Google ScholarGoogle Scholar
  46. Heila van der Merwe, Oksana Tkachuk, Brink van der Merwe, and Willem Visser. 2015. Generation of Library Models for Verification of Android Applications. SIGSOFT Softw. Eng. Notes 40, 1, Article 1 (Feb. 2015), 5 pages.Google ScholarGoogle Scholar
  47. Niki Vazou, Anish Tondwalkar, Vikraman Choudhury, Ryan G. Scott, Ryan R. Newton, Philip Wadler, and Ranjit Jhala. 2018. Refinement reflection: complete verification with SMT. PACMPL 2, POPL (2018), 53:1–53:31.Google ScholarGoogle Scholar
  48. Xinyu Wang, Isil Dillig, and Rishabh Singh. 2017. Synthesis of data completion scripts using finite tree automata. Proceedings of the ACM on Programming Languages 1, OOPSLA (2017), 62.Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. David Wheeler. 2009. SLOCcount. http://www.dwheeler.com/sloccount/Google ScholarGoogle Scholar

Index Terms

  1. Program synthesis with algebraic library specifications

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!