Edinburgh Research Archive

Natural type inference

dc.contributor.advisor
Gordon, Andrew
dc.contributor.advisor
Sutton, Charles
dc.contributor.advisor
Sannella, Don
dc.contributor.author
Vlassi Pandi, Eirene
dc.contributor.sponsor
Edinburgh Microsoft Research Joint Initiative in Informatics
en
dc.date.accessioned
2023-10-19T10:57:58Z
dc.date.available
2023-10-19T10:57:58Z
dc.date.issued
2023-10-19
dc.description.abstract
Recently, dynamic language users have started to recognize the value of types in their code. To fulfil this need, many popular dynamic languages have adopted extensions that support type annotations. A prominent example is that of TypeScript which offers a module system, classes, interfaces, and an optional type system on top of JavaScript. However, providing usable (not too verbose, or complex) types via traditional type inference is more challenging in optional type systems. Motivated by this, we redefine the goal of type inference for optionally typed languages as: infer the maximally natural and sound type, instead of the most general one. By the maximally natural and sound, we refer to a type that (1) is derivable in the type system, and (2) maximally reflects the intention of the programmer with respect to a learnt model. We formally devise a type inference problem that aids the inference of the maximally natural type. Towards this goal, our problem asks to combine information derived from two sources: (1) from algorithmic type systems using deductive logic-based techniques; and (2) from the source code text using inductive machine learning techniques. To tackle our formulated problem, we develop two frameworks that combine the two sources of information using mathematical optimization. In the first framework, we formulate the inference problem as a problem in numerical optimization. In the second framework, we map the inference problem into popular problems in discrete optimization: maximum satisfiability (MaxSAT) and Integer Linear Programming (ILP). Both frameworks are built to be consistent with information derived from the different sources. Moreover, through formal proofs, we validate the soundness and completeness of the developed framework for a core lambda-calculus with named types. To assess the efficacy of the developed frameworks, we implement them in a tool named Optyper that realizes natural type inference for TypeScript. We evaluate Optyperon TypeSript programs obtained from real world projects. By evaluating our theoretical frameworks we show that, in practice, the combination of logical and natural constraints yields a large improvement in performance over either kind of information individually. Further, we demonstrate that our frameworks out-perform state-of-the-art techniques in type inference to produce natural and sound types.
en
dc.identifier.uri
https://hdl.handle.net/1842/41079
dc.identifier.uri
http://dx.doi.org/10.7488/era/3818
dc.language.iso
en
en
dc.publisher
The University of Edinburgh
en
dc.subject
Type systems
en
dc.subject
Type theory
en
dc.subject
Machine learning
en
dc.subject
Constraint satisfaction
en
dc.subject
Maximum satisfiability
en
dc.title
Natural type inference
en
dc.type
Thesis or Dissertation
en
dc.type.qualificationlevel
Doctoral
en
dc.type.qualificationname
PhD Doctor of Philosophy
en

Files

Original bundle

Now showing 1 - 1 of 1
Name:
Vlassi PandiE_2023.pdf
Size:
1.42 MB
Format:
Adobe Portable Document Format
Description:

This item appears in the following Collection(s)