skip to main content
research-article
Open Access
Artifacts Available
Artifacts Evaluated & Reusable

Program synthesis by type-guided abstraction refinement

Published:20 December 2019Publication History
Related Artifact: Hoogle Plus software https://doi.org/10.5281/zenodo.3544697
Skip Abstract Section

Abstract

We consider the problem of type-directed component-based synthesis where, given a set of (typed) components and a query type, the goal is to synthesize a term that inhabits the query. Classical approaches based on proof search in intuitionistic logics do not scale up to the standard libraries of modern languages, which span hundreds or thousands of components. Recent graph reachability based methods proposed for Java do scale, but only apply to monomorphic data and components: polymorphic data and components infinitely explode the size of the graph that must be searched, rendering synthesis intractable. We introduce type-guided abstraction refinement (TYGAR), a new approach for scalable type-directed synthesis over polymorphic datatypes and components. Our key insight is that we can overcome the explosion by building a graph over abstract types which represent a potentially unbounded set of concrete types. We show how to use graph reachability to search for candidate terms over abstract types, and introduce a new algorithm that uses proofs of untypeability of ill-typed candidates to iteratively refine the abstraction until a well-typed result is found.

We have implemented TYGAR in H+, a tool that takes as input a set of Haskell libraries and a query type, and returns a Haskell term that uses functions from the provided libraries to implement the query type. Our support for polymorphism allows H+ to work with higher-order functions and type classes, and enables more precise queries due to parametricity. We have evaluated H+ on 44 queries using a set of popular Haskell libraries with a total of 291 components. H+ returns an interesting solution within the first five results for 32 out of 44 queries. Our results show that TYGAR allows H+ to rapidly return well-typed terms, with the median time to first solution of just 1.4 seconds. Moreover, we observe that gains from iterative refinement over exhaustive enumeration are more pronounced on harder queries.

Skip Supplemental Material Section

Supplemental Material

a12-guo.webm

References

  1. Rajeev Alur, Arjun Radhakrishna, and Abhishek Udupa. 2017. Scaling Enumerative Program Synthesis via Divide and Conquer. In Tools and Algorithms for the Construction and Analysis of Systems - 23rd International Conference, TACAS 2017, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2017, Uppsala, Sweden, April 22-29, 2017, Proceedings, Part I . 319–336. Google ScholarGoogle ScholarCross RefCross Ref
  2. Lennart Augusstson. 2005. Djinn. https://github.com/augustss/djinn .Google ScholarGoogle Scholar
  3. Hendrik Pieter Barendregt. 1985. The lambda calculus - its syntax and semantics. Studies in logic and the foundations of mathematics, Vol. 103. North-Holland.Google ScholarGoogle Scholar
  4. Edmund M. Clarke, Robert P. Kurshan, and Helmut Veith. 2010. The Localization Reduction and Counterexample-Guided Abstraction Refinement. In Time for Verification, Essays in Memory of Amir Pnueli. 61–71. Google ScholarGoogle ScholarCross RefCross Ref
  5. Patrick Cousot. 1997. Types As Abstract Interpretations. In Proceedings of the 24th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’97) . ACM, New York, NY, USA, 316–331. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Patrick Cousot and Radhia Cousot. 1977. Abstract Interpretation: A Unified Lattice Model for Static Analysis of Programs by Construction or Approximation of Fixpoints. In Proceedings of the 4th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL ’77) . ACM, New York, NY, USA, 238–252. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Leonardo Mendonça de Moura and Nikolaj Bjørner. 2008. Z3: An Efficient SMT Solver. In TACAS (LNCS), Vol. 4963. Springer, 337–340.Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Roberto Di Cosmo. 1993. Deciding Type isomorphisms in a type assignment framework. Journal of Functional Programming 3, 3 (1993), 485–525. Google ScholarGoogle ScholarCross RefCross Ref
  9. Roy Dyckhoff and Luís Pinto. 1998. Proof Search in Constructive Logics. In In Sets and proofs. Cambridge University Press, 53–65.Google ScholarGoogle Scholar
  10. Javier Esparza, Ruslán Ledesma-Garza, Rupak Majumdar, Philipp J. Meyer, and Filip Niksic. 2014. An SMT-Based Approach to Coverability Analysis. In Computer Aided Verification - 26th International Conference, CAV 2014, Held as Part of the Vienna Summer of Logic, VSL 2014, Vienna, Austria, July 18-22, 2014. Proceedings . 603–619. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Yu Feng, Ruben Martins, Yuepeng Wang, Isil Dillig, and Thomas W. Reps. 2017. Component-based synthesis for complex APIs. In POPL.Google ScholarGoogle Scholar
  12. Jonathan Frankle, Peter-Michael Osera, David Walker, and Steve Zdancewic. 2016. Example-directed synthesis: a typetheoretic interpretation. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2016, St. Petersburg, FL, USA, January 20 - 22, 2016 . 802–815. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Joel Galenson, Philip Reames, Rastislav Bodik, Björn Hartmann, and Koushik Sen. 2014. CodeHint: Dynamic and Interactive Synthesis of Code Snippets. In Proceedings of the 36th International Conference on Software Engineering (ICSE 2014). ACM, New York, NY, USA, 653–663. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Pierre Ganty, Jean-François Raskin, and Laurent Van Begin. 2007. From Many Places to Few: Automatic Abstraction Refinement for Petri Nets. In Petri Nets and Other Models of Concurrency - ICATPN 2007, 28th International Conference on Applications and Theory of Petri Nets and Other Models of Concurrency, ICATPN 2007, Siedlce, Poland, June 25-29, 2007, Proceedings . 124–143. Google ScholarGoogle ScholarCross RefCross Ref
  15. Ronald Garcia, Alison M. Clark, and Éric Tanter. 2016. Abstracting gradual typing. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2016, St. Petersburg, FL, USA, January 20 -22, 2016 . 429–442. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Susanne Graf and Hassen Saidi. 1997. Construction of abstract state graphs with PVS. In Computer Aided Verification. 72–83.Google ScholarGoogle Scholar
  17. Sumit Gulwani. 2011. Automating string processing in spreadsheets using input-output examples. In Proceedings of the 38th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2011, Austin, TX, USA, January 26-28, 2011 . 317–330. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Zheng Guo, Michael James, David Justo, Jiaxiao Zhou, Ziteng Wang, Ranjit Jhala, and Nadia Polikarpova. 2019. Program Synthesis by Type-Guided Abstraction Refinement. arXiv: 1911.04091Google ScholarGoogle Scholar
  19. Tihomir Gvero, Viktor Kuncak, Ivan Kuraj, and Ruzica Piskac. 2013. Complete completion using types and weights. In PLDI.Google ScholarGoogle Scholar
  20. George T. Heineman, Jan Bessai, Boris Düdder, and Jakob Rehof. 2016. A Long and Winding Road Towards Modular Synthesis. In Leveraging Applications of Formal Methods, Verification and Validation: Foundational Techniques - 7th International Symposium, ISoLA 2016, Imperial, Corfu, Greece, October 10-14, 2016, Proceedings, Part I . 303–317. Google ScholarGoogle ScholarCross RefCross Ref
  21. Susumu Katayama. 2012. 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 2012, Philadelphia, Pennsylvania, USA, January 23-24, 2012 . 43–52. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Johannes Kloos, Rupak Majumdar, Filip Niksic, and Ruzica Piskac. 2013. Incremental, Inductive Coverability. In Computer Aided Verification - 25th International Conference, CAV 2013, Saint Petersburg, Russia, July 13-19, 2013. Proceedings . 158–173. Google ScholarGoogle ScholarCross RefCross Ref
  23. Woosuk Lee, Kihong Heo, Rajeev Alur, and Mayur Naik. 2018. Accelerating Search-based Program Synthesis Using Learned Probabilistic Models. In PLDI.Google ScholarGoogle Scholar
  24. David Mandelin, Lin Xu, Rastislav Bodík, and Doug Kimelman. 2005. Jungloid Mining: Helping to Navigate the API Jungle. In PLDI.Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Neil Mitchell. 2004. Hoogle. https://www.haskell.org/hoogle/ .Google ScholarGoogle Scholar
  26. Vijayaraghavan Murali, Swarat Chaudhuri, and Chris Jermaine. 2017. Bayesian specification learning for finding API usage errors. In Proceedings of the 2017 11th Joint Meeting on Foundations of Software Engineering, ESEC/FSE 2017, Paderborn, Germany, September 4-8, 2017 . 151–162. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Ulf Norell. 2008. Dependently Typed Programming in Agda. In Advanced Functional Programming, 6th International School, AFP 2008, Heijen, The Netherlands, May 2008, Revised Lectures . 230–266. Google ScholarGoogle Scholar
  28. Peter-Michael Osera and Steve Zdancewic. 2015. Type-and-example-directed program synthesis. In Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and Implementation, Portland, OR, USA, June 15-17, 2015 . 619–630. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Daniel Perelman, Sumit Gulwani, Thomas Ball, and Dan Grossman. 2012. Type-directed completion of partial expressions. In ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI ’12, Beijing, China - June 11 -16, 2012 . 275–286. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Benjamin C. Pierce. 2004. Advanced Topics in Types and Programming Languages. The MIT Press.Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Benjamin C. Pierce and David N. Turner. 2000. Local type inference. ACM Trans. Program. Lang. Syst. 22, 1 (2000), 1–44.Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Gordon Plotkin. 1970. Lattice Theoretic Properties of Subsumption. Edinburgh University, Department of Machine Intelligence and Perception. https://books.google.com/books?id=2p09cgAACAAJGoogle ScholarGoogle Scholar
  33. Nadia Polikarpova, Ivan Kuraj, and Armando Solar-Lezama. 2016. Program synthesis from polymorphic refinement types. In Proceedings of the 37th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2016, Santa Barbara, CA, USA, June 13-17, 2016 . 522–538. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Veselin Raychev, Martin Vechev, and Eran Yahav. 2014. Code Completion with Statistical Language Models. SIGPLAN Not. 49, 6 (June 2014), 419–428. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Ilya Sergey, Dimitrios Vytiniotis, Simon L. Peyton Jones, and Joachim Breitner. 2017. Modular, higher order cardinality analysis in theory and practice. J. Funct. Program. 27 (2017), e11. Google ScholarGoogle ScholarCross RefCross Ref
  36. Kensen Shi, Jacob Steinhardt, and Percy Liang. 2019. FrAngel: Component-based Synthesis with Control Structures. Proc. ACM Program. Lang. 3, POPL, Article 73 (Jan. 2019), 29 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Jeremy G. Siek and Walid Taha. 2006. Gradual Typing for Functional Languages. In IN SCHEME AND FUNCTIONAL PROGRAMMING WORKSHOP . 81–92.Google ScholarGoogle Scholar
  38. Armando Solar-Lezama. 2008. Program Synthesis by Sketching. Ph.D. Dissertation. Berkeley, CA, USA. Advisor(s) Bodik, Rastislav. AAI3353225.Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Saurabh Srivastava, Sumit Gulwani, and Jeffrey S. Foster. 2010. From program verification to program synthesis. In Proceedings of the 37th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2010, Madrid, Spain, January 17-23, 2010 . 313–326. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Pawel Urzyczyn. 1997. Inhabitation in Typed Lambda-Calculi (A Syntactic Approach). In Typed Lambda Calculi and Applications, Third International Conference on Typed Lambda Calculi and Applications, TLCA ’97, Nancy, France, April 2-4, 1997, Proceedings . 373–389. Google ScholarGoogle ScholarCross RefCross Ref
  41. Philip Wadler and Stephen Blott. 1989. How to Make ad-hoc Polymorphism Less ad-hoc. In Conference Record of the Sixteenth Annual ACM Symposium on Principles of Programming Languages, Austin, Texas, USA, January 11-13, 1989 . 60–76. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Xinyu Wang, Isil Dillig, and Rishabh Singh. 2018. Program synthesis using abstraction refinement. PACMPL 2, POPL (2018).Google ScholarGoogle Scholar

Index Terms

  1. Program synthesis by type-guided abstraction refinement

      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

      Full Access

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!