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.
Supplemental Material
- 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 Scholar
- Franz Baader and Tobias Nipkow. 1998. Term rewriting and all that. Cambridge University Press, University Press, Cambridge, UK.Google Scholar
Digital Library
- 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 Scholar
Digital Library
- James Bornholt and Emina Torlak. 2017. Synthesizing memory models from framework sketches and litmus tests. ACM SIGPLAN Notices 52, 6 (2017), 467–481.Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
- 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 Scholar
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
- Armando Solar-Lezama. 2013. Program sketching. STTT 15, 5-6 (2013), 475–495. Google Scholar
Digital Library
- Armando Solar-Lezama. 2016. The Sketch Programmers Manual. MIT. Version 1.7.5.Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
- 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 Scholar
- 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 Scholar
- 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 Scholar
- 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 Scholar
Digital Library
- David Wheeler. 2009. SLOCcount. http://www.dwheeler.com/sloccount/Google Scholar
Index Terms
Program synthesis with algebraic library specifications
Recommendations
Towards a visual programming environment generator for algebraic specifications
VL '95: Proceedings of the 11th International IEEE Symposium on Visual LanguagesIn the visual languages community there has been a growing consensus that visual languages will be most successful in the case of special purpose languages. Furthermore, their success will largely depend on the programming environment which is provided ...
Predicate and Relation Lifting for Parametric Algebraic Specifications
Relation lifting Hermida, C. and B. Jacobs, Structural induction and coinduction in a fibrational setting, Information and Computation 145 (1998), pp. 107--152] extends an endofunctor F:C→C to a functor Rel(F):Rel(C)→Rel(C), where Rel(C) is a suitable ...
Abstract computability and algebraic specification
Abstract computable functions are defined by abstract finite deterministic algorithms on many-sorted algebras. We show that there exist finite universal algebraic specifications that specify uniquely (up to isomorphism) (i) all abstract computable ...






Comments