Practical Heterogeneous Unification for Dependent Type Checking
Doktorsavhandling, 2021

Dependent types can specify in detail which inputs to a program are allowed, and how the properties of its output depend on the inputs. A program called the type checker assesses whether a program has a given type, thus detecting situations where the implementation of a program potentially differs from its intended behaviour. When using dependent types, the inputs to a program often occur in the types of other inputs or in the type of the output. The user may omit some of these redundant inputs when calling the program, expecting the type-checker to infer those subterms automatically.

Some type-checkers restrict the inference of missing subterms to those cases where there is a provably unique solution. This makes the process more predictable, but also limits the situations in which the omitted terms can be inferred; specially when considering that whether a unique solution exists is in general an undecidable problem. This restriction can be made less limiting by giving flexibility to the type-checker regarding the order in which the missing subterms are inferred. The type-checker can then use the information gained by filling in any one subterm in order to infer others, until the whole program has been type-checked. However, this flexibility may in some cases lead to ill-typed subterms being inferred, breaking internal invariants of the type-checker and causing it to crash or loop. The type checker could mitigate this by consistently rechecking the type of each inferred subterm, but this might incur a performance penalty.
 
An approach by Gundry and McBride (2012) called twin types has the potential to afford the desired flexibility while preserving well-typedness invariants. However, this method had not yet been tested in a practical setting. In this thesis we streamline the method of twin types in order to ease its practical implementation, justify the correctness of our modifications, and then implement the result in an established dependently-typed language called Agda. We show that our implementation resolves certain existing bugs in Agda while still allowing a wide range of examples to be type-checked, and achieves this without heavily impacting performance.

unification

dependent types

type checking

Rum 8103, EDIT huset, Johanneberg
Opponent: Claudio Sacerdoti Coen, University of Bologna, Italy

Författare

Víctor López Juan

Chalmers, Data- och informationsteknik, Datavetenskap

Will the computer do what we expect it to?

For a computer to carry out a task (for example, sorting a list of names), a programmer must have given the computer precise instructions on how to carry it out (that is, a program). However, if the programmer makes a mistake, the computer may do something different from the intended task. A programmer can use a type system to write a specification of what the task is (that is, the type of the program). A program called the type checker automatically checks whether a program fulfills a specification (that is, whether it has a given type).

The simplest type systems can specify the format of the input and the output, for example: “this program takes a list of names as input and gives a list of names as output”. More advanced type systems (known as dependent type systems) can specify how the output depends on the input; for example: “this program takes a list of names as input, and outputs the same list, but sorted”. Type checkers for dependent type systems are an area of active research. One such type checker is Agda. It is developed by researchers at Chalmers (among others) and counts many computer science researchers and educators as its users.

Agda users often want to omit uninteresting details of a type or program. These details can then be deduced automatically by the Agda type checker in a process called unification. However, some of these deduced details are themselves small programs, which may need to be run by the type checker. If any of these programs does not fulfill a suitable specification, the type-checker itself may hang, frustrating the user.

This thesis describes a method for performing unification in a dependent type checker. Our method can deduce many user-omitted details, while avoiding deducing programs that could make the type checker hang. We show that our method can be used in practice by implementing it in the Agda type checker.

Ämneskategorier

Datavetenskap (datalogi)

ISBN

978-91-7905-583-7

Doktorsavhandlingar vid Chalmers tekniska högskola. Ny serie: 5050

Utgivare

Chalmers tekniska högskola

Rum 8103, EDIT huset, Johanneberg

Online

Opponent: Claudio Sacerdoti Coen, University of Bologna, Italy

Mer information

Senast uppdaterat

2021-11-26