## Section: New Results

### Language design and type systems

#### The Mezzo programming language

Participants : Thibaut Balabonski, François Pottier, Jonathan Protzenko.

Mezzo is a programming language proposal whose untyped foundation is very much like OCaml (i.e., it is equipped with higher-order functions, algebraic data structures, mutable state, and shared-memory concurrency) and whose type system offers flexible means of describing ownership policies and controlling side effects.

In 2013 and early 2014, Thibaut Balabonski and François Pottier re-worked the machine-checked proof of type soundness for Mezzo. They developed a version of the proof which includes concurrency and dynamically-allocated locks, and showed that well-typed programs do not crash and are data-race free. This work was presented by François Pottier at FLOPS 2014 [24] . The proof was then extended with a novel and simplified account of adoption and abandon, a mechanism for combining the static ownership discipline with runtime ownership tests. A comprehensive paper, which contains both a tutorial introduction to Mezzo and a description of its formal definition and proof, was submitted to TOPLAS.

Minor modifications were carried out by Jonathan Protzenko in the implementation. A version of Mezzo that runs in a Web browser was developed and uploaded online, so that curious readers can play with the language without installing the software locally.

Jonathan Protzenko wrote his Ph.D. dissertation [12] , which describes the design of Mezzo and the implementation of the Mezzo type-checker. He defended on September 29, 2014.

Web site: http://protz.github.io/mezzo/

#### System F with coercion constraints

Participants : Julien Cretin [Trust In Soft] , Didier Rémy, Gabriel Scherer.

Expressive type systems often allow non trivial conversions between types,
which may lead to complex, challenging, and sometimes ad hoc type
systems. Such examples are the extension of System F with type equalities to
model GADTs and type families of Haskell, or the extension of System F with
explicit contracts. A useful technique to simplify the meta-theoretical
study of such systems is to view type conversions as *coercions* inside terms.

Following a general approach based on System F, Julien Cretin and Didier
Rémy earlier introduced a language of *explicit coercions* enabling
abstraction over coercions and viewing all type transformations as explicit
coercions [57] . To ensure that coercions are erasable,
*i.e.*, that they only decorate terms without altering their reduction,
they are restricted to those that are parametric in either their domain or
codomain. Despite this restriction, this language already subsumed many
extensions of System F, including bounded polymorphism, instance-bounded
polymorphism, and $\eta $-conversions—but not subtyping constraints.

To lift this restriction, Julien Crétin and Didier Rémy proposed a new approach were coercions are left implicit. Technically, we extended System F with a rich language of propositions containing a first-order logic, a coinduction mechanism, consistency assertions, and coercions (which are thus just a particular form of propositions); we then introduced a type-level language using kinds to classify types, and constrained kinds to restrict kinds to types satisfying a proposition. Abstraction over types of a constrained kind amounts to abstraction over arbitrary propositions, including coercions.

By default, type abstraction should be erasable, which is the case when kinds of abstract type variables are inhabited—we say that such abstractions are consistent. Still, inconsistent type abstractions are also useful, for instance, to model GADTs. We provide them as a different construct, since they are not erasable, as they must delay reduction of subterms that depend on them. This introduces a form of weak reduction in a language with full reduction, which is a known source of difficulties: although the language remains sound, we loose the subject reduction property. This work has been described in [28] and is part of Julien Cretin's PhD dissertation [11] defended in January 2014; a simpler, core subset is also described in [45] .

Recently, Gabriel Scherer and Didier Rémy introduced *assumption
hiding* [32] , [50] to restore confluence when mixing full and weak
reductions and provide a continuum between consistent and inconsistent
abstraction. Assumption hiding allows a fine-grained control of
dependencies between computations and the logical hypotheses they depend on;
although studied for a language of coercions, the solution is more general
and should be applicable to any language with abstraction over propositions
that are left implicit, either for the user's convenience in a surface
language or because they have been erased prior to computation in an
internal language.

#### Singleton types for code inference

Participants : Gabriel Scherer, Didier Rémy.

We continued working on singleton types for code inference. If we can prove that a type contains, in a suitably restricted pure lambda-calculus, a unique inhabitant modulo program equivalence, the compiler can infer the code of this inhabitant. This opens the way to type-directed description of boilerplate code, through type inference of finer-grained type annotations. A decision algorithm for the simply-typed lambda-calculus is still work-in-progress. We presented at the TYPES'14 conference [42] our general approach to such decision procedures, and obtained an independent counting result for intuitionistic logic [52] that demonstrates the finiteness of the search space.

#### Generic programming with ornaments

Participants : Pierre-Évariste Dagand, Didier Rémy, Thomas Williams.

Since their first introduction in ML, datatypes have evolved: besides
providing an organizing *structure* for computation, they are now
offering more *control* over what is a valid result. GADTs,
which are now part of the OCaml language,
offer such a mechanism: ML programmers can express fine-grained,
logical invariants of their datastructures. Programmers thus strive to
express the correctness of their programs in the types: a well-typed
program is correct by construction. However, these carefully crafted
datatypes are a threat to any library design: the same
data-*structure* is used for many logically incompatible
purposes. To address this issue, McBride developed
*ornaments*. It defines conditions under which a new datatype
definition can be described as an ornament of another one, typically
when they both share the same inductive definition scheme. For
example, lists can be described as the ornament of the Church encoding
of natural numbers. Once a close correspondence between a datatype and
its ornament has been established, certain kinds of operations on the
original datatype can be automatically lifted to its ornament.

To account for whole-program transformations, we developed a
type-theoretic presentation of *functional
ornament* [17] as a generalization of
ornaments to functions. This work built up on a type-theoretic
*universe of datatypes*, a first-class description of inductive
types within the type theory itself. Such a presentation allowed us to
analyze and compute over datatypes in a transparent manner. Upon this
foundation, we formalized the concept of functional ornament by
another type-theoretic universe construction. Based on this universe,
we established the connection between a base function (such as
addition and subtraction) and its ornamented version (such as,
respectively, the concatenation of lists and the deletion of a
prefix). We also provided support for driving the computer into
semi-automatically lifting programs: we showed how addition over
natural numbers could be incrementally evolved into concatenation of
lists.

Besides the theoretical aspects, we have also tackled the practical question of offering ornaments in an ML setting [33] . Our goal was to extend core ML with support for ornaments so as to enable semi-automatic program transformation and fully-automatic code refactoring. We thus treated the purely syntactic aspects, providing a concrete syntax for describing ornaments of datatypes and specifying the lifting of functions. Such lifting specifications allow the user to declaratively instruct the system to, for example, lift addition of numbers to concatenation of lists. We gave an algorithm that, given a lifting specification, performs the actual program transformation from the bare types to the desired, ornamented types. This work has been evaluated by a prototype implementation in which we demonstrated a few typical use-cases for the semi-automatic lifting of programs.

Having demonstrated the benefits of ornaments in ML, it has been
tempting to offer ornaments as first-class citizens in a programming
language. Doing so, we wished to rationalize the lifting of programs
as an elaboration process within a well-defined, formal system. To
describe the liftings, one would like to specify only the local
transformations that are applied to the original program. Designing
such a language of *patches* and formalizing its elaboration has
been the focus of our recent efforts.

#### Constraints as computations

Participant : François Pottier.

Hindley-Milner type inference–the problem of determining whether an ML program is well-typed–is well-understood, and can be elegantly explained and implemented in two phases, namely constraint generation and constraint solving. In contrast, elaboration–the task of constructing an explicitly-typed representation of the program–seems to have received relatively little attention in the literature, and did not until now enjoy a modular constraint-based presentation. François Pottier proposed such a presentation, which views constraints as computations and equips them with the structure of an applicative functor. This work was presented as a “functional pearl” at ICFP 2014 [31] . The code, in the form of a re-usable library, is available online.

#### Equivalence and normalization of lambda-terms with sums

Participants : Gabriel Scherer, Guillaume Munch-Maccagnoni [Université 13, LIPN lab] .

Determining uniqueness of inhabitants requires a good understanding of program equivalence in presence of sum types. In yet-unpublished work, Gabriel Scherer worked on the correspondence between two existing normalization techniques, one coming from the focusing community [54] and the other using direct lambda-term rewriting [63] . A collaboration with Guillaume Munch-Maccagnoni has also started this year, whose purpose is to present normalization procedures for sums using System L, a rich, untyped syntax of terms (or abstract machines) for the sequent calculus.

#### Computational interpretation of realizability

Participants : Pierre-Évariste Dagand, Gabriel Scherer.

We are trying to better understand the computational behavior of semantic normalization techniques such as a realizability and logical relation models. As a very first step, we inspected the computational meaning of a normalization proof by realizability for the simply-typed lambda-calculus. It corresponds to an evaluation function; the evaluation order for each logical connective is determined by the definition of the sets of truth and value witnesses. This preliminary work is to be presented at JFLA 2015 [35] .