Program Sketching by Automatically Generating Mocks from Tests

Sketch is a popular program synthesis tool that solves for unknowns in a sketch or partial program. However, while Sketch is powerful, it does not directly support modular synthesis of dependencies, potentially limiting scalability. In this paper, we introduce Sketcham, a new technique that modularizes a regular sketch by automatically generating mocks—functions that approximate the behavior of complete implementations—from the sketch’s test suite. For example, if the function f originally calls g, Sketcham creates a mock $$g_m$$ g m from g’s tests and augments the sketch with a version of f that calls $$g_m$$ g m . This change allows the unknowns in f and g to be solved separately, enabling modular synthesis with no extra work from the Sketch user. We evaluated Sketcham on ten benchmarks, performing enough runs to show at a 95% confidence level that Sketcham improves median synthesis performance on six of our ten benchmarks by a factor of up to 5$$\times $$ × compared to plain Sketch, including one benchmark that times out on Sketch, while exhibiting similar performance on the remaining four. Our results show that Sketcham can achieve modular synthesis by automatically generating mocks from tests.

[1]  E. S. Pearson,et al.  THE USE OF CONFIDENCE OR FIDUCIAL LIMITS ILLUSTRATED IN THE CASE OF THE BINOMIAL , 1934 .

[2]  Armando Solar-Lezama,et al.  Synthesis of Domain Specific CNF Encoders for Bit-Vector Solvers , 2016, SAT.

[3]  Yanjun Wang,et al.  Reconciling enumerative and deductive program synthesis , 2020, PLDI.

[4]  Armando Solar-Lezama,et al.  Program synthesis with algebraic library specifications , 2019, Proc. ACM Program. Lang..

[5]  Sarfraz Khurshid,et al.  EdSketch: execution-driven sketching for Java , 2017, SPIN.

[6]  Aws Albarghouthi,et al.  Program Synthesis with Equivalence Reduction , 2019, VMCAI.

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

[8]  Michael D. Ernst,et al.  Automatic test factoring for java , 2005, ASE '05.

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

[10]  Percy Liang,et al.  FrAngel: component-based synthesis with control structures , 2018, Proc. ACM Program. Lang..

[11]  Nikolaj Bjørner,et al.  Linear Quantifier Elimination as an Abstract Decision Procedure , 2010, IJCAR.

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

[13]  Armando Solar-Lezama,et al.  Program synthesis from polymorphic refinement types , 2015, PLDI.

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

[15]  Armando Solar-Lezama,et al.  Learning to Infer Graphics Programs from Hand-Drawn Images , 2017, NeurIPS.

[16]  Malavika Samak,et al.  Synthesizing replacement classes , 2019, Proc. ACM Program. Lang..

[17]  Lieven Eeckhout,et al.  Statistically rigorous java performance evaluation , 2007, OOPSLA.

[18]  Armando Solar-Lezama,et al.  The Sketching Approach to Program Synthesis , 2009, APLAS.

[19]  Isil Dillig,et al.  Synthesizing JIT Compilers for In-Kernel DSLs , 2020, CAV.

[20]  Alessandra Gorla,et al.  A Framework for Automated Test Mocking of Mobile Apps , 2020, 2020 35th IEEE/ACM International Conference on Automated Software Engineering (ASE).

[21]  Armando Solar-Lezama,et al.  Synthesizing Framework Models for Symbolic Execution , 2016, 2016 IEEE/ACM 38th International Conference on Software Engineering (ICSE).

[22]  Ruzica Piskac,et al.  Complete functional synthesis , 2010, PLDI '10.

[23]  Xavier Rival,et al.  Verification, Model Checking, and Abstract Interpretation - 15th International Conference, VMCAI 2014, San Diego, CA, USA, January 19-21, 2014, Proceedings , 2014 .

[24]  Robert S. Boyer,et al.  A fast string searching algorithm , 1977, CACM.

[25]  Rastislav Bodík,et al.  Programming with angelic nondeterminism , 2010, POPL '10.

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

[27]  Zohar Manna,et al.  The calculus of computation - decision procedures with applications to verification , 2007 .

[28]  Alvin Cheung,et al.  Using program synthesis for social recommendations , 2012, CIKM.

[29]  Armando Solar-Lezama,et al.  Synthesis of Recursive ADT Transformations from Reusable Templates , 2015, TACAS.

[30]  Sarfraz Khurshid,et al.  EdSketch: execution-driven sketching for Java , 2019, International Journal on Software Tools for Technology Transfer.

[31]  Rishabh Singh,et al.  Modular Synthesis of Sketches Using Models , 2014, VMCAI.

[32]  Deepak Kapur,et al.  Connecting Program Synthesis and Reachability: Automatic Program Repair Using Test-Input Generation , 2017, TACAS.