skip to main content
10.1145/2837614.2837629acmconferencesArticle/Chapter ViewAbstractPublication PagespoplConference Proceedingsconference-collections
research-article

Example-directed synthesis: a type-theoretic interpretation

Published:11 January 2016Publication History

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.

References

  1. A. Albarghouthi, S. Gulwani, and Z. Kincaid. Recursive program synthesis. In Computer Aided Verification, pages 934–950, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. J.-M. Andreoli. Logic programming with focusing proofs in linear logic. Journal of Logic and Computation, 2(3):297–347, 1992.Google ScholarGoogle ScholarCross RefCross Ref
  3. 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 ScholarGoogle Scholar
  4. F. Barbanera, M. Dezaniciancaglini, and U. Deliguoro. Intersection and union types. Information and Computation, 119(2):202–230, June 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. R. Davies. A practical refinement-type checker for standard ml.Google ScholarGoogle Scholar
  6. 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 ScholarGoogle Scholar
  7. J. Dunfield. A unified system of type refinements. PhD thesis, Carnegie Mellon University, 2007.Google ScholarGoogle Scholar
  8. J. Dunfield and F. Pfenning. Tridirectional typechecking. pages 281– 292, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  10. K. Fisher, D. Walker, K. Q. Zhu, and P. White. From dirt to shovels: Fully automatic tool generation from ad hoc data. 2008.Google ScholarGoogle Scholar
  11. J. Frankle. Type-directed synthesis of products, Oct. 2015. URL http://arxiv.org/abs/1510.08121.Google ScholarGoogle Scholar
  12. 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 ScholarGoogle Scholar
  13. T. Freeman and F. Pfenning. Refinement types for ML, volume 26. ACM, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. S. Gulwani. Automating string processing in spreadsheets using inputoutput examples. In ACM SIGPLAN Notices, volume 46, pages 317– 330. ACM, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  16. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  17. 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 ScholarGoogle Scholar
  18. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  19. T. Lau. Programming by Demonstration: a Machine Learning Approach. PhD thesis, University of Washington, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  21. Microsoft Corporation. Microsoft by the numbers, 2015. URL http: //news.microsoft.com/bythenumbers/ms\_numbers.pdf.Google ScholarGoogle Scholar
  22. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  23. F. Pfenning. Automated theorem proving, 2004. URL http://www. cs.cmu.edu/~fp/courses/atp/index.html.Google ScholarGoogle Scholar
  24. N. Polikarpova and A. Solar-Lezama. Program synthesis from polymorphic refinement types, Oct. 2015.Google ScholarGoogle Scholar
  25. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  26. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  27. A. Solar-Lezama. Program Synthesis by Sketching. PhD thesis, University of California, Berkeley, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Example-directed synthesis: a type-theoretic interpretation

      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
      • Published in

        cover image ACM Conferences
        POPL '16: Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages
        January 2016
        815 pages
        ISBN:9781450335492
        DOI:10.1145/2837614
        • cover image ACM SIGPLAN Notices
          ACM SIGPLAN Notices  Volume 51, Issue 1
          POPL '16
          January 2016
          815 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/2914770
          • Editor:
          • Andy Gill
          Issue’s Table of Contents

        Copyright © 2016 ACM

        Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 11 January 2016

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Qualifiers

        • research-article

        Acceptance Rates

        Overall Acceptance Rate824of4,130submissions,20%

        Upcoming Conference

        POPL '25

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader