Redirected from "Martin-Lof type theory".
Context
Type theory
Foundations
foundations
The basis of it all
-
mathematical logic
-
deduction system, natural deduction, sequent calculus, lambda-calculus, judgment
-
type theory, simple type theory, dependent type theory
-
collection, object, type, term, set, element
-
equality, judgmental equality, typal equality
-
universe, size issues
-
higher-order logic
Set theory
Foundational axioms
Removing axioms
Contents
Idea
Per Martin-Löf‘s dependent type theory, also known as intuitionistic type theory (Martin-Löf 75), or constructive type theory is a specific form of type theory developed to support constructive mathematics. (Note that both “dependent type theory” and “intuitionistic type theory” may refer more generally to type theories that contain dependent types or are intuitionistic, respectively.)
Martin-Löf’s dependent type theory is notable for several reasons:
-
One can construct an interpretation of first-order intuitionistic logic by interpreting propositions as types (this is true of most any dependent type theory).
-
It has a version of a variant of the axiom of choice as a theorem (because of the properties of the above interpretation), see the discussion below.
-
In its intensional form, it has sufficient computational content to function as a programming language. At the same time, it then has identity types whose presence shows that one is really dealing with a form of homotopy type theory.
There are many different ways to present Martin-Löf dependent type theory in a formal system. In this article, we give two formal presentations of Martin-Löf dependent type theory in the framework of natural deduction, one which has judgmental equality and only one level, and another which has a very weak logic over the dependent type theory as well as propositional equality.
Presentation 1
This first presentation uses judgmental equality, and could be contrasted with the second presentation, which uses propositional equality and a very weak logic over dependent type theory.
Judgments and contexts
The syntax of Martin-Löf dependent type theory can be constructed in two stages:
-
The first is the raw or untyped syntax of the theory consisting of expressions that are readable but not necessarily meaningful.
-
The second stage consists of defining the derivable judgements of the type theory inductively which then pick out the meaningful contexts, types and terms.
A context is a list of succesively dependent types. The variables may be defined as de Bruijn indices, in which case the type of a variable is given by th type in a context.
One may also define contexts as coming with a variable name, in which case one needs a notion of -equivalence (syntactic identity modulo renaming of bound variables) and of capture-free substitution. De Bruijn indices avoid this step but can be more obfuscating.
Types and terms are built inductively from various constructors. Types, terms and contexts are defined mutually.
We have the basic judgement forms:
-
saying that: “ is a well-formed context”;
-
saying that “ is a well-typed dependent type in context ”;
-
saying that “ is a well-typed term of type in context ”;
The following table indicates the corresponding categorical semantics of these notions of dependent type theory:
We work in the logical framework of natural deduction, where everything is given by inference rules.
To start with, contexts are built from dependent types by the following rules (cf. type telescope):
Structural rules
Among the structural rules of dependent type theory are (e.g. Jacobs (1998), p. 122, UFP13, A.2.2, Rijke (2018), Sec. 1.4):
shown in the following table together with their categorical semantics of dependent types:
The weakening and substitution rules are admissible rules: they do not need to be explicitly included in the type theory as they could be proven by induction on the structure of all possible derivations.
Definitional equality
In addition, there are judgments for definitional equality of types and of terms:
- - and are judgementally equal well-typed types in context .
- - and are judgementally equal well-typed terms of type in context .
Definitional equality has its own structural rules: reflexivity, symmetry, transitivity, the principle of substitution, and the variable conversion rule.
- Reflexivity of definitional equality
-
Symmetry of definitional equality
-
Transitivity of definitional equality
-
Principle of substitution of definitionally equal terms:
-
Variable conversion rule:
Definitions
In addition, there are judgments for the initialization operator for types and for terms:
- - is defined to be the type in context .
- - is defined to be the term of type in context .
The initialization operator has its own structural rules: type formation, term introduction, and equality reflection.
Rules for types
Each type in Martin-Löf dependent type theory comes with a type formation rule, a term introduction rule, a term elimination rule, a computation rule, and an optional uniqueness rule. The elimination rules we give here are not contextual elimination rules, and the conversion rules given here are not contextual conversion rules.
Function types
- Formation rules for function types:
- Introduction rules for function types:
- Elimination rules for function types:
- Computation rules for function types:
- Uniqueness rules for function types:
Dependent product types
- Formation rules for dependent product types:
- Introduction rules for dependent product types:
- Elimination rules for dependent product types:
- Computation rules for dependent product types:
- Uniqueness rules for dependent product types:
Product types
- Formation rules for product types:
- Introduction rules for product types:
- Elimination rules for product types:
- Computation rules for product types:
- Uniqueness rules for product types:
Dependent sum types
- Formation rules for dependent sum types:
- Introduction rules for dependent sum types:
- Elimination rules for dependent sum types:
- Computation rules for dependent sum types:
- Uniqueness rules for dependent sum types:
Sum types
- Formation rules for sum types:
- Introduction rules for sum types:
- Elimination rules for sum types:
- Computation rules for sum types:
- Uniqueness rules for sum types:
Empty type
- Formation rules for the empty type:
- Elimination rules for the empty type:
- Uniqueness rules for the empty type:
Unit type
- Formation rules for the unit type:
- Introduction rules for the unit type:
- Elimination rules for the unit type:
- Computation rules for the unit type:
- Uniqueness rules for the unit type:
Natural numbers
-
Formation rules for the natural numbers:
-
Introduction rules for the natural numbers:
-
Elimination rules for the natural numbers:
-
Computation rules for the natural numbers:
- Uniqueness rules for the natural numbers:
Identity types
There is another version of equality, called the identity type or typal equality, because this equality is a type. The identity type is only be used for equality between terms of a type, and unless one is using Russell universes where types are represented by terms of a Russell universe, identity types cannot be used for equality of types.
- Formation rule for identity types:
- Introduction rule for identity types:
-
Elimination rule for identity types:
-
Computation rules for identity types:
-
Optional uniqueness rules for identity types:
…
Intensional and extensional type theories
In Martin-Löf dependent type theory, one makes a distinction between intensional and extensional type theories. A Martin-Löf dependent type theory is an extensional type theory if there is an equality reflection rule where from typal equality of terms, one could derive definitional equality of terms:
The type theory is an intensional type theory if it doesn’t have the equality reflection rule.
Presentation 2
This presentation of Martin-Löf dependent type theory uses a very weak logic over dependent type theory, in the sense that while it does have a notion of proposition, predicate, and truth, there are no conjunctions, disjunctions, implications, universal quantifiers, or existential quantifiers in the logic. Here, propositional equality plays the role of definitional equality and computational equality that judgmental equality played in the first presentation.
Judgments and contexts
The syntax of Martin-Löf dependent type theory can be constructed in two stages. The first is the raw or untyped syntax of the theory consisting of expressions that are readable but not meaningful. The second stage consists of defining the derivable judgements of the type theory inductively which then pick out the meaningful contexts, types and terms.
A context is a list of types. Variables can be defined as De Bruijn indices in which case the type of a variable is given by th type in a context.
One may also define contexts as coming with a variable name, in which case one needs a notion of -equivalence (syntactic identity modulo renaming of bound variables) and of capture-free substitution. De Bruijn indices avoid this step but can be more obfuscating.
Types and terms are built inductively from various constructors. Types, terms and contexts are defined mutually.
We have the basic judgement forms:
- - is a well-typed type in context .
- - is a well-typed term of type in context .
- - is a well-formed proposition in context
- - is a well-formed true proposition in context
- - is a well-formed context.
Contexts are defined by the following rules:
Structural rules
There are three structural rules in dependent type theory, the variable rule, the weakening rule, and the substitution rule.
The variable rule states that we may derive a typing judgment if the typing judgment is in the context already:
Let be any arbitrary judgment. Then we have the following rules:
The weakening rule:
The substitution rule:
The weakening and substitution rules are admissible rules: they do not need to be explicitly included in the type theory as they could be proven by induction on the structure of all possible derivations.
Definitional equality
Definitional equality of types and terms is formed by the following rules:
Definitional equality has its own structural rules: reflexivity, symmetry, transitivity, the principle of substitution, and the variable conversion rule.
- Reflexivity of definitional equality
- Symmetry of definitional equality
- Transitivity of definitional equality
Definitions
In addition, there are judgments for the initialization operator for types and for terms:
- - is defined to be the type in context .
- - is defined to be the term of type in context .
The initialization operator has its own structural rules: type formation, term introduction, and equality reflection.
Rules for types
Each type in Martin-Löf dependent type theory comes with a type formation rule, a term introduction rule, a term elimination rule, a computation rule, and an optional uniqueness rule. The elimination rules we give here are not contextual elimination rules, and the conversion rules given here are not contextual conversion rules.
Function types
- Formation rules for function types:
- Introduction rules for function types:
- Elimination rules for function types:
- Computation rules for function types:
- Uniqueness rules for function types:
Dependent product types
- Formation rules for dependent product types:
- Introduction rules for dependent product types:
- Elimination rules for dependent product types:
- Computation rules for dependent product types:
- Uniqueness rules for dependent product types:
Product types
- Formation rules for product types:
- Introduction rules for product types:
- Elimination rules for product types:
- Computation rules for product types:
- Uniqueness rules for product types:
Dependent sum types
- Formation rules for dependent sum types:
- Introduction rules for dependent sum types:
- Elimination rules for dependent sum types:
- Computation rules for dependent sum types:
- Uniqueness rules for dependent sum types:
Sum types
- Formation rules for sum types:
- Introduction rules for sum types:
- Elimination rules for sum types:
- Computation rules for sum types:
- Uniqueness rules for sum types:
Empty type
- Formation rules for the empty type:
- Elimination rules for the empty type:
- Uniqueness rules for the empty type:
Unit type
- Formation rules for the unit type:
- Introduction rules for the unit type:
- Elimination rules for the unit type:
- Computation rules for the unit type:
- Uniqueness rules for the unit type:
Natural numbers
-
Formation rules for the natural numbers:
-
Introduction rules for the natural numbers:
-
Elimination rules for the natural numbers:
-
Computation rules for the natural numbers:
- Uniqueness rules for the natural numbers:
Identity types
There is another version of equality, called the identity type or typal equality, because this equality is a type. The identity type is only be used for equality between terms of a type, and unless one is using Russell universes where types are represented by terms of a Russell universe, identity types cannot be used for equality of types.
- Formation rule for identity types:
- Introduction rule for identity types:
- Elimination rule for identity types:
- Computation rules for identity types:
- Optional uniqueness rules for identity types:
…
Intensional and extensional type theories
In Martin-Löf dependent type theory, one makes a distinction between intensional and extensional type theories. A Martin-Löf dependent type theory is an extensional type theory if there is an equality reflection rule where from typal equality of terms, one could derive definitional equality of terms:
The type theory is an intensional type theory if it doesn’t have the equality reflection rule.
Propositional reflection and predicate logic
One could add an additional set of rules in this second presentation of Martin-Löf dependent type theory which isn’t available in the first presentation: propositional reflections. Unlike the first presentation, in this presentation, there are two notions of propositions: the external propositions and the internal propositions. The external propositions are the judgmental propositions in the logic layer of Martin-Löf dependent type theory, and correspond to the external logic. On the other hand, the internal propositions are types equipped with a witness of the isProp modality and correspond to the internal logic. They are also called subsingletons or h-propositions. We could make the internal logic imply the external logic with the following proposition reflection rules:
and similar rules for predicates:
If the identity types of Martin-Löf dependent type theory have a uniqueness rule such as the K rule or uniqueness of identity proofs, then propositional reflection implies that the type theory is an extensional type theory.
In addition, since the product type and function type preserve types being a subsingleton, the dependent product of a subsingleton-valued type family, and the unit type and empty type are always subsingletons, one could also add the following propositional reflection rules to the theory, defining conjunction, implication, true, false, and bounded universal quantification:
Adding propositional truncations to Martin-Löf dependent type theory allows for the full intuitionistic logic to be defined, as disjunctions could be defined from the propositional truncation of the sum type, and the existential quantifier could be defined from the propositional truncation of the dependent sum type:
The rules above reflect the propositions as some types philosophy in type theory.
Bounded separation
A predicate on a type is a proposition in the context of the free variable . Bounded separation states that given a predicate on a set , one could construct the set with an injection
Propositions as types
An alternative to the propositions as some types philosophy is the propositions as types philosophy, where instead of reflecting the subsingletons to propositions and the singletons to true propositions, we reflect all types to propositions, and the pointed types to true propositions. The rules are given as follows:
and similar rules for predicates:
There is no need for propositional truncations in this interpretation: the full intuitionistic logic results from reflecting all type formers except for the natural numbers type and identity types:
Properties
Models and categorical semantics
The models of ML type theory depend crucially on whether one considers the variant of extensional type theory or that of intensional type theory.
The models of the extensional version are (just) locally cartesian closed categories.
The faithful models of the intensional version with identity types are however certain (∞,1)-categories, notably (∞,1)-toposes, presented by simplicial model categories (Warren). For this reason one speaks of homotopy type theory.
For a more detailed discussion of these matters see at relation between type theory and category theory.
Axiom of choice
In dependent type theory we can verify the following “logical form of the axiom of choice” (Bell, Tait), see also (Rijke, section 2.5.1).
Theorem
(ACL)
One should note carefully that this “is” only “the axiom of choice” under the above propositions-as-types interpretation of the quantifiers and .
References
See also the references at type theory and at dependent type theory.
The original articles:
-
Per Martin-Löf, A Theory of Types, unpublished note (1971) [pdf, pdf]
-
Per Martin-Löf, An intuitionistic theory of types: predicative part, in: H. E. Rose, J. C. Shepherdson (eds.), Logic Colloquium ‘73, Proceedings of the Logic Colloquium, Studies in Logic and the Foundations of Mathematics 80, Elsevier (1975) 73-118 [doi:10.1016/S0049-237X(08)71945-1, CiteSeer]
-
Per Martin-Löf (notes by Giovanni Sambin), Intuitionistic type theory, Lecture notes Padua 1984, Bibliopolis, Napoli (1984) (pdf, pdf)
As a programming language:
-
Per Martin-Löf, Constructive Mathematics and Computer Programming, in: Proceedings of the Sixth International Congress of Logic, Methodology and Philosophy of Science (1979), Studies in Logic and the Foundations of Mathematics 104 (1982) 153-175 [doi:10.1016/S0049-237X(09)70189-2, ISBN:978-0-444-85423-0]
-
Bengt Nordström, Kent Petersson, Jan M. Smith, Programming in Martin-Löf’s Type Theory, Oxford University Press 1990 (webpage, pdf)
Further discussion:
also published as:
Textbook accounts on general dependent type theory:
-
Simon Thompson, §6.3 in: Type Theory and Functional Programming, Addison-Wesley (1991) [ISBN:0-201-41667-0, webpage, pdf]
-
Bart Jacobs, Chapter 10 in: Categorical Logic and Type Theory, Studies in Logic and the Foundations of Mathematics 141, Elsevier (1998) [ISBN:978-0-444-50170-7, pdf]
(emphasis on the categorical model of dependent types)
-
Univalent Foundations Project, §A of Homotopy Type Theory – Univalent Foundations of Mathematics (2013) [web, pdf]
(in the context of homotopy type theory)
-
Egbert Rijke, Dependent type theory [pdf], Lecture 1 in: Introduction to Homotopy Type Theory, lecture notes, CMU (2018) [pdf, pdf, webpage]
(in the context of homotopy type theory)
A philosophical examination:
An introduction and survey (with an eye towards homotopy type theory):
- Michael Warren, chapter 1 of: Homotopy theoretic aspects of constructive type theory, PhD thesis (2008) (pdf)
as well as
A discussion of ML dependent type theory as the internal language of locally cartesian closed categories is in
- R. A. G. Seely, Locally cartesian closed categories and type theory, Math. Proc. Camb. Phil. Soc. (1984) 95 (pdf)
Discussion of the logical axiom of choice in dependent type theory is in