Team Gallium

Overall Objectives
Scientific Foundations
Application Domains
New Results
Contracts and Grants with Industry
Other Grants and Activities

Section: New Results

Type systems and type inference

Leveraging constraint-based type inference

Participants : Jonathan Protzenko, François Pottier.

Jonathan Protzenko, under the supervision of François Pottier, improved constraint-based type inference. Instead of just checking that a program is typeable, he now generates a typed AST. This allows to translate the source program into a core language, namely System Im1 $F^\#951 $ augmented with explicit coercions. The benefits are threefold: some features of the input language are now precisely described in terms of core constructions; the resulting core program can be type-checked to ensure the consistency of the whole process; this provides a starting point for the rest of the compilation process. This work is a first building block towards a more trustworthy compiler for Caml.

Partial type inference with first-class polymorphism

Participants : Didier Rémy, Boris Yakobowski [CEA LIST] , Gabriel Scherer.

The ML language uses simple types (first-order types without quantifiers) enriched with type schemes (simple types with outer-most universal quantifiers). This allows for simple type inference based on first-order unification, relieving the user from the burden of writing type annotations. However, it only enables a limited form of parametric polymorphism. In contrast, System F uses second-order types (types with inner universal quantifiers at arbitrary depth) that are much more expressive. As a result, type inference is undecidable in System F which forces the user to provide all type annotations.

Didier Le Botlan and Didier Rémy have proposed a type system, called MLF, which enables type synthesis as in ML while retaining the expressiveness of System F. Only type annotations on parameters of functions that are used polymorphically in their body are required. All other type annotations, including all type abstractions and type applications are inferred. Remarkably, type inference in MLF reduces to a new form of unification that amounts to performing first-order unification in the presence of second-order types. The journal version of this work was published in Information and Computation [2] . The initial design was then simplified and made more expressive by Boris Yakobowski in his Ph.D. dissertation  [54] , using graphs rather than terms to represent types and also to perform type inference.

This year, Didier Rémy and Boris Yakobowski have further improved the graphical presentation of MLF by following a more algebraic approach. This is described in two journal articles in preparation. Didier Rémy and Boris Yakobowski also revisited the fully explicit version of MLF, which can be used both to show the preservation of types during reduction and as an internal language for MLF. This work was presented at the International Conference on Functional and Logic Programming, held in Sendai, Japan in April 2010 [26] . An extended version of this work has been submitted for journal publication. The elaboration of eMLF into xMLF has been added to the prototype implementation of MLF by Gabriel Scherer during his master internship [37] .

Gabriel Scherer (master's intern from ENS Paris) and Didier Rémy have continued the exploration of MLF with higher-order types. To keep the system decidable, type abstraction over higher-order kind variables is made explicit while type abstraction over base kinds left implicit as in the original MLF. This gives MLF the power of System Im2 $F^\#969 $ while keeping implicit the introduction and elimination of polymorphism at second-order types and many type type annotations on function parameters. This work is described in Gabriel Scherer's internship dissertation [37] and has been implemented in the new MLF prototype (Available electronically at .).

A generalization of F-eta with abstraction over retyping functions

Participants : Julien Cretin, Didier Rémy.

Expressive type system often allow non trivial conversions between types, leading to complex, challenging, and sometimes ad hoc type systems. Such examples are the extension of System F with type equalities to model Haskell GADT and type families, or the extension of System F with explicit contracts. A useful technique to simplify the meta-theoretical studies of such systems is to make conversions fully explicit in terms via “coercions”.

The essence of coercion functions is perhaps to be found in System FIm3 ${}^\#951 $ , which is the closure of System F by $ \eta$ -reduction, but which can also be seen at the extension of System F with retyping functions: retyping functions allow deep type specialization of terms, strengthening the domain of functions or weakening their codomains a posteriori.

However, System FIm3 ${}^\#951 $ lacks abstraction over retyping functions, which coercion systems often need. We have studied an extension FIm4 ${}^{\#955 \#951 }$ of FIm3 ${}^\#951 $ that precisely allows such abstraction. The main difficulty in the design of FIm3 ${}^\#951 $ is to preserve the erasure semantics of System F, i.e. to allow coercions to be dropped before evaluation without changing the meaning of programs. The language FIm4 ${}^{\#955 \#951 }$ extends both FIm3 ${}^\#951 $ and xMLF, the internal language of MLF. As a side result, this proves the termination of reduction in xMLF. This work is described in Julien Cretin's Master dissertation [36] .

A machine-checked proof of a type-and-capability calculus

Participant : François Pottier.

This year, François Pottier developed a machine-checked proof of an expressive type-and-capability system. Such a system can be used to type-check and prove properties of imperative ML programs. The proof is carried out in Coq and takes up roughly 20,000 lines of code. It confirms that earlier publications by Charguéraud and Pottier [1] , [7] were indeed correct, offers insights into the design of the type-and-capability system, and provides a firm foundation for further research. François Pottier is presently writing a paper on this topic.

Fine-grained static control of side effects

Participants : François Pottier, Jonathan Protzenko.

Building on previous work by Arthur Chargueraud and François Pottier, Jonathan Protzenko started designing a new type system for a functional and imperative language. The goal is to strike a reasonable balance between a fine-grained, highly sophisticated type system, that allows one to gain precise control over side-effects, and a language that is practically usable by mere programmers. This is part of a very active research field that aims at designing new languages that offer stronger guarantees and help better understand side effects.


Logo Inria