A Canonical Form for Universe Levels in Impredicative Type Theory
Abstract
The 0-imax-successor algebra, where is the function defined by and , is used to represent universe levels in impredicative type theory, in particular with universe polymorphism which introduces level variables, so it is present in proof systems such as Rocq and Lean. In particular, we need to know when two elements of this algebra are equivalent, and we may also want to decide the inequality. In this article, we introduce a canonical form for the terms of this algebra, and we provide a canonization algorithm. It permits deciding level equivalence by checking the canonical form equality, and also permits easily checking if a level is smaller than another one.
Keywords and phrases:
universe levels, canonical form, impredicativity, imax algebra2012 ACM Subject Classification:
Theory of computation Type theory ; Theory of computation Equational logic and rewritingSupplementary Material:
Software (Rock formalisation): https://gitlab.crans.org/geran/level_formalisationarchived at
swh:1:dir:79df183835f26e788d568780b46e800bf0d0cfc6
Acknowledgements:
I want to thank my PhD advisors Olivier Hermant and Gilles Dowek for the helpful discussions and comments.Editors:
Stefano Guerrini and Barbara KönigSeries and Publisher:
Leibniz International Proceedings in Informatics, Schloss Dagstuhl – Leibniz-Zentrum für Informatik
1 Introduction
The formalization of mathematical theorems and the verification of software lead to the development of many logical systems. Predicate Logic is a quite general theory but does not allow for instance to quantify over predicates, preventing the expression of some propositions. Then, more expressive logic have been introduced through the years. This paper being motivated by the universe polymorphism in impredicative type theory, the introduction will briefly remind the history of these theories, to understand what they bring.
Pure Type Systems
A lot of type theories are based on extensions of Church’s simply-typed -calculus which does not permit expressing terms over arbitrary types (preventing for instance to talk about all the groups). To address this, Martin-Löf introduced a dependent type theory with a type of all types [25], and later, to avoid paradoxes such as Girard’s one [12, 20], introduced a distinction between small types and large types (which are types containing types, and are also called universes) [27].
In the same years, Girard and Reynolds independently invented System F, an extension of Church’s simply-typed -calculus with type polymorphism, and even later, Girard presented System which adds type operators i.e. the ability to quantify over terms to create types.
The Calculus of Constructions [13] introduced by Coquand in his PhD thesis combined features from both Martin-Löf Type Theory and System . This system allows quantifying on types or terms to build new types and new terms, and it is the pinnacle of the -cube of Barendregt [4], which classifies type systems depending on the quantification possibilities.
The Calculus of Constructions is an elegant system with strong properties such as normalization and logical consistency. However, quantification over Type is not possible since it makes the system incoherent. This led Coquand to generalize the system with a predicative hierarchy of universes [12], in the same way as predicative Martin-Löf type theory [26]. This new system, which we will call , contains a countable sequence of universes , where is the universe of the propositions, the indices being referred to as universes levels.
Definition 1.
A Pure Type System (PTS) is defined by a set of sorts (that corresponds to universes), a set of axioms and a set of rules .
describes the sorts typing ( has the type when ), and describes the possible quantifications and their typing rules. The terms are the following, where and ranges an infinite set of variables.
Both and predicative Martin-Löf type theory have a set of sorts indexed over the natural numbers, with for all , . Their difference resides in their set of rules. These rules permit to type products, so we recall the typing rule for products.
Impredicativity
With the aim of building a consistent system, paradoxes such as Girard’s one should be avoided. When Coquand analysed it, he found that a product from Type to Type could not live in Type: it should live in a greater type (hence the distinction between small and large types).
With an infinite hierarchy of universes, this principle remains: a product from to should live in a greater universe. Therefore, in the predicative Martin-Löf type theory, the set of rules is . The choice of is different (and does not break the consistency either): a product from to lives in , so it follows the rules where is defined for all by and .
This corresponds to the so-called impredicativity of Prop (hence the name for impredicative max) which notably permits to say that we can quantify over all the propositions and still get a new proposition. Accepting or rejecting impredicativity is a philosophical questioning: some consider that should be a proposition (which is of course true), while others think that a proposition cannot be created by quantifying over all the propositions.
Universe Polymorphism
A PTS can be enriched with universe polymorphism which allows the user to quantify over universes [28, 23, 14]. For instance, it permits declaring simultaneously the identity for all the types of any universes with . This feature adds universe variables to the language of a PTS. In the case of , it is equivalent to extend the syntax of the levels with level variables.
Definition 2 (Levels).
A level is a term of the grammar
where is an element of a countable set of variables . We denote by the set of levels, and we say that a level is ground if it does not contain any variable.
Definition 3.
We call the extension of with prenex universe polymorphism.
The universe polymorphic identity of is the term
We can use it by instantiating the level variable. For instance, is the identity of Prop while is ’s one. This instantiation is done throughout substitution functions, which replace a level variable by a level, and valuation functions which replace level variables by integers.
Definition 4 (Valuation).
A function is called a valuation. For all valuations , we define inductively the value of a level over , denoted as , with
This interpretation through the valuations explains why, even if levels are abstract terms, we defined them with the same symbols , , and that are used for the natural numbers. Indeed, the ground levels can clearly be identified as the natural numbers and the levels’ semantic, through the valuations, justifies to use the same symbol and permits to see the valuations as functions that realise levels, turning them into ground ones.
Besides, two levels can also be compared using these valuations. They are equivalent if they give the same ground levels through any valuation.
Definition 5 (Level comparison).
Let . We say that if for all valuations , . In the same way, we say that if for all valuations , . Hence, if and only if and . And we say that and are incomparable if neither nor .
This equivalence shows that universes such as and should be identified. However, it is not obvious to check. It is not syntactic, like it was without universe polymorphism, and the function makes it complicated.
The aim of this paper is to address this problem. Since it is a word problem, a direct solution consists in finding a canonical form and an algorithm which computes the canonical form of a given term. The level equivalence is then checked by syntactic comparison of the canonical form. We follow this path. To do this, we study the 0--successor algebra, and we provide a canonical form for its terms. Besides, this equivalence is decidable by a reduction to Presburger arithmetic, and so we provide an additional motivation to our work.
Motivation
Our main motivation lies in the interoperability between proof systems. Indeed, it became a big challenge in the research on proof-checking, which aims to avoid the redevelopment of the same proof. Instead of developing translators from each system to another one, logical frameworks propose to define theories in a common language, which makes translation easier.
The -calculus modulo rewriting () [10] is a logical framework that extends (the simply-typed -calculus with dependent types) with higher-order rewrite rules [16, 29] that can be used to define functions, but also types; terms are then identified modulo and these rewrite rules. The computational part of the type theories can then be represented using the expressiveness of rewrite systems.
The Calculus of Constructions and its subtheories can be expressed in [8], and, in [15], Cousineau and Dowek showed how to express some PTS. Therefore, several systems have been encoded in : HOL-Light [30, 1], Agda [19], Matita [1], but also parts of Rocq [18, 9]. Besides, since there exist multiple implementations of such as Dedukti [2], Lambdapi [24], or Kontroli [17], these embeddings have been implemented, leading to effective translations [30, 21, 22].
To define in , we need to define its levels. It can be done with a type nat together with functions max, and imax, and rewrite rules to define them. This permits to express in , but the equivalence relation that comes with level variables adds some difficulties.
Indeed, for all term of , let us note its translation in , and let us consider a function and a term where . Since is well-typed, then should be well-typed in . Therefore, should have the type , whereas it has the type . We deduce that and should be convertible types, and then that equivalent levels should be convertible terms.
Related Work
The 0--successor algebra is well-studied, and so, some solutions exist in the predicative case. In [31], Voevodsky represented each level as where . Then, if there exists such that , we simplify the term and keep only . Therefore, we obtain a minimal representation for the 0--successor algebra.
In [19], Genestier encoded the universe polymorphism of Agda in using a similar idea and a representation modulo associativity and commutativity (for the symbol). Blanqui gave another presentation of this algebra in [7], with an encoding without matching modulo associativity and commutativity.
The 0--successor algebra is less studied. An encoding is proposed in [3], but it does not fully reflect the equalities; for instance, the levels and are not convertible. Besides, Férey also worked on the encoding of universe polymorphism [18].
Finally, an algorithm to check level inequality, and so level equivalence, is presented in [11], but it does not rely on a canonical form.
Outline and Contributions
We use the same idea presented above in the predicative case: find a subset of levels such that any level can be represented as with , and such that is a minimal representation that ensures uniqueness property for any other minimal representation :
In the predicative case, ; and the minimal representation consists in having one term (the maximum of two integers can be simplified) and for all at most one term since . To obtain the canonical representation, we push the successor symbols inside the , and we obtain with . Then, can be simplified by removing if there exists such that and , leading to the minimal representation.
This gives us the intuition that we need. The elements of the subset should be very basic and simple in the sense that it is not equivalent to a maximum of other levels.
Section 2 studies the algebra and introduces , a set of basic terms, called canonical sublevels. It turns out that these terms do not have the same expressive power than levels, hence we extend into , the extended levels. But, each level can be represented as a maximum of elements of ; such a maximum is a representation, they will form the set of representations .
Then, in Section 3 we introduce , the set of minimal representations which are representations whose elements are incomparable, and we show that any representation has a unique minimal representation.
Moreover, we will see that is not stable by level substitution, which can generate extended levels. But, in order to have a correct translation of substitution in , we should be able to identify with . That is why we generalize the canonical form to the extended levels in Section 4, showing that all extended levels have a minimal representation: its canonical form. Then , we present the canonization algorithm in Appendix A.
Figure 1 summarises this. Besides, the proofs of the results are given in the full version of the paper, as well as a canonization algorithm. Finally, the existence and uniqueness are also proved in Rocq since we formalised the canonization algorithm for the levels 111https://gitlab.crans.org/geran/level_formalisation.
2 Level Representation
As said in the introduction, in this section we find a set of sublevels that fit our objective of level representation. Before that, let us introduce a basic notion that improves the readability of the text.
Definition 6.
Let be a level and be a valuation. We say that is active (under the valuation ) if . We also say that activates .
The valuation will often be left implicit. For instance, we can say that is if is active and otherwise in the sense that for all valuation , is if is active under and otherwise.
2.1 Levels as Maximum
The very first step to simplify the terms is to express any level as a maximum of levels that do not contain any , that is the principle of our idea. The successor can be distributed over since for all , , and the next two observations show how to distribute over .
Observation 7.
For all ,
Observation 8.
For all ,
Then, any level can be expressed as a maximum of levels without . Note that for this, we consider that takes a finite set of levels as argument. We obtain the following theorem.
Theorem 9.
For all , there exists in the grammar
such that . Moreover, the variables that appear in are exactly the variables that appear in .
2.2 Simplification of the Levels
We can now focus on levels without maximum. The uniqueness property sought for the representation requires the levels to be very basic, and then we search to simplify them.
The main issue in the grammar of Theorem 9 is because it is asymmetric. We aim to restrict the localisation of the symbol to specific parts of the levels in order to understand and control their influence on the levels semantic.
Firstly, we recall some equivalences that are direct consequences of the semantics of . They permit to deal with and the successor.
Observation 10.
For all ,
And we show how to remove symbol in second argument of .
Observation 11.
For all ,
Thus, by applying the simplification suggested by observations 10 and 11, we can restrict the second argument of to be a variable. It is more complicated for its first argument. We can simplify the level when it is .
Observation 12.
For all , .
Moreover, we can distribute over , but this cannot be done as directly as we distribute the over , as shown in the next example.
Example 13.
We consider the levels and . By considering a valuation such that and , , therefore .
Besides, we can observe that ) is at least , but can also be when is active. Therefore, the simplification rule has to take into account the two relevant cases depending on the value of .
Observation 14.
For all ,
Finally, observations 11, 10, 12, and 14 lead to this grammar restriction.
Theorem 15.
For all , there exists in the grammar
such that . Moreover, the variables that appear in are exactly the variables that appear in .
Remark 16.
For all in the grammar of Theorem 15, there exists , and or such that
Such a term will be denoted by . Intuitively, this term is the maximum of
-
,
-
if is active,
-
if and are active,
-
etc.
-
if all the are active.
2.3 Introducing New Levels
Here, we continue the simplification process in order to find simple enough terms to reach the uniqueness property. Indeed, the terms of the grammar of Theorem 15 are still not simple enough.
Example 17.
Let us consider . Then, .
The problem is the following: if permits to take into account if is active, it also takes into account in all cases. Then, it is redundant with and lead to the equivalence . We would like to obtain with some level , but cannot be simplified more.
In fact, the second argument of has too many responsibilities since it should be taken into account, but it is also a condition to take into account the first argument.
The second concern leads us to devise the introduction of a term “” such that is if and otherwise. This permits us to simplify into , and since , can be turned into .
Since, the functions are nested in the grammar of Theorem 15, we may need to have multiple variables as conditions; we generalize this idea of new terms and extend the level’s grammar with two symbols and .
Definition 18 (Extended levels).
An extended level is a term of the grammar
where . We extend and the level comparison to the extended levels with
We denote by the set of extended levels. Levels of the form or are called sublevels.
The symbols and stand for “variable sublevel” and “constant sublevel” in the sense that their semantic consists in taking into account a non-constant or a constant extended level when a set of extended levels only contain active ones.
Definition 19.
We denote by the set of sublevels. Let , or . We call the verification conditions of denoted by , and is its constant part denoted by . We also define the variable part of denoted by which is in the case of a constant sublevel and in the case of a variable sublevel.
Besides, we say that a verification condition is checked (by a valuation ) if and we say that the verification condition are checked if for all , .
The verification conditions and the parts of a sublevel determine its value and if it is active. Indeed, when is active, its value is . And for to be active, the verification condition of should be checked (otherwise the value of is automatically ), and on top of that (which is then the value of ) should not be .
Proposition 20.
For all and for all valuations , if is active and otherwise. Moreover, is active if and only if its verifications conditions are checked and .
Keeping with our idea, we want to show that any level is equivalent to a maximum of sublevels, so we do it for the grammar presented in Theorem 15. Here is the intuition behind the replacement of a nested by a maximum of sublevels. In ,
-
is always considered, so we take ,
-
is considered if is active, so we take ,
-
is considered if and are active, so we take ,
-
…
-
is considered if all the are active, so we take .
The situation is similar in the case , except that the last taken term is .
Proposition 21.
Let , , , , and for all , . Then,
One could note that since the grammar of is really permissive, for all , we have the trivial equivalence to express as a sublevel. This shows that the sublevels are at least as expressive as the levels, but this equivalence is a nonsense in terms of level simplification. Proposition 21 is a much stronger and useful result since it states that the verification conditions and the variable part of variable sublevels can be restricted to variables to have a complete representation of levels of . However, we made the choice of presenting extended levels without this restriction to facilitate the level instantiation (developed in Section 4). Indeed, a variable will then be replaced by any level, and we want to make this substitution transparent in our level representation.
2.4 An Appropriate Set of Sublevels
We have restrained our study to the sublevels whose verification conditions and the variable part (in the case of variable sublevels) are variables. Now, we show that some of them can be obtained as a maximum of other ones. The first restriction is related to the representation of . Indeed, for all , . Since we already have , we can remove all these sublevels. The second restriction is a little more subtle and is illustrated with this example.
Example 22.
With and , we have since for all valuation , .
The issue here is the fact that the variable part of a variable sublevel does not necessarily appear in its first argument. This is the key of the following equivalence.
Proposition 23.
Let , and . Then
If , the sublevel obtained with Proposition 23 is removed accordingly to the first restriction. We end up with the following set of sublevels which permits to express any level.
Definition 24 (Canonical sublevels).
A canonical sublevel is an element of the set
Theorem 25.
Let . Then there exists a finite such that . Moreover, the variables that appear in the elements of are exactly the variables that appear in .
Definition 26.
Let be a finite subset of . We say that is a representation, and we denote by the set of representations.
Besides, for all , we say that is a representation of if , and we say that the elements of are the elements of the representation.
The canonical sublevels correspond to the set of sublevels that we were searching for. We could try to merge the two types of sublevels by introducing a special variable such that for all valuation , . We can then see as . This simplifies some results but makes the presentation less clear, and the distinction should still be done in a lot of cases.
Remark 27.
Let and let be a valuation. Then is active if and only if all its verification conditions are checked.
3 A Canonical Form for levels
The previous section defined , the set of representations, and showed that any level is equivalent to one of its elements. The goal of this one is to show that any level has a minimal representation and that it is unique. This will be the canonical form.
Definition 28 (Minimal representation).
Let . We say that is minimal if and only if for all such that , and are incomparable. We denote by the set of the minimal representations.
By Theorem 25, any level has a representation. Since the set of representations is well-founded with the inclusion order, any level has a minimal representation. The challenging part is the uniqueness of minimal representations. To show it, we study the core of the definition of a minimal representation: the sublevel comparison.
3.1 Sublevel Comparison
The sublevels can be easily compared which is quite normal since we chose them to be very basic. To have , should be active whenever is active hence . And when they are both active, the value of should be greater than the one of .
With two variable sublevels it means that their variable part is the same or else we can set a very large value to in order to falsify the inequality. This also explains that we cannot have . And if is a constant sublevel and a variable sublevel, we should remember that when they are active, is active (because it is included in ) and then suffices.
Theorem 29 (Sublevels comparison).
The following equivalences permit to compare elements of .
| (1) | |||
| (2) | |||
| (3) | |||
| (4) |
As a corollary, we get that the sublevel equivalence is a syntactic equality, which is expected to ease uniqueness.
Corollary 30.
Let . Then .
Figure 2 illustrates the comparison of the canonical sublevels on the set of variables and with or as constant part. We see that we get a greater sublevel by increasing the constant part, reducing the set of verification conditions, or moving to a variable sublevel (in that case, the constant part can be reduced by one).
3.2 The Uniqueness Property
Now, we can show the uniqueness property. We have to show that two equivalent minimal representations and have the same sublevels. Here, we show a slightly different proof. It is more elegant, and it emphasises the property that ensures the uniqueness.
We will show that implies the existence of such that . This statement lead to the uniqueness property. Indeed, if and are two equivalent minimal representation, then for all there exists a such that , and similarly there exists such that . Minimality of permits to conclude that , and then and finally by comparison of canonical sublevels.
To prove this statement, the idea is to find, for any sublevel , a valuation such that the only way to have is to have with . Such a valuation should only activate the verification condition of . Moreover, should be large enough to overtake the other sublevels of the representation. When is a variable sublevel, it means to set its variable part to a large number.
Definition 31.
Let be a constant sublevel and be a set of canonical sublevel. The -minimal over-valuation of is the valuation defined by
Definition 32.
Let be a variable sublevel and be a set of canonical sublevel. The -minimal over-valuation of is the valuation defined by
Proposition 33.
Let be a variable sublevel, be a set of canonical sublevel and be the -minimal over-valuation of . We have
This proposition is fundamental for the following theorem.
Theorem 34.
For all and , if and only if there exists such that .
And we obtain that equivalence of minimal representations is set equality.
Proposition 35.
For all , .
Finally, we obtain the main theorem: the existence and uniqueness of a minimal representation for each level, that is to say a canonical form. First, we show the intuitive property that the minimal representation of a maximum of sublevels is formed with some of them.
Proposition 36.
For all , there exists a unique such that . Moreover, is a subset of .
Theorem 37 (Minimal Representation).
For all , there exists a unique such that . We say that is the canonical form of .
This theorem states the existence of a canonical form function for , being the function that associates any level to its minimal representation.
Remark 38.
The key point of this result is Theorem 34. It should be understood as an independence property. Indeed, if we consider as a linear combination of , then this theorem states that the only way to be smaller than a linear combination is to depend on and be smaller than one of the elements of this combination.
This analogy provides a new point of view on our work: is a “linearly independent” family (uniqueness of the minimal representation) which generates all the levels through “linear combinations”.
Moreover, Theorem 34 provides a method to compare two levels, by comparing each sublevel of the minimal representation of the first one to the second one. More generally, two representations are compared in the following way.
Theorem 39.
For all , if and only if for all , there exists such that .
4 A Canonical Form for Extended Levels
We are now interested in extending the representation theorem to the whole grammar of extended levels in order to have substitution. Indeed, if (the canonical form of ), then
is not a representation. Since is stable by substitution, is a level and then has a minimal representation (which is ).
Here, we provide a way to find this representation by extending the representation to all extended levels, showing that they have representations.
Theorem 40.
For all , there exists such that .
Remark 41.
One could think that we do not have to deal with and because we know that the successor and of representations are representations. But we do not yet have this result ; we only know that it is true for representations of levels (because levels can be represented). Moreover, the development of this section will be helpful to develop a recursive canonization algorithm.
4.1 The Successor
In order to define the successor of a canonical sublevel in terms of representation, we define such that for all , and for all , . This function nearly increments a canonical sublevel but does not fulfil that objective when some elements of are not active (it will give instead of ). That’s why we take it in combination with which is .
Proposition 42.
For all ,
We immediately deduce the following result.
Proposition 43.
Let . Then,
4.2 The Impredicative Maximum
Following the equivalences and , and observations 7 and 8, we have the following equivalence.
Proposition 44.
Let . We have
| (5) |
Then, it is sufficient to show that for all , has a representation. We will then obtain a representation of by taking the elements of the ones of for all and .
Proposition 45.
Let , , and . Then,
4.3 The Sublevels
We now assume that the verification conditions of a sublevel are representations and that its variable part, in the case of a variable sublevel is a representation as well. First, we show how to transform a sublevel into a maximum of sublevels whose verifications conditions are variable.
For the sublevel to be active, all its verification conditions should be checked. Since these verification conditions are representations, it means that each of them have an active sublevel. Then, we have to consider all the combinations obtained by taking one sublevel for each verification condition of . Moreover, a sublevel is active when its verifications conditions are all checked. Then, we have to consider all the combinations of verification conditions of the verification conditions of .
Definition 46.
For all , we define
The term means that if are checked, then we can take into account the value of the sublevel that we want to simplify (which is then ). Then, we consider such terms when are a combination of verification conditions taken from each verification conditions of . This leads to sublevels whose verification conditions are variables.
Proposition 47.
Let and be a sublevel whose verifications conditions are . Then
Remark 48.
It is important to have and not only maximum of (possibly not canonical) sublevels. Indeed, we use the fact that is active if and only if all its verification conditions are checked (Remark 27), which is not always true with non-canonical sublevels. Moreover, note that the result still holds if there exists an such that , since both terms are equivalent to .
The Constant Sublevels
With Proposition 47, we have shown how to transform a constant sublevel whose verification conditions are representations into a representation. Indeed, in the constant sublevel case, for all , if (hence we obtain a representation of ). Besides, if , a representation of is .
The Variable Sublevels
However, in the variable sublevels, it is not the case; Proposition 47 only permits us to obtain variable sublevels where the verification conditions are variables. Besides, the variable part of is not necessarily a variable. That is why we have to take care of the variable part of variable sublevels.
In with and , the value of when it is activated by is the maximum of the value of with . Therefore, can be easily split into a maximum.
Proposition 49.
Let , and . Then,
So, it results in sublevels as variable part of variable sublevels, and we handle these in the next proposition.
To transform the obtained with Proposition 49 into a canonical sublevel, we note that its value can be , or , or . Then, we need a canonical sublevel with as constant part, and as variable part (we will get a constant or a variable sublevel depending on the nature of its variable part ). Besides, has to be active to obtain the value , then the verification conditions of have to be verification conditions of the targeted sublevel. However, when is not active, is not necessarily evaluated to since it can also be evaluated to when are checked. Therefore, we add a second sublevel to keep this behaviour.
Proposition 50.
Let , , and . We note
Then
Note that when , having as verification conditions is equivalent to having as verification condition which simplifies in the case where is a variable sublevel.
We can apply these two propositions to the from Definition 46. For that, we define the following.
Definition 51.
Let . For all , we define (by noting ),
and
Here, , corresponds to the case where all the verification conditions are checked and is active and corresponds to the case where are checked but is not active, hence they form . Finally, we get the following proposition.
Proposition 52.
Let , , , and let be the variable sublevel . Then,
Remark 53.
As for the constant sublevels case, we should take care to consider the sublevel only if its constant part is not . Otherwise, it is equivalent to , and it has to be removed from the max if you want a canonical form.
Besides, one could think that we should have the same consideration with the sublevel (whose constant part is ) when is a constant sublevel, but since (because it is an element of a representation), then .
After that, the case of the variable sublevel is solved. We have proved all the induction cases, which terminates the proof of Theorem 40.
General Representation Theorem
By Theorem 40 any level has a representation, and therefore a minimal one by Proposition 36.
Theorem 54.
For all , there exists a unique such that .
With Theorem 54, we have shown that is as expressive as whereas . To finish this section, we compare the expressiveness of the different shape of levels.
If is semantically, and even syntactically, a subset of , one could note that some extended levels are not equivalent to any level. In fact, even some canonical sublevels are not equivalent to any level. For instance, for all , there is no such that .
In the same way we show that some levels are not expressible with just one canonical level. For instance, for all , there is no such that .
We end up with the inclusion Hasse diagram displayed in Figure 3.
5 Conclusion
We studied the 0--successor and introduced a canonical form for its terms, which gives us an easy procedure decision for the equivalence problem. For that, we extended the grammar with new terms called sublevels, and we expressed any term as a maximum of sublevels, what we have called a representation. Since not all representations are actually terms of the algebra, a next step could be to characterize the representations that are. This could lead to an even better understanding of the 0--successor algebra.
We only provide a naive canonization algorithm since level expressions are usually quite small. However, searching for a better algorithm and a good data structures for representations could be useful.
Finally, this representation can be expressed in with rewrite rules, which is our initial motivation, and it is used in a Work In Progress translator from Lean to Dedukti showing that it can indeed be used to express in . The next step here, is to study how the expression of universe polymorphism, thanks to this level representation, behaves well together with other features such as inductive types or cumulativity.
References
- [1] Ali Assaf. A framework for defining computational higher-order logics. Theses, École polytechnique, September 2015. URL: https://pastel.archives-ouvertes.fr/tel-01235303.
- [2] Ali Assaf, Guillaume Burel, Raphaël Cauderlier, David Delahaye, Gilles Dowek, Catherine Dubois, Frédéric Gilbert, Pierre Halmagrand, Olivier Hermant, and Ronan Saillard. Dedukti : a Logical Framework based on the -Calculus Modulo Theory, 2016.
- [3] Ali Assaf, Gilles Dowek, Jean-Pierre Jouannaud, and Jiaxiang Liu. Encoding Proofs in Dedukti: the case of Coq proofs. In Proceedings Hammers for Type Theories, Proc. Higher-Order rewriting Workshop, Coimbra, Portugal, July 2016. Easy Chair. URL: https://inria.hal.science/hal-01330980.
- [4] Henk Barendregt. Introduction to generalized type systems. Journal of Functional Programming, 1(2):125–154, 1991. doi:10.1017/S0956796800020025.
- [5] Henk Barendregt, S. Abramsky, D. Gabbay, T. Maibaum, and Henk (Hendrik) Barendregt. Lambda Calculi with Types, 2000.
- [6] Stefano Berardi. Type dependence and Constructive mathematics. PhD thesis, PhD thesis, Dipartimento di Informatica, Torino, Italy, 1990.
- [7] Frédéric Blanqui. Encoding Type Universes Without Using Matching Modulo Associativity and Commutativity. In Amy P. Felty, editor, 7th International Conference on Formal Structures for Computation and Deduction (FSCD 2022), volume 228 of Leibniz International Proceedings in Informatics (LIPIcs), pages 24:1–24:14, Dagstuhl, Germany, 2022. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.FSCD.2022.24.
- [8] Frédéric Blanqui, Gilles Dowek, Émilie Grienenberger, Gabriel Hondet, and François Thiré. Some Axioms for Mathematics. In Naoki Kobayashi, editor, 6th International Conference on Formal Structures for Computation and Deduction (FSCD 2021), volume 195 of Leibniz International Proceedings in Informatics (LIPIcs), pages 20:1–20:19, Dagstuhl, Germany, 2021. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.FSCD.2021.20.
- [9] Mathieu Boespflug and Guillaume Burel. CoqInE: Translating the Calculus of Inductive Constructions into the -calculus Modulo. In "Second International Workshop on Proof Exchange for Theorem Proving, 2012.
- [10] Mathieu Boespflug, Quentin Carbonneaux, and Olivier Hermant. The -calculus Modulo as a Universal Proof Language. CEUR Workshop Proceedings, 878, June 2012. URL: https://ceur-ws.org/Vol-878/paper2.pdf.
- [11] Mario Carneiro. The Type Theory of Lean. Master’s thesis, Carnegie Mellon University, 2019. URL: https://github.com/digama0/lean-type-theory/releases.
- [12] Thierry Coquand. An Analysis of Girard’s Paradox. In Proceedings of the First Annual IEEE Symposium on Logic in Computer Science (LICS 1986), pages 227–236. IEEE Computer Society Press, June 1986.
- [13] Thierry Coquand and Gérard Huet. The calculus of constructions. Information and Computation, 76(2):95–120, 1988. doi:10.1016/0890-5401(88)90005-3.
- [14] Judicaël Courant. Explicit Universes for the Calculus of Constructions. In Victor A. Carreño, César A. Muñoz, and Sofiène Tahar, editors, Theorem Proving in Higher Order Logics, pages 115–130, Berlin, Heidelberg, 2002. Springer Berlin Heidelberg. doi:10.1007/3-540-45685-6_9.
- [15] Denis Cousineau and Gilles Dowek. Embedding Pure Type Systems in the Lambda-Pi-Calculus Modulo. In Typed Lambda Calculi and Applications, 8th International Conference, TLCA 2007, Paris, France, June 26-28, 2007, Proceedings, pages 102–117, June 2007. doi:10.1007/978-3-540-73228-0_9.
- [16] Nachum Dershowitz and Jean-Pierre Jouannaud. Rewrite Systems. In Jan van Leeuwen, editor, Handbook of Theoretical Computer Science, Volume B: Formal Models and Semantics, pages 243–320. Elsevier and MIT Press, 1990. doi:10.1016/b978-0-444-88074-1.50011-1.
- [17] Michael Färber. Safe, Fast, Concurrent Proof Checking for the Lambda-Pi Calculus modulo Rewriting. In Proceedings of the 11th ACM SIGPLAN International Conference on Certified Programs and Proofs, CPP 2022, pages 225–238, New York, NY, USA, 2022. Association for Computing Machinery. doi:10.1145/3497775.3503683.
- [18] Gaspard Férey. Higher-Order Confluence and Universe Embedding in the Logical Framework. (Confluence d’ordre supérieur et encodage d’univers dans le Logical Framework). PhD thesis, École normale supérieure Paris-Saclay, France, 2021. URL: https://lmf.cnrs.fr/downloads/Perso/Ferey-thesis.pdf.
- [19] Guillaume Genestier. Encoding Agda Programs Using Rewriting. In Zena M. Ariola, editor, 5th International Conference on Formal Structures for Computation and Deduction (FSCD 2020), volume 167 of Leibniz International Proceedings in Informatics (LIPIcs), pages 31:1–31:17, Dagstuhl, Germany, 2020. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.FSCD.2020.31.
- [20] Girard, Jean-Yves. Interprétation fonctionnelle et élimination des coupures dans l’arithmétique d’ordre supérieur, 1972.
- [21] Yoan Géran. Mathématiques inversées de Coq. Master’s thesis, ENS Paris-Saclay, September 2021. URL: https://inria.hal.science/hal-04319183.
- [22] Yoan Géran. STT GeoCoq, 2021. URL: https://github.com/Karnaj/sttfa_geocoq_euclid.
- [23] Robert Harper and Robert Pollack. Type Checking with Universes. In 2nd International Joint Conference on Theory and Practice of Software Development, TAPSOFT ’89, pages 107–136, NLD, 1991. Elsevier Science Publishers B. V. doi:10.1016/0304-3975(90)90108-T.
- [24] Gabriel Hondet and Frédéric Blanqui. The New Rewriting Engine of Dedukti (System Description). In Zena M. Ariola, editor, 5th International Conference on Formal Structures for Computation and Deduction (FSCD 2020), volume 167 of Leibniz International Proceedings in Informatics (LIPIcs), pages 35:1–35:16, Dagstuhl, Germany, 2020. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.FSCD.2020.35.
- [25] Per Martin-Löf. A theory of types, 1971. Preprint, Stockholm University.
- [26] Per Martin-Löf. An Intuitionistic Theory of Types: Predicative Part. Studies in logic and the foundations of mathematics, 80:73–118, 1975.
- [27] Per Martin-Löf. An intuitionistic theory of types. In Giovanni Sambin and Jan M. Smith, editors, Twenty-five years of constructive type theory (Venice, 1995), volume 36 of Oxford Logic Guides, pages 127–172. Oxford University Press, 1998.
- [28] Matthieu Sozeau and Nicolas Tabareau. Universe Polymorphism in Coq. In Gerwin Klein and Ruben Gamboa, editors, Interactive Theorem Proving, pages 499–514, Cham, 2014. Springer International Publishing. doi:10.1007/978-3-319-08970-6_32.
- [29] Terese. Term rewriting systems, volume 55 of Cambridge tracts in theoretical computer science. Cambridge University Press, 2003.
- [30] François Thiré. Sharing a Library between Proof Assistants: Reaching out to the HOL Family. In Frédéric Blanqui and Giselle Reis, editors, Proceedings of the 13th International Workshop on Logical Frameworks and Meta-Languages: Theory and Practice, LFMTP@FSCD 2018, Oxford, UK, 7th July 2018, volume 274 of EPTCS, pages 57–71, 2018. doi:10.4204/EPTCS.274.5.
- [31] Vladimir Voevodsky. A universe polymorphic type system, October 2014. An unfinished unreleased manuscript. URL: https://www.math.ias.edu/Voevodsky/files/files-annotated/Dropbox/Unfinished_papers/Type_systems/UPTS_current/Universe_polymorphic_type_sytem.pdf.
Appendix A Computation Algorithm
We design a recursive algorithm suited to the inductive structure of . It is presented in Algorithm 1 which already contains the code for the base cases and for which the canonical form are respectively and .
We are now interested in the code to compute the canonical form in the other cases. The algorithm follows the induction performed in Section 4 to prove Theorem 54 since it gives us a representation for the different shapes of levels. Then, it is sufficient to minimize this representation to stick to Proposition 36. For that, we write Algorithm 2 which inserts a sublevel in an independent set of canonical sublevels.
The Maximum
To compute the canonical form of , we use Algorithm 2 to insert the sublevels of into the ones of .
The Successor
Thanks to Proposition 42, for all , we know a representation of . To obtain its canonical form, we could use to add its sublevels to an initially empty set. But, we have a simpler operation.
Proposition 55.
Let and .
We implement this strategy in Algorithm 4.
The Impredicative Maximum
For all , Proposition 45 expresses as a maximum of canonical sublevels, and for all , Proposition 44 expresses as a maximum of with and (hence ). Using these two results, we design Algorithm 5.
The Constant Sublevels
The computation of the canonical form of a constant sublevel relies on Proposition 47. Here, we immediately returns if some VC is , and we do not forget the case which results in .
The Variable Sublevels
The case of the variable sublevel is very similar and relies on Proposition 52.
Theorem 56 (Correction).
Let . Then, computes , the canonical form of .
