For Finitary Induction-Induction, Induction is Enough

12 Inductive-inductive types (IITs) are a generalisation of inductive types in type theory. They allow 13 the mutual deﬁnition of types with multiple sorts where later sorts can be indexed by previous ones. 14 An example is the Chapman-style syntax of type theory with conversion relations for each sort where 15 e.g. the sort of types is indexed by contexts. In this paper we show that if a model of extensional 16 type theory (ETT) supports indexed W-types, then it supports ﬁnitely branching IITs. We use a 17 small internal type theory called the theory of signatures to specify IITs. We show that if a model of 18 ETT supports the syntax for the theory of signatures, then it supports all IITs. We construct this 19 syntax from indexed W-types using preterms and typing relations and prove its initiality following 20 Streicher. The construction of the syntax and its initiality proof were formalised in Agda. 21


Introduction
Many mutual inductive types can be reduced to indexed inductive types, where the index disambiguates different sorts.For example, consider the mutual inductive datatype with two sorts isEven and isOdd, defined by the following constructors.This can be reduced to the following single inductive family where isEven?true represents isEven and isEven?false represent isOdd.
isEven? : Bool → N → Set zeroEven : isEven?true zero sucEven : (n : N) → isEven?false n → isEven?true (suc n) sucOdd : (n : N) → isEven?true n → isEven?false (suc n) Inductive-inductive types (IITs [26]) allow the mutual definition of a type and a family of types over the first one.IITs were originally introduced to represent the well-typed syntax of type theory itself, and a prominent example is still Chapman's [13] syntax for a type theory.
A minimised version is the IIT of contexts and types given by the following constructors.This type has two sorts, Con and Ty.The ext constructor of Con refers to Ty and the Tyconstructor U refers to Con, hence the two sorts have to be defined simultaneously.Moreover, Ty is indexed over Con.This precludes a reduction analogous to the reduction of isEven-isOdd, as we would get a type indexed over itself.Another unique feature of IITs (which also holds for higher inductive types [29]) is that later constructors can refer to previous constructors: in our case, El mentions ext.
The elimination principle for the above IIT has the following two motives (one for each sort) and four methods (one for each constructor).
Above we used implicit quantifications for Γ : Con and A : Ty Γ to ease readability, e.g.T y D has an implicit parameter Γ before its explicit parameter of type Con D Γ .
Given the above motives and methods the elimination principle provides two functions The functions elimCon and elimTy are an example of a recursive-recursive definition (using nomenclature from [26]).This means two mutually defined functions where the type of the second function depends on the first function.The proof assistant Agda [28] allows defining such functions (even from non-IITs) and is currently the only proof assistant supporting IITs 1 .
Reducing IITs to inductive types (more precisely, to indexed W-types) is an open problem.
Forsberg [26] presented a reduction in extensional type theory, however, this only provides a simpler, non-recursive-recursive elimination principle.Hugunin [19] reduced several IITs to inductive types, working inside a cubical type theory, but he also only constructed the simple eliminator.To illustrate the difference, we list the motives, methods and the simple elimination principle for the Con-Ty example.Again, we use implicit quantifications.This simple elimination principle is not capable of defining standard (metacircular) interpretation [4] of our small syntax.Using pattern matching notation, this interpretation is the following: The reason that we need the general elimination principle to define -is that -for types refers to -for contexts, hence this function is recursive-recursive.
Kaposi, Kovács, and Altenkirch [21] introduced a small type theory, called the theory of signatures, to describe quotient inductive-inductive types (QIIT).QIITs are generalisations of IITs where equality constructors are also allowed.A QIIT signature is a context in the theory of QIIT signatures, for example natural numbers are specified by the context (N at : U, zero : N at, suc : N at → N at) of length three (N at, zero and suc are variable names).The theory of QIIT signatures is itself a QIIT.In ibid., it is proved that if a model of extensional type theory supports the theory of QIIT signatures, then it supports all QIITs.
1 An experimental version of Coq with IITs is also available on GitHub.
T Y P E S 2 0 1 9

6:4
For Finitary Induction-Induction, Induction is Enough By omitting the equality type former from the theory of QIIT signatures, we obtain a theory of IIT signatures and the construction is still valid.It follows that if a model of extensional type theory supports the theory of IIT signatures, it supports all IITs.
In this paper we show that any model of extensional type theory with indexed W-types supports the theory of IIT signatures, and as a consequence all IITs.The difficulty in this construction is that the theory of IIT signatures is itself a QIIT, it is both inductive-inductive and has equality constructors.However, it can be seen as the well-typed syntax of a small type theory without any computation rules.Hence we can represent the syntax of normal forms without quotienting.We construct this well-typed normal syntax using preterms and typing relations from indexed W-types.Finally, we prove the elimination principle in the style of the initiality proof of Streicher.
Streicher [30] constructs the syntactic model of type theory using well-typed preterms and then shows initiality of this model by ( 1) defining a partial map to any other model by induction on preterms and (2) showing that whenever this partial function receives a well-typed preterm on its input it actually gives an output.Instead of defining a partial function, we define the graph of the same function as a relation and then show that it is functional as a second step.This can be seen as an indexed variant of the construction using partial functions.
Just as [21], we only consider finitary IITs, that is, constructors can only have a finite number of recursive arguments.An example constructor for Con-Ty which is not allowed is the following:

Structure of paper and list of contributions
We describe related work in Section 1.1, and explain our notation and Agda formalisaton in Section 1.2.Then the following three sections describe our three contributions: Section 2. We define what it means for a model of extensional type theory (ETT, Definition 1) to support all inductive-inductive types (IITs): Definition 12.The novel contribution here is a (predicative) Church encoding of signatures following [8].
Section 3. In Theorem 23, we show that if a model of ETT supports the theory of IIT signatures (Definition 15), then it supports IITs.This is an adaptation of a proof in [21].
Section 4. Our main contribution is showing that if a model of ETT supports indexed W-types, then it supports the theory of IIT signatures (Theorem 57), and hence, all IITs (Corollary 58).
We list further work in Section 5.
The contents of this paper were presented at the TYPES 2019 conference in Oslo [22].

Related Work
The current work builds heavily on the work of Kaposi et al. [21] on finitary quotient inductive-inductive types (QIITs); we reuse both QIIT syntax and semantics by restricting to IITs, and we reuse the term model construction of QIITs as well.We also make use of the extension to infinitary QIITs [24] to derive the specification of the elimination principle for the theory of IIT signatures.
IITs (although not by this name) were first used to describe the well-typed syntax of type theory [15,13].Agda supported these general inductive definitions even before they were named IITs and given semantics by Nordvall Forsberg and Setzer [27].Nordvall Forsberg's

6:5
thesis [26] contains a specification similar in style to Dybjer and Setzer's codes for inductiverecursive types [17].He also develops a categorical semantics based on dialgebras and provides a reduction of IITs to indexed inductive types, however only constructs the simple elimination principle as opposed to the general one.Altenkirch et al. [2] define signatures for QIITs (thus IITs as well) and their categorical semantics, however without proving existence of initial algebras.Their notion of signature, like Nordvall Forsberg's, involves more encoding overhead than ours.
Removing equations from his signatures and only considering finite signatures, we obtain finitary IIT signatures similar to ours.He does not consider constructing initial algebras using simpler classes of inductive types.
Hugunin [19]  Intrinsic (well-typed) syntaxes for type theories were constructed using IITs [13], inductiverecursive types [15,6] and QIITs [4].In this paper we avoid using such general classes of inductive types as our goal is to reduce IITs to indexed inductive types.
Reducing general classes of inductive types to simpler classes has a long tradition in type theory.Indexed W-types were reduced to W-types [3] (using the essentially Streicher's idea of preterms and a typing predicate), small inductive-recursive types to indexed W-types [25], mutual inductive types to indexed W-types [23], W-types to natural numbers and quotients [1].(Q)IITs can be reduced to quotient inductive types using the reduction of generalised algebraic theories to essentially algebraic theories [12].Using the same reduction as mutual inductive types to indexed inductive types, (Q)IITs with more than two sorts can be reduced to (Q)IITs with only two sorts [20].
Awodey, Frey and Speight [8] construct inductive types using a restricted Church encoding in a type theory with an impredicative universe.We use the predicative version of their encoding to define IIT signatures.
Our reduction of IITs to indexed inductive types goes through two steps: first we construct a concrete QIIT using inductive types, then we construct all IITs from this particular QIIT.
A more direct approach is proposed by [5]: here the initial algebra would be constructed directly for any IIT signature without going through an intermediate step.

Notation and Formalisation
Definition 1 (Model of extensional type theory (ETT)).By a model of ETT we mean a category with families (CwF) [16,18] with a countable predicative hierarchy of universes T Y P E S 2 0 1 9

6:6
For Finitary Induction-Induction, Induction is Enough closed under the following type formers: Π, Σ, and an identity type with uniqueness of identity proofs and equality reflection.
We will use Agda-like type theoretic syntax to work in the internal language of models of ETT: Universes are written Set i .We usually omit level indices in this paper.
Π types are notated as (x : A) → B, or as A → B when non-dependent.We sometimes omit function arguments, by implicitly generalising over variables.
Σ-types, notated either as (x : A) × B, or as x B when we want to leave the type of the first projection implicit.Projections are either named or given by proj 1 and proj 2 .We use A × B for non-dependent pairs.
The unit type has the constructor tt which is definitionally equal to all elements of .
The contents of Section 4 were formalised in Agda, the formalisation is available at https://github.com/amblafont/UniversalII.Agda's pattern matching mechanism implies uniqueness of identity proofs, we assumed function extensionality as an axiom and used rewrite rules [14] to obtain limited equality reflection.

A Definition of Inductive-Inductive Types
In this section we specify what it means that a model of ETT supports IITs.We first define the notion of IIT signature.Signatures for algebraic theories are usually given by inductive definitions.On the one hand, we take this even further: our notion of signature is given by a small type theory tailor-made to describe signatures, which we call the theory of IIT signatures.On the other hand we would like to avoid using a complicated inductive definition (a type theory is a quotient inductive-inductive type [4]) to describe a simpler class of inductive types.Hence we use a Church encoding [8] of the theory of IIT signatures, thereby avoiding the need for pre-existing inductive definitions.Another feature of our signatures is that they can include types from the model of ETT (such as N in the isEven-isOdd).This is why signatures are specified internally to the particular model of ETT. 2e define the theory of IIT signatures by saying what its algebras (models) are.We call the theory of IIT signatures algebras simply signature algebras.The theory of signatures is a small type theory consisting of a (1) a substitution calculus (category with families, CwF [16]) equipped with (2) a universe, (3) a function space where the domain is in the universe and ( 4) another function space with external domain.We explain the usage of these type formers through examples after the definition.
Definition 2 (Signature algebra, SignAlg).In a model of ETT, a signature algebra is an iterated Σ type consisting of the following four (families of) sets, 17 operations and 18 equalities.

6:8
For Finitary Induction-Induction, Induction is Enough Given an M : SignAlg, we denote its components by Con M , Ty M , Sub M , Tm M , id M , and so on.We omit the indices if there is only one signature algebra in scope (e.g. in Definition 3 and Example 4).

Definition 3 (Abbreviations).
For a signature algebra, we use wk : Sub (Γ A) Γ to mean π 1 id.We recover de Bruijn indices by setting 0 := π 2 id and 1 Example 4 (Example contexts in a signature algebra).Given a signature algebra, we can define a context which specifies natural numbers.For readability, an informal version of the same context is displayed on the right using variable names.
We start with the empty context •, then we declare a sort U, then we declare an operator producing an element of the sort denoted by El 0 where 0 is the de Bruijn index referring to the sort.Finally, we declare an operator which takes as input an element of the sort (now it became de Bruijn index 1) and produces an element of the same sort.Note the asymmetry of the function type ⇒: the domain needs to be an element of U, while the codomain can be any type (including another function type).This ensures strict positivity of the operators.
Lists with elements of a given T : Set type are given by the following context.Here we use the function space with external domain ⇒ to include a T in the signature.For readability, we omit the λ and the superscripts and we do not write the compatibility condition.On the right we list the same signature with variable names.
The Con-Ty example from Section 1 is given by the following context.
The above examples are contexts in any signature algebra, and we could take this as a definition of signature: (M : SignAlg) → Con M is the usual Church-encoding of contexts.
However (as we will see in Remark 24) the notion of constructor for such signatures would be too strong.Another approach would be to assume that there is a syntax for signature algebras (an initial signature algebra), and then a signature would be a context in this signature algebra.We will define syntactic signatures using this approach in the next section 6:9 (Definition 16), but for now we do not want to assume the existence of any inductive type.
Instead, we will use a restricted Church encoding.This requires the notion of morphism of signatures.
The notion of morphism is determined by the notion of algebra [24], but we include it here for completeness.
Definition 5 (Signature morphism, SignMor).A morphism from signature algebras M to N denoted SignMor M N consists of four functions and 17 equalities expressing that the functions preserve the operations of the two algebras.We use the same naming as in Definition 2 and use superscripts to denote which algebra is meant.
(1) Substitution calculus (3) Inductive parameters Given an f : SignMor M N , we denote its first four components just by f Con , f Ty , f Sub , f Tm or just write f if it is clear which one is meant.
We define IIT signatures using the Church encoding introduced by Awodey, Frey and Speight [8].A difference is that we avoid impredicativity.This restricts the possible eliminations on signatures: we can only eliminate into a universe which is smaller than the level of signatures.However, this still covers all eliminations in this paper, and it is also not an issue for us that signatures do not live in the smallest universe.
T Y P E S 2 0 1 9

6:10
For Finitary Induction-Induction, Induction is Enough Definition 6 (IIT signature).An IIT signature is a context in an arbitrary signature algebra, which is also compatible with morphisms: The compatibility condition says that if we obtain an M -context using sig at signature algebra M and then we transport it to N using f , we get the same N -context as directly applying sig to N .
The lack of impredicativity implies that our notion of signatures do not form a signature algebra.

Lemma 7.
There is no M : SignAlg, in which Con M = Sign.

Proof. If the
The first component builds the context describing natural numbers in M , the second one uses the fact that f is a morphism, that is, it preserves all operations.
The signatures for lists and Con-Ty can be given analogously.
Given a model of ETT and an IIT signature in it, we would like to say what it means that the model supports the given IIT.For this we define the signature algebra ADS which will provide notions of algebras, displayed algebras and sections for each signature.This is the same as the -A , -D and -S operations in [21].Before defining ADS, we illustrate its usage by an example.
Example 9 (Algebras, displayed algebras and sections for natural numbers).For the signature of natural numbers as given in Example 8, algebras are given by the Σ-type (N : Set) × N × (N → N ).A displayed algebra over (N, z, s) is given by the Σ-type A. Kaposi, A. Kovács and A. Lafont

6:11
and a section of a displayed algebra (N D , z D , s D ) over (N, z, s) is given by the Σ-type Displayed algebras over the initial algebra are called motives and methods of the eliminator, while a section of a displayed algebra over the initial algebra is the eliminator together with its computation rules.
Definition 10 (The signature algebra ADS).We define an element of SignAlg by listing all its components Con, Ty, Sub, and so on, one per row.Each such component has three parts denoted by A , D and S , respectively.The equality components of SignAlg are omitted as they are all reflexivity.In other words, for any signature, we have an algebra called con (constructors) and for any displayed algebra over the constructors, we have a section (called the eliminator).
One can check that Definition 12 gives the right notion of constructors and elimination principle for the signatures in Example 8.
Example 13 (A model of ETT supports natural numbers).For the signature (nat, natc) of natural numbers in Example 8, the type of con nat is A. Kaposi, A. Kovács and A. Lafont

6:14
For Finitary Induction-Induction, Induction is Enough Remark 14.The computation rules of the elimination principle are only expected up to the internal equality type, but as we work with a model of ETT, we also get them as definitional equalities by equality reflection.

Constructing all IITs from the Theory of IIT Signatures
In the previous section, using the notions of signature algebras and signature morphisms, We will define the term signature algebra by which we obtain the constructors con for any IIT signature.Then we will define another signature algebra which provides the eliminator.
Before doing these, we illustrate the idea of both constructions on natural numbers.

Example 18.
For natural numbers, we will define the constructors con as the following natural number algebra (Nat, zero, suc).We write variable names instead of de Bruijn indices for readability.
Natural numbers are simply I-terms of type El N in the context which is the syntactic signature for natural numbers.In this context, the only way to define a term of type El N is to use z and s, corresponding to the zero and suc constructors.
To define the action of the eliminator on a natural number n : Nat, let's look at the type of the displayed algebra interpretation of the number: This says that for a displayed algebra γ D = (N D , z D , s D ) over con (i.e. the motives and methods of the eliminator), we get a witness of the predicate El N D = N D at the algebra interpretation of n.This is not yet good, as we would like to get N D n instead of N D ( n A con) as a result.However, interpretation into the term signature algebra will imply that n = n A con.
Definition 19 (Term signature algebra IC -).For an Ω : Con I , we define IC Ω : SignAlg which we call the term signature algebra.It is equipped with a morphism -I : SignMor (IC Ω ) I. We define IC Ω by listing its components Con, Ty, Sub, and so on, one per row.Each component has two parts denoted by I and C .The I part just reuses the corresponding components from I, and thus the morphism -I is defined as the obvious projection.We omit the equality components, as they come from UIP or are trivial.We also omit the components for terms and substitutions as their C parts consist of uninformative equational reasoning.
Example 20.Now, given a syntactic signature Ω : Con I , we get the constructors as an If Ω is the syntactic signature for natural numbers, we get the constructors as in Example 18.
An a : Tm I Ω U is a sort term for the syntactic signature Ω.If Ω is the syntactic signature for natural numbers, a can only be N (1 as a de Bruijn index).If Ω is the syntactic signature for Con-Ty (Example 4), a can be Con, T y @ empty, T y @(ext @ empty @(U @ empty)), and so on.In any case, for such an a, we obtain ( a IC Ω ) C id I : Tm I Ω (El a) = a A ω.That is, the algebra interpretation of a sort term at the constructors is equal to terms of that sort.
A t : Tm I Ω (El a) is a term of a sort type a constructed using the constructors in Ω.For natural numbers, such a t can only be s applied iteratively to z.For such a t, we obtain That is, a constructor term is equal to its algebra interpretation at the constructors.This is exactly the equation needed at the end of Example 18.
Definition 21 (Eliminator signature algebra IE -).Given an Ω : Con I , we use the abbreviation Example 20.Assuming an ω D : ( Ω ADS ) D ω, we define the signature algebra IE ω D .It is equipped with a morphism -I : SignMor IE ω D I. We define IE ω D by listing its components Con, Ty, Sub, and so on, one per row.Each component has two parts denoted by I and E .The I part just reuses the corresponding components of I, thus the morphism -I is defined as the obvious projection.We omit the equality components, as they come from UIP or are trivial.We also omit the components for terms and substitutions as their E parts are uninformative equational reasonings.
T Y P E S 2 0 1 9

6:16
For Finitary Induction-Induction, Induction is Enough Example 22.Given the assumptions Ω, ω D of IE, we obtain the eliminator by Ω IE ω D id I : The eliminator is a section of the displayed algebra ω D , that is, a dependent function together with equalities witnessing that all the operations are preserved.If Ω is the syntactic signature for natural numbers, we get the eliminator of Example 18.
For a sort term a : ( Ω E id), that is, the function for the sort a in the eliminator section is the displayed algebra interpretation at ω D (motives and methods).For natural numbers, this is the same The interpretation of a constructor term t : Tm I Ω (El a) is uninteresting as it provides an equality between two different equality proofs of the computation (β) rule for t.Remark 24.In the above proof, we crucially relied on the sigc property to define the constructors (and the eliminator).This is why the simple Church encoding of signatures is not sufficient.

Constructing the Theory of IIT Signatures
In this section we show that any model of ETT which supports indexed W-types also supports the theory of signatures, and as a consequence of Theorem 23, all IITs.For this, we work in the internal language of a model of ETT supporting indexed W-types [3].Indexed W-types correspond to the usual notion of (possibly mutual) indexed inductive types.We use Agda-style notation to define such inductive families: we list the sorts and constructors and use pattern matching when eliminating from them.For an encoding of mutual inductive families as indexed W-types, see e.g.[23].
We construct the theory of IIT signatures in the following steps: 1. We view the theory of signatures as a type theory, and we define its untyped syntax as mutual inductive types together with typing judgments given by inductive relations on the untyped syntax.Then the syntax I : SignAlg is constructed using those untyped terms for which the typing relation holds.

2.
We construct -: SignMor I M for arbitrary M : SignAlg, by: a. defining a relation -∼ -between the well-typed syntax and a given signature algebra.
The idea is that given a syntactic context Γ and a semantic context Γ M of the signature algebra M , we have Γ ∼ Γ M if and only if Γ = Γ M , and similarly for types, terms, and substitutions; b. showing that this relation is functional and thus obtaining a morphism.

3.
Proving the uniqueness of this morphism by showing that any morphism f : SignMor I M satisfies the relation.For example, for any syntactic context Γ we have Γ ∼ f Γ .
The next sections detail each of these steps.

Syntax
The goal is to define the syntactic signature algebra where contexts are pairs of a precontext together with a well-formedness proof, and similarly for types, terms and substitutions.
Crucially, we do not have conversion relations for typed syntax, nor do we need to use quotients when constructing the syntax.This is possible because there are no β-rules in the theory of signatures.Hence, we consider only normal terms in the untyped syntax, and define weakening and substitution by recursion.Avoiding quotients is important for two reasons.First, it greatly simplifies formalisation.Second, we aim to reduce the theory of signatures only to inductive types, thus making Theorem 57 stronger.Now we present the definition of the untyped syntax and the associated typing judgments.

Untyped Syntax and its Properties
Definition 25 (Untyped syntax).The untyped syntax is defined as the following inductive datatype.
(1) Substitution calculus Variables are modeled as de Bruijn indices, i.e. as natural numbers pointing to a position in the context.We use the additional default constructor err p : Tm p in case of error (ill-scoped substitution).The typing judgments will not mention err p .The main interest of err p is that it behaves like a closed term (which the theory of signatures lacks), in the sense that it is invariant under substitution.This makes expected equalities about substitution true even in the ill-typed case, thus reducing the number of hypotheses for the corresponding lemmas (see Lemma 32).
We will define substitutions -[ -] of types and terms recursively.
Note that (Π p A B)[σ] should be defined as Π p (A[σ]) (B[wk 0 σ , p var p 0]), and thus we need to define wk 0 , the weakening of substitutions.The basic idea is to increment the de Bruijn indices of all the variables.Actually, this is not so simple because of the Π p type: we want to define wk 0 (Π p A B) as the Π type of the weakening of A and B, but here, B must be weakened with respect to the second last variable of the context, rather than the last one.
For this reason, we need to generalise the weakening as occuring anywhere in the context.
Definition 26 (Untyped weakening).We define untyped weaking recursively on terms by the following functions.The natural number n specifies at which position of the context the weakening occurs.Here, wk 0 weakens with respect to the last variable.
Later, in Lemma 36, we show that weakening preserves typing.Stating a typing rule for this operation requires weakening at the middle of a context.This is why we define pairs of untyped contexts, which should be thought of as a splitting of a context at some position.
We call the second context a telescope over the first one.
Definition 27 (Untyped telescopes).An untyped telescope is given simply by a Con p .

6:19
Definition 28 (Merging of a context and a telescope).This is enough to state the typing judgments: indeed, the typing rule for application involves only a unary substitution.
However, to construct the syntax as a signature algebra, we need to define parallel substitutions: Definition 31 (Untyped substitution calculus).
-[ -] : These can be defined either by iterating unary substitutions, or by recursion on untyped syntax: the two ways yield provably equal definitions.In the following, we assume that they are defined by recursion.We also make use of the following definition: The idea is that if σ is a substitution from Γ to ∆, then keep σ is a substitution between contexts Γ A[σ] and ∆ A for any type A where the last term is just a de Bruijn index 0.

This occurs when defining (Π
We define the identity substitution on a context Γ as follows, where keep Γ is keep iterated Γ times:

6:20
For Finitary Induction-Induction, Induction is Enough Proof.By induction on the untyped syntax.
Corollary 33.As particular cases for n = 0, we get Lemma 34 (Composition functor law and associativity). [ We defer laws for identity substitutions after the definition of the typing judgments, as the proofs require that some inputs are well-typed.
There is possibility of redundancy in the arguments of the constructors.Here, we are "paranoid" (nomenclature from [9]), so that we get more inductive hypotheses when performing recursion.
Lemma 36 (Weakening preserves typing).We show that judgments are stable under substitution.
[] w : (Γ ) Proof.By mutual induction on the typing relations.
We show the category and functor laws involving identity substitution for well-formed types, terms and substitutions.

Con S :
Con → Set T y S : Ty Γ → Set empty S : Con S empty ext S : Con S Γ → T y S A → Con S (ext Γ A) U S : Con S Γ → T y S (U Γ ) El S : Con S Γ → T y S (El Γ ) selimCon : (Γ : Con) → Con S Γ selimTy : (A : Ty Γ ) → T y S A

(Definition 11 (
El a)S is the graph of the function a S .Π S for a function again says that the function respects the relation, however we do not simply say(Π a B) S γ S f f D := (α : a A γ)(α D : a D γ D α)(α S : (El a) S γ S α α D ) → B S . . .,as (El a) S γ S α α D is just an equality a S γ S α = α D which we can singleton contract.So we omit α D and this equality as an input and replace α D by a S γ S α in the definition.When viewing ADS by rows, we can see that it is a part of the CwF model of type theory[21, Section 7.4].In the CwF model, a context is given by a CwF.Now, from the category part of the CwF, we only have objects (Γ A ), and from the families, we have the families for types Γ D and terms Γ S .Types are the corresponding parts of displayed CwFs, substitutions are parts of CwF morphisms, terms are parts of CwF sections.U is part of the CwF of sets, El a is the part of the discrete displayed CwF coming from a (which is a CwF-morphism from Γ to the CwF of sets).Π is given by a dependent product of displayed CwFs where it is essential that the domain is discrete, Π is the pointwise direct product.The set signature algebra A).A : SignAlg is given by the first A components of ADS (Definition 10), that is, Con A := Set, Ty A Γ := Γ → Set, Sub A Γ ∆ := Γ → ∆, and so on.There is a morphism from ADS to A defined by -A at each component, which we also denote by -A : SignMor ADS A.Definition 12 (A model of ETT supports IITs).A model of ETT supports IITs if for anysignature (sig, sigc) : Sign there is a con sig : (sig ADS) A and an elim sig : (γ D : (sig ADS) D con sig ) → (sig ADS) S con sig γ D .

Lemma 17 .
we defined IIT signatures and what it means for a model of ETT to support all IITs.In this section we show that if a model of ETT supports the theory of IIT signatures, then it supports all IITs.Using the Church encoding of Definition 6, every model of ETT can describe ITT signatures.In contrast, in Definition 15, we will require existence of an initial signature algebra.The contents of this section are an adjustment of [21, Sections 4 and 6] to our setting.Definition 15.A model of ETT supports the theory of IIT signatures if there is a signature algebra I : SignAlg equipped with a unique morphism -M : SignMor I M into any algebra M .Sometimes we omit the subscript M .We call I the syntax or initial algebra, the morphism -is called recursor.Definition 16 (Syntactic signatures).In a model of ETT supporting the theory of ITT signatures, we call elements of Con I syntactic signatures.One may wonder what is the relationship between the two notion of signatures.In a model of ETT supporting the theory of ITT signatures, signatures and syntactic signatures are isomorphic.Proof.We can turn a (sig, sigc) : Sign into Con I by sig I and an Ω : Con I into a Sign by λM.Ω M , λM N f.f Ω M = (f • -M ) Ω = Ω N where the equality proof in the second component comes from uniqueness of the recursor (we have to define composition of morphisms • for this).The compositions of these two maps are the identities: (sig, sigc) is mapped to (λM.sig I M , . . . ) = (λM.-M (sig I), . . . ) which is equal to (λM.sig M, . . . ) because of sigc; Ω is mapped to Ω I = Ω by uniqueness of -.

Theorem 23 .
If a model of ETT supports the theory of IIT signatures, then it supports all IITs.Proof.For a signature (sig, sigc), we define constructors as con sig := ( sig I IC sig I ) C id I : (sig ADS) A This typechecks as sig I A = -A (sig I) sigc = sig A = (sig ADS) A .We define the eliminator by and an elim sig γ D := ( sig I IE γ D ) E id I : (sig ADS) S con sig γ D .This typechecks firstly because the type of γ D matches the type of the parameter of IE: (sig ADS) D con sig sigc = ( -ADS (sig I)) D con sig = ( sig I ADS ) D con sig , and the result also has the correct type: sig I S con sig γ D = ( -ADS (sig I)) S con sig γ D sigc = (sig ADS) S con sig γ D .

wk n :
Ty p → Ty p wk n : Tm p → Tm p wk 0 : Sub p → Sub p

id p :
Con p → Sub p := λΓ .keepΓ p Lemma 32 (Exchange laws for weakening and substitution).Below, Z denotes either a term or a type and keep n denotes the n times iteration of keep.wk-wk : wk n+p+1 (wk n Z) = wk n (wk n+p Z) T Y P E S 2 0 1 9

4 . 1 . 3
Tm w =Ty : (Γ t ∈ A) → (Γ t ∈ B) → A = B Var w =Ty : (Γ x ∈ N A) → (Γ x ∈ N B) → A = BLet us consider for instance the application constructor app w : for a codomain type B it yields an overall type C = B[0 := u] for an application.Even if C is known a priori, there may be another B for which B[0 := u] = C, possibly leading to many proofs that t @ p u has type C.Unicity of typing solves this issue, as B is then uniquely determined by the type Π p A B of t.The Syntax as a Signature Algebra Definition 43 (Syntax for the theory of signatures).We define the syntax as an element of SignAlg by pairs of untyped syntax and typing relations:Tm I (Γ , Γ w )(A, A w ) := t Γ t ∈ A Sub I (Γ , Γ w )(∆, ∆ w ) := σ Γ σ ⇒ ∆The other fields are given straightforwardly.Regarding the equations, it is enough to prove them only for the untyped syntactic part: as we argued in Lemma 41, the proofs of typing judgments are automatically equal.Remark 44.Up until Definition 43, UIP is not used.Function extensionality on the other hand is necessary because the untyped metatheoretic Π takes a metatheoretic function as an argument.An example induction step that uses function extensionality is in Lemma 38, in particular in the case ( Π T A)[id] = Π T A. Indeed, the left hand side of this equation is equal to Π T (λt.(A t)[id]) by definition, whereas the induction hypothesis states that (t : T ) → (A t)[id] = A t.
The equality (identity) type is written t = u, it has a constructor refl : t = t, and equality reflection, hence we use the same = sign for definitional equality.We occasionally indicate by e1,...,en# t that t is well-typed thanks to the equalities e 1 ,. . .,e n .To construct proofs, sometimes we write equational reasoning, e.g.f a e = f b where e : a = b.We also have uniqueness of identity proofs (UIP), expressing (e : t = t) → e = refl.Note that function extensionality, expressing ((x : Con component in SignAlg is Set i , then SignAlg is in Set i+1 , but as Sign is defined as (SignAlg → . . . ) × ..., it is at least in Set i+1 , so we can't choose Con M : Set i to be Sign : Set i+1 .Note that the notion of IIT signature is relative to a model of ETT: it is expressed as a term (of a function type) in the model.This is necessary because of the function space Π, which has as domain an arbitrary type in the model.We make use of Π in signatures with external parameters, like the type of the elements in lists.Example 8 (Example signature).Now we can formally describe the contexts given inExample 4 as signatures.For natural numbers, we have the following pair of functions.The second function returns an equality proof which we describe using equational reasoning.(nat,natc)

0 1 9 6:12 For Finitary Induction-Induction, Induction is Enough families
[7]erms are functions, the universe U is given by Set, function spaces are given by the external function space.The D column is a logical predicate interpretation, A and D together are a unary version of the parametric model for dependent types[7].Contexts are predicates, types are families of predicates, terms say that the A interpretation respects the predicates (this is ususally called fundamental lemma of the logical predicate).U is given by predicate space, the predicate at a Π type holds for a function if it respects the predicates.For Π, the predicate is defined pointwise.The last column S is a modified dependent logical relation which refers to both A and D .Contexts are binary relations where the second parameter depends on the first one, types are dependent variants of this, terms say that the relation is respected by A and D , respectively.U is however not relation space, but a function and [4]first explain it by columns: the first column ( A components) corresponds to the standard model (set model, metacircular interpretation[4]): contexts are sets, types areT Y P E S 2