Intensionality, Extensionality, and Proof Irrelevance in Modal Type Theory
Total Page:16
File Type:pdf, Size:1020Kb
Intensionality, Extensionality, and Proof Irrelevance in Modal Type Theory Frank Pfenning∗ Department of Computer Science Carnegie Mellon University [email protected] Abstract decidable, non-extensional theory. On the other hand, we need external arguments to validate the correctness of pro- We develop a uniform type theory that integrates inten- grams, defeating at least in part the motivations underly- sionality, extensionality, and proof irrelevance as judgmen- ing the separation of judgments from propositions [11, 12]. tal concepts. Any object may be treated intensionally (sub- Furthermore, the development of extensional concepts in a ject only to α-conversion), extensionally (subject also to non-extensional type theory is far from straightforward, as βη-conversion), or as irrelevant (equal to any other object can be seen from Hofmann’s systematic study [10]. at the same type), depending on where it occurs. Modal re- Related is the issue of proof irrelevance, which plays an strictions developed in prior work for simple types are gen- important role in the development of mathematical concepts eralized and employed to guarantee consistency between in type theory via subset types or quotient types. For exam- these views of objects. Potential applications are in logical ple, the type {x:A | B(x)} should contain the elements M frameworks, functional programming, and the foundations of type A that satisfy property B. If we want type-checking of first-order modal logics. to be decidable, we require evidence that B(M) is satisfied, Our type theory contrasts with previous approaches that but we should not distinguish between different proofs of a priori distinguish propositions (whose proofs are all B(M)—they are irrelevant. identified—only their existence is important) from specifi- In this paper we present a type theory that internalizes cations (whose implementations are subject to some defini- the concepts of intensionality, extensionality, and proof ir- tional equalities). relevance via distinctions familiar from modal logic. We strictly follow Martin-L¨of’s separation of judgments from propositions and both type-checking and definitional equal- ity are decidable. 1 Introduction At the heart of our modal type theory are three judgments In the development of type theory, there has been con- M :: AMis an expression of type A, siderable debate about the degree of extensionality or inten- M : AMis an term of type A,and sionality that should be inherent in its formulation. In an ex- M ÷AMis a proof of type A, tensional theory such as the one underlying Nuprl [4] type- checking is undecidable. In a non-extensional theory1 such constructed from the same set of objects M and types A. as later versions of Martin-L¨of’s type theory [17], we distin- Expressions are treated intensionally: they are subject only guish a definitional equality (also called judgmental equal- to α-conversion. Terms are treated extensionally:they ity) which is not extensional and decidable, from a proposi- are additionally subject to β and η-conversion. Proofs are tional equality which is extensional and undecidable. There treated as if irrelevant: any two proofs of the same type are a number of tradeoffs, both from the philosophical and are identified. All these are part of the definitional equality pragmatic points of view. In an undecidable, extensional of the type theory, which therefore combines intensional- theory, programs are significantly more compact than in a ity, extensionality, and irrelevance into a single system in a ∗ coherent way. This work was partially supported by NSF Grant CCR-9988281. It is a critical property of our type theory that the dis- 1Such type theories are often called intensional, but this is somewhat misleading since the meaning of objects is still subject to some conversion tinction between expressions, terms, and proofs is not made rules. at the time the constituent constants are declared, but at the time those constants are used. Any type A can be seen as 2.1 Syntax the type of an expression, the type of a term (= a specifi- cation), or the type of a proof (= a proposition). Similarly, The syntax is stratified into objects, families, and kinds an object M may be seen as an expression, as a term, or as as for LF. a proof, depending only on whether some conditions on its Kinds K ::= type | Πx:A. K free variables are satisfied. We believe that this flexibility is | Πx::A. K | Πx÷A. K an inherent advantage of our approach compared to a priori Families A ::= a | AM |Πx:A1.A2 separating propositions (inhabited by proofs that are always |A•M|Πx::A1.A2 irrelevant) from specifications (inhabited by terms that are |A◦M|Πx÷A1.A2 never irrelevant). This is the approach mostly taken in the Objects M ::= c | x | λx:A. M | M1 M2 literature (see, for example, [18] or, allowing even for some | λx::A. M | M1 • M2 classical reasoning, [2]). | λx÷A. M | M1 ◦ M2 Our system is also interesting in its relation to intuition- Signatures Σ ::= ·|Σ,a:K |Σ,c:A istic modal logic when we ignore the objects. Our default judgment M : A can be interpreted as “A is true”. The Contexts Γ ::= ·|Γ,x:A|Γ,x::A | Γ,x÷A judgment M :: A can be read as “A is valid”. The judg- Here, M • M is an application whose argument (M ) ment M ÷ A can be read as “A is provable”, hiding the 1 2 2 is treated as an expression (intensionally), while M ◦ M proof object. These can be seen as modes of truth, and the 1 2 is an application whose argument is treated as a proof (ir- work presented here is an extension of prior work on proof relevant for equality). We use K for kinds, A, B, C for term calculi for the modal logic S4 [20] where validity cor- type families, M, N, P for objects, Γ for contexts and Σ responds to necessary truth. for signatures. We also use the symbol “kind” to clas- In a type theory as a foundation for functional program- sify the valid kinds. We consider terms that differ only in ming, irrelevant objects (that is, proofs) are erased be- the names of their bound variables as identical. We write fore execution without affecting the observable outcome. [N/x]M, [N/x]A and [N/x]K for capture-avoiding substi- From this point of view, our type system internally captures tution. Signatures and contexts may declare each constant a notion of dead-code elimination (see, for example, [1] and variable at most once. For example, when we write for a survey and position paper on related type-based ap- Γ,x:A we assume that x is not already declared in Γ.If proaches). However, we need to extend our type theory with necessary, we tacitly rename x before adding it to the con- first-class modal operators in order to use it in the context text Γ. Since a signature is generally fixed, and constants of a complete functional language. Two non-dependent the- may be used anywhere, we have permitted only two forms ories in this style are given in [20], explaining an intuition- of constant declaration, namely a:K and c:A. Note that this 3 istic modal logic with necessity (2A) and possibility ( A). is not a restriction for our applications, since it is the use not A proper treatment of the fully dependent version of these the definition of a constant which determines its status with theories would seem to require an equational theory with respect to definitional equality. commuting conversions and is therefore left to future work. Fortunately, it is possible to develop a consistent and useful 2.2 Judgments type theory where these judgments are considered primarily as hypotheses. Instead of internalizing them as modal op- The modal type theory is defined by the following prin- erators, we internalize the corresponding hypothetical judg- cipal judgments. ment as function types. Such a restriction is not new—it ` goes back to similar treatments of linear logic [9] and linear Σ sig Σ is a valid signature ` type theory [3] with similar motivations. Σ Γ ctx Γ is a valid context In the remainder of the paper we present our type theory, Γ `Σ M : AMhas type A investigate its properties, and sketch some further develop- Γ `Σ A : KAhas type K ments and potential applications. Γ `Σ K : kind K is a valid kind Γ `Σ M = N : AMextensionally equals N Γ ` A = B : KA B 2 A Modal Type Theory Σ extensionally equals Γ `Σ K = L : kind K extensionally equals L Γ ` M ≡ N : AMintensionally equals N Our modal type theory is a conservative extension of Σ LF [7]. Our approach follows the outline of [8], adapted As explained later, intensional equality for types and here to our more general type theory. The interested reader kinds is not needed directly, and proof irrelevance is a de- may find additional details in [19]. rived concept. 2 For the judgment `Σ Γ ctx we presuppose that Σ is a Irrelevant Proofs. The new judgments valid signature. For the remaining judgments of the form ` ÷ Γ `Σ J we presuppose that Σ is a valid signature and that Γ Γ Σ M AMis a proof of type A ` ÷ is valid in Σ. For the sake of brevity we omit the signature Γ Σ A KAis a proof type of kind K ` ÷ Σ from all judgments but the first, since it does not change Γ Σ M = N AMand N are equal proofs ` ÷ throughout a derivation. Γ Σ A = B KAand B are equal proof types If J is a typing or equality judgment, then we write [M/x]J for the obvious substitution of M for x in J.For are defined by the following rules example, if J is N : B,then[M/x]J stands for the judg- ⊕ ` ⊕ ` ment [M/x]N :[M/x]B.