Component-based synthesis for complex APIs

Component-based approaches to program synthesis assemble programs from a database of existing components, such as methods provided by an API. In this paper, we present a novel type-directed algorithm for component-based synthesis. The key novelty of our approach is the use of a compact Petri-net representation to model relationships between methods in an API. Given a target method signature S, our approach performs reachability analysis on the underlying Petri-net model to identify sequences of method calls that could be used to synthesize an implementation of S. The programs synthesized by our algorithm are guaranteed to type check and pass all test cases provided by the user. We have implemented this approach in a tool called SyPet, and used it to successfully synthesize real-world programming tasks extracted from on-line forums and existing code repositories. We also compare SyPet with two state-of-the-art synthesis tools, namely InSynth and CodeHint, and demonstrate that SyPet can synthesize more programs in less time. Finally, we compare our approach with an alternative solution based on hypergraphs and demonstrate its advantages.

[1]  Giorgio Gallo,et al.  Directed Hypergraphs and Applications , 1993, Discret. Appl. Math..

[2]  Tatsuhiro Tsuchiya,et al.  SAT-Based Verification of Safe Petri Nets , 2004, ATVA.

[3]  Richard Fikes,et al.  STRIPS: A New Approach to the Application of Theorem Proving to Problem Solving , 1971, IJCAI.

[4]  R. Holmes,et al.  Using structural context to recommend source code examples , 2005, Proceedings. 27th International Conference on Software Engineering, 2005. ICSE 2005..

[5]  Daniele Pretolani,et al.  Finding the K shortest hyperpaths , 2005, Comput. Oper. Res..

[6]  Solar-LezamaArmando,et al.  Data-driven synthesis for object-oriented frameworks , 2011 .

[7]  Sumit Gulwani,et al.  Type-directed completion of partial expressions , 2012, PLDI.

[8]  Patrick Fabiani,et al.  Planning with tokens: an approach between satisfaction and optimisation , 2000, PuK.

[9]  Robert K. Brayton,et al.  Partial-Order Reduction in Symbolic State-Space Exploration , 2001, Formal Methods Syst. Des..

[10]  Sumit Gulwani,et al.  Oracle-guided component-based program synthesis , 2010, 2010 ACM/IEEE 32nd International Conference on Software Engineering.

[11]  Sumit Gulwani,et al.  Recursive Program Synthesis , 2013, CAV.

[12]  Sumit Gulwani,et al.  Automating string processing in spreadsheets using input-output examples , 2011, POPL '11.

[13]  Kenneth L. McMillan,et al.  Using Unfoldings to Avoid the State Explosion Problem in the Verification of Asynchronous Circuits , 1992, CAV.

[14]  Sumit Gulwani,et al.  Synthesizing Number Transformations from Input-Output Examples , 2012, CAV.

[15]  Javier Esparza,et al.  Unfoldings - A Partial-Order Approach to Model Checking , 2008, Monographs in Theoretical Computer Science. An EATCS Series.

[16]  Armando Solar-Lezama,et al.  Programming by sketching for bit-streaming programs , 2005, PLDI '05.

[17]  Ruzica Piskac,et al.  A Type-Directed Approach to Program Repair , 2015, CAV.

[18]  Sanjit A. Seshia,et al.  Combinatorial sketching for finite programs , 2006, ASPLOS XII.

[19]  Laurie Hendren,et al.  Soot: a Java bytecode optimization framework , 2010, CASCON.

[20]  Gerard Salton,et al.  A vector space model for automatic indexing , 1975, CACM.

[21]  Sumit Gulwani,et al.  Learning Semantic String Transformations from Examples , 2012, Proc. VLDB Endow..

[22]  Robert K. Brayton,et al.  Partial-Order Reduction in Symbolic State Space Exploration , 1997, CAV.

[23]  Sanjit A. Seshia,et al.  Sketching stencils , 2007, PLDI '07.

[24]  Richard M. Karp,et al.  Parallel Program Schemata , 1969, J. Comput. Syst. Sci..

[25]  Scott A. Mahlke,et al.  The theory of deadlock avoidance via discrete control , 2009, POPL '09.

[26]  Sumit Gulwani,et al.  Test-driven synthesis , 2014, PLDI.

[27]  Doron A. Peled,et al.  Ten Years of Partial Order Reduction , 1998, CAV.

[28]  Alain Finkel,et al.  The Minimal Coverability Graph for Petri Nets , 1991, Applications and Theory of Petri Nets.

[29]  Koushik Sen,et al.  CodeHint: dynamic and interactive synthesis of code snippets , 2014, ICSE.

[30]  Tadao Murata,et al.  Petri nets: Properties, analysis and applications , 1989, Proc. IEEE.

[31]  Sumit Gulwani,et al.  Synthesis of loop-free programs , 2011, PLDI '11.

[32]  Peter-Michael Osera,et al.  Type-and-example-directed program synthesis , 2015, PLDI.

[33]  Eran Yahav,et al.  Code completion with statistical language models , 2014, PLDI.

[34]  Keith H. Randall,et al.  Denali: a goal-directed superoptimizer , 2002, PLDI '02.

[35]  Sumit Gulwani,et al.  Spreadsheet table transformations from examples , 2011, PLDI '11.

[36]  Sumit Gulwani,et al.  Synthesizing geometry constructions , 2011, PLDI '11.

[37]  Jussi Rintanen,et al.  Planning via Petri Net Unfolding , 2007, IJCAI.

[38]  Armando Solar-Lezama,et al.  Data-driven synthesis for object-oriented frameworks , 2011, OOPSLA '11.

[39]  Viktor Kuncak,et al.  Synthesizing Java expressions from free-form queries , 2015, OOPSLA.

[40]  Rastislav Bodík,et al.  Jungloid mining: helping to navigate the API jungle , 2005, PLDI '05.

[41]  Armando Solar-Lezama,et al.  Program synthesis by sketching , 2008 .

[42]  Ruzica Piskac,et al.  Complete completion using types and weights , 2013, PLDI.

[43]  Donald E. Knuth,et al.  A Generalization of Dijkstra's Algorithm , 1977, Inf. Process. Lett..

[44]  Tao Xie,et al.  Parseweb: a programmer assistant for reusing open source code on the web , 2007, ASE.

[45]  Kajal T. Claypool,et al.  XSnippet: mining For sample code , 2006, OOPSLA '06.

[46]  Armando Solar-Lezama,et al.  JSketch: sketching for Java , 2015, ESEC/SIGSOFT FSE.

[47]  Walter Vogler Efficiency of Asynchronous Systems and Read Arcs in Petri Nets , 1997, ICALP.

[48]  Keijo Heljanko,et al.  Using Logic Programs with Stable Model Semantics to Solve Deadlock and Reachability Problems for 1-Safe Petri Nets , 1999, Fundam. Informaticae.

[49]  Isil Dillig,et al.  Synthesizing data structure transformations from input-output examples , 2015, PLDI.

[50]  Daniel Le Berre,et al.  The Sat4j library, release 2.2 , 2010, J. Satisf. Boolean Model. Comput..

[51]  Sumit Gulwani,et al.  Spreadsheet data manipulation using examples , 2012, CACM.

[52]  Ruzica Piskac,et al.  Interactive Synthesis of Code Snippets , 2011, CAV.