一句话:提出 TYGAR,以抽象类型图可达性搜索结合不可类型性证明迭代精化,实现多态组件的高效类型导向程序合成。
本文研究类型导向的基于组件的程序合成:给定一组带类型组件和一个查询类型,目标是合成出具有该类型的项。传统基于直觉主义逻辑证明搜索的方法难以扩展到现代语言动辄成百上千组件的标准库;已有的基于图可达性的 Java 方法虽可扩展,却只适用于单态数据与组件,多态会无限膨胀待搜索图,使合成不可行。作者提出 TYGAR,在表示潜在无界具体类型集合的抽象类型上构图,用图可达性搜索候选项,并引入新算法,利用错误类型候选的不可类型性证明迭代精化抽象,直至找到良类型结果。作者在 H+ 中实现该方法,输入 Haskell 库与查询类型,输出使用库函数的 Haskell 项。对 44 个查询、合计 291 个组件的评估显示,32 个查询在前五个结果内返回有趣解,首个解中位时间仅 1.4 秒,且迭代精化相对穷举枚举的收益在更难查询上更明显。
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.
@article{paperbot577,
title = {Program synthesis by type-guided abstraction refinement},
author = {Zheng Guo and Michael James and David Justo and Jiaxiao Zhou and Ziteng Wang and Ranjit Jhala and Nadia Polikarpova},
journal = {Proceedings of the ACM on Programming Languages},
volume = {4},
number = {POPL},
year = {2019},
doi = {10.1145/3371080}
}