ON IRRELEVANCE AND ALGORITHMIC EQUALITY IN PREDICATIVE TYPE THEORY

ANDREAS ABEL AND GABRIEL SCHERER

Department of Computer Science, Ludwig-Maximilians-University Munich

e-mail address: andreas.abel@ifi.lmu.de

Gallium team, INRIA Paris-Rocquencourt e-mail address: gabriel.scherer@gmail.com

Abstract. Dependently typed programs contain an excessive amount of static terms which are necessary to please the type checker but irrelevant for computation. To obtain reasonable performance of not only the compiled program but also the type checker such static terms need to be erased as early as possible, preferably immediately after type checking. To this end, Pfenning’s type theory with irrelevant quantification, that models a distinction between static and dynamic code, is extended to universes and large eliminations. Normalization, consistency, and decidability are obtained via a universal Kripke model based on algorithmic equality.

1. Introduction and Related Work

Dependently typed programming languages such as Agda [BDN09], Coq [INR10], and Epigram [MM04] allow the programmer to express in one language programs, their types, rich invariants, and even proofs of these invariants. Besides code executed at run-time, dependently typed programs contain much code needed only to please the type checker, which is a the same time the verifier of the proofs woven into the program.

Program extraction takes type-checked terms and discards parts that are irrelevant for execution. Augustsson’s dependently typed functional language Cayenne [Aug99] erases types using a universe-based analysis. Coq’s extraction procedure has been designed by Paulin-Mohring and Werner [PMW93] and Letouzey [Let02] and discards not only types but also proofs. The erasure rests on Coq’s universe-based separation between propositional (Prop) and computational parts (Set/Type). The rigid Prop/Set distinction has the drawback of code duplication: A structure which is sometimes used statically and sometimes dynamically needs to be coded twice, once in Prop and once in Set.

An alternative to the fixed Prop/Set-distinction is to let the usage context decide whether a term is a proof or a program. Besides whole-program analyses such as data flow, some type-based analyses have been put forward. One of them is Pfenning’s modal type theory of Intensionality, Extensionality, and Proof Irrelevance [Pfe01], later pursued by Reed [Ree03], which introduces functions with irrelevant arguments that play the role of proofs.^{1} Not only can these arguments be erased during extraction, they can also be disregarded in type conversion tests during type checking. This relieves the user of unnecessary proof burden (proving that two proofs are equal). Furthermore, proofs can not only be discarded during program extraction but directly after type checking, since they will never be looked at again during type checking subsequent definitions.

1998 ACM Subject Classification: F.4.1.

Key words and phrases: dependent types, proof irrelevance, typed algorithm equality, logical relation, universal Kripke model.

Revision and extension of FoSSaCS 2011 conference publication.

LOGICAL METHODS IN COMPUTER SCIENCE  DOI:10.2168/LMCS-???  \begin{matrix}c \\ ◯ \end{matrix} Andreas Abel and Gabriel Scherer Creative Commons

In principle, we have to distinguish “post mortem” program extraction, let us call it external erasure, and proof disposal during type checking, let us call it internal erasure. External erasure deals with closed expressions, programs, whereas internal erasure deals with open expressions that can have free variables. Such free variables might be assumed proofs of (possibly false) equations and block type casts, or (possibly false) proofs of wellfoundedness and prevent recursive functions from unfolding indefinitely. For type checking to not go wrong or loop, those proofs can only be externally erased, thus, the Prop/Set distinction is not for internal erasure. In Pfenning’s type theory, proofs can never block computations even in open expressions (other than computations on proofs), thus, internal erasure is sound.

Miquel’s Implicit Calculus of Constructions (ICC) [Miq01a] goes further than Pfenning and considers also parametric arguments as irrelevant. These are arguments which are irrelevant for function execution but relevant during type conversion checking. Such arguments may only be erased in function application but not in the associated type instantiation. Barras and Bernardo [BB08] and Mishra-Linger and Sheard [MLS08] have build decidable type systems on top of ICC, but both have not fully integrated inductive types and types defined by recursion (large eliminations). Barras and Bernardo, as Miquel, have inductive types only in the form of their impredicative encodings, Mishra-Linger [ML08] gives introduction and elimination principles for inductive types by example, but does not show normalization or consistency.

While Pfenning’s type theory uses typed equality, ICC and its successors interpret typed expressions as untyped λ-terms up to untyped equality. In our experience, the implicit quantification of ICC, which allows irrelevant function arguments to appear unrestricted in the codomain type of the function, is incompatible with type-directed equality. Examples are given in Section 2.3. Therefore, we have chosen to scale Pfenning’s notion of proof irrelevance up to inductive types, and integrated it into Agda.

In this article, we start with the “extensionality and proof irrelevance” fragment of Pfenning’s type theory in Reed’s version [Ree02, Ree03]. We extend it by a hierarchy of predicative universes, yielding Irrelevant Intensional Type Theory IITT (Sec. 2). After specifying a type-directed equality algorithm (Sec. 3), we construct a Kripke model for IITT (Sec. 4). It allows us to prove normalization, subject reduction, and consistency, in one go (Sec. 5). A second Kripke logical relation yields correctness of algorithmic equality and decidability of IITT (Sec. 6). Our models are ready for data types, large eliminations, types with extensionality principles, and internal erasure (Sec. 7).

1 Awodey and Bauer [AB04] give a categorical treatment of proof irrelevance which is very similar to Pfenning and Reed’s. However, they work in the setting of Extensional Type Theory with undecidable type checking, we could not directly use their results for this work.

Contribution and Related Work. We consider the design of our meta-theoretic argument as technical novelty, although it heavily relies on previous works to which we owe our inspiration. Allen [All87] describes a logical relation for Martin-Löf type theory with a countable universe hierarchy. The seminal work of Coquand [Coq91] describes an untyped equality check for the Logical Framework and justifies it by a logical relation for dependent types that establishes subject reduction, normalization, completeness of algorithmic equality, and injectivity of function types in one go. However, his approach cannot be easily extended to a typed algorithmic equality, due to problems with transitivity.

Goguen introduces Typed Operational Semantics [Gog94] to construct a Kripke logical relation that simultaneously proves normalization, subject reduction, and confluence for a variant of the Calculus of Inductive Constructions. From his results one can derive an equality check based on reduction to normal form. Goguen also shows how to derive syntactic properties, such as closure of typing and equality under substitution, by a Kripke-logical relation [Gog00].

Harper and Pfenning [HP05] popularize a type-directed equality check for the Logical Framework that scales to extensionality for unit types. They prove completeness of algorithmic equality by a Kripke model on simple types which are obtained by erasure from the dependent types. Erasure is necessary since algorithmic equality cannot be shown transitive before it is proven sound; yet soundness hinges on subject reduction which rests on function type injectivity which in turn is obtained from completeness of algorithmic equality—a vicious cycle. While erasure breaks the cycle, it also prevents types to be defined by recursion on values (so-called large eliminations), a common feature of proof assistants like Agda, Coq, and Epigram.

Normalization by evaluation (NbE) has been successfully used to obtain a type-directed equality check based on evaluation in the context of dependent types with large eliminations [ACD07]. In previous work [ACD08], the first author applied NbE to justify a variant of Harper and Pfenning’s algorithmic equality without erasure. However, the meta-theoretic argument is long-winded, and there is an essential gap in the proof of transitivity of the Kripke logical relation.

In this work, we explore a novel approach to justify type-directed algorithmic equality for dependent types with predicative universes. First, we show its soundness by a Kripke model built on top of definitional equality. The Kripke logical relation yields normalization, subject reduction, and type constructor injectivity, which also imply logical consistency of IITT. Further, it proves syntactic properties such as closure under substitution, following Goguen’s lead [Gog00]. The semantic proof of such syntactic properties relieves us from the deep lemma dependencies and abundant traps of syntactic meta-theory of dependent types [HP05, AC07]. Soundness of algorithmic equality entails transitivity (which is the stumbling stone), paving the way to show completeness of algorithmic equality by a second Kripke logical relation, much in the spirit of Coquand [Coq91] and Harper and Pfenning [HP05].

This article is a revised and extended version of paper Irrelevance in Type Theory with a Heterogeneous Equality Judgement presented at the conference FoSSaCS 2011 [Abe11]. Unfortunately, the conference version has inherited the above-mentioned gap [ACD08] in the proof of transitivity of the Kripke logical relation. This is fixed in the present article by an auxiliary Kripke model (Section 4). Further, we have dropped the heterogeneous approach to equality in favor of a standard homogeneous one. Heterogeneous equality is not necessary for the style of irrelevance we are embracing here.

2. Irrelevant Intensional Type Theory

In this section, we present Irrelevant Intensional Type Theory IITT which features two of Pfenning’s function spaces [Pfe01], the ordinary “extensional” (x:U) → T and the proof irrelevant (x÷U) → T. The main idea is that the argument of a (x÷U) → T function is counted as a proof and can neither be returned nor eliminated on, it can only be passed as argument to another proof irrelevant function or data constructor. Technically, this is realized by annotating variables as relevant, x:U, or irrelevant, x÷U, in the typing context, to confine occurrences of irrelevant variables to irrelevant arguments.

Expression and context syntax. We distinguish between relevant (t^{:}u or simply t u) and irrelevant application (t^{÷}u). Accordingly, we have relevant (λx: U. T) and irrelevant abstraction (λx÷U. T). Our choice of typed abstraction is not fundamental; a bidirectional type-checking algorithm [Coq96] can reconstruct type and relevance annotations at abstractions and applications.

Var ∋ x, y, X, Y
Sort ∋ s  ::= Set_{k} (k ∈ ℕ)  universes
Ann ∋ ⋆  ::= ÷ | :  annotation: irrelevant, relevant
Exp ∋ t, u, T, U ::= s | (x⋆U) →^{s,s′} T sort, (ir)relevant function type
| x | λx⋆U. t | t^{⋆}u lambda-calculus
Cxt ∋ Γ, Δ ::= ⋄ | Γ. x⋆T empty, (ir)relevant extension

Expressions are considered modulo α-equality, we write t ≡ t′ when we want to stress that t and t′ identical (up to α). Similarly, we consider variables bound in a context to be distinct, and when opening a term binder we will implicitly use α-conversion to add a fresh variable in the context.

For technical reasons, namely, to prove transitivity (Lemma 12) of the Kripke logical

relation in Section 4, we explicitly annotate function types (x⋆U) →^{s,s′} T with the sorts s of domain U and s′ of codomain T. We may omit the annotation if it is inessential or determined by the context of discourse. In case T does not mention x, we may write U → T for (x:U) → T.

Sorts. IITT is a pure type system (PTS) with infinite hierarchy of predicative universes Set_{0} : Set_{1} : .... The universes are not cumulative. We have the PTS axioms Axiom = {(Set_{i}, Set_{i+1}) | i ∈ ℕ} and the rules Rule = {(Set_{i}, Set_{j}, Set_{max(i,j)}) | i, j ∈ ℕ}. As is customary, we will write the side condition (s, s′) ∈ Axiom just as (s, s′) and likewise (s_{1}, s_{2}, s_{3}) ∈ Rule just as (s_{1}, s_{2}, s_{3}). IITT is a full and functional PTS, which means that for all s_{1}, s_{2} there is exactly one s_{3} such that (s_{1}, s_{2}, s_{3}). There is no subtyping, so that types—and thus, sorts—are unique up to equality. A proof of sort unicity might relieve us from the sort annotation in function types, however, we obtain sort discrimination too late in our technical development (Lemma 36).

Substitutions. Substitutions σ are maps from variables to expressions. We require that the domain dom(σ) = {x | σ(x) ≠ x} is finite. We write id for the identity substitution and [u/x] for the singleton substitution σ such that σ(x) := u and σ(y) := y for y ≠ x. Substitution extension (σ, u/x) is formally defined as σ ⊎ [u/x]. Capture avoiding parallel substitution of σ in t is written as juxtaposition tσ.

Contexts. Contexts Γ feature two kinds of bindings, relevant (x:U) and irrelevant (x ÷ U) ones. The intuition, implemented by the typing rules below, is that only relevant variables are in scope in an expression. Resurrection Γ^{÷} turns all irrelevant bindings (x ÷ T) into the corresponding relevant ones (x: T) [Pfe01]. It is the tool to make irrelevant variables, also called proof variables, available in proofs. The generalization Γ^{⋆} shall mean Γ^{÷} if ⋆ = ÷, and just Γ otherwise. We write Γ.Δ for the concatenation of Γ and Δ; herein, we suppose dom(Γ) ∩ dom(Δ) = ∅.

Primitive judgements of IITT. The following three judgements are mutually inductively defined by the rules given below and in Figure 1.

⊢ Γ  Context Γ is well-formed.
Γ ⊢ t : T  In context Γ, expression t has type T.
Γ ⊢ t = t′ : T  In context Γ, t and t′ are equal expressions of type T.

Derived judgements. To simplify notation, we introduce the following four abbreviations:

Γ ⊢ t ÷ T  iff Γ^{÷} ⊢ t : T,
Γ ⊢ t = t′ ÷ T iff Γ ⊢ t ÷ T and Γ ⊢ t′ ÷ T,
Γ ⊢ T  iff Γ ⊢ T : s for some s,
Γ ⊢ T = T′  iff Γ ⊢ T = T′ : s for some s.

Γ ⊢ t ⋆ T may mean Γ ⊢ t : T or Γ ⊢ t ÷ T, depending on the value of placeholder ⋆; same for Γ ⊢ t = t′ ⋆ T. We sometimes write Γ ⊢ t, t′ ⋆ T to abbreviate the conjunction of Γ ⊢ t ⋆ T and Γ ⊢ t′ ⋆ T. The notation Γ ⊢ T, T′ is to be understood similarly.

2.1. Rules. Our rules for well-typed terms Γ ⊢ t : T extend Reed’s rules [Ree02] to PTS style. There are only 6 rules; we shall introduce them one-by-one.

Variable rule. Only relevant variables can be extracted from the context.

\frac{⊢ Γ (x:U) ∈ Γ}{Γ ⊢ x : U}

There is no variable rule for irrelevant bindings (x ÷ U) ∈ Γ, in particular, the judgement x÷U ⊢ x : U is not derivable. This essentially forbids proofs to appear in relevant positions.

Abstraction rule. Relevant and irrelevant functions are introduced analogously.

\frac{Γ. x⋆U ⊢ t : T Γ ⊢ (x⋆U) →^{s,s′} T}{Γ ⊢ λx⋆U. t : (x⋆U) →^{s,s′} T}

To check a relevant function λx:U. t, we introduce a relevant binding x:U into the context and continue checking the function body t. In case of an irrelevant function λx÷U. t, we proceed with an irrelevant binding x ÷ U. This means that an irrelevant function cannot computationally depend on its argument—it is essentially a constant function. In particular, λx÷U. x is never well-typed.

As a side condition, we also need to check that the introduced function type (x⋆U) →^{s,s′} T is well-sorted; the rule is given below.

Application rule.

\frac{Γ ⊢ t : (x⋆U) → T Γ ⊢ u ⋆ U}{Γ ⊢ t^{⋆}u : T [u/x]}

This rule uses our overloaded notations for bindings ⋆, that can be specialized into two different instances for relevant and irrelevant applications.

For relevant functions, we get the ordinary dependently-typed application rule:

\frac{Γ ⊢ t : (x:U) → T Γ ⊢ u : U}{Γ ⊢ t u : T [u/x]}

When applying an irrelevant function, we resurrect the context before checking the function argument.

\frac{Γ ⊢ t : (x÷U) → T Γ^{÷} ⊢ u : U}{Γ ⊢ t^{÷}u : T [u/x]}

This means that irrelevant variables become relevant and can be used in u. The intuition is that the application t^{÷}u does not computationally depend on u, thus, u may refer to any variable, even the “forbidden ones”. One may think of u as a proof which may refer to both ordinary and proof variables.

For example, let Γ = f : (y÷U) → U. Then the irrelevant η-expansion λx÷U. f ^{÷}x is well-typed in Γ, with the following derivation:

\begin{matrix}Γ. x ÷ U ⊢ f : (y÷U) → U & Γ. x : U ⊢ x : U \\ Γ. x ÷ U ⊢ f ^{÷}x : U \end{matrix} ; Γ ⊢ λx ÷ U. f ^{÷}x : (x÷U) → U

Observe how the status of x changes for irrelevant to relevant when we check the argument of f.

Sorting rules. These are the “Axioms” and the “Rules” of PTSs to form types.

\frac{⊢ Γ}{Γ ⊢ s : s′} (s, s′)  \frac{Γ ⊢ U : s_{1}  Γ. x⋆U ⊢ T : s_{2}}{Γ ⊢ (x⋆U) →^{s_{1},s_{2}} T : s_{3}} (s_{1}, s_{2}, s_{3})

The rule for irrelevant function type formation follows Reed [Ree02].

\frac{Γ ⊢ U : s_{1} Γ. x÷U ⊢ T : s_{2}}{Γ ⊢ (x÷U) →^{s_{1},s_{2}} T : s_{3}} (s_{1}, s_{2}, s_{3})

It states that the codomain of an irrelevant function cannot depend relevantly on the function argument. This fact is crucial for the construction of our semantics in Section 4. Note that it rules out polymorphism in the sense of Barras and Bernado’s Implicit Calculus of Constructions ICC^{∗} [BB08] and Mishra-Linger and Sheard’s Erasure Pure Type Systems EPTS [MLS08]; the type (X÷Set_{0}) → (x: X) → X is ill-formed in IITT, but not in ICC^{∗} or EPTS. In EPTS, there is the following rule:

\frac{Γ ⊢ U : s_{1} Γ. x:U ⊢ T : s_{2}}{Γ ⊢ (x÷U) →^{s_{1},s_{2}} T : s_{3}} (s_{1}, s_{2}, s_{3})

It allows the codomain T of an irrelevant function to arbitrarily depend on the function argument x. This is fine in an erasure semantics, but incompatible with our typed semantics in the presence of large eliminations; we will detail the issues in examples 3 and 8.

Another variant is Pfenning’s rule for irrelevant function type formation [Pfe01].

\frac{Γ ⊢ U ÷ s_{1} Γ. x÷U ⊢ T : s_{2}}{Γ ⊢ (x÷U) →^{s_{1},s_{2}} T : s_{3}} (s_{1}, s_{2}, s_{3})

It allows the domain of an irrelevant function to make use of irrelevant variables in scope. It does not give polymorphism, e. g., (X÷Set_{0}) → (x:X) → X is still ill-formed. However, (X÷Set_{0}) → (x÷X) → X would be well-formed. It is unclear how the equality rule for irrelevant function types would look like—it is not given by Pfenning [Pfe01]. The rule

\frac{Γ ⊢ U = U′ ÷ s_{1} Γ. x÷U ⊢ T = T′ : s_{2}}{Γ ⊢ (x÷U) →^{s_{1},s_{2}} T = (x÷U′) →^{s_{1},s_{2}} T′ : s_{3}} (s_{1}, s_{2}, s_{3})

would mean that any two irrelevant function types are equal as long as their codomains are equal—their domains are irrelevant. This is not compatible with our typed semantics and seems a bit problematic in general.^{2}

Type conversion rule. We have typed conversion, thus, strictly speaking, IITT is not a PTS, but a Pure Type System with Judgemental Equality [Ada06].

\frac{Γ ⊢ t : T Γ ⊢ T = T′}{Γ′ ⊢ t : T′}

Equality. Figure 1 recapitulates the typing rules and lists the rules to derive context wellformedness ⊢ Γ and equality Γ ⊢ t = t′ : T. Equality is the least congruence over the βand η-axioms. Since equality is typed we can extend IITT to include an extensional unit type (Section 7). Let us inspect the congruence rule for application:

\frac{Γ ⊢ t = t′:(x⋆U) → T Γ ⊢ u = u′ ⋆ U}{Γ ⊢ t^{⋆}u = t′ ^{⋆}u′ : T [u/x]}

In case of relevant functions (⋆ = :) we obtain the usual dependently-typed application rule of equality. Otherwise, we get:

\frac{Γ ⊢ t = t′:(x÷U) → T  Γ^{÷} ⊢ u : U  Γ^{÷} ⊢ u′ : U}{Γ ⊢ t^{÷}u = t′ ^{÷}u′ : T [u/x]}

Note that the arguments u and u′ to the irrelevant functions need to be well-typed but not related to each other. This makes precise the intuition that t and t′ are constant functions.

2.2. Simple properties of IITT. In the following, we prove two basic invariants of derivable IITT-judgements: The context is always well-formed, and judgements remain derivable under well-formed context extensions (weakening).

Lemma 1 (Context well-formedness).

(1) If ⊢ Γ. x:U. Γ′ then Γ ⊢ U.

(2) If Γ ⊢ t : T or Γ ⊢ t = t′ : T then ⊢ Γ.

Proof. By a simple induction on the derivations. □

2Maybe this is the reason why Reed [Ree02] differs from Pfenning.

Context well-formedness.  ⊢ Γ
\overline{⊢ ⋄}  \frac{⊢ Γ  Γ ⊢ T}{⊢ Γ. x⋆T}
Typing.  Γ ⊢ t : T
\frac{⊢ Γ}{Γ ⊢ s : s′} (s, s′)  \frac{Γ ⊢ U : s_{1}  Γ. x⋆U ⊢ T : s_{2}}{Γ ⊢ (x⋆U) →^{s_{1},s_{2}} T : s_{3}} (s_{1}, s_{2}, s_{3})
\frac{⊢ Γ  (x:U) ∈ Γ}{Γ ⊢ x : U}  \frac{Γ. x⋆U ⊢ t : T  Γ ⊢ (x⋆U) →^{s,s′} T}{Γ ⊢ λx⋆U. t : (x⋆U) →^{s,s′} T}
\frac{Γ ⊢ t : (x⋆U) → T  Γ ⊢ u ⋆ U}{Γ ⊢ t^{⋆}u : T [u/x]}  \frac{Γ ⊢ t : T  Γ ⊢ T = T′}{Γ′ ⊢ t : T′}
Equality.  Γ ⊢ t = t′ : T

Computation (β) and extensionality (η).

\frac{Γ. x⋆U ⊢ t : T  Γ ⊢ u ⋆ U}{Γ ⊢ (λx⋆U. t)^{⋆}u = t[u/x] : T [u/x]}  \frac{Γ ⊢ t : (x⋆U) →^{s,s′} T}{Γ ⊢ t = λx⋆U. t^{⋆}x : (x⋆U) →^{s,s′} T}

Equivalence rules.

\frac{Γ ⊢ t : T}{Γ ⊢ t = t : T} \frac{Γ ⊢ t = t′ : T}{Γ ⊢ t′ = t : T} \frac{Γ ⊢ t_{1} = t_{2} : T Γ ⊢ t_{2} = t_{3} : T}{Γ ⊢ t_{1} = t_{3} : T}

Compatibility rules.

\frac{Γ ⊢ U = U′ : s_{1} Γ. x⋆U ⊢ T = T′ : s_{2}}{Γ ⊢ (x⋆U) →^{s_{1},s_{2}} T = (x⋆U′) →^{s_{1},s_{2}} T′ : s_{3}} (s_{1}, s_{2}, s_{3})

\frac{Γ ⊢ U = U′ : s_{1}  Γ. x⋆U ⊢ T : s_{2}  Γ. x⋆U ⊢ t = t′ : T}{Γ ⊢ λx⋆U. t = λx⋆U′. t′ : (x⋆U) →^{s_{1},s_{2}} T}

\frac{Γ ⊢ t = t′:(x⋆U) → T Γ ⊢ u = u′ ⋆ U}{Γ ⊢ t^{⋆}u = t′ ^{⋆}u′ : T [u/x]}

Conversion rule.

\frac{Γ ⊢ t = t′ : T Γ ⊢ T = T′}{Γ ⊢ t = t′ : T′}

Figure 1: Rules of IITT

It should be noted that we only prove the most basic well-formedness statements here. One would expect that Γ ⊢ t : T or Γ ⊢ t = t′ : T also implies Γ ⊢ T, or that Γ ⊢ t = t′ : T implies Γ ⊢ t : T. This is true—and we will refer to these implications as syntactic validity—but this cannot be proven without treatment of substitution, due to the typing rule for application, which requires substitution in the type, and due to the equality rule for a β-redex, which uses substitution in both term and type. Therefore, syntactic validity is delayed until Section 4 (Corollary 26), where substitution will be handled by semantic, rather than syntactic, methods.

Weakening. We can weaken a context Γ by adding bindings or making irrelevant bindings relevant. Formally, we have an order on binding annotations, which is the order induced by : ≤ ÷, and we define weakening by monotonic extension.

A well-formed context ⊢ Δ extends a well-formed context ⊢ Γ, written Δ ≤ Γ, if and only if:

∀x ∈ dom(Γ), (x ⋆_{1} U) ∈ Γ ⟹ (x ⋆_{2} U) ∈ Δ with ⋆_{1} ≤ ⋆_{2}.

Note that this allows to insert new bindings or relax existing ones at any position in Γ, not just at the end.

Lemma 2 (Weakening). Let Δ ≤ Γ.

(1) If ⊢ Γ.Γ′ and dom(Δ) ∩ dom(Γ′) = ∅ then ⊢ Δ.Γ′.

(2) If Γ ⊢ t : T then Δ ⊢ t : T.

(3) If Γ ⊢ t = t′ : T′ then Δ ⊢ t = t′ : T.

Proof. Simultaneously by induction on the derivation. Let us look at some cases: Case

\frac{⊢ Γ}{Γ ⊢ s = s : s′} (s, s′)

By assumption ⊢ Δ, thus Δ ⊢ s = s : s′.

Case

\frac{(x:U) ∈ Γ ⊢ Γ}{Γ ⊢ x = x : U}

Since Δ ≤ Γ we have (x:U) ∈ Δ, thus Δ ⊢ x = x : U.

Case

\frac{Γ ⊢ U = U′ : s_{1}  Γ. x⋆U ⊢ T : s_{2}  Γ. x⋆U ⊢ t = t′ : T}{Γ ⊢ λx⋆U. t = λx⋆U′. t′ : (x⋆U) →^{s_{1},s_{2}} T}

W. l. o. g., x ∉ dom(Δ). By (1) and definition of context weakening, Δ ≤ Γ implies Δ. x⋆U ≤ Γ. x⋆U, so all premises can be appropriately weakened by induction hypothesis.

□

2.3. Examples.

Example 3 (Relevance of types). ^{3} We can extend IITT by a unit type 1 with extensionality principle.

\frac{⊢ Γ}{Γ ⊢ 1 : Set_{i}}  \frac{⊢ Γ}{Γ ⊢ () : 1}  \frac{Γ ⊢ t : 1  Γ ⊢ t′ : 1}{Γ ⊢ t = t′ : 1}

Typed equality allows us to equate all inhabitants of the unit type. As a consequence, the Church numerals over the unit type all coincide, e. g.,

\begin{matrix}Γ ⊢ & λf:1 → 1. λx:1. x \\ = & λf:1 → 1. λx:1. f x : (1 → 1) → 1 → 1. \end{matrix}

In systems with untyped equality, like ICC^{∗} and EPTS, these terms erase to untyped Church-numerals λfλx.x and λfλx. f x and are necessarily distinguished.

If we trade the unit type for Bool or any other type with more than one inhabitant, the two terms become different in IITT. This means that in IITT, types are relevant, and we need to reject irrelevant quantification over types like in (X÷Set_{0}) → (X → X) → X → X. In IITT, the polymorphic types of Church numerals are (X:Set_{i}) → (X → X) → X → X.

Example 4 (Σ-types). IITT can be readily extended by weak Σ-types.

\frac{Γ ⊢ U : s_{1} Γ. x⋆U ⊢ T : s_{2}}{Γ ⊢ (x⋆U) × T : s_{3}} (s_{1}, s_{2}, s_{3})

\frac{Γ ⊢ u ⋆ U  Γ ⊢ t : T [u/x]  Γ ⊢ (x⋆U) × T}{Γ ⊢ (u, t) : (x⋆U) × T}

\frac{Γ ⊢ p : (x⋆U) × T Γ. x⋆U. y:T ⊢ v : V}{Γ ⊢ let (x, y) = p in v : V}

\frac{Γ ⊢ u ⋆ U  Γ ⊢ t : T [u/x]  Γ. x⋆U. y:T ⊢ v : V  Γ ⊢ (x⋆U) × T}{Γ ⊢ (let (x, y) = (u, t) in v) = v[u/x][t/y] : V}

Additional laws for equality could be considered, like commuting conversions, or the identity (let (x, y) = p in (x, y)) = p. The relevant form (x: U) × T admits a strong version with projections fst and snd and full extensionality p = (fst p, snd p) : (x : U) × T. However, strong irrelevant Σ-types (x÷U) × T are problematic because of the first projection:

\frac{Γ ⊢ p : (x÷U) × T}{Γ ⊢ fst p ÷ U}

With our definition of Γ ⊢ u ÷ U as Γ^{÷} ⊢ u : U, this rule is misbehaved: it allows us get hold of an irrelevant value in a relevant context. We could define a closed function π_{1} : (x÷U) × 1 → U, and composing it with ( , ()) : (x÷U) → (x÷U) × 1 would give us an identity function of type (x÷U) → U which magically makes irrelevant things relevant and IITT inconsistent. In this article, we will not further consider strong Σ-types with irrelevant components; we leave the in-depth investigation to future work.

Example 5 (Squash type). The squash type ||T || was first introduced in the context of NuPRL [CAB^{+}86]; it contains exactly one inhabitant iff T is inhabited. Semantically, one obtains ||T || from T by equating all of T ’s inhabitants. In IITT, we can define ||T || as internalization of the irrelevance modality, as already suggested by Pfenning [Pfe01]. The first alternative is via the weak irrelevant Σ-type.

3Example suggested by a reviewer of this paper.

|| ||  : Set_{i} → Set_{i}
|| ||  := λT:Set_{i}. ( ÷T) × 1
[ ]  : (x÷T) → ||T ||
[ ]  := λx÷T. (x, ())
sqelim : (T:Set_{i}) →
(P:||T || → Set_{j}) →
(f:(x÷T) → P ([x])) →
(t:||T ||) →
P t
sqelim := λT:Set_{i}.
λP:||T || → Set_{j}.
λf:(x÷T) → P ([x]).
λt:||T ||.
let (x, ) = t in f ^{÷}x

It is not hard to see that || || is a monad. All canonical inhabitants of ||T || are definitionally equal:

\frac{Γ ⊢ t, t′ ÷ T}{Γ ⊢ [t] = [t′] : ||T ||}

This is easily shown by expanding the definition of [ ] and using the congruence rule for pairs with an irrelevant first component.

However, we cannot show that all inhabitants of ||T || are definitionally equal, because of the missing extensionality principles for weak Σ. Thus, the second alternative is to add the squash type to IITT via the rules:

\frac{Γ ⊢ T : Set_{i}}{Γ ⊢ ||T || : Set_{i}}  \frac{Γ ⊢ t ÷ T}{Γ ⊢ [t] : ||T ||}  \frac{Γ ⊢ t : ||T ||  Γ. x÷T ⊢ v : V}{Γ ⊢ let [x] = t in v : V}

\frac{Γ ⊢ t, t′ : ||T ||}{Γ ⊢ t = t′ : ||T ||}  \frac{Γ ⊢ t ÷ T  Γ. x÷T ⊢ v : V}{Γ ⊢ (let [x] = [t] in v) = v[t/x] : V}

Our model (Section 4) is ready to interpret these rules, as well as normalization-by-evaluation inspired models [ACP11].

Example 6 (Subset type). The subset type {x : U | T } is definable from Σ and squash as (x:U) × ||T ||.

To discuss the next example, we consider a further extension of IITT by Leibniz equality and natural numbers:

a ≡ b : Set_{i}  for A : Set_{i} and a, b : A
refl  : a ≡ a for A : Set_{i} and a : A
Nat  : Set_{i}
0, 1, …: Nat
+, ∗ : Nat → Nat → Nat.

Example 7 (Composite). ^{4} Let the set of composite numbers {4, 6, 8, 9, 10, 12, 14, 15, … } be numbers that are the product of two natural numbers ≥ 2.

Composite = {n : Nat | (k:Nat) × (l:Nat) × (n ≡ (k + 2) ∗ (l + 2))}

Most composite numbers have several factorizations, and thanks to irrelevance the specific composition is ignored when handling composite numbers. For instance, 12 as product of 3 and 4 is not distinguished from the 12 as product of 2 and 6.

(12, [(1, (2, refl))]) = (12, [(0, (4, refl))]) : Composite.

Example 8 (Large eliminations). ^{5} The ICC^{∗} [BB08] or EPTS [MLS08] irrelevant function type (x ÷ A) → B allows x to appear relevantly in B. This extra power raises some issues with large eliminations. Consider

T  : Bool → Set_{0}
T true = Bool → Bool
T false = Bool
t  = λF : (b÷Bool) → (T b → T b) → Set_{0}.
λg : (F ^{÷}false (λx : Bool. x)) → Bool.
λa : F ^{÷}true (λx : Bool → Bool.λy : Bool. x y). g a.

The term t is well-typed in ICC^{∗} + T because the domain type of g and the type of a are βη-equal after erasure (−)^{∗} of type annotations and irrelevant arguments:

(F ^{÷}false (λx : Bool. x))^{∗} = F (λxx)
=_{βη} F (λxλy. x y) = (F ^{÷}true (λx : Bool → Bool.λy : Bool. x y))^{∗}

While a Curry view supports this, it is questionable whether identity functions at different types should be viewed as one. It is unclear how a type-directed equality algorithm (see Sec. 3) should proceed here; it needs to recognize that x : Bool is equal to λy: Bool. x y : Bool → Bool. This situation is amplified by a unit type 1 with extensional equality. When we change T true to 1 and the type of a to F ^{÷}true (λx:1. ()) then t should still type-check, because λx. () is the identity function on 1. However, η-equality for 1 cannot be checked without types, and a type-directed algorithm would end up checking (successfully) x : Bool for equality with () : 1. This algorithmic equality cannot be transitive, because then any two booleans would be equal.

Summarizing, we may conclude that the type of F bears trouble and needs to be rejected. IITT does this because it forbids the irrelevant b in relevant positions such as T b; ICC^{∗} lacks T altogether. Extensions of ICC^{∗} should at least make sure that b is never eliminated, such as in T b. Technically, T would have to be put in a separate class of recursive functions, those that actually compute with their argument. We leave the interaction of the three different function types to future research.

4Example suggested by reviewer.

5Inspired by discussions with Ulf Norell during the 11th Agda Implementers’ Meeting.

3. Algorithmic Equality

The algorithm for checking equality in IITT is inspired by Harper and Pfenning [HP05]. Like theirs, it is type-directed, but we are using the full dependent type and not an erasure to simple types (which would anyway not work due to large eliminations). We give the algorithm in form of judgements and rules in direct correspondence to a functional program.

Algorithmic equality is meant to be used as part of a type checking algorithm. It is the algorithmic counterpart of the definitional conversion rule; in particular, it will only be called on terms that are already know to be well-typed – in fact, types that are well-sorted. We rely on this precondition in the algorithmic formulation.

Algorithmic equality consists of three interleaved judgements. A type equality test checks equality between two types, by inspecting their weak head normal forms. Terms found inside dependent types are reduced and the resulting neutral terms are compared by structural equality. The head variable of such neutrals provides type information that is then used to check the (non-normal) arguments using type-directed equality, by reasoning on the (normalized) type structure to perform η-expansions on product types. After enough expansions, a base type is reached, where structural equality is called again, or a sort, at which we use type equality.

Informally, the interleaved reductions are the algorithmic counterparts of the β-equality axiom, the type and structural equalities account for the compatibility rules, and typedirected equality corresponds to the η-equality axiom. The remaining equivalence rules are emergent global properties of the algorithm.

Weak head reduction. Weak head normal forms (whnfs) are given by the following grammar:

Whnf ∋ a, b, f, A, B, F ::= s | (x⋆U) →^{s,s′} T | λx⋆U. t | n whnf
Wne ∋ n, N  ::= x | n^{⋆}u  neutral whnf

Weak head evaluation t ↘ a and active application f @^{⋆} u ↘ a are functional relations given by the following rules.

\frac{t ↘ f  f @^{⋆} u ↘ a}{t^{⋆}u ↘ a}  \overline{a ↘ a}  \frac{t[u/x] ↘ a}{(λx⋆U. t) @^{⋆} u ↘ a}  \overline{n @^{⋆} u ↘ n^{⋆}u}

Instead of writing the propositions t ↘ a and P [a] we will sometimes simply write P [↓t]. Similarly, we might write P [f @^{⋆} u] instead of f @^{⋆} u ↘ a and P [a]. In rules, it is understood that the evaluation judgement is always an extra premise, never an extra conclusion.

Algorithmic equality is given as type equality, structural equality, and type-directed equality, which are mutually recursive. The equality algorithm is only invoked on wellformed expressions of the correct type.

Type equality. Type equality Δ ⊢ A ⟺ A′, for weak head normal forms, and Δ ⊢ T ⟺ T′, for arbitrary well-formed types, checks that two given types are equal in their respective contexts.

\frac{Δ ⊢ ↓T ⟺ ↓T′}{Δ ⊢ T ⟺ T′}  \frac{Δ ⊢ N ⟷ N′ : T}{Δ ⊢ N ⟺ N′}

\overline{Δ ⊢ s ⟺ s}  \frac{Δ ⊢ U ⟺ U′  Δ. x:U ⊢ T ⟺ T′}{Δ ⊢ (x⋆U) →^{s,s′} T ⟺ (x⋆U′) →^{s,s′} T′}

Note that when invoking structural equality on neutral types N and N′, we do not care which type T is returned, since we know by well-formedness that N and N′ must have the same sort.

Structural equality. Structural equality Δ ⊢ n ⟷ n′ : A and Δ ⊢ n ⟷ n′ : T checks the neutral expressions n and n′ for equality and at the same time infers their type, which is returned as output.

\frac{Δ ⊢ n ⟷ n′ : T}{Δ ⊢ n ⟷ n′ : ↓T}  \frac{(x:T) ∈ Δ}{Δ ⊢ x ⟷ x : T}

\frac{Δ ⊢ n ⟷ n′ : (x:U) → T  Δ ⊢ u ⟺ u′ : U}{Δ ⊢ n u ⟷ n′ u′ : T [u/x]}  \frac{Δ ⊢ n ⟷ n′ : (x÷U) → T}{Δ ⊢ n^{÷}u ⟷ n′ ^{÷}u′ : T [u/x]}

Type-directed equality. Type-directed equality Δ ⊢ t ⟺ t′ : A and Δ ⊢ t ⟺ t′ : T checks terms t and t′ for equality and proceeds by the structure of the supplied type, to account for η.

\frac{Δ ⊢ t ⟺ t′ : ↓T}{Δ ⊢ t ⟺ t′ : T}  \frac{Δ. x⋆U ⊢ t^{⋆}x ⟺ t′ ^{⋆}x : T}{Δ ⊢ t ⟺ t′ : (x⋆U) → T}

\frac{Δ ⊢ T ⟺ T′}{Δ ⊢ T ⟺ T′ : s}  \frac{Δ ⊢ ↓t ⟷ ↓t′ : T}{Δ ⊢ t ⟺ t′ : N}

Note that in the but-last rule we do not check that the inferred type T of ↓t equals the ascribed type N. Since algorithmic equality is only invoked for well-typed t, we know that this must always be the case. Skipping this test is a conceptually important improvement over Harper and Pfenning [HP05].

Due to dependent typing, it is not obvious that algorithmic equality is symmetric and transitive. For instance, consider symmetry in case of application: We have to show that Δ ⊢ n′ u′ ⟷ n u : T [u/x], but using the induction hypothesis we obtain this equality only at type T [u′/x]. To conclude, we need to convert types, which is only valid if we know that u and u′ are actually equal. Thus, we need soundness of algorithmic equality to show its transitivity. Soundness w. r. t. declarative equality requires subject reduction, which is not trivial, due to its dependency on function type injectivity. In the next section (4), we construct by a Kripke logical relation which gives us subject reduction and soundness of algorithmic equality (Section 5), and, finally, symmetry and transitivity of algorithmic equality.

A simple fact about algorithmic equality is that the inferred types are unique up to syntactic equality (where we consider α-convertible expressions as identical). Also, they only depend on the left hand side neutral term n.

Lemma 9 (Uniqueness of inferred types).

(1) If Δ ⊢ n ⟷ n_{1} : A_{1} and Δ ⊢ n ⟷ n_{2} : A_{2} then A_{1} ≡ A_{2}.

(2) If Δ ⊢ n ⟷ n_{1} : T_{1} and Δ ⊢ n ⟷ n_{2} : T_{2} then T_{1} ≡ T_{2}.

Extending structural equality to irrelevance, we let

\frac{Δ^{÷} ⊢ n ⟷ n : A Δ^{÷} ⊢ n′ ⟷ n′ : A}{Δ ⊢ n ⟷ n′ ÷ A}

and analogously for Δ ⊢ n ⟷ n′ ÷ T.

4. A Kripke Logical Relation for Soundness

In this section, we construct a Kripke logical relation in the spirit of Goguen [Gog00] and Vanderwaart and Crary [VC02] that proves weak head normalization, function type injectivity, and subject reduction plus syntactical properties like substitution in judgements and syntactical validity. As an important consequence, we obtain soundness of algorithmic equality w. r. t. definitional equality. This allows us to establish that algorithmic equality on well-typed terms is a partial equivalence relation.

4.1. An Induction Measure. Following Goguen [Gog94] and previous work [ACD08], we first define a semantic universe hierarchy U_{i} whose sole purpose is to provide a measure for defining a logical relation and proving some of its properties. The limit U_{ω} corresponds to the proof-theoretic strength or ordinal of IITT.

We denote sets of expressions by A, B and functions from expressions to sets of expressions by F. Let Â = {t | ↓t ∈ A} denote the closure of A by weak head expansion. The dependent function space is defined as Π A F = {f ∈ Whnf | ∀u ∈ Â. f @ u ∈ F(u)}.

By recursion on i ∈ ℕ we define inductively sets U_{i} ⊆ Whnf × P(Whnf) as follows [ACD08, Sec. 5.1]:

\overline{(N, Wne) ∈ U_{i}} \overline{(Set_{j}, |U_{j}|) ∈ U_{i}} (Set_{j}, Set_{i}) ∈ Axiom

\frac{(U, A) ∈ Û_{i} ∀u ∈ Â. (T [u/x], F(u)) ∈ Û_{j}}{((x⋆U) → T, Π A F) ∈ U_{k}} (Set_{i}, Set_{j}, Set_{k}) ∈ Rule

Herein, Û_{i} = {(T, A) | (↓T, A) ∈ U_{i}} and |U_{j}| = {A | (A, A) ∈ U_{j} for some A}. Only interested in computational strength, we treat relevant and irrelevant function spaces alike— at the level of predicates A, irrelevance is anyhow not observable, only by relations as given later.

The induction measure A ∈ Set_{i} shall now mean the minimum height of a derivation of (A, A) ∈ U_{i} for some A. Note that due to universe stratification, A ∈ Set_{i} is smaller than Set_{i} ∈ Set_{j}.

4.2. A Kripke Logical Relation. Let Δ ⊢ t :=: t′ ⋆ T stand for the conjunction of the propositions

• Δ ⊢ t ⋆ T and Δ ⊢ t′ ⋆ T, and

• Δ ⊢ t = t′ ⋆ T.

By induction on A ∈ s we define two Kripke relations

\begin{matrix}Δ ⊢ A & Ⓢ & A′ : s \\ Δ ⊢ a & Ⓢ & a′ : A. \end{matrix}

together with their respective closures ˆⓈ and the generalization to ⋆. For better readability, the clauses are given in rule form meaning that the conclusion is defined as the conjunction of the premises. ∀ and ⟹ are meta-level quantification and implication, respectively.

\frac{Δ ⊢ N :=: N′ : s}{Δ ⊢ N Ⓢ N′ : s}  \frac{Δ ⊢ n :=: n′ : N}{Δ ⊢ n Ⓢ n′ : N}  \frac{⊢ Δ}{Δ ⊢ s Ⓢ s : s′} (s, s′)

\frac{\begin{matrix}Δ ⊢ U ˆⓈ U′ : s_{1} \\ ∀Γ ≤ Δ, Γ ⊢ u ˆⓈ u′ ⋆ U ⟹ Γ ⊢ T [u/x] ˆⓈ T′[u′/x] : s_{2} \\ Δ ⊢ (x⋆U) →^{s_{1},s_{2}} T :=: (x⋆U′) →^{s_{1},s_{2}} T′ : s_{3} \end{matrix}}{Δ ⊢ (x⋆U) →^{s_{1},s_{2}} T Ⓢ (x⋆U′) →^{s_{1},s_{2}} T′ : s_{3}} (s_{1}, s_{2}, s_{3})

\frac{\begin{matrix}∀Γ ≤ Δ, Γ ⊢ u ˆⓈ u′ ⋆ U ⟹ Γ ⊢ f ^{⋆}u ˆⓈ f′ ^{⋆}u′ : T [u/x] \\ Δ ⊢ f :=: f′ : (x⋆U) →^{s,s′} T \end{matrix}}{Δ ⊢ f Ⓢ f′ : (x⋆U) →^{s,s′} T}

\frac{\begin{matrix}T ↘ A  Δ ⊢ T = A \\ t ↘ a  Δ ⊢ t = a : A  Δ ⊢ t′ = a′ : A  t′ ↘ a′ \\ Δ ⊢ a Ⓢ a′ : A \\ Δ ⊢ t :=: t′ : T \end{matrix}}{Δ ⊢ t ˆⓈ t′ : T}

\frac{Δ^{÷} ⊢ a Ⓢ a : A  Δ^{÷} ⊢ a′ Ⓢ a′ : A}{Δ ⊢ a Ⓢ a′ ÷ A}  \frac{Δ^{÷} ⊢ t ˆⓈ t : T  Δ^{÷} ⊢ t′ ˆⓈ t′ : T}{Δ ⊢ t ˆⓈ t′ ÷ T}

It is immediate that the logical relation contains only well-typed and definitionally equal terms. We will demonstrate that it is also closed under weakening and conversion, symmetric and transitive.

Lemma 10 (Weakening).

(1) If Δ ⊢ a Ⓢ a′ : A and Γ ≤ Δ then there exists a derivation of Γ ⊢ a Ⓢ a′ : A with the same height.

(2) Analogously for Δ ⊢ t ˆⓈ t′ : T.

Proof. By induction on A ∈ s and T ∈ s, resp. □

Lemma 11 (Type conversion).

(1) If Γ ⊢ A Ⓢ A′ : s then Γ ⊢ a Ⓢ a′ : A iff Γ ⊢ a Ⓢ a′ : A′.

(2) If Γ ⊢ T ˆⓈ T′ : s then Γ ⊢ t ˆⓈ t′ : T iff Γ ⊢ t ˆⓈ t′ : T′.

Proof. Simultaneously induction in A ∈ s and T ∈ s, resp. We show the “if” direction, the “only if” follows analogously. The interesting case is the one of functions.

Case

\frac{\begin{matrix}Δ ⊢ U ˆⓈ U′ : s_{1} \\ ∀Γ ≤ Δ, Γ ⊢ u ˆⓈ u′ ⋆ U ⟹ Γ ⊢ T [u/x] ˆⓈ T′[u′/x] : s_{2} \\ Δ ⊢ (x⋆U) →^{s_{1},s_{2}} T :=: (x⋆U′) →^{s_{1},s_{2}} T′ : s_{3} \end{matrix}}{Δ ⊢ (x⋆U) →^{s_{1},s_{2}} T Ⓢ (x⋆U′) →^{s_{1},s_{2}} T′ : s_{3}}

\frac{\begin{matrix}∀Γ ≤ Δ, Γ ⊢ u ˆⓈ u′ ⋆ U ⟹ Γ ⊢ f ^{⋆}u ˆⓈ f′ ^{⋆}u′ : T [u/x] \\ Δ ⊢ f :=: f′ : (x⋆U) →^{s,s′} T \end{matrix}}{Δ ⊢ f Ⓢ f′ : (x⋆U) →^{s,s′} T}

First, Δ ⊢ f :=: f′ : (x⋆U′) →^{s,s′} T′, holds because of the conversion rule for typing and equality. Now assume arbitrary Γ ≤ Δ and Γ ⊢ u ˆⓈ u′⋆U′ and show Γ ⊢ f ^{⋆}u ˆⓈ f′ ^{⋆}u′ : T′[u/x]. By induction hypothesis on U ∈ s_{1} we have Γ ⊢ u ˆⓈ u′ ⋆ U, thus, Γ ⊢ f ^{⋆}u ˆⓈ f′ ^{⋆}u′ : T [u/x] by assumption. By induction hypothesis on T [u/x] ∈ s_{2} we obtain Γ ⊢ f ^{⋆}u ˆⓈ f′ ^{⋆}u′ : T′[u/x].

□

Lemma 12 (Symmetry and Transitivity). Let Δ ⊢ T ˆⓈ T : s.

(1) If Δ ⊢ t ˆⓈ t′ : T then Δ ⊢ t′ ˆⓈ t : T.

(2) If Δ ⊢ t_{1} ˆⓈ t_{2} : T and Δ ⊢ t_{2} ˆⓈ t_{3} : T then Δ ⊢ t_{1} ˆⓈ t_{3} : T.

Proof. We generalize the two statements to whnfs Δ ⊢ A Ⓢ A : s and prove all four statements simultaneously by induction in A ∈ s and T ∈ s, resp.

Case Let us look at the case for functions.

\frac{\begin{matrix}Δ ⊢ U ˆⓈ U : s_{1} \\ ∀Γ ≤ Δ, Γ ⊢ u ˆⓈ u′ ⋆ U ⟹ Γ ⊢ T [u/x] ˆⓈ T [u′/x] : s_{2} \\ Δ ⊢ (x⋆U) →^{s_{1},s_{2}} T :=: (x⋆U) →^{s_{1},s_{2}} T : s_{3} \end{matrix}}{Δ ⊢ (x⋆U) →^{s_{1},s_{2}} T Ⓢ (x⋆U) →^{s_{1},s_{2}} T : s_{3}}

Subcase Symmetry:

\frac{\begin{matrix}∀Γ ≤ Δ, Γ ⊢ u ˆⓈ u′ ⋆ U ⟹ Γ ⊢ f ^{⋆}u ˆⓈ f′ ^{⋆}u′ : T [u/x] \\ Δ ⊢ f :=: f′ : (x⋆U) → T \end{matrix}}{Δ ⊢ f Ⓢ f′ : (x⋆U) → T}

To show Δ ⊢ f′ Ⓢ f : (x⋆U) → T, assume arbitrary Γ ≤ Δ and Γ ⊢ u′ ˆⓈ u⋆U and show Γ ⊢ f′ ^{⋆}u′ ˆⓈ f ^{⋆}u : T [u′/x]. By induction hypothesis on U ∈ s_{2}, with weakened Γ ⊢ U ˆⓈ U : s_{1}, we have Γ ⊢ u ˆⓈ u′ ⋆ U, thus, Γ ⊢ f ^{⋆}u ˆⓈ f′ ^{⋆}u′ : T [u/x] by assumption. Using symmetry and transitivity on U we obtain Γ ⊢ u ˆⓈ u ⋆ U, thus, Γ ⊢ T [u/x] ˆⓈ T [u/x] : s_{2}. By induction hypothesis on T [u/x] ∈ s_{2} we apply symmetry to obtain Γ ⊢ f′ ^{⋆}u′ ˆⓈ f ^{⋆}u : T [u/x], and since Γ ⊢ T [u/x] ˆⓈ T [u′/x] : s_{2} we conclude by type conversion (Lemma 11).

Subcase Transitivity:

\frac{\begin{matrix}∀Γ ≤ Δ, Γ ⊢ u ˆⓈ u′ ⋆ U ⟹ Γ ⊢ f_{1} ^{⋆}u ˆⓈ f_{2} ^{⋆}u′ : T [u/x] \\ Δ ⊢ f_{1} :=: f_{2} : (x⋆U) →^{s,s′} T \end{matrix}}{Δ ⊢ f_{1} Ⓢ f_{2} : (x⋆U) →^{s,s′} T}

\frac{\begin{matrix}∀Γ ≤ Δ, Γ ⊢ u ˆⓈ u′ ⋆ U ⟹ Γ ⊢ f_{2} ^{⋆}u ˆⓈ f_{3} ^{⋆}u′ : T [u/x] \\ Δ ⊢ f_{2} :=: f_{3} : (x⋆U) →^{s,s′} T \end{matrix}}{Δ ⊢ f_{2} Ⓢ f_{3} : (x⋆U) →^{s,s′} T}

We wish to prove that Δ ⊢ f_{1} Ⓢ f_{3} : (x⋆U) →^{s,s′} T. We get Δ ⊢ f_{1} :=: f_{3} :

(x⋆U) →^{s,s′} T immediately by transitivity of definitional equality. Given Γ ≤ Δ and Γ ⊢ u ˆⓈ u′ ⋆ U, we need to show that Γ ⊢ f_{1} ^{⋆}u ˆⓈ f_{3} ^{⋆}u′ : T [u/x]. As Γ ⊢ ˆⓈ : U is a PER by induction hypothesis, we have Γ ⊢ u ˆⓈ u ⋆ U, which entails f_{1} ^{⋆}u ˆⓈ f_{2} ^{⋆}u : T [u/x]. From Γ ⊢ u ˆⓈ u′ ⋆ U also have Γ ⊢ f_{2} ^{⋆}u ˆⓈ f_{3} ^{⋆}u′ : T [u/x], which allows to conclude Γ ⊢ f_{1} ^{⋆}u ˆⓈ f_{3} ^{⋆}u′ : T [u/x] by transitivity at T [u/x].

Case Now, we consider function spaces: Subcase Transitivity:

\frac{\begin{matrix}Δ ⊢ U_{1} ˆⓈ U_{2} : s_{1} \\ ∀Γ ≤ Δ, Γ ⊢ u ˆⓈ u′ ⋆ U_{1} ⟹ Γ ⊢ T_{1}[u/x] ˆⓈ T_{2}[u′/x] : s_{2} \\ Δ ⊢ (x⋆U_{1}) →^{s_{1},s_{2}} T_{1} :=: (x⋆U_{2}) →^{s_{1},s_{2}} T_{2} : s_{3} \end{matrix}}{Δ ⊢ (x⋆U_{1}) →^{s_{1},s_{2}} T_{1} Ⓢ (x⋆U_{2}) →^{s_{1},s_{2}} T_{2} : s_{3}}

\frac{\begin{matrix}Δ ⊢ U_{2} ˆⓈ U_{3} : s_{1} \\ ∀Γ ≤ Δ, Γ ⊢ u ˆⓈ u′ ⋆ U_{2} ⟹ Γ ⊢ T_{2}[u/x] ˆⓈ T_{3}[u′/x] : s_{2} \\ Δ ⊢ (x⋆U_{2}) →^{s_{1},s_{2}} T_{2} :=: (x⋆U_{3}) →^{s_{1},s_{2}} T_{3} : s_{3} \end{matrix}}{Δ ⊢ (x⋆U_{2}) →^{s_{1},s_{2}} T_{2} Ⓢ (x⋆U_{3}) →^{s_{1},s_{2}} T_{3} : s_{3}}

By transitivity we have Δ ⊢ (x⋆U_{1}) → T_{1} :=: (x⋆U_{3}) → T_{3} : s_{3} and Δ ⊢ U_{1} ˆⓈ U_{3} : s_{1} by induction hypothesis on s_{1}. Note that this is where the arrow sort annotations are useful. Without them we would not know that the sorts in both derivations are equal. We could have Δ ⊢ U_{1} ˆⓈ U_{2} : s_{1} and Δ ⊢ U_{2} ˆⓈ U_{3} : s′_{1} for apparently unrelated s_{1} and s′_{1}, and would therefore be unable to use transitivity. Given Γ ≤ Δ and Γ ⊢ u ˆⓈ u′ ⋆ U_{1}, we need to show that Γ ⊢ T_{1}[u/x] ˆⓈ T_{3}[u′/x] : s_{3}. As ˆⓈ at type U is a PER by induction hypothesis, we have Γ ⊢ u ˆⓈ u ⋆ U_{1}, from which we can deduce Γ ⊢ T_{1}[u/x] ˆⓈ T_{2}[u/x] : s_{2}. By conversion using Δ ⊢ U_{1} ˆⓈ U_{2} : s_{1} – weakened at Γ – we have Γ ⊢ u ˆⓈ u′ ⋆ U_{2}, which implies Γ ⊢ T_{2}[u/x] ˆⓈ T_{3}[u′/x] : s_{2}. This allows us to conclude by transitivity at type s_{2}.

□

In the following we show that the variables are in the logical relation, i. e., Δ ⊢ x Ⓢ x : Δ(x) for well-formed contexts Δ. As usual, this statement has to be generalized to neutrals n to be proven inductively.

Lemma 13 (Into the logical relation). Let T ∈ s. If Δ ⊢ n :=: n′ ⋆ T then Δ ⊢ n ˆⓈ n′ ⋆ T.

Proof. By induction on T ∈ s.

Case N ∈ s and Δ ⊢ n :=: n′ ⋆ N. Then Δ ⊢ n Ⓢ n′ ⋆ N by cases on ⋆, unfolding definitions. Case s ∈ s′ and Δ ⊢ N :=: N′ ⋆ s. Then Δ ⊢ N Ⓢ N′ ⋆ s by cases on ⋆. Case (x⋆U) → T ∈ s_{3} and Δ ⊢ n :=: n′ ⋆_{0} (x⋆U) → T.

First, the case for ⋆_{0} = :. We have Δ ⊢ n :=: n′ : (x⋆U) → T. Assume arbitrary Γ ≤ Δ and Γ ⊢ u ˆⓈ u′ ⋆U, which yields Γ ⊢ u :=: u′ ⋆U and Γ ⊢ T [u/x] ˆⓈ T [u/x] : s_{2}. By weakening, Γ ⊢ n^{⋆}u :=: n′ ^{⋆}u′ : T [u/x], thus, by induction hypothesis, Γ ⊢ n^{⋆}u Ⓢ n′ ^{⋆}u′ : T [u/x], q.e.d.

The case for ⋆_{0} = ÷ proceeds analogously.

□

4.3. Validity in the Model. We now extend our logical relation ˆⓈ to substitutions, by induction on the destination context.

\overline{Δ ⊢ σ ˆⓈ σ′ : ⋄}  \frac{Δ ⊢ σ ˆⓈ σ′ : Γ  Δ ⊢ σ(x) ˆⓈ σ′(x) ⋆ Uσ}{Δ ⊢ σ ˆⓈ σ′ : Γ. x⋆U}

This relation inherits weakening from ˆⓈ for terms.

We then define the context ( ⊩ Γ), type (Γ ⊩ T = T′) and term (Γ ⊩ t = t′ : T) validity relations, by induction on the length of contexts.

\overline{⊩ ⋄}  \frac{⊩ Γ Γ ⊩ U}{⊩ Γ. x⋆U}  \frac{Γ ⊩ T = T′ : s}{Γ ⊩ T = T′}  \frac{Γ ⊩ T = T}{Γ ⊩ T}

\frac{⊩ Γ  (Γ ⊩ T unless T = s) ∀Δ, σ, σ′, Δ ⊢ σ ˆⓈ σ′ : Γ ⟹ Δ ⊢ tσ ˆⓈ t′σ′ : T σ}{Γ ⊩ t = t′ : T}  \frac{Γ ⊩ t = t : T}{Γ ⊩ t : T}

Because of its asymmetric definition, the logical relation on substitutions may not be a PER in general, but it is for valid contexts.

Lemma 14 (Substitution relation is a PER). If ⊩ Γ, then Δ ⊢ ˆⓈ : Γ is symmetric and transitive.

Proof. By induction on Γ. We demonstrate symmetry for the case ⊩ Γ. x⋆U.

\frac{Δ ⊢ σ ˆⓈ σ′ : Γ Δ ⊢ σ(x) ˆⓈ σ′(x) ⋆ Uσ}{Δ ⊢ σ ˆⓈ σ′ : Γ. x⋆U}

By induction hypothesis, Δ ⊢ σ′ ˆⓈ σ : Γ, and by symmetry of ˆⓈ for terms (Lemma 12), Δ ⊢ σ′(x) ˆⓈ σ(x) ⋆ Uσ. We instantiate Γ ⊩ U to Δ ⊢ Uσ ˆⓈ Uσ′ : s and conclude Δ ⊢ σ′(x) ˆⓈ σ(x) ⋆ Uσ′ by conversion (Lemma 11). □

Lemma 15 (Validity is a PER). The relation Γ ⊩ = : T is symmetric and transitive.

Proof. Symmetry requires symmetry of ˆⓈ for substitutions and conversion with Δ ⊢ T σ ˆⓈ T σ′ : s′, similar as in Lemma 14.

We demonstrate transitivity in detail. Given Γ ⊩ t_{1} = t_{2} : T and Γ ⊩ t_{2} = t_{3} : T we show Γ ⊩ t_{1} = t_{3} : T. Clearly, ⊩ Γ and Γ ⊩ T or T = s by one of our two assumptions. Assume arbitrary Δ ⊢ σ ˆⓈ σ′ : Γ and show Δ ⊢ t_{1}σ ˆⓈ t_{3}σ′ : T σ. By Lemma 14, Δ ⊢ σ ˆⓈ σ : Γ, thus Δ ⊢ t_{1}σ ˆⓈ t_{2}σ : T σ. Also, Δ ⊢ t_{2}σ ˆⓈ t_{3}σ′ : T σ which entails our goal by transitivity of ˆⓈ (Lemma 12). □

Lemma 16 (Function type injectivity is valid). If Γ ⊩ (x⋆U) →^{s_{1},s_{2}} T = (x⋆U′) →^{s′_{1},s′_{2}} T′ then s_{1} = s′_{1} and s_{2} = s′_{2} and Γ ⊩ U = U′ : s_{1} and Γ. x⋆U′ ⊩ T = T′ : s_{2}.

Proof. Assume arbitrary Δ ⊢ σ ˆⓈ σ′ : Γ. We have Δ ⊢ (x⋆Uσ) →^{s_{1},s_{2}} T σ ˆⓈ (x⋆U′σ′) →^{s′_{1},s′_{2}} T′σ′ : s_{3}, thus by definition s_{1} = s′_{1} and s_{2} = s′_{2} and Δ ⊢ U′σ′ ˆⓈ Uσ : s_{1}—note that sorts are closed and therefore invariant by substitution. By symmetry of ˆⓈ, and since Δ, σ, σ′ were arbitrary, we have Γ ⊩ U = U′ : s_{1}.

Further, assume arbitrary Δ ⊢ u ˆⓈ u′ ⋆ U′σ and let ρ = (σ, u/x) and ρ′ = (σ′, u′/x). Note that w. l. o. g., x ∉ dom(Γ) and x ∉ FV(U′) and Δ ⊢ ρ ˆⓈ ρ′ : Γ. x⋆U′. We have Δ ⊢ T ρ ˆⓈ T′ρ′ : s_{2} and since ρ, ρ′ were arbitrary, Γ. x⋆U′ ⊩ T = T′ : s_{2}. □

Lemma 17 (Context satisfiable). If ⊩ Γ then ⊢ Γ and Γ ⊢ id ˆⓈ id : Γ.

Proof. By induction on Γ. The ⋄ case is immediate. In the Γ. x⋆U case, given

\frac{⊩ Γ Γ ⊩ U}{⊩ Γ. x⋆U}

we can use inference

\frac{Γ. x⋆U ⊢ id ˆⓈ id : Γ Γ. x⋆U ⊢ id(x) ˆⓈ id(x) ⋆ Uid}{Γ. x⋆U ⊢ id ˆⓈ id : Γ. x⋆U}.

From the induction hypothesis Γ ⊢ id ˆⓈ id : Γ, we obtain the first premise by weakening of ˆⓈ. It also yields Γ ⊢ Uid : sid for some s by definition of Γ ⊩ U. Using induction hypothesis, ⊢ Γ, this entails ⊢ Γ. x⋆U. Further, Γ. x⋆U ⊢ x = x ⋆ U, and since trivially Γ. x⋆U ⊢ x ⟷ x⋆U, we can derive Γ. x⋆U ⊢ x ˆⓈ x⋆U, by the Lemma 13. This concludes the second premise Γ. x⋆U ⊢ id(x) ˆⓈ id(x) ⋆ Uid. □

We can now show that every equation valid in the model is derivable in IITT.

Theorem 18 (Completeness of IITT rules). If Γ ⊩ t = t′ : T then both Γ ⊢ t : T and Γ ⊢ t′ : T and Γ ⊢ t = t′ : T and Γ ⊢ T.

Proof. Using Lemma 17 we obtain Γ ⊢ t ˆⓈ t′ : T, which entails Γ ⊢ t, t′ : T and Γ ⊢ t = t′ : T. Analogously, since our assumption entails Γ ⊩ T by definition, we get Γ ⊢ T. □

4.4. Fundamental theorem. We prove a series of lemmata which constitute parts of the fundamental theorem for the Kripke logical relation.

Lemma 19 (Resurrection). If ⊩ Γ and Δ ⊢ σ ˆⓈ σ′ : Γ then Δ^{÷} ⊢ σ ˆⓈ σ : Γ^{÷} and Δ^{÷} ⊢ σ′ ˆⓈ σ′ : Γ^{÷}.

Proof. By induction on Γ, the interesting case being

\frac{Δ ⊢ σ ˆⓈ σ′ : Γ Δ ⊢ σ(x) ˆⓈ σ′(x) ⋆ Uσ}{Δ ⊢ σ ˆⓈ σ′ : Γ. x⋆U} .

First, we show Δ^{÷} ⊢ σ ˆⓈ σ : (Γ^{÷}. x: U). By induction hypothesis Δ^{÷} ⊢ σ ˆⓈ σ : Γ^{÷}, and by definition, Δ^{÷} ⊢ σ(x) ˆⓈ σ(x) : Uσ. This immediately entails our goal.

For the second goal Δ^{÷} ⊢ σ′ ˆⓈ σ′ : (Γ^{÷}. x: U), observe that Γ ⊩ U, hence Δ ⊢ Uσ ˆⓈ Uσ′ : s for some sort s. Thus, we can cast our hypothesis Δ ⊢ σ′(x) ˆⓈ σ′(x) : Uσ to Uσ′ and conclude analogously. □

Corollary 20. If Γ^{⋆} ⊩ u : U and Δ ⊢ σ ˆⓈ σ′ : Γ then Δ ⊢ uσ ˆⓈ uσ′ ⋆ Uσ.

Proof. In case ⋆ = : it holds by definition, but we need resurrection for ⋆ = ÷. If Δ ⊢ σ ˆⓈ σ′ : Γ, then by resurrection (Lemma 19) we have Δ^{÷} ⊢ σ ˆⓈ σ : Γ^{÷}, so from Γ^{÷} ⊩ u : U we deduce Δ^{÷} ⊢ uσ ˆⓈ uσ : Uσ. Analogously we get Δ^{÷} ⊢ uσ′ ˆⓈ uσ′ : Uσ′ which we cast to Δ^{÷} ⊢ uσ′ ˆⓈ uσ′ : Uσ. □

Lemma 21 (Validity of β-reduction).

\frac{Γ. x⋆U ⊩ t : T Γ^{⋆} ⊩ u : U}{Γ ⊩ (λx⋆U. t)^{⋆}u = t[u/x] : T [u/x]}

Proof. ⊩ Γ is contained in the first hypothesis Γ ⊩ u ⋆ U. Then, given Δ ⊢ ρ ˆⓈ ρ′ : Γ we need to show Δ ⊢ (λx⋆U. t)ρ^{⋆}uρ ˆⓈ t(ρ′, uρ′/x) : T (ρ, uρ/x) and also Δ ⊢ T [u/x]ρ ˆⓈ T [u/x]ρ′ : s for some s (the latter to get Γ ⊩ T [u/x]).

Let σ = (ρ, uρ/x) and σ′ = (ρ′, uρ′/x). From the second hypothesis and Cor. 20 we get Δ ⊢ uρ ˆⓈ uρ′ ⋆ Uρ, which gives Δ ⊢ σ ˆⓈ σ′ : Γ. x⋆U. By instantiating the first hypothesis we get Δ ⊢ tσ ˆⓈ tσ′ : T σ, and also (from the premise Γ. x⋆U ⊩ T) Δ ⊢ T σ = T σ′, which gives Γ ⊩ T [u/x].

Finally, from Δ ⊢ tσ ˆⓈ tσ′ we get the desired Δ ⊢ (λx⋆U. t)ρ^{⋆}uρ ˆⓈ tσ′ : T σ, as ˆⓈ is closed by weak head expansion to well-typed Δ ⊢ (λx⋆U. t)ρ^{⋆}uρ : T σ. □

Lemma 22 (Validity of η).

\frac{Γ ⊩ t : (x⋆U) → T}{Γ ⊩ t = λx⋆U. t^{⋆}x : (x⋆U) → T}

Proof. ⊩ Γ and Γ ⊩ (x⋆U) → T are direct consequences of our hypothesis. Given Δ ⊢ ρ ˆⓈ ρ′ : Γ, we need to show Δ ⊢ tρ ˆⓈ (λx⋆U. t^{⋆}x)ρ′ : ((x⋆U) → T)ρ. W. l. o. g., x is not free in the domain nor range of substitutions ρ and ρ′, thus with t′ := tρ, t′′ := tρ′, U′ := Uρ, U′′ := Uρ′, T′ := T ρ and T′′ := T ρ′ it is sufficient to show Δ ⊢ t′ ˆⓈ λx⋆U′′. t′′ ^{⋆}x : (x⋆U′) → T′.

First, given (Δ′, u, u′) such that Δ′ ≤ Δ and Δ′ ⊢ u ˆⓈ u′ ⋆ U′, we show Δ′ ⊢ t′ ^{⋆}u ˆⓈ (λx⋆U′′. t′′ ^{⋆}x)^{⋆}u′ : T′[u/x]. Our hypothesis Γ ⊩ t : (x⋆U) → T entails Δ ⊢ tρ ˆⓈ tρ′ : ((x⋆U) → T)ρ, that is to say Δ ⊢ t′ ˆⓈ t′′ : (x⋆U′) → T′. This logical relation at a function type, when instantiated to (Δ′, u, u′), gives us Δ′ ⊢ t′ ^{⋆}u ˆⓈ t′′ ^{⋆}u′ : T′[u/x], which weak-head expands to the desired goal.

Second, we show Δ ⊢ t′ :=: λx⋆U′′. t′′ ^{⋆}x : (x⋆U′) → T′.

• Γ ⊢ t′ : (x⋆U′) → T′ is a simple consequence of our hypothesis Γ ⊩ t : (x⋆U) → T.

• Γ ⊢ λx⋆U′′. t′′ ^{⋆}x : (x⋆U′) → T′ has the following proof:

Γ ⊩ t : (x⋆U) → T ; = ; Δ ⊢ t′′ : (x⋆U′′) → T′′ ; \overline{weak} ; Δ. x⋆U′′ ⊢ t′′ : (x⋆U′′) → T′′ \overline{var} ; (Δ. x⋆U′′)^{⋆} ⊢ x : U′′
Δ. x⋆U′′ ⊢ t′′ ^{⋆}x : T′′

Γ ⊩ (x⋆U) → T = Δ ⊢ (x⋆U′′) → T′′

Δ ⊢ λx⋆U′′. t′′ ^{⋆}x : (x⋆U′′) → T′′

\overline{conv}

Δ ⊢ λx⋆U′′. t′′ ^{⋆}x : (x⋆U′) → T′

• Δ ⊢ t′ = λx⋆U′′. t′′ ^{⋆}x : (x⋆U′) → T′. The η-rule of definitional equality gives us Δ ⊢ t′′ = λx⋆U′′. t′′ ^{⋆}x : (x⋆U′′) → T′′. From Γ ⊩ (x⋆U) → T we can convert it to the type (x⋆U′) → T′, and then conclude by transitivity using Δ ⊢ t′ = t′′ : (x⋆U′) → T′, which is a direct consequence of Γ ⊩ t : (x⋆U) → T.

□

Lemma 23 (Validity of function equality).

\frac{Γ ⊩ U = U′ Γ. x⋆U ⊩ t = t′ : T}{Γ ⊩ (λx⋆U. t) = (λx⋆U′. t′) : (x⋆U) → T}

Proof. Again ⊩ Γ and Γ ⊩ (x⋆U) → T are simple consequences of our hypotheses. Given Δ ⊢ ρ ˆⓈ ρ′ : Γ (w. l. o. g., x is not free in ρ, ρ′ domain or range), we need to show Δ ⊢ (λx⋆Uρ. tρ) ˆⓈ (λx⋆U′ρ′. t′ρ′) : ((x⋆Uρ) → T ρ). We will skip the proof of Δ ⊢ (λx⋆Uρ. tρ) :=: (λx⋆U′ρ′. t′ρ′) : ((x⋆Uρ) → T ρ), as it is similar to the corresponding part of the η-validity lemma.

Given (Δ′, u, u′) such that Δ′ ≤ Δ and Δ′ ⊢ u ˆⓈ u′ ⋆ Uρ, we have to show that Δ′ ⊢ (λx⋆Uρ. tρ)^{⋆}u ˆⓈ (λx⋆U′ρ′. t′ρ′)^{⋆}u′ : T ρ[u/x]. Let σ = (ρ, u/x) and σ′ = (ρ′, u′/x). As we supposed Δ′ ⊢ u ˆⓈ u′ ⋆ Uρ, we have Δ′ ⊢ σ ˆⓈ σ′ : Γ. x⋆Uρ. Instantiating the second hypothesis with Δ′, σ, σ′ therefore gives us Δ′ ⊢ tσ = t′σ′ : T σ, which can also be written Δ′ ⊢ tρ[u/x] ˆⓈ t′ρ′[u′/x] : T ρ[u/x], which is weak-head expansible to our goal. □

Lemma 24 (Validity of irrelevant application).

\frac{Γ ⊩ t = t′:(x÷U) → T  Γ^{÷} ⊩ u : U  Γ^{÷} ⊩ u′ : U}{Γ ⊩ t^{÷}u = t′ ^{÷}u′ : T [u/x]}

Proof. Assume arbitrary Δ ⊢ ρ ˆⓈ ρ′ : Γ and show Δ ⊢ tρ^{÷}uρ ˆⓈ t′ρ′ ^{÷}u′ρ′ : T (ρ, uρ/x). By the first hypothesis, it is sufficient to show Δ ⊢ uρ ˆⓈ u′ρ′ ÷ Uρ, which means Δ^{÷} ⊢ uρ ˆⓈ uρ : Uρ and Δ^{÷} ⊢ u′ρ′ ˆⓈ u′ρ′ : Uρ. By Resurrection (Lemma 19), Δ^{÷} ⊢ ρ ˆⓈ ρ : Γ^{÷}, hence Δ^{÷} ⊢ uρ ˆⓈ uρ : Uρ from the second hypothesis. Analogously, we obtain Δ^{÷} ⊢ u′ρ′ ˆⓈ u′ρ′ : Uρ′ from the third hypothesis which we can cast to Uρ by virtue of Γ ⊩ U which we get from Γ ⊩ (x÷U) → T by Lemma 16. □

Theorem 25 (Fundamental theorem of logical relations).

(1) If ⊢ Γ then ⊩ Γ.

(2) If Γ ⊢ t : T then Γ ⊩ t : T.

(3) If Γ ⊢ t = t′ : T then Γ ⊩ t = t′ : T.

Proof. By induction on the derivation. □

As a simple corollary we obtain syntactic validity, namely that definitional equality implies well-typedness and well-typedness implies well-formedness of the involved type. This lemma could have been proven purely syntactically, but the syntactic proof requires a sequence of carefully arranged lemmata like context conversion, substitution, functionality, and inversion on types [HP05, AC07]. Our “sledgehammer” semantic argument is built into the Kripke logical relation, in the spirit of Goguen [Gog00].

Corollary 26 (Syntactic validity).

(1) If Γ ⊢ t : T then Γ ⊢ T.

(2) If Γ ⊢ t = t′ : T then Γ ⊢ t : T and Γ ⊢ t′ : T.

Proof. By the fundamental theorem, Γ ⊢ t = t′ : T implies Γ ⊩ t = t′ : T, which by Thm. 18 implies Γ ⊢ t, t′ : T and Γ ⊢ T. □

5. Meta-theoretic Consequences of the Model Construction

In this section, we explicate the results established by the Kripke model.

5.1. Admissibility of Substitution. Goguen [Gog00] observes that admissibility of substitution for the syntactic judgements can be inherited from the Kripke logical relation, which is closed under substitution by its very definition.

To show that the judgements of IITT are closed under substitution we introduce relations Γ ⊢ σ : Γ′ for substitution typing and Γ ⊢ σ = σ′ : Γ′ for substitution equality which are given inductively by the following rules:

\frac{⊢ Γ}{Γ ⊢ σ : ⋄}  \frac{Γ ⊢ σ : Γ′  Γ′ ⊢ U  Γ ⊢ σ(x) ⋆ Uσ}{Γ ⊢ σ : Γ′. x⋆U}

\frac{⊢ Γ}{Γ ⊢ σ = σ′ : ⋄}  \frac{Γ ⊢ σ = σ′ : Γ′  Γ′ ⊢ U  Γ ⊢ σ(x) = σ′(x) ⋆ Uσ}{Γ ⊢ σ = σ′ : Γ′. x⋆U}

Substitution typing and equality are closed under weakening.

Semantically, substitutions are explained by environments. We define substitution validity as follows, again in rule form but not inductively:

\frac{Γ ⊩ σ = σ : Γ′}{Γ ⊩ σ : Γ′}  \frac{\begin{matrix}⊩ Γ  ⊩ Γ′ \\ ∀Δ ⊩ ρ ˆⓈ ρ′ : Γ. Δ ⊩ σρ ˆⓈ σ′ρ′ : Γ′ \end{matrix}}{Γ ⊩ σ = σ′ : Γ′}

Lemma 27 (Fundamental lemma for substitutions).

(1) If Γ ⊢ σ : Γ′ then Γ ⊩ σ : Γ′.

(2) If Γ ⊢ σ = σ′ : Γ′ then Γ ⊩ σ = σ′ : Γ′.

Proof. We demonstrate 2 by induction on Γ ⊢ σ = σ′ : Γ′.

Case

\frac{⊢ Γ}{Γ ⊢ σ = σ′ : ⋄}

We have ⊩ Γ by Thm. 25 and ⊩ ⋄ trivially. Also, Δ ⊢ σρ ˆⓈ σ′ρ′ : ⋄ trivially for any Δ ⊢ ρ ˆⓈ ρ′ : Γ.

Case

\frac{Γ ⊢ σ = σ′ : Γ′  Γ′ ⊢ U  Γ ⊢ σ(x) = σ′(x) ⋆ Uσ}{Γ ⊢ σ = σ′ : Γ′. x⋆U}

We have ⊩ Γ and ⊩ Γ′ by induction hypothesis and Γ′ ⊩ U by Thm. 25, thus, ⊩ Γ′. x⋆U. Now assume arbitrary Δ ⊢ ρ ˆⓈ ρ′ : Γ and show Δ ⊢ σρ ˆⓈ σ′ρ′ : Γ′. x⋆U. First, Δ ⊢ σρ ˆⓈ σ′ρ′ : Γ′ follows by induction hypothesis. The second subgoal Δ ⊢ (σρ)(x) ˆⓈ (σ′ρ′)(x) ⋆ Uσρ is just an instance of the second induction hypothesis.

□

Theorem 28 (Substitution and functionality).

(1) If Γ ⊢ σ : Γ′ and Γ′ ⊢ t : T then Γ ⊢ tσ : T σ.

(2) If Γ ⊢ σ : Γ′. and Γ′ ⊢ t = t′ : T then Γ ⊢ tσ = t′σ : T σ.

(3) If Γ ⊢ σ = σ′ : Γ′. and Γ′ ⊢ t : T then Γ ⊢ tσ = tσ′ : T σ.

(4) If Γ ⊢ σ = σ′ : Γ′. and Γ′ ⊢ t = t′ : T then Γ ⊢ tσ = t′σ′ : T σ.

Proof. We demonstrate 4, the other cases are just variations of the theme. First, from Γ ⊢ σ = σ′ : Γ′ we get Γ ⊢ σ ˆⓈ σ′ : Γ′ by the fundamental lemma for substitutions (Lemma 27), using the identity environment Γ ⊢ id ˆⓈ id : Γ. Now, by the fundamental theorem on Γ ⊢ t = t′ : T we obtain Γ ⊢ tσ ˆⓈ t′σ′ : T σ, which entails our goal Γ ⊢ tσ = t′σ′ : T σ by Thm. 18. □

5.2. Context conversion. Context equality ⊢ Γ = Γ′ is defined inductively by the rules

\overline{⊢ ⋄ = ⋄}  \frac{⊢ Γ = Γ′  Γ ⊢ U = U′}{⊢ Γ. x⋆U = Γ′. x⋆U′} .

All declarative judgements are closed under context conversion. This fact is easy to prove by induction over derivations, but we get it as just a special case of substitution.

Lemma 29 (Identity substitution). If ⊢ Γ = Γ′ then Γ ⊢ id = id : Γ′.

Proof. By induction on ⊢ Γ = Γ′.

Case

\frac{⊢ Γ = Γ′ Γ ⊢ U = U′}{⊢ Γ. x⋆U = Γ′. x⋆U′}

By induction hypothesis and weakening, Γ. x⋆U ⊢ id = id : Γ′. Also, Γ. x⋆U ⊢ x = x ⋆ U and by conversion Γ. x⋆U ⊢ x = x ⋆ U′. Together, Γ. x⋆U ⊢ id = id : Γ′. x⋆U′.

□

Theorem 30 (Context conversion). Let ⊢ Γ′ = Γ.

(1) If Γ ⊢ t : T then Γ′ ⊢ t : T.

(2) If Γ ⊢ t = t′ : T then Γ′ ⊢ t = t′ : T.

Proof. By Thm. 28 with Γ′ ⊢ id = id : Γ. □

As a consequence, context equality is symmetric and transitive (we can trade Γ ⊢ U = U′ for Γ′ ⊢ U = U′). Thus, context conversion can be applied in the other direction as well.

5.3. Inversion, injectivity, and type unicity. A condition for the decidability of type checking is the ability to invert typing derivations. The proof requires substitution.

Lemma 31 (Inversion).

(1) If Γ ⊢ x : T then (x:U) ∈ Γ for some U with Γ ⊢ U = T.

(2) If Γ ⊢ λx⋆U. t : T then Γ. x⋆U ⊢ t : T′ for some T′ with Γ ⊢ (x⋆U) → T′ = T.

(3) If Γ ⊢ t^{⋆}u : T then Γ ⊢ t : (x⋆U) → T′ and Γ ⊢ u ⋆ U for some U, T′ with Γ ⊢ T′[u/x] = T.

(4) If Γ ⊢ s : T then there is (s, s′) ∈ Axiom such that Γ ⊢ s′ = T.

(5) If Γ ⊢ (x⋆U) →^{s_{1},s_{2}} T′ : T then Γ ⊢ U : s_{1} and Γ. x⋆U ⊢ T′ : s_{2}, and for some s_{3} we have Γ ⊢ s_{3} = T and (s_{1}, s_{2}, s_{3}) ∈ Rule.

Proof. Each by induction on the typing derivation. □

Remark 32. The need for inversion during type checking is the only good reason to have separate typing rules and not simply define typing Γ ⊢ t : T as the diagonal Γ ⊢ t = t : T of equality. While by a logical relation argument we will obtain a suitable inversion result for Γ ⊢ (x⋆U) → T = (x⋆U) → T —the famous function type injectivity (Theorem 33)— it seems hard to get something similar for application t u.

Injectivity for function types w. r. t. typed equality is known to be tricky. It is connected to subject reduction and required for many meta-theoretic results. We harvest it from our Kripke model.

Theorem 33 (Function type injectivity). If Γ ⊢ (x⋆U) →^{s_{1},s_{2}} T = (x⋆U′) →^{s′_{1},s′_{2}} T′ : s_{3} then s_{1} = s′_{1} and s_{2} = s′_{2} and Γ ⊢ U = U′ : s_{1} and Γ. x⋆U ⊢ T = T′ : s_{2}.

Proof. This follows from Lemma 16. Or we can prove it directly as follows: Since Γ ⊢ id ˆⓈ id : Γ we have by the fundamental theorem Γ ⊢ (x⋆U) →^{s_{1},s_{2}} T ˆⓈ (x⋆U′) →^{s_{1},s_{2}} T′ : s_{3} which by inversion yields first s_{1} = s′_{1} and s_{2} = s′_{2} and Γ ⊢ U ˆⓈ U′ : s_{1} and Γ ⊢ U = U′ : s_{1}. Since Γ. x⋆U ⊢ x ˆⓈ x⋆U, we also obtain Γ. x⋆U ⊢ T ˆⓈ T′ : s_{2} and conclude Γ. x⋆U ⊢ T = T′ : s_{2}.

□

From the inversion lemma we can prove uniqueness of types, since we are dealing with a functional PTS, and we have function type injectivity.

Theorem 34 (Type unicity). If Γ ⊢ t : T and Γ ⊢ t : T′ then Γ ⊢ T = T′.

Proof. By induction on t, using inversion. □

5.4. Normalization and Subject Reduction. An immediate consequence of the model construction is that each term has a weak head normal form and that typing and equality is preserved by weak head normalization.

Theorem 35 (Normalization and subject reduction). If Γ ⊢ t : T then t ↘ a and Γ ⊢ t = a : T.

Proof. By the fundamental theorem, Γ ⊢ t ˆⓈ t : T which by definition contains a derivation of Γ ⊢ t = ↓t : T. □

5.5. Consistency. Importantly, not every type is inhabited in IITT, thus, it can be used as a logic. A prerequisite is that types can be distinguished, which follows immediately from the construction of the logical relation.

Lemma 36 (Type constructor discrimination). Neutral types, sorts and function types are mutually unequal.

(1) Γ ⊢ N ≠ s.

(2) Γ ⊢ N ≠ (x⋆U) → T.

(3) Γ ⊢ s = s′ implies s ≡ s′.

(4) Γ ⊢ s ≠ (x⋆U) → T.

Proof. By the fundamental theorem applied to the identity substitution. For instance, assuming Γ ⊢ N = s : s′ we get Γ ⊢ N Ⓢ s : s′ but this is a contradiction to the definition of Ⓢ. □

From normalization and type constructor discrimination we can show that not every type is inhabited.

Theorem 37 (Consistency). X:Set_{0} ⊬ t : X.

Proof. Let Γ = (X : Set_{0}). Assuming Γ ⊢ t : X, we have Γ ⊢ a : X for the whnf a of t. We invert on the typing of a. By Lemma 36, X cannot be equal to a function type or sort, thus, a can neither be a λ nor a function type nor a sort, it can only be neutral. The only variable X must be in the head of a, but since X is not of function type, it cannot be applied. Thus, a ≡ X and Γ ⊢ X : X, implying Γ ⊢ X = Set_{0} by inversion (Lemma 31). This is in contradiction to Lemma 36! □

5.6. Soundness of Algorithmic Equality. Soundness of the equality algorithm is a consequence of subject reduction.

Theorem 38 (Soundness of algorithmic equality).

(1) Let Δ ⊢ t, t′ : T . If Δ ⊢ t ⟺ t′ : T then Δ ⊢ t = t′ : T.

(2) Let Δ ⊢ n, n′ : T . If Δ ⊢ n ⟷ n′ : U then Δ ⊢ n = n′ : U and Δ ⊢ U = T.

Proof. Generalize the theorem to all six algorithmic equality judgments and prove it by induction on the algorithmic equality derivation. Since we have subject reduction, the proof proceeds mechanically, because each algorithmic rule corresponds, modulo weak head normalization, to a declarative rule.

Case Δ ⊢ T : s and Δ′ ⊢ T′ : s and

\frac{Δ ⊢ ↓T ⟺ ↓T′}{Δ ⊢ T ⟺ T′}

By induction hypothesis, Δ ⊢ ↓T = ↓T′ : s. By subject reduction Δ ⊢ T = ↓T : s and Δ ⊢ T′ = ↓T′ : s. By transitivity Δ ⊢ T = T′ : s. Case

\frac{Δ ⊢ T ⟺ T′}{Δ ⊢ T ⟺ T′ : s}

By induction hypothesis, Δ ⊢ T = T′ : s.

□

5.7. Symmetry and Transitivity of Algorithmic Equality. Since algorithmic equality is sound for well-typed terms, it is also symmetric and transitive.

Lemma 39 (Type and context conversion in algorithmic equality). Let ⊢ Δ = Δ′. (1) If Δ ⊢ A, A′ and Δ ⊢ A ⟺ A′ then Δ′ ⊢ A ⟺ A′.

(2) If Δ ⊢ n, n′ : A and Δ ⊢ n ⟷ n′ : A then Δ′ ⊢ n ⟷ n′ : A′ for some A′ with Δ ⊢ A = A′.

(3) If Δ ⊢ t, t′ : A and Δ ⊢ t ⟺ t′ : A and Δ ⊢ A = A′ then Δ′ ⊢ t ⟺ t′ : A′.

Proof. By induction on the derivation of algorithmic equality, where we extend the statements to ⟷ and ⟺ accordingly.

(1) Type equality.

Case

\frac{Δ ⊢ U ⟺ U′ Δ. x⋆U ⊢ T ⟺ T′}{Δ ⊢ (x⋆U) → T ⟺ (x⋆U′) → T′}

By inversion, Δ ⊢ U, U′ and by induction hypothesis, Δ′ ⊢ U ⟺ U′. Again by inversion, Δ. x⋆U ⊢ T and Δ. x⋆U′ ⊢ T′, yet by soundness of algorithmic equality, Δ ⊢ U = U′, hence Δ. x⋆U ⊢ T′ by context conversion. Further, ⊢ Δ. x⋆U = Δ′. x⋆U. Thus, we can apply the other induction hypothesis to obtain Δ′. x⋆U ⊢ T ⟺ T′, which finally yields Δ′ ⊢ (x⋆U) → T ⟺ (x⋆U′) → T′.

(2) Structural equality.

Case

\frac{(x:T) ∈ Δ}{Δ ⊢ x ⟷ x : T}

Since ⊢ Δ = Δ′, there is a unique (x: T′) ∈ Δ′ with Δ ⊢ T = T′. Hence, Δ′ ⊢ x ⟷ x : T′.

Case

\frac{Δ ⊢ n ⟷ n′ : (x:U) → T Δ ⊢ u ⟺ u′ : U}{Δ ⊢ n u ⟷ n′ u′ : T [u/x]}

Note that since n u and n′ u′ are well-typed in Δ, so are n and n′, thus, by soundness of algorithmic equality, they have the type returned by structural equality check, Δ ⊢ n, n′ : (x : U) → T. By type unicity (Thm. 34), Δ ⊢ u, u′ : U, thus, we can apply the induction hypotheses. By the first ind. hyp., Δ′ ⊢ n ⟷ n′ : A′ with Δ ⊢ (x: U) →^{s_{1},s_{2}} T = A′. Since A′ is a whnf, by type constructor discrimination (Lemma 36), A ≡ (x:U′) →^{s_{1},s_{2}} T′. By function type injectivity (Thm. 33), this implies Δ ⊢ U = U′ : s_{1} and Δ ⊢ T [u/x] = T′[u/x] : s_{2} since by soundness of algorithmic equality (Thm. 38) Δ ⊢ u = u′ : U. By the second ind. hyp. Δ′ ⊢ u ⟺ u′ : U′, which yields Δ′ ⊢ n u ⟷ n′ u′ : T′[u/x].

(3) Type-directed equality.

Case Δ ⊢ t, t′ : T and Δ ⊢ T = T′ and

\frac{T ↘ A Δ ⊢ t ⟺ t′ : A}{Δ ⊢ t ⟺ t′ : T}

By normalization, T′ ↘ A′, and subject reduction Δ ⊢ A = T = T′ = A′. Since by conversion, Δ ⊢ t, t′ : A, by induction hypothesis Δ′ ⊢ t ⟺ t′ : A′. Thus, Δ′ ⊢ t ⟺ t′ : T′.

Case Δ ⊢ (x⋆U) → T = A′ and

\frac{Δ. x⋆U ⊢ t^{⋆}x ⟺ t′ ^{⋆}x : T}{Δ ⊢ t ⟺ t′ : (x⋆U) → T}

By injectivity A′ ≡ (x⋆U′) → T′ with Δ ⊢ U = U′ and Δ. x⋆U ⊢ T = T′. Since ⊢ Δ. x⋆U = Δ′. x⋆U′, by induction hypothesis we have Δ′. x⋆U′ ⊢ t^{⋆}x ⟺

t′ ^{⋆}x : T′. We conclude Δ′ ⊢ t ⟺ t′ : (x⋆U′) → T′.
□

Lemma 40 (Algorithmic equality is transitive). Let ⊢ Δ = Δ′. In the following, let the terms submitted to algorithmic equality be well-typed.

(1) If Δ ⊢ n_{1} ⟷ n_{2} : T and Δ′ ⊢ n_{2} ⟷ n_{3} : T′ then Δ ⊢ n_{1} ⟷ n_{3} : T and Δ ⊢ T = T′.

(2) If Δ ⊢ t_{1} ⟺ t_{2} : T and Δ′ ⊢ t_{2} ⟺ t_{3} : T′ and Δ ⊢ T = T′ then Δ ⊢ t_{1} ⟺ t_{3} : T.

(3) If Δ ⊢ T_{1} ⟺ T_{2} : s and Δ′ ⊢ T_{2} ⟺ T_{3} : s then Δ ⊢ T_{1} ⟺ T_{3} : s

Proof. We extend these statements to ⟷ and ⟺ and prove them simultaneously by induction on the first derivation.

Case

\frac{Δ ⊢ n_{1} ⟷ n_{2} : T}{Δ ⊢ n_{1} ⟺ n_{2} : N}  \frac{Δ′ ⊢ n_{2} ⟷ n_{3} : T′}{Δ′ ⊢ n_{2} ⟺ n_{3} : N′}

By induction hypothesis Δ ⊢ n_{1} ⟷ n_{3} : T, hence, Δ ⊢ n_{1} ⟺ n_{3} : N. Case

\frac{Δ ⊢ N_{1} ⟷ N_{2} : T}{Δ ⊢ N_{1} ⟺ N_{2}}  \frac{Δ ⊢ N_{2} ⟷ N_{3} : T′}{Δ ⊢ N_{2} ⟺ N_{3}}

Analogously. Case

\frac{Δ ⊢ n_{1} ⟷ n_{2} : (x:U) →^{s_{1},s_{2}} T Δ ⊢ u_{1} ⟺ u_{2} : U}{Δ ⊢ n_{1} u_{1} ⟷ n_{2} u_{2} : T [u_{1}/x]}

\frac{Δ′ ⊢ n_{2} ⟷ n_{3} : (x:U′) →^{s′_{1},s′_{2}} T′ Δ′ ⊢ u_{2} ⟺ u_{3} : U′}{Δ′ ⊢ n_{2} u_{2} ⟷ n_{3} u_{3} : T′[u_{2}/x]}

By induction hypothesis we have Δ ⊢ n_{1} ⟷ n_{3} : (x: U) →^{s_{1},s_{2}} T and Δ ⊢ (x:

U) →^{s_{1},s_{2}} T = (x:U′) →^{s′_{1},s′_{2}} T′ which gives in particular s_{1} = s′_{1}, s_{2} = s′_{2}, and Δ ⊢ U = U′ : s_{1} by function type injectivity (Thm. 33). By induction hypothesis we can then deduce Δ ⊢ u_{1} ⟺ u_{3} : U, and therefore conclude Δ ⊢ n_{1}u_{1} ⟷ n_{3}u_{3} : T [u_{1}/x]. Case

\frac{Δ ⊢ U_{1} ⟺ U_{2} : s_{1} Δ. x⋆U_{1} ⊢ T_{1} ⟺ T_{2} : s_{2}}{Δ ⊢ (x⋆U_{1}) →^{s_{1},s_{2}} T_{1} ⟺ (x⋆U_{2}) →^{s_{1},s_{2}} T_{2} : s_{3}}

\frac{Δ ⊢ U_{2} ⟺ U_{3} : s_{1} Δ. x⋆U_{2} ⊢ T_{2} ⟺ T_{3} : s_{2}}{Δ ⊢ (x⋆U_{2}) →^{s_{1},s_{2}} T_{2} ⟺ (x⋆U_{3}) →^{s_{1},s_{2}} T_{3} : s_{2}}

We get Δ ⊢ U_{1} ⟺ U_{3} : s_{1} by transitivity. To also get Δ. x⋆U_{1} ⊢ T_{1} ⟺ T_{3} : s_{2} we need ⊢ Δ. x⋆U_{2} = Δ. x⋆U_{1}, but this stems from Δ ⊢ U_{1} ⟺ U_{2} : s_{1} by soundness of algorithmic equality.

□

Theorem 41. The algorithmic equality relations are PERs on well-typed expressions.

Proof. By Lemma 40 and an analogous proof of symmetry. □

6. A Kripke Logical Relation for Completeness

The only open issues in the meta-theory of IITT are completeness and termination of algorithmic equality. In parts, completeness has been established in the last section already, namely, we have shown injectivity and discrimination for type constructors. What is missing is injectivity and discrimination for neutrals, e. g., if Δ ⊢ n u = n′ u′ : T′ then necessarily Δ ⊢ n = n′ : (x: U) → T and Δ ⊢ u = u′ : U, plus Δ ⊢ T [u/x] = T′. In untyped λcalculus, this is an instance of Boehm’s theorem [Bar84]. We follow Coquand [Coq91] and Harper and Pfenning [HP05] and prove it by constructing a second Kripke logical relation, \begin{matrix}c \\ ◯ \end{matrix}, for completeness which is very similar to the first one, Ⓢ, but at base types additionally requires algorithmic equality to hold. After proving the fundamental lemma again, we know that definitionally equal terms are also algorithmically so. As a consequence, equality is decidable in IITT, and so is type checking.

6.1. Another Kripke Logical Relation. Again, by induction on A ∈ s we define two Kripke relations

\begin{matrix}Δ ⊢ A & \begin{matrix}c \\ ◯ \end{matrix} & A′ : s \\ Δ ⊢ a & \begin{matrix}c \\ ◯ \end{matrix} & a′ : A. \end{matrix}

together with their respective closures ˆ \begin{matrix}c \\ ◯ \end{matrix} and the generalization to ⋆. This time, however, at base types we will additionally require algorithmic equality to hold, more precisely, the relation Δ ⊢ t :⟺: t′ : T which stands for the conjunction of the propositions

• Δ ⊢ t : T and Δ ⊢ t′ : T, and

• Δ ⊢ t ⟺ t′ : T.

Note that by soundness of algorithmic equality, :⟺: implies :=:.

Again, we allow ourselves rule notation for the defining clauses of \begin{matrix}c \\ ◯ \end{matrix}.

\frac{Δ ⊢ N :⟺: N′ : s}{Δ ⊢ N \begin{matrix}c \\ ◯ \end{matrix} N′ : s}  \frac{Δ ⊢ n :⟺: n′ : N}{Δ ⊢ n \begin{matrix}c \\ ◯ \end{matrix} n′ : N}  \frac{⊢ Δ}{Δ ⊢ s \begin{matrix}c \\ ◯ \end{matrix} s : s′} (s, s′)

\frac{Δ ⊢ U ˆ \begin{matrix}c \\ ◯ \end{matrix} U′ : s_{1} ∀Γ ≤ Δ, Γ ⊢ u ˆ \begin{matrix}c \\ ◯ \end{matrix} u′ ⋆ U ⟹ Γ ⊢ T [u/x] ˆ \begin{matrix}c \\ ◯ \end{matrix} T′[u′/x] : s_{2} Δ ⊢ (x⋆U) →^{s_{1},s_{2}} T :=: (x⋆U′) →^{s_{1},s_{2}} T′ : s_{3}}{Δ ⊢ (x⋆U) →^{s_{1},s_{2}} T \begin{matrix}c \\ ◯ \end{matrix} (x⋆U′) →^{s_{1},s_{2}} T′ : s_{3}} (s_{1}, s_{2}, s_{3})

\frac{\begin{matrix}∀Γ ≤ Δ, Γ ⊢ u ˆ \begin{matrix}c \\ ◯ \end{matrix} u′ ⋆ U ⟹ Γ ⊢ f ^{⋆}u ˆ \begin{matrix}c \\ ◯ \end{matrix} f′ ^{⋆}u′ : T [u/x] \\ Δ ⊢ f :=: f′ : (x⋆U) →^{s,s′} T \end{matrix}}{Δ ⊢ f \begin{matrix}c \\ ◯ \end{matrix} f′ : (x⋆U) →^{s,s′} T}

\frac{Δ ⊢ ↓t \begin{matrix}c \\ ◯ \end{matrix} ↓t′ : ↓T Δ ⊢ t :=: t′ : T}{Δ ⊢ t ˆ \begin{matrix}c \\ ◯ \end{matrix} t′ : T}

\frac{Δ^{÷} ⊢ a \begin{matrix}c \\ ◯ \end{matrix} a : A  Δ^{÷} ⊢ a′ \begin{matrix}c \\ ◯ \end{matrix} a′ : A}{Δ ⊢ a \begin{matrix}c \\ ◯ \end{matrix} a′ ÷ A}  \frac{Δ^{÷} ⊢ t ˆ \begin{matrix}c \\ ◯ \end{matrix} t : T  Δ^{÷} ⊢ t′ ˆ \begin{matrix}c \\ ◯ \end{matrix} t′ : T}{Δ ⊢ t ˆ \begin{matrix}c \\ ◯ \end{matrix} t′ ÷ T}

This logical relation contains only well-typed and definitionally equal terms. It is symmetric, transitive, and closed under weakening and type conversion. The proofs are in analogy to those of Section 4, which are relying on the fact that the underlying relation :=: is a Kripke PER and closed under type conversion. The relation :⟺: underlying \begin{matrix}c \\ ◯ \end{matrix} has the same properties, thanks to soundness of algorithmic equality.

Note that in the definition of Δ ⊢ f \begin{matrix}c \\ ◯ \end{matrix} f′ : (x⋆U) → T we did not require f and f′ to be algorithmically equal. This would hinder the proof of the fundamental theorem for \begin{matrix}c \\ ◯ \end{matrix}, since algorithmic equality is not closed under application by definition—it will follow from the fundamental theorem, though. In the next lemma we shall prove that f and f′ are algorithmically equal if they are related by \begin{matrix}c \\ ◯ \end{matrix}. The name Escape Lemma was coined by Jeffrey Sarnat [SS08].

Lemma 42 (Escape from the logical relation). Let Δ ⊢ A \begin{matrix}c \\ ◯ \end{matrix} A′ : s (1) Δ ⊢ A ⟺ A′.

(2) If Δ ⊢ t ˆ \begin{matrix}c \\ ◯ \end{matrix} t′ : A then Δ ⊢ t ⟺ t′ : A.

(3) If Δ ⊢ n ⟷ n′ ⋆ A and Δ ⊢ n = n′ ⋆ A then Δ ⊢ n \begin{matrix}c \\ ◯ \end{matrix} n′ ⋆ A.

Corollary 43. Let Δ ⊢ T ˆ \begin{matrix}c \\ ◯ \end{matrix} T′ : s (1) Δ ⊢ T ⟺ T′.

(2) If Δ ⊢ t ˆ \begin{matrix}c \\ ◯ \end{matrix} t′ : T then Δ ⊢ t ⟺ t′ : T.

(3) If Δ ⊢ n ⟷ n′ ⋆ T and Δ ⊢ n = n′ ⋆ T then Δ ⊢ n ˆ \begin{matrix}c \\ ◯ \end{matrix} n′ ⋆ T.

The corollary is a direct, non-inductive consequence of the lemma, so we can use it in the proof of the lemma, quoted as “IH”.

Proof of the lemma. Simultaneously by induction on A :⟺: A′ : s.

Case Δ ⊢ N \begin{matrix}c \\ ◯ \end{matrix} N′ : s.

Subcase 1. Δ ⊢ N ⟺ N′ by assumption.

Subcase 2. We have Δ ⊢ ↓t ⟷ ↓t′ : , thus Δ ⊢ t ⟺ t′ : N.

Subcase 3.

First, consider ⋆ = :. If Δ ⊢ n = n′ : N and Δ ⊢ n ⟷ n′ : N then Δ ⊢ n ⟺ n′ : N and trivially Δ ⊢ n \begin{matrix}c \\ ◯ \end{matrix} n′ : N. Then, take ⋆ = ÷. Note that if Δ^{÷} ⊢ n = n : N and Δ^{÷} ⊢ n ⟷ n : N then Δ^{÷} ⊢ n ⟺ n : N and Δ^{÷} ⊢ n \begin{matrix}c \\ ◯ \end{matrix} n : N. This implies that if Δ ⊢ n = n′ ÷ N

and Δ ⊢ n ⟷ n′ ÷ N then Δ ⊢ n ⟺ n′ ÷ N and Δ ⊢ n \begin{matrix}c \\ ◯ \end{matrix} n′ ÷ N.

Case Δ ⊢ s \begin{matrix}c \\ ◯ \end{matrix} s : s′.

Subcase 1. Clearly, Δ ⊢ s ⟺ s.

Subcase 2. Let Δ ⊢ T ˆ \begin{matrix}c \\ ◯ \end{matrix} T′ : s. Then Δ ⊢ T ⟺ T′ by IH 1, thus Δ ⊢ T ⟺

T′ : s

Subcase 3. For ⋆ = : let Δ ⊢ N ⟷ N′ : s. By inversion, Δ ⊢ N ⟷ N′ : T for some T. Then Δ ⊢ N ⟺ N′ and Δ ⊢ N \begin{matrix}c \\ ◯ \end{matrix} N′ : s by definition. Considering ⋆ = ÷, it is sufficient to observe that Δ^{÷} ⊢ N ⟷ N : s implies Δ^{÷} ⊢ N ⟺ N and Δ^{÷} ⊢ N \begin{matrix}c \\ ◯ \end{matrix} N : s by definition.

Case Δ ⊢ (x⋆U) → T \begin{matrix}c \\ ◯ \end{matrix} (x⋆U′) → T′ : s_{3}.

Subcase 1. Similar to 2.

Subcase 2. By assumption, Δ ⊢ t ˆ \begin{matrix}c \\ ◯ \end{matrix} t′ : (x⋆U) → T. It is sufficient to show Δ. x⋆U ⊢ t^{⋆}x ⟺ t′ ^{⋆}x : T. Since Δ ⊢ U ˆ \begin{matrix}c \\ ◯ \end{matrix} U′ : s_{1}, which includes Δ ⊢ U, we have Δ. x⋆U ⊢ x = x ⋆ U. Since also Δ. x⋆U ⊢ x ⟷ x ⋆ U, we obtain Δ. x⋆U ⊢ t^{⋆}x ˆ \begin{matrix}c \\ ◯ \end{matrix} t′ ^{⋆}x : ↓T via IH 3, Δ. x⋆U ⊢ x \begin{matrix}c \\ ◯ \end{matrix} x ⋆ U. IH 2 then entails our goal.

Subcase 3. First, the case for ⋆ = :. We reuse variable ⋆ for a different irrelevance marker. We have Δ ⊢ n ⟷ n′ : (x⋆U) → T. Assume arbitrary Γ :⟺: Γ ≤ Δ and Γ ⊢ u ˆ \begin{matrix}c \\ ◯ \end{matrix} u′ ⋆ U, which yields Γ ⊢ u = u′ ⋆ U and Γ ⊢ T [u/x] ˆ \begin{matrix}c \\ ◯ \end{matrix} T [u′/x] : Set_{i}. In case ⋆ = : we have to apply IH 2 for Γ ⊢ u ⟺ u′ : ↓U. Otherwise, we obtain directly Γ ⊢ n^{⋆}u ⟷ n′ ^{⋆}u′ : ↓(T [u/x]). By IH 3,

Γ ⊢ n^{⋆}u \begin{matrix}c \\ ◯ \end{matrix} n′ ^{⋆}u′ : ↓(T [u/x]).

The case for ⋆ = ÷ proceeds analogously.

□

In analogy to ˆⓈ we extend ˆ \begin{matrix}c \\ ◯ \end{matrix} to substitutions and define the semantic validity judgements ⊩^{c} Γ and Γ ⊩^{c} t : T and Γ ⊩^{c} t = t′ : T based on ˆ \begin{matrix}c \\ ◯ \end{matrix}. Since by the escape lemma, Δ ⊢ x ˆ \begin{matrix}c \\ ◯ \end{matrix} x : Δ(x), we have Γ ⊢ id ˆ \begin{matrix}c \\ ◯ \end{matrix} id : Γ for ⊩^{c} Γ. Finally, we reprove the fundamental theorem:

Theorem 44 (Fundamental theorem for ˆ \begin{matrix}c \\ ◯ \end{matrix}).

(1) If ⊢ Γ then ⊩^{c} Γ.

(2) If Γ ⊢ t : T then Γ ⊩^{c} t : T.

(3) If Γ ⊢ t = t′ : T then Γ ⊩^{c} t = t′ : T.

6.2. Completeness and Decidability of Algorithmic Equality. Derivations of algorithmic equality can now be obtained by escaping from the logical relation.

Theorem 45 (Completeness of algorithmic equality). If Γ ⊢ t = t′ : T then Γ ⊢ t ⟺ t′ : T.

Proof. Since Γ ⊢ id ˆ \begin{matrix}c \\ ◯ \end{matrix} id : Γ, we have Γ ⊢ t ˆ \begin{matrix}c \\ ◯ \end{matrix} t′ : T by the fundamental theorem, and conclude with Lemma 42.2. □

Termination of algorithmic equality is a consequence of completeness. When invoking the algorithmic equality check Δ ⊢ t ⟺ t′ : T on two well-typed expressions Δ ⊢ t, t′ : T we know by completeness that t and t′ are related to themselves, i. e., Δ ⊢ t ⟺ t : T and Δ ⊢ t′ ⟺ t′ : T. This means that t, t′, and T are weakly normalizing by the strategy the equality algorithm implements: reduce to weak head normal form and recursively continue with the subterms. Running the equality check on t and t′ performs, if successful, exactly the same reductions, and if it fails, at most the same reductions in t, t′, and T. Hence, testing equality on well-typed terms always terminates. This argument has been applied in previous work to untyped equality [AC07]. Here, we apply it to typed equality; it is an alternative to Goguen’s technique of proving termination for typed equality from strong normalization [Gog05], which, in our opinion, does not scale to dependently-typed equality.

Lemma 46 (Termination of algorithmic equality). Let ⊢ Δ.

(1) Type equality.

(a) Let Δ ⊢ A, A′. If D :: Δ ⊢ A ⟺ A and Δ ⊢ A′ ⟺ A′ then the query Δ ⊢ A ⟺ A′ terminates.

(b) Let Δ ⊢ T, T′. If D :: Δ ⊢ T ⟺ T and Δ ⊢ T′ ⟺ T′ then the query

Δ ⊢ T ⟺ T′ terminates.

(2) Structural equality. Let Δ ⊢ n : T and Δ ⊢ n′ : T′.

(a) If D :: Δ ⊢ n ⟷ n : A and Δ ⊢ n′ ⟷ n′ : A′ then the query Δ ⊢ n ⟷ n′ : ? terminates. If successfully, it returns A and we have Δ ⊢ A = T = T′ = A.

(b) If D :: Δ ⊢ n ⟷ n : T and Δ ⊢ n′ ⟷ n′ : T′ then the query Δ ⊢ n ⟷ n′ : ?

terminates. If successfully, it returns T and we have Δ ⊢ T = T′.

(3) Type-directed equality.

(a) Let Δ ⊢ t, t′ : A. If D :: Δ ⊢ t ⟺ t : A and Δ ⊢ t′ ⟺ t′ : A then the query Δ ⊢ t ⟺ t′ : A terminates.

(b) Let Δ ⊢ t, t′ : T. If D :: Δ ⊢ t ⟺ t : T and Δ ⊢ t′ ⟺ t′ : T then the query Δ ⊢ t ⟺ t′ : T terminates.

Proof. Simultaneously by induction on derivation D.

(1) Type equality.

Case A = A′ = s. The query Δ ⊢ A ⟺ A′ terminates successfully. Case A = (x⋆U) → T and A′ = (x⋆U′) → T′. First, the query Δ ⊢ U ⟺ U′

runs. By induction hypothesis, it terminates. If it fails, the whole query fails. Otherwise, the query Δ. x⋆U ⊢ T ⟺ T′ is run. By induction hypothesis on Δ. x⋆U ⊢ T ⟺ T and Δ. x⋆U′ ⊢ T′ ⟺ T′, the query terminates.

Case A = N and A′ = N′ neutral. By induction hypothesis on Δ ⊢ N ⟷ N : T and Δ ⊢ N′ ⟷ N′ : T′, the query Δ ⊢ N ⟷ N′ : ? terminates. Hence, the query Δ ⊢ N ⟺ N′ terminates.

Case Weak head normal forms A, A′ not covered by previous cases: the query Δ ⊢ A ⟺ A′ fails immediately, since there is no applicable algorithmic type equality rule.

Case The query Δ ⊢ T ⟺ T′ first invokes weak head normalization on T and T′. Both terminate since Δ ⊢ T ⟺ T, which implies T ↘ A, and analogously T′ ↘ A′ since Δ ⊢ T′ ⟺ T′ by assumption. Then, the query Δ ⊢ A ⟺ A′ is run, which terminates by induction hypothesis on Δ ⊢ A ⟺ A and Δ ⊢ A′ ⟺ A′.

(2) Structural equality.

Case n = n′ = x. The query Δ ⊢ n ⟷ n′ : ? terminates successfully, returning

type Δ(x). Since ⊢ Δ, by inversion (Lemma 31) Δ ⊢ T = T′ = Δ(x). Case Neutral relevant application for Δ ⊢ n u : T_{0} and Δ ⊢ n′ u′ : T′_{0}.

\frac{Δ ⊢ n ⟷ n : (x:U) → T Δ ⊢ u ⟺ u : U}{Δ ⊢ n u ⟷ n u : T [u/x]}

\frac{Δ ⊢ n′ ⟷ n′ : (x:U′) → T′ Δ ⊢ u′ ⟺ u′ : U′}{Δ ⊢ n′ u′ ⟷ n′ u′ : T′[u′/x]}

The query Δ ⊢ n u ⟷ n′ u′ : ? first invokes query Δ ⊢ n ⟷ n′ : ?. By induction hypothesis on Δ ⊢ n ⟷ n : (x: U) → T and Δ ⊢ n′ ⟷ n′ : (x: U′) → T′ the query terminates. If it fails the whole query fails. Otherwise it returns a type A in weak head normal form, which is identical to (x: U) → T by uniqueness of inferred types (Lemma 9). Further, Δ ⊢ (x : U) → T = (x : U′) → T′, and by function type injectivity (Thm. 33), Δ ⊢ U = U′ and Δ. x : U ⊢ T = T′. Thus, we can invoke the induction hypothesis on Δ ⊢ u ⟺ u : U and Δ ⊢ u′ ⟺ u′ : U (cast from Δ ⊢ u′ ⟺ u′ : U′, Lemma 39) to infer that the second subquery Δ ⊢ u ⟺ u′ : U terminates. If this one is successful, then by soundness of algorithmic equality, Δ ⊢ u = u′ : U, which implies Δ ⊢ T [u/x] = T′[u′/x].

Case Neutral irrelevant application with typing

\frac{Δ ⊢ n : (x÷U_{1}) → T_{1}  Δ ⊢ u ÷ U_{1}}{Δ ⊢ n^{÷}u : T_{1}[u/x]}  \frac{Δ ⊢ n′ : (x÷U′_{1}) → T′_{1}  Δ ⊢ u′ ÷ U′_{1}}{Δ ⊢ n′ ^{÷}u′ : T′_{1}[u′/x]}

and algorithmic self-equality

\frac{Δ ⊢ n ⟷ n : (x÷U) → T}{Δ ⊢ n^{÷}u ⟷ n^{÷}u : T [u/x]}  \frac{Δ ⊢ n′ ⟷ n′ : (x÷U′) → T′}{Δ ⊢ n′ ^{÷}u′ ⟷ n′ ^{÷}u′ : T′[u′/x]}

The query Δ ⊢ n^{÷}u ⟷ n′ ^{÷}u′ : ? invokes query Δ ⊢ n ⟷ n′ : ?, which terminates by induction hypothesis. If successfully, then Δ ⊢ (x÷U_{1}) → T_{1}(x÷U) → T = (x÷U′) → T′ = (x÷U′_{1}) → T′_{1}. By function type injectivity, Δ ⊢ U_{1} = U = U′ = U′_{1} and Δ. x÷U ⊢ T_{1} = T = T′ = T′_{1}. By conversion Δ ⊢ u = u′ ÷ U, thus, Δ ⊢ T_{1}[u/x] = T [u/x] = T′[u′/x] = T′_{1}[u′/x].

Case In all other cases, the query Δ ⊢ n ⟷ n′ : ? fails immediately. Case The query Δ ⊢ n ⟷ n : ? spawns subquery Δ ⊢ n ⟷ n′ : ? which

terminates by induction hypothesis on Δ ⊢ n ⟷ n : T and Δ ⊢ n′ ⟷ n′ : T′. If successfully, it returns type T, and since T ↘ A, the original query also terminates, returning A.

(3) Type-directed equality.

Case Function type Δ ⊢ t, t′ : (x⋆U) → T. The query Δ ⊢ t ⟺ t′ : (x⋆U) → T spawns subquery Δ. x⋆U ⊢ t^{⋆}x ⟺ t′ ^{⋆} : T. Since Δ. x⋆U ⊢ t^{⋆}x, t′ ^{⋆}x : T and the subquery terminates by induction hypothesis on Δ. x⋆U ⊢ t^{⋆}x ⟺ t^{⋆}x : T and Δ. x⋆U ⊢ t′ ^{⋆}x ⟺ t′ ^{⋆}x : T.

Case Sort Δ ⊢ T, T′ : s. The query Δ ⊢ T ⟺ T′ : s calls Δ ⊢ T ⟺ T′, which

terminates by induction hypothesis on Δ ⊢ T ⟺ T and Δ ⊢ T′ ⟺ T′. Case Neutral type N.

\frac{t ↘ n  Δ ⊢ n ⟷ n : T}{Δ ⊢ t ⟺ t : N}  \frac{t′ ↘ n′  Δ ⊢ n′ ⟷ n′ : T′}{Δ ⊢ t′ ⟺ t′ : N}

The query Δ ⊢ t ⟺ t′ : N first weak head normalizes t and t′. By assumption, t ↘ n and t′ ↘ n′, so this terminates. The subquery Δ ⊢ n ⟷ n′ : ? terminates by induction hypothesis. Thus, the whole query terminates.

Case If A is neither a function type, a sort, or a neutral type, the query Δ ⊢ t ⟺

t′ : A fails immediately. Case The query Δ ⊢ t ⟺ t′ : T first weak head normalizes T which terminates

since T ↘ A by assumption. Then it calls Δ ⊢ t ⟺ t′ : A which terminates by induction hypothesis.

□

Theorem 47. If Δ ⊢ t : T and Δ ⊢ t′ : T then the query Δ ⊢ t ⟺ t′ : T terminates.

Proof. From the lemma by completeness of algorithmic equality. □

Thus we have shown that algorithmic equality is correct, i. e., sound, complete, and terminating. Together, this entails decidability of equality in IITT.

Theorem 48 (Decidability of IITT).

(1) Γ ⊢ t = t′ : T is decidable.

(2) Γ ⊢ t : T is decidable.

Proof. Decidability of equality follows from soundness (Thm. 38), completeness (Thm. 45), and termination (Thm. 47). Decidability of typing follows from decidability of type conversion, weak head normalization, and function type injectivity, using inversion (Lemma 31) on typing derivations. Any reasonable type inference algorithm will do. □

7. Extensions

Data types and recursion. The semantics of IITT is ready to cope with inductive data types like the natural numbers and the associated recursion principles. Recursion into types, aka known as large elimination, is also accounted for since we have universes and a semantics which does not erase dependencies (unlike Pfenning’s model [Pfe01]).

Types with extensionality principles. One purpose of having a typed equality algorithm is to handle η-laws that are not connected to the shape of the expression (like η-contraction for functions) but to the shape of the type only. Typically these are types T with at most one inhabitant, i. e., the empty type, the unit type, singleton types or propositions.^{6} For such T we have the η-law

\frac{Γ ⊢ t, t′ : T}{Γ ⊢ t = t′ : T}

which can only be checked in the presence of type T. Realizing such η-laws gives additional “proof” irrelevance which is not covered by Pfenning’s irrelevant quantification (x÷U) → T.

Internal erasure. Terms u÷U in irrelevant position are only there to please the type checker, they are ignored during equality checking. This can be inferred from the substitution principle: If Γ. x÷U ⊢ T and Γ ⊢ u, u′ ÷ U, then Γ ⊢ T [u/x] = T [u′/x]; the type T has the same shape regardless of u, u′. Hence, terms like u serve the sole purpose to prove some proposition and could be replaced by a dummy • immediately after type-checking.

Internal erasure can be realized by making Γ ⊢ t ÷ T a judgement (as opposed to just a notation for Γ^{÷} ⊢ t : T) and adding the rule

\frac{Γ ⊢ t ÷ T}{Γ ⊢ • ÷ T} .

The rule states that if there is already a proof t of T, then • is a new proof of T. This preserves provability while erasing the proof terms. Conservativity of this rule can be proven as in joint work of the author with Coquand and Pagano [ACP11].

6Some care is necessary for the type of Leibniz equality [Abe09, Wer08].

8. Conclusions

We have extended Pfenning’s notion of irrelevance to a type theory IITT with universes that accommodates types defined by recursion. We have constructed a Kripke model Ⓢ that shows soundness of IITT, yielding normalization, subject reduction and consistency, plus syntactical properties of the judgements of IITT. A second Kripke logical relation \begin{matrix}c \\ ◯ \end{matrix} has proven correctness of algorithmic equality and, thus, decidability of IITT.

Integrating irrelevance and data types in dependent type theory does not seem without challenges. We have succeeded to treat Pfenning’s notion of irrelevance, but our proof does not scale directly to parametric function types, a stronger notion of irrelevant function types called implicit quantification by Miquel [Miq01b].^{7} Two more type theories build on Miquel’s calculus [Miq01a], Barras and Bernardo’s ICC^{∗} [BB08] and Mishra-Linger and Sheard’s Erasure Pure Type Systems (EPTS) [MLS08], but none has offered a satisfying account of large eliminations yet. Miquel’s model [Miq00] features data types only as impredicative encodings. For irrelevant, parametric, and recursive functions to coexist it seems like three different function types are necessary, e. g., in the style of Pfenning’s irrelevance, extensionality and intensionality. We would like to solve this puzzle in future work, not least to implement high-performance languages with dependent types.

Acknowledgments. The first author thanks Bruno Barras, Bruno Bernardo, Thierry Coquand, Dan Doel, Hugo Herbelin, Conor McBride, Ulf Norell, and Jason Reed for discussions on irrelevance in type theory. Work on a previous paper has been carried out while he was invited researcher at PPS, Paris, in the INRIA πr^{2} team headed by Pierre-Louis Curien and Hugo Herbelin. The second author acknowledges financial support by the École Normale Superiéure de Paris for his internship at the Ludwig-Maximilians-Universität München from May to September 2011. We thank the two anonymous referees, who suggested improvements and examples which improved the presentation, and the patience of the editors.

References

[AB04] Steven Awodey and Andrej Bauer. Propositions as [Types]. Journal of Logic and Computation, 14(4):447–471, 2004.

[Abe09] Andreas Abel. Extensional normalization in the logical framework with proof irrelevant equality. In Olivier Danvy, editor, Workshop on Normalization by Evaluation, affiliated to LiCS 2009, Los Angeles, 15 August 2009, 2009.

[Abe11] Andreas Abel. Irrelevance in type theory with a heterogeneous equality judgement. In Martin Hofmann, editor, Foundations of Software Science and Computational Structures, 14th International Conference, FOSSACS 2011, Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2011, Saarbrücken, Germany, March 26 - April 3, 2011. Proceedings, volume 6604 of Lecture Notes in Computer Science, pages 57–71. Springer-Verlag, 2011.

[AC07] Andreas Abel and Thierry Coquand. Untyped algorithmic equality for Martin-Löf’s logical framework with surjective pairs. Fundamenta Informaticae, 77(4):345–395, 2007. TLCA’05 special issue.

[ACD07] Andreas Abel, Thierry Coquand, and Peter Dybjer. Normalization by evaluation for Martin-Löf Type Theory with typed equality judgements. In 22nd IEEE Symposium on Logic in Computer Science (LICS 2007), 10-12 July 2007, Wroclaw, Poland, Proceedings, pages 3–12. IEEE Computer Society Press, 2007.

7A function argument is parametric if it is irrelevant for computing the function result while the type of the result may depend on it. In Pfenning’s notion, the argument must also be irrelevant in the type.

[ACD08] Andreas Abel, Thierry Coquand, and Peter Dybjer. Verifying a semantic βη-conversion test for Martin-Löf type theory. In Philippe Audebaud and Christine Paulin-Mohring, editors, Mathematics of Program Construction, 9th International Conference, MPC 2008, Marseille, France, July 15-18, 2008. Proceedings, volume 5133 of Lecture Notes in Computer Science, pages 29–56. Springer-Verlag, 2008.

[ACP11] Andreas Abel, Thierry Coquand, and Miguel Pagano. A modular type-checking algorithm for type theory with singleton types and proof irrelevance. Logical Methods in Computer Science, 7(2:4):1–57, May 2011.

[Ada06] Robin Adams. Pure type systems with judgemental equality. Journal of Functional Programming, 16(2):219–246, 2006.

[All87] Stuart Allen. A Non-Type-Theoretic Semantics for Type-Theoretic Language. PhD thesis, Cornell University, 1987.

[Ama08] Roberto M. Amadio, editor. Foundations of Software Science and Computational Structures, 11th International Conference, FOSSACS 2008, Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2008, Budapest, Hungary, March 29 - April 6, 2008. Proceedings, volume 4962 of Lecture Notes in Computer Science. Springer-Verlag, 2008.

[Aug99] Lennart Augustsson. Cayenne - a language with dependent types. In Proceedings of the third ACM SIGPLAN International Conference on Functional Programming (ICFP ’98), Baltimore, Maryland, USA, September 27-29, 1998, volume 34 of SIGPLAN Notices, pages 239–250. ACM Press, 1999.

[Bar84] Henk Barendregt. The Lambda Calculus: Its Syntax and Semantics. North Holland, Amsterdam, 1984.

[BB08] Bruno Barras and Bruno Bernardo. The implicit calculus of constructions as a programming language with dependent types. In Amadio [Ama08], pages 365–379.

[BDN09] Ana Bove, Peter Dybjer, and Ulf Norell. A brief overview of Agda - a functional language with dependent types. In Stefan Berghofer, Tobias Nipkow, Christian Urban, and Makarius Wenzel, editors, Theorem Proving in Higher Order Logics, 22nd International Conference, TPHOLs 2009, Munich, Germany, August 17-20, 2009. Proceedings, volume 5674 of Lecture Notes in Computer Science, pages 73–78. Springer-Verlag, 2009.

[CAB^{+}86] Robert L. Constable, Stuart F. Allen, Mark Bromley, Rance Cleaveland, J. F. Cremer, Robert W. Harper, Douglas J. Howe, Todd B. Knoblock, Nax P. Mendler, Prakash Panangaden, James T. Sasaki, and Scott F. Smith. Implementing mathematics with the Nuprl proof development system. Prentice Hall, 1986.

[Coq91] Thierry Coquand. An algorithm for testing conversion in type theory. In G. Huet and G. Plotkin, editors, Logical Frameworks, pages 255–279. Cambridge University Press, 1991.

[Coq96] Thierry Coquand. An algorithm for type-checking dependent types. In Mathematics of Program Construction. Selected Papers from the Third International Conference on the Mathematics of Program Construction (July 17–21, 1995, Kloster Irsee, Germany), volume 26 of Science of Computer Programming, pages 167–177. Elsevier, May 1996.

[Gog94] Healfdene Goguen. A Typed Operational Semantics for Type Theory. PhD thesis, University of Edinburgh, August 1994. Available as LFCS Report ECS-LFCS-94-304.

[Gog00] Healfdene Goguen. A Kripke-style model for the admissibility of structural rules. In Paul Callaghan, Zhaohui Luo, James McKinna, and Robert Pollack, editors, Types for Proofs and Programs, International Workshop, TYPES 2000, Durham, UK, December 8-12, 2000, Selected Papers, volume 2277 of Lecture Notes in Computer Science, pages 112–124. Springer-Verlag, 2000.

[Gog05] Healfdene Goguen. Justifying algorithms for βη conversion. In Vladimiro Sassone, editor, Foundations of Software Science and Computational Structures, 8th International Conference, FoS-SaCS 2005, Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2005, Edinburgh, UK, April 4-8, 2005, Proceedings, volume 3441 of Lecture Notes in Computer Science, pages 410–424. Springer-Verlag, 2005.

[HP05] Robert Harper and Frank Pfenning. On equivalence and canonical forms in the LF type theory. ACM Transactions on Computational Logic, 6(1):61–101, 2005.

[INR10] INRIA. The Coq Proof Assistant Reference Manual. INRIA, version 8.3 edition, 2010. http://coq.inria.fr/.

[Let02] Pierre Letouzey. A new extraction for Coq. In Herman Geuvers and Freek Wiedijk, editors, Types for Proofs and Programs, Second International Workshop, TYPES 2002, Berg en Dal, The Netherlands, April 24-28, 2002, Selected Papers, volume 2646 of Lecture Notes in Computer Science, pages 200–219. Springer-Verlag, 2002.

[Miq00] Alexandre Miquel. A model for impredicative type systems, universes, intersection types and subtyping. In 15th IEEE Symposium on Logic in Computer Science (LICS 2000), 26-29 June 2000, Santa Barbara, California, USA, Proceedings, pages 18–29, 2000.

[Miq01a] Alexandre Miquel. The implicit calculus of constructions. In Samson Abramsky, editor, Typed Lambda Calculi and Applications, 5th International Conference, TLCA 2001, Krakow, Poland, May 2-5, 2001, Proceedings, volume 2044 of Lecture Notes in Computer Science, pages 344–359. Springer-Verlag, 2001.

[Miq01b] Alexandre Miquel. Le Calcul des Constructions implicite: syntaxe et sémantique. PhD thesis, Université Paris 7, December 2001.

[ML08] Richard Nathan Mishra-Linger. Irrelevance, Polymorphism, and Erasure in Type Theory. PhD thesis, Portland State University, 2008.

[MLS08] Nathan Mishra-Linger and Tim Sheard. Erasure and polymorphism in pure type systems. In Amadio [Ama08], pages 350–364.

[MM04] Conor McBride and James McKinna. The view from the left. Journal of Functional Programming, 14(1):69–111, 2004.

[Pfe01] Frank Pfenning. Intensionality, extensionality, and proof irrelevance in modal type theory. In 16th IEEE Symposium on Logic in Computer Science (LICS 2001), 16-19 June 2001, Boston University, USA, Proceedings. IEEE Computer Society Press, 2001.

[PMW93] Christine Paulin-Mohring and Benjamin Werner. Synthesis of ML programs in the system Coq. Journal of Symbolic Computation, 15(5/6):607–640, 1993.

[Ree02] Jason Reed. Proof irrelevance and strict definitions in a logical framework, 2002. Senior Thesis, published as Carnegie-Mellon University technical report CMU-CS-02-153.

[Ree03] Jason Reed. Extending higher-order unification to support proof irrelevance. In David A. Basin and Burkhart Wolff, editors, Theorem Proving in Higher Order Logics, 16th International Conference, TPHOLs 2003, Rom, Italy, September 8-12, 2003, Proceedings, volume 2758 of Lecture Notes in Computer Science, pages 238–252. Springer-Verlag, 2003.

[SS08] Carsten Schürmann and Jeffrey Sarnat. Structural logical relations. In Frank Pfenning, editor, Proceedings of the Twenty-Third Annual IEEE Symposium on Logic in Computer Science, LICS 2008, 24-27 June 2008, Pittsburgh, PA, USA, pages 69–80. IEEE Computer Society Press, 2008.

[VC02] Joseph C. Vanderwaart and Karl Crary. A simplified account of the metatheory of Linear LF. In Third International Workshop on Logical Frameworks and Metalanguages (LFM 2002), FLoC’02 affiliated workshop, Copenhagen, Denmark, 2002. An extended version appeared as CMU Technical Report CMU-CS-01-154.

[Wer08] Benjamin Werner. On the strength of proof-irrelevant type theories. Logical Methods in Computer Science, 4(3), 2008.