Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
article

Example-directed synthesis: a type-theoretic interpretation

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

Cited By

View all
  • (2024)Example-Based Reasoning about the Realizability of Polymorphic ProgramsProceedings of the ACM on Programming Languages10.1145/36746368:ICFP(317-337)Online publication date: 15-Aug-2024
  • (2024)Relational Synthesis of Recursive Programs via Constraint Annotated Tree AutomataComputer Aided Verification10.1007/978-3-031-65633-0_3(41-63)Online publication date: 24-Jul-2024
  • (2024)Program Synthesis from Graded TypesProgramming Languages and Systems10.1007/978-3-031-57262-3_4(83-112)Online publication date: 5-Apr-2024
  • Show More Cited By

Index Terms

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

      Recommendations

      Comments

      Information & Contributors

      Information

      Published In

      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
      • 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
      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
      Published in SIGPLAN Volume 51, Issue 1

      Check for updates

      Author Tags

      1. Functional Programming
      2. Program Synthesis
      3. Proof Search
      4. Refinement Types
      5. Sequent Calculus
      6. Type Theory

      Qualifiers

      • Article

      Funding Sources

      • NSF

      Contributors

      Other Metrics

      Bibliometrics & Citations

      Bibliometrics

      Article Metrics

      • Downloads (Last 12 months)50
      • Downloads (Last 6 weeks)17
      Reflects downloads up to 13 Jan 2025

      Other Metrics

      Citations

      Cited By

      View all
      • (2024)Example-Based Reasoning about the Realizability of Polymorphic ProgramsProceedings of the ACM on Programming Languages10.1145/36746368:ICFP(317-337)Online publication date: 15-Aug-2024
      • (2024)Relational Synthesis of Recursive Programs via Constraint Annotated Tree AutomataComputer Aided Verification10.1007/978-3-031-65633-0_3(41-63)Online publication date: 24-Jul-2024
      • (2024)Program Synthesis from Graded TypesProgramming Languages and Systems10.1007/978-3-031-57262-3_4(83-112)Online publication date: 5-Apr-2024
      • (2023)Passport: Improving Automated Formal Verification Using IdentifiersACM Transactions on Programming Languages and Systems10.1145/359337445:2(1-30)Online publication date: 26-Jun-2023
      • (2023)Synthesizing MILP Constraints for Efficient and Robust OptimizationProceedings of the ACM on Programming Languages10.1145/35912987:PLDI(1896-1919)Online publication date: 6-Jun-2023
      • (2023)Program Synthesis Using Example PropagationPractical Aspects of Declarative Languages10.1007/978-3-031-24841-2_2(20-36)Online publication date: 16-Jan-2023
      • (2022)Data-driven lemma synthesis for interactive proofsProceedings of the ACM on Programming Languages10.1145/35633066:OOPSLA2(505-531)Online publication date: 31-Oct-2022
      • (2022)Learning to Synthesize Relational InvariantsProceedings of the 37th IEEE/ACM International Conference on Automated Software Engineering10.1145/3551349.3556942(1-12)Online publication date: 10-Oct-2022
      • (2022)Recursion synthesis with unrealizability witnessesProceedings of the 43rd ACM SIGPLAN International Conference on Programming Language Design and Implementation10.1145/3519939.3523726(244-259)Online publication date: 9-Jun-2022
      • (2022)Bottom-up synthesis of recursive functional programs using angelic executionProceedings of the ACM on Programming Languages10.1145/34986826:POPL(1-29)Online publication date: 12-Jan-2022
      • Show More Cited By

      View Options

      Login options

      View options

      PDF

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader

      Media

      Figures

      Other

      Tables

      Share

      Share

      Share this Publication link

      Share on social media