OptTyper: Probabilistic Type Inference by Optimising Logical and Natural Constraints

04/01/2020
by   Irene Vlassi Pandi, et al.
0

We present a new approach to the type inference problem for dynamic languages. Our goal is to combine logical constraints, that is, deterministic information from a type system, with 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, such as variable names. 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. As proof of concept, we build a tool called OptTyper to predict missing types for TypeScript files. OptTyper combines a continuous interpretation of logical constraints derived by a simple program transformation and 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 3

READ FULL TEXT

page 1

page 2

page 3

page 4

research
08/06/2021

Non-ground Abductive Logic Programming with Probabilistic Integrity Constraints

Uncertain information is being taken into account in an increasing numbe...
research
04/29/2020

LambdaNet: Probabilistic Type Inference using Graph Neural Networks

As gradual typing becomes increasingly popular in languages like Python ...
research
05/08/2021

HiTyper: A Hybrid Static Type Inference Framework with Neural Prediction

Type inference for dynamic programming languages is an important yet cha...
research
04/06/2020

Typilus: Neural Type Hints

Type inference over partial contexts in dynamically typed languages is c...
research
08/04/2023

TIPICAL – Type Inference for Python In Critical Accuracy Level

Type inference methods based on deep learning are becoming increasingly ...
research
01/29/2020

On Constraint Definability in Tractable Probabilistic Models

Incorporating constraints is a major concern in probabilistic machine le...
research
03/26/2018

code2vec: Learning Distributed Representations of Code

We present a neural model for representing snippets of code as continuou...

Please sign up or login with your details

Forgot password? Click here to reset