论文标题
OptTyper:通过优化逻辑和自然约束来推断概率类型
OptTyper: Probabilistic Type Inference by Optimising Logical and Natural Constraints
论文作者
论文摘要
我们为动态语言的类型推理问题提供了一种新方法。我们的目标是结合\ emph {逻辑}约束,即来自类型系统的确定性信息,以及\ emph {natural}约束,即,从诸如标识符名称之类的源中学习的类型的不确定统计信息。为此,我们引入了一个结合逻辑和学习的概率类型推理的框架:从程序中提取了类型的逻辑约束,并将深度学习应用于从统计上关联的表面级代码属性中预测类型。我们方法的首要洞察力是将学习过程中的预测限制为尊重逻辑约束,我们通过将类型预测的逻辑推断问题放松为连续优化问题来实现。我们构建一个称为OptTyper的工具,可预测打字稿文件的缺失类型。 OptTyper结合了通过对打字稿代码的经典静态分析得出的逻辑约束的连续解释,以及从深度学习模型获得的自然约束,该模型从大型代码库中学习了类型的命名约定。通过评估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.