Indexed Induction-Recursion

Peter Dybjer^{∗}and Anton Setzer^{†}

September 24, 2001

Abstract

We give two finite axiomatizations of indexed inductive-recursive definitions in intuitionistic type theory. They extend our previous finite axiomatizations of inductive-recursive definitions of sets to indexed families of sets and encompass virtually all definitions of sets which have been used in intuitionistic type theory. The more restricted of the two axiomatization arises naturally by considering indexed inductive-recursive definitions as initial algebras in slice categories, whereas the other admits a more general and convenient form of an introduction rule.

The class of indexed inductive-recursive definitions properly contains the class of indexed inductive definitions (so called “inductive families”). Such definitions are ubiquitous when using intuitionistic type theory for formalizing mathematics and program correctness. A side effect of the present paper is to get compact finite axiomatizations of indexed inductive definitions in intuitionistic type theory as special cases.

Proper indexed inductive-recursive definitions (those which do not correspond to indexed inductive definitions) are useful in intuitionistic metamathematics, and as an example we formalize Tait-style computability predicates for dependent types. We also show that Palmgren’s prooftheoretically strong construction of higher-order universes is an example of a proper indexed inductive-recursive definition. A third interesting example is provided by Bove and Capretta’s definition of termination predicates for functions defined by nested recursion.

Our axiomatizations form a powerful foundation for generic programming with dependent types by introducing a type of codes for indexed inductive-recursive definitions and making it possible to define generic functions by recursion on this type.

Keywords: Dependent type theory, Martin-Löf Type Theory, inductive definitions, inductive-recursive definitions, inductive families, initial algebras, normalization proofs, generic programming.

∗Department of Mathematics and Computing Science, Chalmers University of Technology.

Email: peterd@cs.chalmers.se, Fax: +46 31 165655.

†Supported by Nuffield Foundation, grant No. NAL/00303/G; Department of Computer Science, University of Wales Swansea, Singleton Park, Swansea SA2 8PP, UK. Email:

a.g.setzer@swan.ac.uk, Fax: +44 1792 295651.

1 Introduction

In [8], the first author introduced the concept of inductive-recursive definitions, an extension of ordinary inductive definitions. By inductive-recursive definitions one can inductively define a set U while simultaneousely recursively defining a function T : U → D, where D is an arbitrary type.

The prime example of an inductive-recursive definition is a universe, that is, a set U of codes for sets together with a decoding function T : U → set, which assigns to a code in U the set it denotes. As an example consider the constructor Σ̂ introducing codes for the Σ-type. We have Σ̂ : (a : U, b : T (a) → U) → U (the reader not familiar with this notation, which will be explained in Sec. 2, might temporarily substitute Πa : U.Πb : (T (a) → U).U for the type of Σ̂). Note that the second argument b of Σ̂(a, b) refers to T (a). This makes sense since before Σ̂(a, b) is introduced, a : U has to be established, and when a : U is established, one can recursively define T (a). We then define recursively T (Σ̂(a, b)) = Σ(T (a), (x)T (b(x))) (or in more traditional notation T (Σ̂(a, b)) = Σx : T (a).T (b(x))). This is possible, since T (a) and T (b(x)) are known before we introduce Σ̂(a, b). Here we see the novelty of inductiverecursive definitions relative to inductive definitions: an introduction rule for U may refer to the function T which is simultaneously defined. Note that T even can appear negatively in the type of a constructor, as in the type of Σ̂. However, the constructor refers only strictly positively to elements of the inductively defined set U.

In the special case where T : U → 1, where 1 is the type with only one element, so that T does not contain any information, inductive-recursive definitions specialize to inductive definitions. For a detailed explanation of the concept of inductive-recursive definitions, the reader is advised to read the aforementioned article [8].

In [8] the case of indexed inductive-recursive definitions (IIR) is also considered. In an IIR one defines a family of sets U(i), indexed over i : I, inductively, while simultaneously recursively defining a family of functions T (i) : U(i) → D[i] for some collection of types D[i] (i : I). (We have to write D[i], the result of substituting i for a fixed variable in D here, since D[i] is a type and we cannot write D : I → type.) Again constructors of U(i) can refer to T (j) applied to elements of U(j).

In [9] and [10] we presented closed axiomatizations of the theory of nonindexed inductive-recursive definitions. It is the objective of this article to extend this to indexed inductive-recursive definitions. We will see that the resulting rules are not much more complicated than the rules for the non-indexed case. We will look at two alternatives: In restricted IIR (introduced by T. Coquand for use in the Half and Agda [4] systems) we can determine for each index i the set of arguments of the constructors introducing elements of the set U_{i}. In unrestricted IIR [8], for a constructor C with arguments a⃗, the index i s.t. C(a⃗) : U_{i} depends on the arguments a⃗ of C.

Indexed inductive definitions (IID) subsume inductively defined relations, such as the identity relation understood as the least reflexive relation. The identity relation was indeed the only example of an IID in the early versions of Martin-Löf type theory [13]. Theoretically, this is not very limiting since one can define many other families of sets (predicates) using the identity together with the other set formers of type theory. But from a more practical point of view it became desirable to extend Martin-Löf type theory with a general notion of inductive definition of an indexed family of sets (often called “inductive family” for short) [6, 7]. Such a general mechanism is also a key part of the Calculus of Inductive Constructions [21], the impredicative type theory underlying the Coq system. Indexed inductive definitions are ubiquitous in formalizations carried out in the different proof systems for Martin-Löf type theory and the Calculus of Inductive Constructions.

No proper IIR were part of the original versions of Martin-Löf type theory. However, when proving normalization for an early version of this theory, Martin-Löf made use of an informal construction on the metalevel which has an implicit indexed inductive-recursive character.

Plan. In Section 2 we introduce the logical framework of dependent types which is the basis for our theories of IIR. This section also explains the notation used in the paper. In Section 3 we begin by reviewing a few examples of IID, such as finitely branching trees, the even and odd numbers, the accessible part of a relation, the identity set, and context free grammars. Then we give some examples of proper IIR: Martin-Löf’s computability predicates for dependent types, Palmgren’s higher order universes, and Bove and Capretta’s analysis of the termination of nested recursive definitions of functional programs. We also introduce the restricted form of an inductive-recursive definition which has an easier syntax and is easier to implement. In Section 4 we first explain how the restricted version of indexed inductive-recursive definitions arises from the existence of initial algebras of strictly positive endofunctors on slice categories over the category of indexed families of types. Then we show how to formalize the general notion of an indexed inductive-recursive definition and give a uniform theory for both the general and the restricted form by giving a type of codes for IIR and then derive the formation, introduction, elimination and equality rules for a particular code. In Section 5 we show how to instantiate the general theory to some of the examples given in Section 3.

2 The Logical Framework

Before giving the rules for IIR we need to introduce the basic Logical Framework of dependent types. This is essentially Martin-Löf’s Logical Framework [18] extended with rules for the types 0, 1, and 2. A more detailed presentation can be found in [10].

The Logcial Framework has the following forms of judgements: Γ context, and A : type, A = B : type, a : A, a = b : A, depending on contexts Γ (written as Γ ⇒ A : type, etc.). We have set : type and if A : set, then A : type. The collection of types is closed under the formation of dependent function types written as (x : A) → B (which is often written as Πx : A.B in the literature – we prefer to reserve Πx : A.B for the inductive-recursively defined set with constructor λ : ((x : A) → B) → (Πx : A.B)). The elements of (x : A) → B are denoted by (x : A)a (abstraction of x in a; this is often denoted by λx : A.a in the literature) and application is written in the form a(b). We have β− and η-rules. Types are also closed under the formation of dependent products written as (x : A)×B (often denoted by Σx : A.B which is here reserved for the inductively defined set with introduction rule p : ((x : A) × B) → (Σx : A.B)). The elements of (x : A) × B are denoted by ⟨a, b⟩, the projection functions by π_{0} and π_{1} and again we have β and η-rule (surjective pairing). There is the type 1, with unique element ⋆ : 1 and η-rule expressing that, if a : 1, then a = ⋆ : 1. Further we have the empty type 0 with elimination rule Efq (ex falsum quodlibet).

Moreover, we include in our logical framework the type 2 with two elements ⋆_{0} : 2 and ⋆_{1} : 2, ordinary elimination rule C_{2} : (a : 2, A[⋆_{0}], A[⋆_{1}]) → A(a) (where x : 2 ⇒ A[x] : type) and the strong elimination rule

\frac{a : 2  A : type  B : type}{C_{2}^{type}(a, A, B) : type}

with equality rules

C_{2}^{type}(⋆_{0}, A, B) = A , C_{2}^{type}(⋆_{1}, A, B) = B .

It is necessary to have the strong elimination rule, since we want to inductively define indexed families of sets U : I → set and functions T : (i : I) → U(i) → D[i] where D[i] depends non-trivially on i, as in the definition of Palmgren’s higher-order universe (where for instance D[0] = set, D[1] = Fam(set) → Fam(set), see 3.2 for more explanation).

We will also add a level between set and type, which we call stype for small types: stype : type. (The reason for the need for stype is discussed in [8].) If a : set then a : stype. Moreover, stype is also closed under dependent function types, dependent products and includes 0, 1, 2. However, set itself will not be in stype. The logical framework does not have any rules for introducing elements of set, they will be introduced by IIR later and set will therefore consist exactly of the sets introduced by IIR.

We also use some abbreviations, such as omitting the type in an abstraction, that is, writing (x)a instead of (x : A)a, and writing repeated application as a(b_{1}, …, b_{n}) instead of a(b_{1}) ⋯ (b_{n}) and repeated abstraction as (x_{1} : A_{1}, …, x_{n} : A_{n})a instead of (x_{1} : A_{1}) ⋯ (x_{n} : A_{n})a.

In the following we will sometimes refer to a type depending on a variable x. We want to use the notation D[t] for D[x := t] for some fixed variable x and D for (x)D[x]. Note that we can’t simply introduce D : I → type, since this goes beyond the logical framework. Instead we introduce the notion of an abstracted expression, which is an expression together with one or several designated free variables. For an abstracted expression E, E[t_{1}, …, t_{n}] means the substitution of the variables by t_{1}, …, t_{n}. If we take for D above an abstracted expression of the form (x)E, then D[t] denotes D[x := t] and we can write D as parameter for (x)E. More formally:

Definition 1 (a) An n-times abstracted expression is an expression (x_{1}, …, x_{n})E where x_{1}, …, x_{n} are distinct variables and E an expression of the language of type theory. An abstracted expression is a 1-times abstracted expression.

(b) ((x_{1}, …, x_{n})E)[t_{1}, …, t_{n}] := E[x_{1} := t_{1}, …, x_{n} := t_{n}].

(c) Whenever we write s[a_{1}, …, a_{n}], s is to be understood as an n-times abstracted expression.

(d) If U : A → B, we identify U with the abstracted expression (a)U(a).

3 Some Examples

3.1 Indexed Inductive Definitions

Trees and forests. Many IID occur as the simultaneous inductive definition of finitely many sets, each of which has a different name. One example is the set of well-founded trees Tree with finite branching degrees, which is defined together with the set Forest of finite lists of such trees. The constructors are:

tree : Forest → Tree ,
nil : Forest ,
cons : Tree → Forest → Forest .

If we replace Tree by Tree′(⋆_{0}) and Forest by Tree′(⋆_{1}), where x : 2 ⇒ Tree′(x) : set, we obtain an IID with index set 2. Since for every index we know the set of constructors introducing elements of it in advance, we have an example of restricted IID.

The even number predicate. Another simple example of an IID is the predicate Even : N → set. This is inductively generated by the two rules

C_{0} : Even(0) ,
C_{1} : (n : N) → Even(n) → Even(S(S(n))) .

In this form we have unrestricted IID, since in this form the constructors introducing an element of Even(n) is not given in advance.

The accessible part of a relation. Let I be a set and <: I → I → set be a binary relation on it. We define the accessible part (the largest well-founded initial segment) of < as a predicate Acc : I → set by a generalized indexed inductive definition with one introduction rule:

acc : (i : I) → ((x : I) → (x < i) → Acc(x)) → Acc(i) .

Note that acc introduces elements of Acc(i) while referring to possibly infinitely many elements of the sets Acc(x) (for each x : I and each proof of x < i). Acc is an example of a restricted IID.

The identity relation. The only example of an IID in Martin-Löf’s original formulation of type theory, which is not an ordinary inductive-recursive definition is the identity type (“identity type” is only used for historic reason – a more appropriate name would be “identity set”). Assume A : set. The identity on A is given as the least reflexive relation on A × A, and is the intensional equality type on A. We have as formation rule a : A, b : A ⇒ I(A, a, b) : set. The introduction rule expresses that it is reflexive:

r : (a : A) → I(A, a, a) .

The elimination rule inverts the introduction rule. Assume we have a type which is a reflexive relation on A × A and a subrelation of the identity type on A. So assume a : A, b : A, p : I(A, a, b) ⇒ C[a, b, p] : type and for every a : A we have s[a] : C[a, a, r(a)] (so s is the step-function corresponding to the constructor r). Then for every a, b : A and p : I(A, a, b) we have J(a, b, p, (x)s[x]) : C[a, b, p]. The equality rule now uses the step function in case an element is introduced by a constructor: J(a, a, r(a), (x)s[x]) = s[a].

If we write I′_{A}(⟨a, b⟩) instead of I(A, a, b), we obtain for every A : set an unrestricted IID I′_{A} with index set A × A.

Context free grammars. IID occur very frequently in applications in computer science. For example a context free grammars over a finite alphabet Σ and a finite set of nonterminals NT can be seen as an NT×Σ^{∗}-indexed inductive definition L, where each production corresponds to an introduction rule.

As an example consider the context free grammar with Σ = {a, b}, NT = {A, B} and productions A ⟶ a, A ⟶ BB, B ⟶ AA, B ⟶ b. This corresponds to an inductive definition of an indexed family L, where L(A, α) is the set of derivation trees of the string α from the start symbol A. So α is in the language generated by the grammar with start symbol A iff L(A, α) is inhabited. L has one constructor for each production: C_{0} : L(A, a), C_{1} : L(B, α) → L(B, β) → L(A, αβ), C_{2} : L(A, α) → L(A, β) → L(B, αβ), C_{3} : L(B, b).

Alternatively, we can inductively define an NT-indexed set D of “abstract syntax trees” for the grammar, and then recursively define the string d(A, p) (“concrete syntax”) corresponding to the abstract syntax tree p : D(A). In the example given before we get C_{0} : D(A), C_{1} : D(B) → D(B) → D(A), C_{2} : D(A) → D(A) → D(B), C_{3} : D(B). Further d(A, C_{0}) = a, d(A, C_{1}(p, q)) = d(B, p) ∗ d(B, q), d(B, C_{2}(p, q)) = d(A, p) ∗ d(B, q), d(B, C_{3}) = b.

More examples. There are many more examples (eg. the set of formulas derivable in a formal system, computation rules of the operational semantics of a programming language) of similar nature. If Formula is a set of formulas of the formal system, then to be a theorem is given by a Formula-indexed inductive definition Theorem : Formula → set, where the axioms and inference rules correspond to introduction rules. An element d : Theorem(ϕ) is a notation for a derivation (or proof tree) with conclusion ϕ. Yet more examples are provided by the computation rules in the definition of the operational semantics of a programming language.

Proofs by induction on the structure of an indexed inductive definition of these kinds are often called proofs by “rule induction”. Thus the general form of rule induction is captured by the elimination rule for unrestricted IIR which we will give later.

3.2 Indexed Inductive-Recursive Definitions

Martin-Löf’s computability predicates for dependent types. We shall now turn to proper IIR. As a first example we shall formalize the Tait-style computability predicates for dependent types introduced by Martin-Löf [17]. This example was crucial for the historical development of IIR, since it may be viewed as an early occurrence of the informal notion of an IIR. In [17] Martin-Löf presents an early version of his intuitionistic type theory and proves a normalization theorem using such Tait-style computability predicates. He works in an informal intuitionistic metalanguage but gives no explicit justification for the meaningfulness of these computability predicates. (Later Aczel [1] has shown how to model a similar construction in classical set theory.) Since the metalanguage is informal the inductive-recursive nature of this definition is implicit. One of the objectives of the current work is indeed to formalize an extension of Martin-Löf type theory where the inductive-recursive nature of this and other definitions is formalized. In this way we hope to help clarify the reason why it is an acceptable notion from the point of view of intuitionistic meaning explanations in the sense of Martin-Löf [14, 16, 15].

First recall that for the case of the simply typed lambda calculus the Taitcomputability predicates ϕ_{A} are predicates on terms of type A which are defined by recursion on the structure of A. We read ϕ_{A}(a) as “a is a computable term of type A”. To match Martin-Löf’s definition [17] we consider here a version where the clause for function types is

• If ϕ_{B}(b[a]) for all closed terms a such that ϕ_{A}(a) then ϕ_{A→B}(λx.b[x]).

(Here b[x] denotes an expression with a possible occurrence of the free variable x and b[a] denotes the expression which is obtained by substituting x by a in b[x].)

How can we generalize this to dependent types? First we must assume that we have introduced the syntax of expressions for dependent types including Πtypes, with lambda abstraction and application. Now we cannot define ϕ_{A} for all (type) expressions A but only for those which are “computable types”. The definition of ϕ_{A} has several clauses, such as the following one for Π [17, p. 161]:

4.1.1.2. Suppose that ϕ_{A} has been defined and that ϕ_{B[a]} has been defined for all closed terms a of type A such that ϕ_{A}(a). We then define ϕ_{Πx:A.B[x]} by the following three clauses.

4.1.1.2.1. If λx.b[x] is a closed term of type Πx : A.B[x] and ϕ_{B[a]}(b[a]) for all closed terms a of type A such that ϕ_{A}(a), then ϕ_{Πx:A.B[x]}(λx.b[x]). 4.1.1.2.2…. 4.1.1.2.3….

(We omit the cases 4.1.1.2.2 and 4.1.1.2.3, which express closure under reduction, since they are not relevant for the present discussion. Note also that the complete definition of the computability predicate also has one case for each of the other type formers of type theory.)

We also note that Martin-Löf does not use the term “A is a computable type” but only states “that ϕ_{A} has been defined”. We can understand Martin-Löf’s definition as an indexed inductive-recursive definition by introducing a predicate Φ on expressions, where Φ(A) stands for “ϕ_{A} is defined” or “A is a computable type”. Moreover, we add a second argument to ϕ so that ϕ_{A}(p, a) means that “a is a computable term of the computable type A, where p is a proof that A is computable. Now we observe that we define Φ inductively while we simultaneously recursively define ϕ.

It would be possible to formalize Martin-Löf’s definition verbatim, but for simplicity we shall follow a slightly different version due to C. Coquand [5]. Assume that we have inductively defined the set Exp of expressions and have an operation Apl : Exp → Exp → Exp for the application of one expression to another. Apl is a constructor of Exp, and there will be additional reduction rules for expressions, like reduction of β-redexes. We will write in the following A b for Apl(A, b).

Now define an Exp-indexed IIR

Ψ : Exp → set ,
ψ : (A : Exp) → Ψ(A) → Exp → set .

So the index set is Exp, Ψ plays the rôle of U, ψ the rôle of T : (a : U) → D[a], where D[a] = Exp → set for a : Exp. Note that ψ depends negatively on Ψ, so this is not a simultaneous inductive definition. The introduction rule for Ψ (corresponding to Martin-Löf’s 4.1.1.2) is:

π : (A : Exp) → (p : Ψ(A)) → (B : Exp) →
(q : (a : Exp) → ψ(A, p, a) → Ψ(B a)) →
Ψ(Π(A, B)) .

Note that q refers to ψ(A, p, a) which is short notation for ψ(A, p)(a), where ψ(A, p) is the result of the recursively defined function for the second argument p. The corresponding equality rule is

ψ(Π(A, B), π(A, p, B, q), b) = ∀a : Exp.∀x : ψ(A, p, a).ψ(B a, q(a, x), b a) .

Again, the reader should be aware that we have presented only one crucial case of the complete IIR in [5]. For instance there are clauses corresponding to closure under reductions.

Palmgren’s higher-order universes [20]. This construction generalizes Palmgren’s super universe [19], that is, a universe which for any family of sets in it contains a universe containing this family.

It is outside the scope of this paper to give a full explanation of higherorder universes, and the interested reader is referred to Palmgren [20]. They are included here as an example of a proof-theoretically strong construction which is subsumed by our theory of IIR: they are conjectured to reach (without elimination rules into arbitrary types) the strength of Kripke-Platek set theory with one recursive Mahlo ordinal. They also provide an example where we have decoding functions T_{k} : U_{k} → D[k] with D[k] = OP^{k}(set) which depend non-trivially on k and, for k > 0, is a higher type which goes beyond set.

The higher-order universes of level n is a family of universes U_{k}, T_{k}, indexed by k < n, where U_{k} is a set of codes for operators on families of sets of level k, and T_{k} : U_{k} → OP^{k}(set) is the decoding function. The set OP^{k}(set) of such operators is defined by introducing more generally for A : type

Fam(A) := (X : set) × (X → A) ,  Op(A) := Fam(A) → Fam(A) ,
Op^{n}(A) := \underbrace{Op(⋯ (Op}_{n times}(A)) ⋯) ,

Let

n : N,  A_{k} : set ,  B_{k} : A_{k} → Op^{k}(set) (k = 0, …, n) .

In the following all sets and constructors are parameterized with respect to n, A_{k}, B_{k}, but for simplicity we omit those parameters.

U_{0}, T_{0} have the standard closure properties of a universe. Additionally we have for k = 0, …, n the two constructors (with decodings)

Â_{k} : U_{0} ,  T_{0}(Â_{k}) = A_{k} ,
B̂_{k} : A_{k} → U_{k} , T_{k}(B̂_{k}(a)) = B_{k}(a) .

Furthermore, under the additional assumptions i ∈ {0, …, n − 1}, f : U_{i+1}, we have two more constructors (with decodings)

ap_{i}^{0}(f) : (u : U_{0}, T_{0}(u) → U_{i}) → U_{0} ,
T_{0}(ap_{i}^{0}(f, u, v)) = π_{0}(T_{i+1}(f)(⟨T_{0}(u), T_{i} ∘ v⟩)) ,
ap_{i}^{1}(f) : (u : U_{0}, v : T_{0}(u) → U_{i}, π_{0}(T_{i+1}(f)(⟨T_{0}(u), T_{i} ∘ v⟩))) → U_{i} ,
T_{i}(ap_{i}^{1}(f, u, v, a)) = π_{1}(T_{i+1}(f)(⟨T_{0}(u), T_{i} ∘ v⟩))(a) .

If we let I := {0, …, n} (which more formally should be replaced by N_{n+1}), then we observe that we have introduced U : I → set together with T : (i : I, U(i)) → D_{i} where D_{i} = Op^{i}(set). For each i : I we can determine a collection of constructors, each of which refers strictly positively to U and (positively and negatively) to T applied to the arguments of U referred to.

Bove and Capretta’s analysis of the termination of nested recursive definitions of functional programs. In a recent paper [3], Bove and Capretta use indexed inductive-recursive definitions in their analysis of the termination of functions defined by nested general recursion. Given such a function f the idea is to simultaneously define a predicate D(x) expressing that f(x) terminates, and a function f′(x, p) which returns the same value as f(x) but has as second argument a proof p : D(x) that f(x) terminates.

Assume for instance the rewrite rules f(0) ⟶ f(f(1)), f(1) ⟶ 2, f(2) ⟶ f(1) on the domain {0, 1, 2}. We now inductive-recursively define the termination predicate D for for f. We get one constructor for each rewrite rule: C_{0} : (p : D(1), q : D(f′(1, p))) → D(0), C_{1} : D(1), C_{2} : (p : D(1)) → D(2). Furthermore, the equality rules for f′ are f′(0, C_{0}(p, q)) = f′(f′(1, p), q), f′(1, C_{1}) = 2, f′(2, C_{2}(p)) = f′(1, p). This is a proper IIR, since in the type of C_{0} the second argument depends on f′(1, p), where p is the first argument.

3.3 Restricted Indexed Inductive-Recursive Definitions

There are reasons for focussing attention on IIR where we can determine for every index i the set of constructors introducing elements of U_{i}. More precisely this means that if C is a constructor of the IIR, and we write its type in uncurried form, then its type is of the form ((i : I) × A(i)) → U_{i}, so the first argument determines the index i. An example which satisfies this restriction is the accessible part of a relation.

We can also determine the set of constructors for U_{i}, where a constructor has type B → U_{i} and i does not depend on B, provided the equality on I is decidable. In this case the type of C can be replaced by (i′ : I) → C_{2}^{type}(i =_{dec} i′, B, 0) → U_{i′}, where =_{dec} is the decidable equality on I, with result in 2). In this way for example finitely branching trees and forests can be seen to be captured by restricted IIR.

In the implementation of the Half proof system of type theory Thierry Coquand enforced this restriction, and it was kept in the Agda system [4], the successor of Half. One reason is that both the introduction and elimination rules can be specified more simply: for introducing an IIR, the constructors C_{i} of U_{j} are just listed in the form data{C_{1}(a⃗_{1}) | ⋯ | C_{n}(a⃗_{n})}, and one doesn’t have to include the index j in the arguments of a⃗_{i} of C_{i}(a⃗_{i}) – this simplifies the syntax of the system substantially. If one wants to define g(x) for x : U_{i}, one can write it in the form

case x of \begin{cases}C_{1}(a⃗_{1}) & → & f_{1}(a⃗_{n}); \\ ⋯ \\ C_{n}(a⃗_{n}) & → & f_{n}(a⃗); \} \end{cases}

For defining unrestricted IIR, a more complicated syntax has to be used, especially the elimination rules have to make use of a more general form of pattern matching. See for instance the proof assistant Alf ([12], [2]), where unrestricted IIR can be implemented.

Another reason for this restriction is that it is easier to construct mathematical models: below we will see that restricted IIR can be modelled as initial algebras in an I-indexed slice category. Furthermore, domain-theoretic models of restricted IIR can be given more easily. That complications arise when modelling unrestricted IIR is one of the reasons why many believe that a fully satisfactory understanding of the identity type has not yet been achieved.

It is often possible to replace general IIR by restricted IIR, especially if we have a decidable equality on the index set. For example, we can define a function by recursion which tests equality of natural numbers. Using this equality we can write the introduction rules for the even number predicate in an alternative way: Even(n) holds iff n = 0 or there exists m such that n = S(S(m)) and Even(m). That is, we have two constructors: C_{0}(n) : (n = 0) → Even(n), and C_{1}(n) : (m : N) × (n = S(S(m))) × (Even(m)) → (Even(n)). (It is also worth mentioning here that alternatively, we can directly define the even numbers by primitive recursion on the natural numbers: Even(0) is true and Even(S(n)) is the negation of Even(n), using the two element universe 2 with decoding T : 2 → set.)

However, it is not always possible to transform a definition into the restricted form. The prime example is that of the identity relation. In [11] we however show that if we have extensional equality, we can simulate general IIR by restricted IIR. The definitions are quite complicated though, and the resulting programs may be computationally inefficient.

4 Formalizing the Theory of Indexed Inductive-Recursive Definitions

4.1 The Category of Indexed Families of Types

As for the non-indexed case, we shall derive a formalization of IIR by modeling them as initial algebra constructions in slice categories. Let R be a set of rules for the language of type theory (where each rule is given by a finite set of judgements as premisses and one judgement as conclusion) which includes the logical framework used in this article and an equality. For such R let TT(R) be the resulting type theory. The category Type(R) is the category, the objects of which are A s.t. TT(R) proves A : type, and the morphisms from A to B of which are terms f s.t. TT(R) proves f : A → B. Objects A, A′ such that TT(R) proves A = A′ : type and functions f, f′ s.t. TT(R) proves f = f′ : B → C are identified. In order to model I-indexed inductive-recursive definitions, where I is an arbitrary stype, we will use the category Fam(R, I) of I-indexed families of types. An object of Fam(R, I) is an I-indexed family of types, that is, an abstracted expression A for which we can prove i : I ⇒ A[i] : type in TT(R). An arrow from A to B is a I-indexed function, that is, an abstracted expression f for which we can prove (in TT(R)) i : I ⇒ f[i] : A[i] → B[i]. Again we identify A, A′ s.t. we can prove i : I ⇒ A[i] = A′[i] : type and f, f′ s.t. we can can prove i : I ⇒ f[i] = f′[i] : B[i] → C[i]. We will usually omit the argument R in Fam(R, I).

If C is a category, D an object of it, then C/D is the slice category with objects pairs (A, f) where A is an object of C and f an arrow A → D, and as morphisms from (A, f) to (B, g) morphisms h : A → B s.t. g ∘ h = f. Note that we write pairs with round brackets on this level. This is different from the notation ⟨a, b⟩ for the pair of a and b in the logical framework.

General assumption 4.1.1 In the following we assume in all rules I : stype, i : I ⇒ D[i] : type (D an abstracted expression).

4.2 Coding Several Constructors by One

We can code several constructors of an IIR into one as follows: let J be a finite index set for all constructors and A_{j} be the type of the jth constructor. Then replace all constructors by one constructor of type (j : J) → A_{j}, which is definable using case distinction on 2. In case of restricted IIR we can obtain one constructor in restricted form with type (i : I, j : J) → A_{ij} → C_{i}, if the type of the jth constructor is i : I → A_{ij} → C_{i}.

In this way it will suffice to consider only IIR with one constructor in the sequel.

4.3 Restricted IIR as Initial Algebras in Slice Categories

Assume we have a restricted IIR with one constructor

intro : (i : I) → ℍ^{U}(U, T, i) → U(i)

(with all arguments of intro except i in uncurried form), which introduces U : I → set and T : (i : I, U(i)) → D[i]. Here ℍ^{U} : (U : I → set, T : (i : I, U(i)) → D[i], I) → stype with no free occurrences of U, T and i. Let further the equality rule for T be

T(i, intro(i, a)) = ℍ^{T}(U, T, i, a) ,

where ℍ^{T} : (U : I → set, T : (i : I, U(i)) → D[i], i : I, ℍ^{U}(U, T, i)) → D[i] with no free occurrences of U, T, i or a. Now one observes that the introduction rule and equality rule are captured as an I-indexed family of algebras for ℍ in Fam(I)/D, where ℍ(U, T) = (ℍ^{U}(U, T), ℍ^{T}(U, T)):^{1}

1To be pedantic: one has to replace ℍ(U, T), ℍ^{U}(U, T), ℍ^{T}(U, T) by uncurried variants ℍ′((U, T)), ℍ′^{U}((U, T)), ℍ′^{T}((U, T))

ℍ^{𝕌}(U, T, i) \overline{\begin{matrix}intro(i) \\  \end{matrix}}U(i)

[figure: ℍ^{T}(U, T, i)]

D[i] \begin{matrix}T(i) \\  \end{matrix}

Note that the situation generalizes the situation for non-indexed inductionrecursion [10], where the rules for U and T are captured as an algebra of an appropriate endofunctor 𝔽 on the slice category Type/D.

If D[i] = 1 and therefore ℍ(U, T, i) does not depend on T, we have the important special case of a restricted indexed inductive definition. We show the example of the accessible part of a relation:

(x : I) → (x < i) → Acc(x) \overline{\begin{matrix}acc(i) \\  \end{matrix}}Acc(i)

[figure: !]

1{! \atop }

i.e. ℍ^{U}(U, T, i) = (x : I) → (x < i) → U(x).

4.4 A Diagram for General IIR

If a particular IIR does not have the restricted form then we do not prima facie know the set of constructors for a particular expression. On the other hand, given an argument to the constructor, we can determine the index of the constructed element.

To capture this situation the categorical representation must be changed. Depending on U : I → set and T : (i : I, U(i)) → D[i] we have an stype 𝔾^{U}(U, T) of the arguments of the constructor intro, and, depending on a : 𝔾^{U}(U, T), we have 𝔾^{I}(U, T, a) : I, which provides the i s.t. intro(a) : U_{i}, and 𝔾^{T}(U, T, a) : D[𝔾^{I}(U, T, a)], which determines the value of T(i, intro(a)). The diagram is:

(a : 𝔾^{U}(U, T)) \overline{{intro \atop }} U(𝔾^{I}(U, T, a))

[figure: 𝔾^{T}(U, T, a)]

D[𝔾^{I}(U, T, a)] \begin{matrix}T (𝔾^{I}(U, T, a)) \\  \end{matrix}

As a first simple instance we look at the identity relation on A. It has index set I := A × A, D[i] = 1, and 𝔾^{U}(U, T) = A, 𝔾^{I}(U, T, a) = ⟨a, a⟩, and U(⟨a, a⟩) = I_{A}(a, a):

(a : A) \overline{r} I(a, a)

[figure: !]

1{! \atop }

As a second illustration we show how to obtain the rules for computability predicates for dependent types. (As in Section 3 we only give a definition containing one case, but the complete definition [5] can be obtained by expanding the definition corresponding to the additional constructors).

𝔾^{U}(Ψ, ψ) = (A : Exp) × (p : Ψ(A)) ×

(B : Exp) × ((a : Exp) → ψ(A, p, a) → ψ(B a)) ,

𝔾^{I}(Ψ, ψ, ⟨A, p, B, q⟩) = Π(A, B) ,
𝔾^{T}(Ψ, ψ, ⟨A, p, B, q⟩) = (b)∀a : Exp.∀x : ψ(A, p, a).ψ(B a, q(a, x), b a) .

Note that in the general case we no longer have an endofunctor Fam(I)/D → Fam(I)/D.

4.5 A Uniform Theory for Restricted and General IIR

If we look at the functors arising in general IIR we observe that we have obtained one stype 𝔾^{U}(U, T) and two functions

𝔾^{I}(U, T) : 𝔾^{U}(U, T) → I ,
𝔾^{T}(U, T) : (a : 𝔾^{U}(U, T)) → D[𝔾^{I}(U, T, a)] .

where (U, T) is an element of Fam(I)/D, 𝔾^{IT}(U, T) := ⟨𝔾^{I}(U, T), 𝔾^{T}(U, T)⟩ an element of E := (i : I) × D[i], so (𝔾^{U}(U, T), 𝔾^{IT}(U, T)) is an element of Type/E. This can be expanded to a functor

𝔾 : Fam(I)/D → Type/E .

In restricted IIR we have for i : I

ℍ^{U}(U, T, i) : stype ,
ℍ^{T}(U, T, i) : (a : ℍ^{U}(U, T, i)) → D[i] ,

which can be combined to an endofunctor (with obvious arrow part and extension to U s.t. i : I ⇒ U[i] : type)

ℍ : Fam(I)/D → Fam(I)/D .

Consider the functor π_{i} : Fam(I)/D → Type/D[i] with object part π_{i}(U, T) := (U[i], T [i]) and obvious arrow part.

Every element (U, T) : Fam(I)/D is uniquely determined by its projections π_{i}(U, T). One also notes that for every sequence of functors ℍ_{i} : Fam(I)/D → Type/D[i] there exists a unique functor ℍ : Fam(I)/D → Fam(I)/D s.t. π_{i} ∘ ℍ = ℍ_{i}. ℍ and 𝔾 will be strictly positive functors in much the same way as 𝔽 in [10] . But since ℍ is determined by π_{i} ∘ ℍ and both π_{i} ∘ ℍ and 𝔾 are functors Fam(I)/D ⟶ Type/E, (where E = (i : I) × D[i] in the general case and E = D[i] in the restricted case), it is more economical to more generally introduce the notion of a strictly positive functor

𝔽 : Fam(I)/D ⟶ Type/E

for an arbitrary type E. From this we can derive the functors 𝔾 and ℍ. As in [10], we define for E : type the type of indices for strictly positive functors

\frac{E : type}{OP_{I,D,E} : type} ,

together with, for γ : OP_{I,D,E} (we omit I, D, E, if the parameter γ is given)

𝔽 _{γ}^{U} : (U : I → set, T : (i : I, U(i)) → D[i]) → stype ,
𝔽 _{γ}^{T} : (U : I → set, T : (i : I, U(i)) → D[i], a : 𝔽 _{γ}^{U}(U, T)) → E .

(It is straightforward to define arrow parts of these functor and the extension to arguments (U, T) s.t. i : I ⇒ U[i] : type.)

We construct elements of OP_{I,D,E} in a similar way as in the non-indexed case:

• Base Case: This corresponds to having IIR with no arguments of the constructor and one only has to determine the result of E:

ι : E → OP_{I,D,E} ,
𝔽 _{ι(e)}^{U}(U, T) = 1 ,
𝔽 _{ι(e)}^{T}(U, T, ⋆) = e .

• Nondependent union of functors: This corresponds to the situation where the constructor has an argument A and (depending on a : A) further arguments coded as γ(a).

σ : (A : stype, γ : A → OP_{I,D,E}) → OP_{I,D,E} ,
𝔽 _{σ(A,γ)}^{U}(U, T) = (a : A) × 𝔽 _{γ(a)}^{U}(U, T) ,
𝔽 _{σ(A,γ)}^{T}(U, T, ⟨a, b⟩) = 𝔽 _{γ(a)}^{T}(U, T, b) .

• Dependent union of functors: This corresponds to the situation where the constructor has one inductive argument indexed over A. For each element a : A we have to determine an index i(a) : I, which indicates the set U(i(a)), the inductive argument is chosen from. The result of T for this argument is an element of (a : A) → D[i(a)] and the other arguments depend on this function. Let T ∘ [i, f] := (x)T (i(x), f(x)).

δ : (A : stype, i : A → I, γ : ((a : A) → D[i(a)]) → OP_{I,D,E}) → OP_{I,D,E} ,

𝔽 _{δ(A,i,γ)}^{U}(U, T) = (f : (a : A) → U(i(a))) × 𝔽 _{γ(T ∘[i,f])}^{U}(U, T) ,
𝔽 _{δ(A,i,γ)}^{T}(U, T, ⟨f, b⟩) = 𝔽 _{γ(T ∘[i,f])}^{T}(U, T, b) .

We finish this subsection by drawing a diagram which shows the relationship between the functors 𝔾 and ℍ for general and restricted IIR:

Fam(I)/D \overline{\begin{matrix}𝔾 \\  \end{matrix}}Type/(i : I) × D[i]

[figure: ℍ]

[figure: Type/D[i]; π_{i} ∘ ℍ; π_{i}; Fam(I)/D; e]

where e(U, T) = ((i : I) × U(i), (a)⟨π_{0}(a), T (π_{0}(a), π_{1}(a))⟩). So the functors in the restricted case are those which factor through an endofunctor ℍ, which itself is determined by the “fibers” π_{i} ∘ ℍ.

The functors for the restricted case have codes of the form

σ(I, (i) ⋯ δ(A, f, (a) ⋯ δ(B, g, (b) ⋯ σ(C, (c) ⋯ δ(D, (d) ⋯ ι(⟨i, e⟩)))))) ,

ie. the codes always start with σ(I, (i) … and the innermost parts are of the form ι(⟨i, e⟩) where i is value of the first non-inductive argument. (Note that the order of the constructors in an element of OP might depend on arguments preceding them). That a functor 𝔾 has such a code corresponds exactly to the fact that it is obtained by the above diagram from strictly positive functors π_{i} ∘ ℍ.

4.6 Formation and Introduction Rules for Restricted IIR

Restricted IIR (indicated by a superscript r) are given by strictly positive endofunctors ℍ in the category Fam(I)/D, which can be given by their (strictly positive) projections π_{i} ∘ ℍ : Fam(I)/D → Type/D[i]. So the set of codes for these functors is given as a family of codes for π_{i} ∘ ℍ, and the type of codes is given as

OP_{I,D}^{r} : type , OP_{I,D}^{r} = (i : I) → OP_{I,D,D[i]} .

Assume now γ : OP_{I,D}^{r}, U : I → set, T : (i : I, U(i)) → D[i], i : I. The object part of ℍ (restricted to U : I → set) is defined as

ℍ _{γ}^{U}(U, T, i) := 𝔽 _{γ(i)}^{U}(U, T) : stype
ℍ _{γ}^{T}(U, T, i, a) := 𝔽 _{γ(i)}^{T}(U, T, a) : D[i]

for a : ℍ _{γ}^{U}(U, T, i).

We have the following formation rules for U_{γ}^{r} and T_{γ}^{r}:

U_{γ}^{r}(i) : set , T_{γ}^{r}(i) : U_{γ}^{r}(i) → D[i] .

U_{γ}^{r}(i) has constructor

intro_{γ}^{r}(i) : ℍ _{γ}^{U}(U_{γ}^{r}, T_{γ}^{r}, i) → U_{γ}^{r}(i) ,

and the equality rule for T_{γ}^{r}(i) is:

T_{γ}^{r}(i, intro_{γ}^{r}(i, a)) = ℍ _{γ}^{T}(U_{γ}^{r}, T_{γ}^{r}, i, a) .

4.7 Formation and Introduction Rules for General IIR

In general IIR (as indicated by superscript g) we have to consider strictly positive functors in 𝔾 : Fam(I)/D → Type/(i : I) × D[i]. The type of codes is given as

OP_{I,D}^{g} : type , OP_{I,D}^{g} = OP_{I,D,(i:I)×D[i]} .

Assume now γ : OP_{I,D}^{g}, U : I → set, T : (i : I, U(i)) → D[i]. The components of 𝔾 needed in the following are

𝔾 _{γ}^{U}(U, T) := 𝔽 _{γ}^{U}(U, T) : stype
𝔾 _{γ}^{I}(U, T, a) := π_{0}(𝔽 _{γ}^{T}(U, T, a)) : I
𝔾 _{γ}^{T}(U, T, a) := π_{1}(𝔽 _{γ}^{T}(U, T, a)) : D[𝔾 _{γ}^{I}(U, T, a)]

for a : 𝔾 _{γ}^{U}(U, T).

We have essentially the same formation rules for U_{γ}^{g} and T_{γ}^{g}

U_{γ}^{g} : I → set , T_{γ}^{g} : (i : I, U_{γ}^{g}(i)) → D[i] .

There is one constructor for all U_{γ}^{g}(i). Depending on its arguments 𝔾 _{γ}^{I}(U_{γ}^{g}, T_{γ}^{g}, a) determines the index it belongs to. So the introduction rule is:

intro_{γ}^{g} : (a : 𝔾 _{γ}^{U}(U_{γ}^{g}, T_{γ}^{g})) → U_{γ}^{g}(𝔾 _{γ}^{I}(U_{γ}^{g}, T_{γ}^{g}, a)) .

The equality rule for T_{γ}^{g} is:

T^{g}(𝔾 _{γ}^{I}(U_{γ}^{g}, T_{γ}^{g}, a), intro_{γ}^{g}(a)) = 𝔾 _{γ}^{T}(U_{γ}^{g}, T_{γ}^{g}, a) .

4.8 Elimination Rules for IIR

We now define the induction principle both for the restricted and the general case. We define first more generally 𝔽 _{γ}^{IH} and 𝔽 _{γ}^{map} for γ : OP_{I,D,E}. Assume F is a twice abstracted expression and

γ : OP_{I,D,E} , U : I → set , T : (i : I, U(i)) → D[i] ,
i : I, u : U(i) ⇒ F [i, u] : type .

The rules for 𝔽^{IH} and 𝔽^{map} are as follows:

\frac{a : 𝔽 _{γ}^{U}(U, T)}{𝔽 _{γ}^{IH}(U, T, F, a) : type}  \frac{h : (i : I, a : U(i)) → F [i, u]}{𝔽 _{γ}^{map}(U, T, F, h) : (a : 𝔽 _{γ}^{U}(U, T)) → 𝔽 _{γ}^{IH}(U, T, F, a)}

𝔽 _{ι(e)}^{IH}(U, T, F, ⋆) = 1 ,

𝔽 _{ι(e)}^{map}(U, T, F, h, ⋆) = ⋆ ,

𝔽 _{σ(A,γ)}^{IH}(U, T, F, ⟨a, b⟩) = 𝔽 _{γ(a)}^{IH}(U, T, F, b) ,

𝔽 _{σ(A,γ)}^{map}(U, T, F, h, ⟨a, b⟩) = 𝔽 _{γ(a)}^{map}(U, T, F, h, b) ,

𝔽 _{δ(A,i,γ)}^{IH}(U, T, F, ⟨f, b⟩) = ((a : A) → F [i(a), f(a)]) × 𝔽 _{γ(T ∘[i,f])}^{IH}(U, T, F, b) ,

𝔽 _{δ(A,i,γ)}^{map}(U, T, F, h, ⟨f, b⟩) = ⟨h ∘ [i, f], 𝔽 _{γ(T ∘[i,f])}^{map}(U, T, F, h, b)⟩ .

In the restricted case we have now under the assumptions

γ : OP_{I,D}^{r} ,
i : I, a : U_{γ}^{r}(i) ⇒ F [i, a] : type ,
h : (i : I, a : ℍ _{γ}^{U}(U_{γ}^{r}, T_{γ}^{r}, i), 𝔽 _{γ(i)}^{IH}(U_{γ}^{r}, T_{γ}^{r}, F, a)) → F [i, intro_{γ}^{r}(i, a)] ,
R_{γ,F}^{r} (h) : (i : I, a : U_{γ}^{r}(i)) → F [i, a] ,
R_{γ,F}^{r} (h, i, intro_{γ}^{r}(i, a)) = h(i, a, 𝔽 _{γ(i)}^{map}(U_{γ}^{r}, T_{γ}^{r}, F, R_{γ,F}^{r} (h), a)) .

And for the general case we have under the assumptions

γ : OP_{I,D}^{g} ,

i : I, a : U_{γ}^{g}(i) ⇒ F [i, a] : type ,

h : (a : 𝔾 _{γ}^{U}(U_{γ}^{g}, T_{γ}^{g}), 𝔽 _{γ}^{IH}(U_{γ}^{g}, T_{γ}^{g}, F, a)) → F [𝔾 _{γ}^{I}(U_{γ}^{g}, T_{γ}^{g}, a), intro_{γ}^{g}(a)] ,

R_{γ,F}^{g} (h) : (i : I, a : U_{γ}^{g}(i)) → F [i, a] ,

R_{γ,F}^{g} (h, 𝔾 _{γ}^{I}(U_{γ}^{g}, T_{γ}^{g}, a), intro_{γ}^{g}(a)) = h(a, 𝔽 _{γ}^{map}(U_{γ}^{g}, T_{γ}^{g}, F, R_{γ,F}^{g} (h), a)) .

In the restricted case one can show that the above rules express that the family (U_{γ}^{r}(i), T_{γ}^{r}(i)) for i : I is (the carrier of) an initial algebra for the endofunctor ℍ on Fam(I)/D. This generalizes a theorem in [10] about the connection between inductive-recursive definitions of a set U and a function T : U → D and initial algebras in the slice category Type/D.

Definition 2 (a) The basic theory of indexed inductive recursive definitions (Bas-IIR) consists of the rules for the logical framework as introduced in this article, the formation and introduction rules for OP and the defining rules for 𝔽^{U}, 𝔽^{T}, 𝔽^{IH} and 𝔽^{map}.

(b) The theory IIR^{r} of restricted indexed inductive recursive definitions consists of Bas-IIR, the defining rules for OP^{r}, ℍ^{U}, ℍ^{T}, and the formation/introduction/elimination/equality rules for U^{r} and T^{r}.

(c) The theory IIR^{g} of general indexed inductive recursive definitions consists of Bas-IIR, the defining rules for OP^{g}, 𝔾^{U}, 𝔾^{I}, 𝔾^{T}, and the formation/introduction/elimination/equality rules for U^{g} and T^{g}.

(d) IID^{r} and IID^{g} are the restrictions of IIR^{r} and IIR^{g}, where in all rules in this article D[i] = 1. These are the theories of restricted and general indexed inductive definitions.

5 The Examples Revisited

We first introduce the following abbreviations:

γ +_{OP} γ′ := σ(2, (x)C_{2}(x, γ, γ′))

and

γ_{1} +_{OP} ⋯ +_{OP} γ_{n} := (⋯ ((γ_{1} +_{OP} γ_{2}) +_{OP} γ_{3}) +_{OP} ⋯ +_{OP} γ_{n})

if n ≥ 3.

So if γ_{1}, …, γ_{n} are codes for constructors C_{i} then γ_{1} +_{OP} ⋯+_{OP} γ_{n} is a code for a constructor C. The first argument of C codes an element i of {1, …, n}. The later arguments of C are the arguments of the constructor C_{i}.

In the following (−) stands for an abstraction (x) for a variable x, which is not used later. Let ι_{⋆}^{g}(a) := ι(⟨a, ⋆⟩), ι_{⋆}^{r} := ι(⋆).

• The trees and forests have code γ : OP_{2,(−)1}^{r} (= 2 → OP_{2,(−)1,1}), where

\begin{aligned}γ(⋆_{0}) & = & δ(1, (−)⋆_{1}, (−)ι_{⋆}^{r}) , \\ γ(⋆_{1}) & = & ι_{⋆}^{r} +_{OP} δ(1, (−)⋆_{0}, (−)δ(1, (−)⋆_{1}, (−)ι_{⋆}^{r})) . \end{aligned}

Then Tree = U_{2,(−)1,γ}^{r}(⋆_{0}), Forest = U_{2,(−)1,γ}^{r}(⋆_{1}).

• The even number predicate has code ι_{⋆}^{g}(0) +_{OP} σ(N, (n)δ(1, (−)n, (−)ι_{⋆}^{g}(S(S(n)))))\begin{matrix}: OP_{N,(−)1}^{g} \\ (= OP_{N,(−)1,N×1}) . \end{matrix}

• The accessible part of a relation has code

(i)δ((x : I) × (x < i), (z)π_{0}(z), (−)ι_{⋆}^{r})\begin{matrix}: OP_{I,(−)1}^{r} \\ (= (i : I) → OP_{I,(−)1,1}) . \end{matrix}

As a general IIR it has code

σ(I, (i)δ((x : I) × (x < i), (z)π_{0}(z), (−)ι_{⋆}^{g}(i)))\begin{matrix}: OP_{I,(−)1}^{g} \\ (= OP_{I,(−)1,I×1}) . \end{matrix}

• The identity set has code σ(A, (a)ι_{⋆}^{g}(⟨a, a⟩)) : OP_{A×A,(−)1}^{g} (= OP_{A×A,(−)1,(A×A)×1}) .

• For the Tait-style computability predicates for dependent types we have I = Exp, D[i] = Exp → set. The rules given in Subsection 3.2 are incomplete, additional constructors have to be added by using +_{OP} (the current definition actually defines the empty set). The code for the constructor given in Subsection 3.2 is

σ(Exp, (A)

δ(1, (−)A, (ψ_{A}) σ(Exp, (B)

\begin{matrix}δ((a : Exp) × ψ_{A}(⋆, a), (y)(B π_{0}(y)), (ψ_{B}) \\ ι(⟨Π(A, B), (b)∀a : Exp.∀x : ψ_{A}(⋆, a).ψ_{B}(⟨a, x⟩, (b a))⟩))))) \end{matrix}

: OP_{I,(i)D[i]}^{g} (= OP_{I,(i)D[i],(i:I)×D[i]}) .

• E. Palmgren’s higher order universe has code γ : OP_{{0,...,n},(l)Op^{l}(set)}^{r} (= (k : {0, …, n}) → OP_{{0,...,n},(l)Op^{l}(set),Op^{k}(set)}) ,

where

γ(0) := γ_{Univ} +_{OP} γÂ_{0} +_{OP} ⋯ +_{OP} γÂ_{n} +_{OP} γB̂_{0}+_{OP}
γ_{ap}_{0}^{0} +_{OP} γ_{ap}_{1}^{0} +_{OP} ⋯ +_{OP} γ_{ap}_{n}^{0} +_{OP} γ_{ap}_{0}^{1} ,
γ(i) := γB̂_{i} +_{OP} γ_{ap}_{i}^{1}  (i = 1, …, n − 1) ,
γ(n) := γB̂_{n} .

and γ_{Univ} is a code for all standard universe constructors,

γÂ_{k} := ι(A_{k}) ,
γB̂_{k} := σ(A_{k}, (a)ι(B_{k}(a))) ,
γ_{ap}_{i}^{0} := δ(1, (−)(i + 1), (T_{f}) ; δ(1, (−)0, (T_{u}) ; \begin{matrix}δ(T_{u}(⋆), (−)i, (T_{v}) \\ ι(π_{0}(T_{f}(⋆, ⟨T_{u}(⋆), T_{v}⟩)))))) , \end{matrix}

γ_{ap}_{i}^{1} := δ(1, (−)(i + 1), (T_{f}) ; δ(1, (−)0, (T_{u}) ; δ(T_{u}(⋆), (−)i, (T_{v}) ; \begin{matrix}σ(π_{0}(T_{f}(⋆, ⟨T_{u}(⋆), T_{v}⟩)), (a) \\ ι(π_{1}(T_{f}(⋆), ⟨T_{u}(⋆), T_{v}⟩)(a)))))) . \end{matrix}

(To be formally correct we would have to work with N_{n+1} instead of {0, …, n}).

6 Further Results

There is an extended version [11] of this article which contains some additional topics.

In particular we show the consistency of our theories by constructing a model in classical set theory where type-theoretic function spaces are interpreted as full set-theoretic function spaces, and some axioms for large cardinals are used for interpreting the type of sets closed under IIR and also to interpret the logical framework. This construction is a generalization of the model for non-indexed induction-recursion given in [9].

Furthermore, we show that the restricted and general form of an IIR are intertranslatable under certain conditions. We also show how to simulate certain forms of IIR by non-indexed inductive-recursive definitions (IR).

References

[1] P. Aczel. Frege Structures and the Notions of Proposition, Truth, and Set, pages 31–59. North-Holland, 1980.

[2] T. Altenkirch, V. Gaspes, B. Nordström, and B. von Sydow. A user’s guide to ALF. http://www.www.cs.chalmers.se/ComputingScience/Research/ Logic/alf/guide.html, 1996.

[3] A. Bove and V. Capretta. Nested general recursion and partiality in type theory. To appear in the Proceedings of TPHOL 2001.

[4] C. Coquand. Agda. 2000. http://www.cs.chalmers.se/ catarina/agda/.

[5] C. Coquand. A realizability interpretation of Martin-Löf’s type theory. In G. Sambin and J. Smith, editors, Twenty-Five Years of Constructive Type Theory. Oxford University Press, 1998.

[6] P. Dybjer. Inductive sets and families in Martin-Löf’s type theory and their set-theoretic semantics. In G. Huet and G. Plotkin, editors, Logical Frameworks, pages 280–306. Cambridge University Press, 1991.

[7] P. Dybjer. Inductive families. Formal Aspects of Computing, 6:440–465, 1994.

[8] P. Dybjer. A general formulation of simultaneous inductive-recursive definitions in type theory. Journal of Symbolic Logic, 65(2), June 2000.

[9] P. Dybjer and A. Setzer. A finite axiomatization of inductive-recursive definitions. In J.-Y. Girard, editor, Typed Lambda Calculi and Applications, volume 1581 of Lecture Notes in Computer Science, pages 129–146. Springer, April 1999.

[10] P. Dybjer and A. Setzer. Induction-recursion and initial algebras. Submitted for publication, April 2000.

[11] P. Dybjer and A. Setzer. Indexed induction-recursion. To appear as a Report of Institut Mittag-Leffler, 2001.

[12] L. Magnusson and B. Nordström. The ALF proof editor and its proof engine. In Types for proofs and programs, volume 806 of Lecture Notes in Computer Science, pages 213–317. Springer, 1994.

[13] P. Martin-Löf. An intuitionistic theory of types: Predicative part. In H. E. Rose and J. C. Shepherdson, editors, Logic Colloquium ‘73, pages 73–118. North-Holland, 1975.

[14] P. Martin-Löf. Constructive mathematics and computer programming. In Logic, Methodology and Philosophy of Science, VI, 1979, pages 153–175. North-Holland, 1982.

[15] P. Martin-Löf. On the meaning of the logical constants and the justification of the logical laws, 1983. Notes from a series of lectures given in Siena.

[16] P. Martin-Löf. Intuitionistic Type Theory. Bibliopolis, 1984.

[17] P. Martin-Löf. An intuitionistic theory of types. In G. Sambin and J. Smith, editors, Twenty-Five Years of Constructive Type Theory. Oxford University Press, 1998. Reprinted version of an unpublished report from 1972.

[18] B. Nordström, K. Petersson, and J. Smith. Programming in Martin-Löf’s Type Theory: an Introduction. Oxford University Press, 1990.

[19] E. Palmgren. On Fixed Point Operators, Inductive Definitions and Universes in Martin-Löf’s Type Theory. PhD thesis, Uppsala University, 1991.

[20] E. Palmgren. On universes in type theory. In G. Sambin and J. Smith, editors, Twenty-Five Years of Constructive Type Theory. Oxford University Press, 1998.

[21] C. Paulin-Mohring. Inductive definitions in the system Coq - rules and properties. In Proceedings Typed λ-Calculus and Applications, pages 328– 245. Springer-Verlag, LNCS, March 1993.