ABSTRACT
Input-output examples have emerged as a practical and user-friendly specification mechanism for program synthesis in many environments. While example-driven tools have demonstrated tangible impact that has inspired adoption in industry, their underlying semantics are less well-understood: what are "examples" and how do they relate to other kinds of specifications? This paper demonstrates that examples can, in general, be interpreted as refinement types. Seen in this light, program synthesis is the task of finding an inhabitant of such a type. This insight provides an immediate semantic interpretation for examples. Moreover, it enables us to exploit decades of research in type theory as well as its correspondence with intuitionistic logic rather than designing ad hoc theoretical frameworks for synthesis from scratch. We put this observation into practice by formalizing synthesis as proof search in a sequent calculus with intersection and union refinements that we prove to be sound with respect to a conventional type system. In addition, we show how to handle negative examples, which arise from user feedback or counterexample-guided loops. This theory serves as the basis for a prototype implementation that extends our core language to support ML-style algebraic data types and structurally inductive functions. Users can also specify synthesis goals using polymorphic refinements and import monomorphic libraries. The prototype serves as a vehicle for empirically evaluating a number of different strategies for resolving the nondeterminism of the sequent calculus---bottom-up theorem-proving, term enumeration with refinement type checking, and combinations of both---the results of which classify, explain, and validate the design choices of existing synthesis systems. It also provides a platform for measuring the practical value of a specification language that combines "examples" with the more general expressiveness of refinements.
- A. Albarghouthi, S. Gulwani, and Z. Kincaid. Recursive program synthesis. In Computer Aided Verification, pages 934–950, 2013. Google ScholarDigital Library
- J.-M. Andreoli. Logic programming with focusing proofs in linear logic. Journal of Logic and Computation, 2(3):297–347, 1992.Google ScholarCross Ref
- L. Augustsson. {haskell} announcing djinn, version 2004-12-11, a coding wizard. Mailing List, 2004. http://www.haskell.org/ pipermail/haskell/2005-December/017055.html.Google Scholar
- F. Barbanera, M. Dezaniciancaglini, and U. Deliguoro. Intersection and union types. Information and Computation, 119(2):202–230, June 1995. Google ScholarDigital Library
- R. Davies. A practical refinement-type checker for standard ml.Google Scholar
- B. Düdder, M. Martens, and J. Rehof. Staged composition synthesis. In Programming Languages and Systems - 23rd European Symposium on Programming, ESOP 2014, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2014, Grenoble, France, April 5-13, 2014, Proceedings, pages 67–86, 2014.. URL http://dx.doi.org/10.1007/978-3-642-54833-8_5.Google Scholar
- J. Dunfield. A unified system of type refinements. PhD thesis, Carnegie Mellon University, 2007.Google Scholar
- J. Dunfield and F. Pfenning. Tridirectional typechecking. pages 281– 292, 2004. Google ScholarDigital Library
- J. K. Feser, S. Chaudhuri, and I. Dillig. Synthesizing data structure transformations from input-output examples. In Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), 2015. Google ScholarDigital Library
- K. Fisher, D. Walker, K. Q. Zhu, and P. White. From dirt to shovels: Fully automatic tool generation from ad hoc data. 2008.Google Scholar
- J. Frankle. Type-directed synthesis of products, Oct. 2015. URL http://arxiv.org/abs/1510.08121.Google Scholar
- J. Frankle, P.-M. Osera, D. Walker, and S. Zdancewic. Exampledirected synthesis: A type-theoretic interpretation (extended version). Technical Report MS-CIS-15-12, University of Pennsylvania, 2015.Google Scholar
- T. Freeman and F. Pfenning. Refinement types for ML, volume 26. ACM, 1991. Google ScholarDigital Library
- S. Gulwani. Automating string processing in spreadsheets using inputoutput examples. In ACM SIGPLAN Notices, volume 46, pages 317– 330. ACM, 2011. Google ScholarDigital Library
- T. Gvero, V. Kuncak, I. Kuraj, and R. Piskac. Complete completion using types and weights. In Proceedings of the 2013 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), 2013. Google ScholarDigital Library
- S. Katayama. An analytical inductive functional programming system that avoids unintended programs. In Proceedings of the ACM SIGPLAN 2012 Workshop on Partial Evaluation and Program Manipulation, PEPM ’12, pages 43–52, New York, NY, USA, 2012. ACM. ISBN 978-1-4503-1118-2. Google ScholarDigital Library
- E. Kitzelmann. A Combined Analytical and Search-based Approach to the Inductive Synthesis of Functional Programs. PhD thesis, Fakulät für Wirtschafts-und Angewandte Informatik, Universität Bamberg, 2010.Google Scholar
- V. Kuncak, M. Mayer, R. Piskac, and P. Suter. Complete functional synthesis. In Proceedings of the 31th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI ’10, 2010. Google ScholarDigital Library
- T. Lau. Programming by Demonstration: a Machine Learning Approach. PhD thesis, University of Washington, 2001. Google ScholarDigital Library
- V. Le and S. Gulwani. Flashextract: A framework for data extraction by examples. In Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI ’14. ACM, 2014. Google ScholarDigital Library
- Microsoft Corporation. Microsoft by the numbers, 2015. URL http: //news.microsoft.com/bythenumbers/ms\_numbers.pdf.Google Scholar
- P.-M. Osera and S. Zdancewic. Type-and-example-directed program synthesis. In Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and Implementation. ACM, 2015. Google ScholarDigital Library
- F. Pfenning. Automated theorem proving, 2004. URL http://www. cs.cmu.edu/~fp/courses/atp/index.html.Google Scholar
- N. Polikarpova and A. Solar-Lezama. Program synthesis from polymorphic refinement types, Oct. 2015.Google Scholar
- J. Rehof and P. Urzyczyn. Finite combinatory logic with intersection types. In L. Ong, editor, Typed Lambda Calculi and Applications, volume 6690 of Lecture Notes in Computer Science, pages 169–183. Springer Berlin Heidelberg, 2011. ISBN 978-3-642-21690-9.. URL http://dx.doi.org/10.1007/978-3-642-21691-6_15. Google ScholarDigital Library
- G. Scherer and D. Rèmy. Which simple types have a unique inhabitant? In Proceedings of the 18th ACM SIGPLAN International Conference on Functional Programming (ICFP), 2015. Google ScholarDigital Library
- A. Solar-Lezama. Program Synthesis by Sketching. PhD thesis, University of California, Berkeley, 2008. Google ScholarDigital Library
- P. Wadler. Theorems for free! In Proceedings of the fourth international conference on Functional programming languages and computer architecture, pages 347–359. ACM, 1989. Google ScholarDigital Library
Index Terms
- Example-directed synthesis: a type-theoretic interpretation
Recommendations
Constraint-based type-directed program synthesis
TyDe 2019: Proceedings of the 4th ACM SIGPLAN International Workshop on Type-Driven DevelopmentWe explore an approach to type-directed program synthesis rooted in constraint-based type inference techniques. By doing this, we aim to more efficiently synthesize polymorphic code while also tackling advanced typing features such as GADTs that build ...
Type-and-example-directed program synthesis
PLDI '15: Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and ImplementationThis paper presents an algorithm for synthesizing recursive functions that process algebraic datatypes. It is founded on proof-theoretic techniques that exploit both type information and input–output examples to prune the search space. The algorithm ...
Program synthesis from polymorphic refinement types
PLDI '16: Proceedings of the 37th ACM SIGPLAN Conference on Programming Language Design and ImplementationWe present a method for synthesizing recursive functions that provably satisfy a given specification in the form of a polymorphic refinement type. We observe that such specifications are particularly suitable for program synthesis for two reasons. ...
Comments