Impredicative Encodings of (Higher) Inductive Types

02/08/2018 ∙ by Steve Awodey, et al. ∙ University of Oxford Carnegie Mellon University 0

Postulating an impredicative universe in dependent type theory allows System F style encodings of finitary inductive types, but these fail to satisfy the relevant η-equalities and consequently do not admit dependent eliminators. To recover η and dependent elimination, we present a method to construct refinements of these impredicative encodings, using ideas from homotopy type theory. We then extend our method to construct impredicative encodings of some higher inductive types, such as 1-truncation and the unit circle S1.



There are no comments yet.


page 1

page 2

page 3

page 4

This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1 Introduction

System F, also known as the ‘Girard-Reynolds polymorphic -calculus’, goes back to [Gir72] and [Rey74]. It extends the simply typed -calculus with universal quantification over types. Under the Curry-Howard correspondence [How80], it is the type-theoretic analog of second-order propositional logic.

One of the remarkable things about System F is that it allows for the encoding of types such as products, sums, natural numbers, and, more generally, finitary inductive types. These encodings are called impredicative, since in defining a specific type they quantify over the totality of all types, which in particular contains the type which is being defined. For example, the type of natural numbers is encoded in System F as

A well-known defect of such encodings, however, is that they do not satisfy the appropriate ‘-rules’, which are uniqueness principles stating that for every recursive definition there is only one function realizing it. One way to think about this failure of is that e.g. the type described by the formula is ‘too large’, in that certain models [Rum04] may contain non-standard elements which are not generated from the constructors. On the other hand, one can show using parametricity arguments [Rey83] that all the ‘named’ elements are standard. This discrepancy has led to attempts to refine the models by imposing parametricity, dinaturality [BFSS90], or realizability [CFS88] conditions.

System F-style, impredicative encodings can also be given in dependent type theory with an impredicative universe (such as the calculus of constructions [CH88]), but here a further consequence of the failure of uniqueness of the recursors is that the encoded types do not admit dependent elimination rules, which are necessary for proofs by induction, and thus indispensable for the development of mathematics in type theory.

In this article we present a new technique to restore -rules by refining impredicative encodings in a way that is related to the parametricity and dinaturality techniques mentioned above, but in contrast to them, takes place inside the type theory, so that the -equalities on the refined types become provable, rather than just admissible w.r.t. a model. To be more specific, for our refined encodings we can prove propositional versions of the required -equalities, which – as shown in [AGS12, AGS17] – are sufficient to derive the existence of the corresponding dependent eliminators.

The system of type theory that we use is similar to the calculus of constructions with a hierarchy of predicative universes (like in older versions of the Coq proof assistant), but in contrast to the calculus of constructions we assume that the lowest, impredicative universe is closed under small sums and identity types.

Some of our arguments make use of the ‘uniqueness of identity proofs’ principle, but instead of postulating it globally we exploit the notion of -types from homotopy type theory to state the relevant results for that level of the definable hierarchy of h-levels. This also allows us to explore the applicability of our techniques to higher inductive types in the later sections.

We emphasize that our main contribution is to give impredicative encodings of inductive types in dependent type theory that satisfy the relevant dependent elimination rules (along with the other rules). This seems to solve a long-standing problem, considered in [Geu01], of giving “2nd-order encodings” satisfying induction. We do this by “refining” the impredicative encodings inside the type theory using identity types. This is in contrast to interpreting the system into a model and having the universal properties hold there, which is the spirit of the “parametric polymorphism” approach set out in [Rey83], where the universal quantification of System F is “cut down” on interpretation.


Section 2 specifies the system of type theory in which our work takes place, recalls the definition of -types in homotopy type theory, and introduces the (pre-)category of small -types. We also include a brief description of how System F can be translated into our setting. In Section 3 we show how to refine the System F encodings of some non-recursive, inductive sets such as the binary sum of two sets to recover appropriate -rules, using an argument based on a type-theoretic version of the Yoneda lemma. Section 4 gives a related technique involving impredicative encodings of initial algebras in order to achieve the same result for genuinely inductive sets such as the type of natural numbers. In Section 5 we show how these techniques generalize from sets (-types) to -types, giving impredicative encodings of some of the recently introduced higher inductive types [Uni13, Ch. 6]. Specifically, we give encodings for the -truncation and the unit circle. We believe that these encodings also illuminate the ones for conventional inductive types. Indeed, our general methodology is very much informed by the HoTT point of view. Finally, Section 6 addresses issues such as limitations of our techniques, open questions, consistency and the existence of models, and future work.

2 The System of Type Theory

Although our results are not all “higher dimensional” in nature, our work is best understood in the context of homotopy type theory (HoTT); we refer to [Uni13] as our standard reference for conventions and terminology. We thus work in a system of dependent type theory with products , strong sums , (intensional) identity types , and function extensionality, as in [Uni13]. However, we make no use of the univalence axiom. We usually write simply for , as is now common. We then distinguish notationally between propositional equality and definitional equality .


We augment the hierarchy of predicative universes

assumed in [Uni13] by adding a single impredicative universe at the bottom.

This new universe is also closed under dependent sums and identity types, like the , but instead of the usual (predicative) product formation rule

it satisfies the impredicative product formation rule

which is stronger since there is no size restriction on the .

Note that in the following, when writing , we always mean the impredicative universe – in this respect we deviate from [Uni13], in that we do not use as a placeholder for an unspecified .


Recall from [Uni13, 7.1] the hierarchy of n-types (Voevodsky: “h-levels”): is called a (-1)-type, or proposition, if it satisfies ; it is a 0-type, or set, if its identity types are always propositions; and generally, it is an (n+1)-type if its identity types are always n-types. Formally, let


Note that the types , , etc., are themselves propositions [Uni13, Theorem 7.1.10], so that , , etc., are subtypes of , in the sense that the first projection from the respective -type is an embedding.

We normally suppress the coercion and treat expressions of type as if they were themselves types. Thus, in particular if is a -indexed family of types then the expression is a shorthand for

which in turn is equivalent to

Moreover, since the -types are closed under arbitrary products [Uni13, Theorem 7.1.9] (and suppressing the unpacking and repacking of dependent pairs), the rule

is admissible for all . Thus, in sum, we can view the types as impredicative subuniverses of .

We exploit the convenience of having an impredicative universe that is closed under most constructions, by working mostly inside – as opposed to the usual methodology of predicative systems, where a hierarchy of universes are used “parametrically”. Accordingly, we adopt the convention that the terms “proposition”, “set”, “n-type”, etc., refer only to types in .

The precategory of sets in

The subtype of -types in gives rise to a precategory where

for ([Uni13, Example 9.1.5]).

As pointed out in [Uni13, Section 10.1.1], this precategory is (small) complete in that it admits equalizers (defined using - and identity-types) and small products (given by type-theoretic products). Since in our setting is an impredicative universe, even admits ‘large’ products – i.e. products indexed by arbitrary types – which we make use of in what follows.

Translation of System F

There is an evident syntactic translation from System F (see Appendix A) to our system of dependent type theory. Types of the form in System F are translated to , and types of the form are translated to , where and are the translations of the System F types and . The translation of terms is equally obvious.

Similarly, we can restrict the translation by replacing above with any of the impredicative subuniverses of -types. For example, we may define the translation with:

In this sense, we can speak of System F encodings of inductive types in our system of dependent type theory.

Generally, if is a (family of) propositions, then as above is a subtype of via the first projection. Our impredicative encodings of inductive types will be subtypes of the usual System F encodings in this sense; we say that they “sharpen” or “refine” the usual encodings.

3 Basic Set Encodings

As stated in the foregoing section, the impredicative universe allows us to give ‘System F style’ encodings of certain inductive types. In this section we explain how these encodings fall short of the usual inductive types assumed in dependent type theory. We then indicate a way to remedy these shortcomings to a certain extent.

We start with the sum of two types and , whose System F encoding we translate into type theory, as explained above, by replacing the quantification over types by a dependent product over :


It is easy to see that this encoding admits injections111We adopt the convention that arguments in braces in types denote implicit arguments, meaning that we may write e.g.  instead of .


and a recursor


satisfying the definitional -equalities

for all , , , and .

However there are several problems:

  1. the recursor only allows us to define functions into types in ,

  2. the -rule

    where , doesn’t hold, even propositionally,

  3. the encoding does not admit a dependent eliminator, which would have to have the type

    and satisfy the propositional equalities

    for all appropriately typed , , , and .

We defer discussion of issue (i) in general to section 6 below. Issues (ii) and (iii) are related by the general theory developed in [AGS12, AGS17]: briefly, in the present setting the dependent elimination rule is equivalent to the -rule. In the following we give a way to restore the propositional -rule for sums of sets by restricting the product in (3.1) to and taking a suitable subtype.

3.1 Refining the encoding

Restricting the dependent product in (3.1) to the subuniverse of propositions, we obtain a well-known encoding of logical disjunction:

Observe that is a proposition, because is closed under -types.

In a similar vein it seems natural to define a sum operation


of sets , by restricting the impredicative product to types . This type also admits injections and a recursor

analogous to those for . The -rule still fails for , but as we shall see, it is now possible to carve out a subtype for which it is satisfied.

As a warm-up exercise, consider first the unary case. For there is an embedding-retraction pair

A [rr]^-e [rrd]_= && [d]^r ∏_(X:)(A→X)→X
&& A ,

where and .

Now, a term is a family of maps (switching notation for emphasis),

We can cut down the type to (one equivalent to) the image of in (3.5) by requiring that the family of maps be natural in in the sense that for all sets and all maps , the following square commutes.

X^A [r]^α_X [d]_f^A & [d]^f X
Y^A [r]_α_Y & Y

Here, is the action of the functor on .

The sharper encoding of is now:


Note that is an embedding since is a proposition for all .

Theorem 3.1 (Basic Lemma).

For any set , we have .


First, we show that factors through . For , the family consists of the evaluations , where . If , then indeed

Now let be natural in the sense expressed in (3.7), and define We claim that , which suffices since is a set. Indeed, take any and , then we have

using the naturality of in the third step. ∎


The categorically minded reader will recognize that the previous theorem is an instance of the Yoneda lemma. Indeed, (3.7) is the type of all natural transformations from the (covariant) representable functor to the identity functor , so by Yoneda we indeed have

But since we do not require this level of generality here, we will not develop the required details.

Taking inspiration from the previous theorem, we return to the preliminary encoding from (3.4), and in order to recover the -rule define a subtype by imposing a suitable naturality condition.

We start with the observation that if we already had such a type , then would be equivalent to :

Now by transporting the naturality condition of the lemma along the equivalence, we can define as a subtype of , where the defining condition can again be read as a naturality property, but now one that does not assume the existence of . Specifically, we define


If we substitute or for in , the two sides of the identity type become definitionally equal, whence we can refine the injections defined in (3.2) to get the following.

The recursor (3.3) gets replaced by

With these definitions we can now prove the following.

Theorem 3.2.

For all sets and , the encoding (3.8) of the sum , along with the structure , , and just defined, satisfy

  1. the definitional -rules

    for all , , , ,  ,

  2. the propositional -rule

    for all and .


The rules follow mechanically by unfolding definitions.

For the rule, we first prove a special case, namely


By function extensionality and -induction it is sufficient to show that for all and . Since is an embedding, this reduces to , and again by function extensionality this follows from

for , and . This is shown by

where the second equality is given by and the third one follows from and function extensionality.

For the general case, let again and . We have:

which proves the claim. ∎

We emphasize that it is crucial to the proof that the encoding (3.8) of is itself a set, so that is in the range of the variable – and of course, so that the sum of two sets is again a 0-type. This is ensured by the fact that the n-types are closed under -, -, and identity-types, and of course, the impredicativity of . In more detail, in (3.4), the ranges over sets, and thus the type is a 0-types. But then by impredicativity of , the entire type is a set. In , the identity type is a proposition, since it is over the type of functions , which is a 0-type. Thus is itself a proposition, whence is a set.

Finally, as mentioned in Section 3, the induction principle below follows from recursion together with the uniqueness of the recursor (the -rule) [AGS12, AGS17]:

with propositional equalities

for all appropriately typed , , , and .

Having done the unary and binary case of sums of sets, we might as well do the nullary one, too. The System F style encoding of the empty type in , given by

admits a recursor

and it turns out that in this case we don’t need any refinement, since we can already derive that is a proposition and that satisfies an equality – indeed, we have

and the eliminator is unique, by

for any and .

Other non-recursive 0-types

Unlike , the terminal set does not have the System F form (uniqueness of the maps fails), but instead can be encoded as a (-1)-type via the familiar


Indeed, this is easily seen to be terminal for all .

The method of adding a naturality condition can be used to encode the set-truncation of an arbitrary type . Indeed, we can simply take


as in the Basic Lemma 3.1, since is a set even when is not one.

Observe how this generalizes the well-known [Hof95, AB04] [Uni13, Exercise 3.15] propositional truncation of a type ,

We only mention that it is also possible to give correct impredicative encodings of set-quotients [Uni13, 6.10], as well as general coequalizers of sets, by related methods.

4 General inductive sets

While sums and truncations are viewed as inductive types in modern terminology, the classical idea of an inductive type involves generation from constants by repeated application of constructors. A well understood class of inductive types in type theory and category theory are W-types [ML84, pg. 43], which are generated from a family of constructors of specified – possibly infinite – arities.

Inductive types of this kind with only finitely many constructors, each of finite arity, can be encoded in System F [GTL89, Section 11.5], and translating these encodings into type theory by quantifying over the impredicative universe leads again to types which admit the correct constructors and recursors but fail to satisfy the appropriate -rules.

On the other hand, it is known from category theory that W-types can be understood as initial algebras of so called polynomial functors [MP02, GH03]. In the following we show how a categorical construction of initial algebras relying on the impredicativity of gives rise to subtypes of the System F style encodings satisfying . We elaborate this idea using as running example the inductive type of natural numbers, but the method is easily seen to generalize.

4.1 Initial algebras of endofunctors

As pointed out in Section 2, the precategory is complete in the very strong sense that it has all equalizers (constructed using - and identity-types) as well as products of families of objects indexed by arbitrary types. It is an old observation by Hyland [Hyl88, Section 3.1] that this implies the existence of initial algebras for arbitrary endofunctors, at least in the related semantical setting of certain kinds of internal categories. In the following we give explicit type-theoretic descriptions of the required limits and initial algebras by unwinding the categorical definitions.

First, observe that limits over arbitrary (pre)category-indexed diagrams can be expressed using products and equalizers, as usual. Specifically, let be a precategory: an arbitrary type of objects and a family of sets of arrows , equipped with the usual composition and unit structure, and satisfying the usual equations on these, which are propositional, because the are sets for all . A -indexed ‘diagram’ is just a functor , which can also be defined as usual, since the values are all sets. The limit of is the equalizer of the two maps

which is given explicitly by the type


together with projections

Crucially for proving the rule in Section 4.2, observe that is a set, since all the are sets, is impredicative, and is therefore a sum of a family of propositions over a set.

Now recall that, given an endofunctor , the category of -algebras has as objects pairs , and as morphisms from to the functions satisfying . Thus, type-theoretically, we have the precategory:

The forgetful functor is just the first projection, that is:

It is well-known, and easy to prove, that the precategory inherits arbitrary limits from , and these can be computed pointwise. Thus has an initial object, which is just the limit of the identity functor. Since limits in are computed pointwise, they are preserved by , which means that the initial algebra has as its underlying set the limit of the functor , which using (4.1) we can write explicitly as


Summarizing the foregoing discussion, we have the following.

Theorem 4.1.

For any functor , the category of -algebras has an initial object


  1. the set is given by the type (4.2) and is the limit of the forgetful functor , and

  2. the map is given by

    where is constructed from functoriality of and naturality of the limit cone.

We emphasize that the foregoing theorem is not merely semantically true in a certain model, but is provable in our system of type theory. In the following we use this construction of initial algebras to obtain an encoding of the type of natural numbers which refines the System F encoding.

4.2 Natural numbers

The inductive type of natural numbers is generated by the constructors

From this specification we can derive the set-level System F style encoding


admitting constructors

and a recursor

These satisfy the -rules

for , and , but not the -rule, which states that is uniquely determined in the sense that

for all (and writing in place of for propositions).

On the other hand, can be categorically characterized as the initial algebra of the functor functor given by

Here is the unit type from (3.10).

Instantiating the type in Theorem 4.1 we get the type

for the underlying set of the initial algebra, and it turns out that the index type of the sum is equivalent to :

We compose the predicate with this equivalence to get a description of the initial algebra directly as a subtype of the System F encoding:


Observe that the triples and in the definition of can be coerced into -algebras and . Leaving this coercion implicit (as we shall do from now on), can be read as saying that we have

for every -algebra morphism

It is easy to see that the predicate satisfies

whence the System F constructors and can be restricted to operations

about which it is sufficient to know that they behave like and on the first components of dependent pairs. The recursor also restricts to in a straightforward manner

and we have the following theorem.

Theorem 4.2.

The encodings of , , and given above satisfy

  1. definitional -rules saying that