Book of Abstracts - IRIT
Book of Abstracts - IRIT
Book of Abstracts - IRIT
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Universe Polymorphism and Inference in Coq<br />
Matthieu Sozeau<br />
INRIA Paris & PPS, Paris 7 University<br />
matthieu.sozeau@inria.fr<br />
Abstract<br />
Type theories such as the Calculus <strong>of</strong> Inductive Constructions maintain a universe<br />
hierarchy to prevent logical paradoxes. To ensure consistency while not troubling the user<br />
with this necessary information, systems using typical ambiguity were designed, which<br />
handle universes implicitly. Universes are seen as floating and their usage determines a<br />
graph <strong>of</strong> constraints, which must statisfy a property <strong>of</strong> acyclicity to ensure consistency.<br />
While this is a useful mechanism, there are a number <strong>of</strong> situations where the user would<br />
like to have developments made polymorphic on the universes used and instantiate his<br />
constructions at different levels. Typically, this is necessary to nest different instances <strong>of</strong> a<br />
given structure containing universes. We present an elaboration from terms using typical<br />
ambiguity into explicit terms which also accomodates universe polymorphism, i.e. the<br />
ability to write a term once and use it at different universe levels. Elaboration relies on<br />
an enhanced type inference algorithm to provide the freedom <strong>of</strong> typical ambiguity while<br />
also supporting polymorphism, in a fashion similar to usual Hindley-Milner polymorphic<br />
type inference. This elaboration is implemented as a drop-in replacement for the existing<br />
universe system <strong>of</strong> Coq and has been benchmarked favorably against the previous version.<br />
We demonstrate how it provides a solution to a number <strong>of</strong> formalization issues present in<br />
the original system.<br />
The Calculus <strong>of</strong> Inductive Constructions implemented in the Coq pro<strong>of</strong> assistant relies on a<br />
system <strong>of</strong> universes to ensure logical consistency. It avoids paradoxes coming from the infamous<br />
Type : Type rule <strong>of</strong> system U- [1] by stratifying the universes used in a development, giving them<br />
names (“levels”) and building up a graph <strong>of</strong> their inclusion relationships. It ensures that these<br />
relationships are coherent at any given point <strong>of</strong> a development. This can be checked by showing<br />
that there is always an assignment <strong>of</strong> natural numbers to universe levels that satisfy the universe<br />
constraints, which implies that the stratified universe levels map to the well-founded suite <strong>of</strong><br />
universes Type 0 < Type 1 < .. < Type n .<br />
To avoid forcing the user to work directly with levels, a system <strong>of</strong> typical ambiguity is used<br />
in Coq, where one can leave out the names <strong>of</strong> universes involved in a definition and let the<br />
system generate fresh universe variables and associated constraints. However in its current form<br />
this system has a serious limitation as it does not allow one to make definitions that can be<br />
instantiated at different levels: levels are always global. Let’s look at a simple example. The<br />
polymorphic identity function id is written:<br />
Definition id (A : Type) (a : A) := a<br />
It takes a type A in an unspecified universe, an object <strong>of</strong> that type and returns it. The<br />
actual CIC term constructed by this definition involves a fresh universe variable (say l) and its<br />
type-checking judgement has conclusion:<br />
⊢ (λ(A : Type l )(a : A), a) : Π(A : Type l ), A → A<br />
The rule for type-checking product types in CIC allows us to derive for the type <strong>of</strong> the<br />
identity function a judgment:<br />
76