arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2004.00348cs.PLcs.LG
收藏

OptTyper:通过优化逻辑和自然约束的概率类型推断

OptTyper: Probabilistic Type Inference by Optimising Logical and Natural Constraints

University of Edinburgh(爱丁堡大学);University College London(伦敦大学学院);Microsoft Research(微软研究院);The Alan Turing Institute(艾伦·图灵研究所);Google AI(谷歌人工智能)

Irene Vlassi Pandi, Earl T. Barr, Andrew D. Gordon, Charles Sutton

摘要:

我们提出了一种新的方法来解决动态语言的类型推断问题。我们的目标是将\emph{logical}约束(即来自类型系统的确定性信息)与\emph{natural}约束(即从标识符名称等来源学习的有关类型的不确定统计信息)相结合。为此,我们引入了一个结合逻辑和学习的概率类型推断框架:从程序中提取类型的逻辑约束,并应用深度学习从统计相关的表面级代码属性预测类型。我们的方法的最重要的见解是约束学习过程中的预测,以尊重逻辑约束,这是通过将类型预测的逻辑推理问题放松为连续优化问题来实现的。我们构建了一个名为OptTyper的工具来预测TypeScript文件中缺失的类型。OptTyper结合了对TypeScript代码的经典静态分析得出的逻辑约束的连续解释,以及从深度学习模型获得的自然约束,该模型从大型代码库中学习类型的命名约定。通过评估OptTyper,我们表明,逻辑和自然约束的组合产生了很大的改善,在性能上的任何一种信息单独和实现了4%的改进,比最先进的。

英文摘要:

We present a new approach to the type inference problem for dynamic languages. Our goal is to combine \emph{logical} constraints, that is, deterministic information from a type system, with \emph{natural} constraints, that is, uncertain statistical information about types learnt from sources like identifier names. To this end, we introduce a framework for probabilistic type inference that combines logic and learning: logical constraints on the types are extracted from the program, and deep learning is applied to predict types from surface-level code properties that are statistically associated. The foremost insight of our method is to constrain the predictions from the learning procedure to respect the logical constraints, which we achieve by relaxing the logical inference problem of type prediction into a continuous optimisation problem. We build a tool called OptTyper to predict missing types for TypeScript files. OptTyper combines a continuous interpretation of logical constraints derived by classical static analysis of TypeScript code, with natural constraints obtained from a deep learning model, which learns naming conventions for types from a large codebase. By evaluating OptTyper, we show that the combination of logical and natural constraints yields a large improvement in performance over either kind of information individually and achieves a 4% improvement over the state-of-the-art.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑