Jump to content

Intuitionistic type theory: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Cydebot (talk | contribs)
m Robot - Moving category Mathematical constructivism to Category:Constructivism (mathematics) per CFD at Wikipedia:Categories for discussion/Log/2012 February 15.
m ISBNs (Build KE)
Line 10: Line 10:
The basic connectives of Type Theory are:
The basic connectives of Type Theory are:


===Π-types ===
===Π-types===


<math>\Pi</math>-types, also called dependent product types, are analogous to the indexed [[Cartesian product|products]] of sets. As such, they generalize the normal [[function space]] to model functions whose result type may vary on their input. E.g. writing <math>\mbox{Vec}({\mathbb R},n)</math> for <math>n</math>-tuples of [[real numbers]], <math>\Pi n:{\mathbb N}.\mbox{Vec}({\mathbb R},n)</math> stands for the type of functions which given a [[natural number]] returns a tuple of real numbers of this size. The usual function space arises as a special case when the range type does not actually depend on the input, e.g. <math>\Pi n:{\mathbb N}.{\mathbb R}</math> is the type of functions from natural numbers to the real numbers, which is also written as <math>{\mathbb N}\to{\mathbb R}</math>. Using the [[Curry–Howard isomorphism]] <math>\Pi</math>-types also serve to model [[implication]] and [[universal quantification]]: e.g. a term inhabiting <math>\Pi m,n:{\mathbb N}.m+n = n+m</math> is a function which assigns to any pair of natural numbers a proof that addition is [[commutative]] for that pair and hence can be considered as a proof that addition is commutative for all natural numbers. The generalisation from function type to dependent product type is analogous to the generalisation from exponentiation of natural numbers to indexed products of them. Consider the expression <math>a^b = \Pi_{k=1}^ba</math>: in this case, the dummy variable <math>k</math> of the product is not mentioned within the term <math>a</math>. However, it is clear that exponentiation can be generalised by allowing terms in the product to mention the dummy variable, i.e. by allowing indexing. In its general form, such a product then becomes: <math>\Pi_{k=1}^ba_k</math>.
<math>\Pi</math>-types, also called dependent product types, are analogous to the indexed [[Cartesian product|products]] of sets. As such, they generalize the normal [[function space]] to model functions whose result type may vary on their input. E.g. writing <math>\mbox{Vec}({\mathbb R},n)</math> for <math>n</math>-tuples of [[real numbers]], <math>\Pi n:{\mathbb N}.\mbox{Vec}({\mathbb R},n)</math> stands for the type of functions which given a [[natural number]] returns a tuple of real numbers of this size. The usual function space arises as a special case when the range type does not actually depend on the input, e.g. <math>\Pi n:{\mathbb N}.{\mathbb R}</math> is the type of functions from natural numbers to the real numbers, which is also written as <math>{\mathbb N}\to{\mathbb R}</math>. Using the [[Curry–Howard isomorphism]] <math>\Pi</math>-types also serve to model [[implication]] and [[universal quantification]]: e.g. a term inhabiting <math>\Pi m,n:{\mathbb N}.m+n = n+m</math> is a function which assigns to any pair of natural numbers a proof that addition is [[commutative]] for that pair and hence can be considered as a proof that addition is commutative for all natural numbers. The generalisation from function type to dependent product type is analogous to the generalisation from exponentiation of natural numbers to indexed products of them. Consider the expression <math>a^b = \Pi_{k=1}^ba</math>: in this case, the dummy variable <math>k</math> of the product is not mentioned within the term <math>a</math>. However, it is clear that exponentiation can be generalised by allowing terms in the product to mention the dummy variable, i.e. by allowing indexing. In its general form, such a product then becomes: <math>\Pi_{k=1}^ba_k</math>.
Line 18: Line 18:
<math>\Sigma</math>-types, also called dependent sum types, are analogous to the indexed [[disjoint union]]s of sets. As such, they generalize the usual [[Cartesian product]] to model pairs where the type of the 2nd component depends on the first. E.g. the type <math>\Sigma n:{\mathbb N}.\mbox{Vec}({\mathbb R},n)</math> stands for the type of pairs of a [[natural number]] and a [[tuple]] of [[real numbers]] of that size, i.e. this type can be used to model sequences of arbitrary length (usually called lists). The conventional [[Cartesian product]] type arises as a special case when the type of the 2nd component doesn't actually depend on the first, e.g. <math>\Sigma n:{\mathbb N}.{\mathbb R}</math> is the type of pairs of a [[natural number]] and a [[real number]], which is also written as <math>{\mathbb N}\times{\mathbb R}</math>. Again, using the [[Curry–Howard isomorphism]], <math>\Sigma</math>-types also serve to model [[conjunction]] and [[existential quantification]]. The generalisation of the Cartesian product by the <math>\Sigma</math>-type is analogous to the generalisation of regular multiplication <math>ab = \Sigma_{k=1}^ba</math> by the indexed sum <math>\Sigma_{k=1}^ba_k</math>.
<math>\Sigma</math>-types, also called dependent sum types, are analogous to the indexed [[disjoint union]]s of sets. As such, they generalize the usual [[Cartesian product]] to model pairs where the type of the 2nd component depends on the first. E.g. the type <math>\Sigma n:{\mathbb N}.\mbox{Vec}({\mathbb R},n)</math> stands for the type of pairs of a [[natural number]] and a [[tuple]] of [[real numbers]] of that size, i.e. this type can be used to model sequences of arbitrary length (usually called lists). The conventional [[Cartesian product]] type arises as a special case when the type of the 2nd component doesn't actually depend on the first, e.g. <math>\Sigma n:{\mathbb N}.{\mathbb R}</math> is the type of pairs of a [[natural number]] and a [[real number]], which is also written as <math>{\mathbb N}\times{\mathbb R}</math>. Again, using the [[Curry–Howard isomorphism]], <math>\Sigma</math>-types also serve to model [[conjunction]] and [[existential quantification]]. The generalisation of the Cartesian product by the <math>\Sigma</math>-type is analogous to the generalisation of regular multiplication <math>ab = \Sigma_{k=1}^ba</math> by the indexed sum <math>\Sigma_{k=1}^ba_k</math>.


=== Finite types===
===Finite types===


Of special importance are '''0''' or ⊥ (the [[empty type]]), '''1''' or ⊤ (the [[unit type]]) and '''2''' (the type of [[Boolean data type|Booleans]] or classical [[truth value]]s). Invoking the [[Curry–Howard isomorphism]] again, ⊥ stands for False and ⊤ for True.
Of special importance are '''0''' or ⊥ (the [[empty type]]), '''1''' or ⊤ (the [[unit type]]) and '''2''' (the type of [[Boolean data type|Booleans]] or classical [[truth value]]s). Invoking the [[Curry–Howard isomorphism]] again, ⊥ stands for False and ⊤ for True.
Line 102: Line 102:
* Bengt Nordström; Kent Petersson; Jan M. Smith (1990). ''Programming in Martin-Löf's Type Theory''. Oxford University Press. The book is out of print, but a free version can be picked up from [http://www.cs.chalmers.se/Cs/Research/Logic/book/ here].
* Bengt Nordström; Kent Petersson; Jan M. Smith (1990). ''Programming in Martin-Löf's Type Theory''. Oxford University Press. The book is out of print, but a free version can be picked up from [http://www.cs.chalmers.se/Cs/Research/Logic/book/ here].
* Thompson, Simon (1991). ''[http://www.cs.kent.ac.uk/people/staff/sjt/TTFP/ Type Theory and Functional Programming]'' Addison-Wesley. ISBN 0-201-41667-0.
* Thompson, Simon (1991). ''[http://www.cs.kent.ac.uk/people/staff/sjt/TTFP/ Type Theory and Functional Programming]'' Addison-Wesley. ISBN 0-201-41667-0.
* Granström, Johan G. (2011). ''[http://www.springer.com/philosophy/book/978-94-007-1735-0 Treatise on Intuitionistic Type Theory]'' Springer. ISBN 978-94-007-1735-0.
* Granström, Johan G. (2011). ''[http://www.springer.com/philosophy/book/978-94-007-1735-0 Treatise on Intuitionistic Type Theory]'' Springer. ISBN 978-9400717350{{Please check ISBN|reason=does not match hyphenation rules and is probably invalid}}.


==External links==
==External links==

Revision as of 05:55, 9 May 2012

Intuitionistic type theory, or constructive type theory, or Martin-Löf type theory or just Type Theory is a logical system and a set theory based on the principles of mathematical constructivism. Intuitionistic type theory was introduced by Per Martin-Löf, a Swedish mathematician and philosopher, in 1972. Martin-Löf has modified his proposal a few times; his 1971 impredicative formulation was inconsistent as demonstrated by Girard's paradox. Later formulations were predicative. He proposed both intensional and extensional variants of the theory.

Intuitionistic type theory is based on a certain analogy or isomorphism between propositions and types: a proposition is identified with the type of its proofs. This identification is usually called the Curry–Howard isomorphism, which was originally formulated for intuitionistic logic and simply typed lambda calculus. Type Theory extends this identification to predicate logic by introducing dependent types, that is types which contain values. Type Theory internalizes the interpretation of intuitionistic logic proposed by Brouwer, Heyting and Kolmogorov, the so called BHK interpretation. The types of Type Theory play a similar role to sets in set theory but functions definable in Type Theory are always computable.

Connectives of Type Theory

In the context of Type Theory a connective is a way of constructing types, possibly using already given types. The basic connectives of Type Theory are:

Π-types

-types, also called dependent product types, are analogous to the indexed products of sets. As such, they generalize the normal function space to model functions whose result type may vary on their input. E.g. writing for -tuples of real numbers, stands for the type of functions which given a natural number returns a tuple of real numbers of this size. The usual function space arises as a special case when the range type does not actually depend on the input, e.g. is the type of functions from natural numbers to the real numbers, which is also written as . Using the Curry–Howard isomorphism -types also serve to model implication and universal quantification: e.g. a term inhabiting is a function which assigns to any pair of natural numbers a proof that addition is commutative for that pair and hence can be considered as a proof that addition is commutative for all natural numbers. The generalisation from function type to dependent product type is analogous to the generalisation from exponentiation of natural numbers to indexed products of them. Consider the expression : in this case, the dummy variable of the product is not mentioned within the term . However, it is clear that exponentiation can be generalised by allowing terms in the product to mention the dummy variable, i.e. by allowing indexing. In its general form, such a product then becomes: .

Σ-types

-types, also called dependent sum types, are analogous to the indexed disjoint unions of sets. As such, they generalize the usual Cartesian product to model pairs where the type of the 2nd component depends on the first. E.g. the type stands for the type of pairs of a natural number and a tuple of real numbers of that size, i.e. this type can be used to model sequences of arbitrary length (usually called lists). The conventional Cartesian product type arises as a special case when the type of the 2nd component doesn't actually depend on the first, e.g. is the type of pairs of a natural number and a real number, which is also written as . Again, using the Curry–Howard isomorphism, -types also serve to model conjunction and existential quantification. The generalisation of the Cartesian product by the -type is analogous to the generalisation of regular multiplication by the indexed sum .

Finite types

Of special importance are 0 or ⊥ (the empty type), 1 or ⊤ (the unit type) and 2 (the type of Booleans or classical truth values). Invoking the Curry–Howard isomorphism again, ⊥ stands for False and ⊤ for True.

Using finite types we can define negation as .

Equality type

Given then is the type of equality proofs that is equal to . There is only one (canonical) inhabitant of and this is the proof of reflexivity .

Inductive types

A prime example of an inductive type is the type of natural numbers which is generated by and . An important application of the propositions as types principle is the identification of (dependent) primitive recursion and induction by one elimination constant: for any given type indexed by . In general inductive types can be defined in terms of W-types, the type of well-founded trees.

An important class of inductive types are inductive families like the type of vectors mentioned above, which is inductively generated by the constructors and . Applying the Curry–Howard isomorphism once more, inductive families correspond to inductively defined relations.

Universes

An example of a universe is , the universe of all small types, which contains names for all the types introduced so far. To every name we associate a type , its extension or meaning. It is standard to assume a predicative hierarchy of universes: for every natural number , where the universe contains a code for the previous universe, i.e. we have with . This hierarchy is often assumed to be cumulative, that is the codes from are embedded in .

Stronger universe principles have been investigated, i.e. super universes and the Mahlo universe. In 1992 Huet and Coquand introduced the calculus of constructions, a type theory with an impredicative universe, thus combining Type Theory with Girard's System F. This extension is not universally accepted by Intuitionists since it allows impredicative, i.e. circular, constructions, which are often identified with classical reasoning.

Formalisation of Type Theory

Type Theory is usually presented as a dependently typed lambda calculus, using the judgements:

  • , is a well-formed context of typing assumptions.
  • , is a well-formed type in context .
  • , is a well-formed term of type in context .
  • , and are equal types in context .
  • , and are equal terms of type in context .

Of special importance is the conversion rule, which says that given and then .

Categorical models of Type Theory

Using the language of category theory, R.A.G. Seely introduced the notion of a locally cartesian closed category (LCCC) as the basic model of Type Theory. This has been refined by Hofmann and Dybjer to Categories with Families or Categories with Attributes based on earlier work by Cartmell.

A category with families is a category C of contexts (in which the objects are contexts, and the context morphisms are substitutions), together with a functor T : CopFam(Set).

Fam(Set) is the category of families of Sets, in which objects are pairs (A,B) of an "index set" A and a function B: XA, and morphisms are pairs of functions f : AA' and g : XX' , such that B' ° g = f ° B - in other words, f maps Ba to B'g(a).

The functor T assigns to a context G a set Ty(G) of types, and for each A : Ty(G), a set Tm(G,A) of terms. The axioms for a functor require that these play harmoniously with substitution. Substitution is usually written in the form Af or af, where A is a type in Ty(G) and a is a term in Tm(G,A), and f is a substitution from D to G. Here Af : Ty(D) and af : Tm(D,Af).

The category C must contain a terminal object (the empty context), and a final object for a form of product called comprehension, or context extension, in which the right element is a type in the context of the left element. If G is a context, and A : Ty(G), then there should be an object (G,A) final among contexts D with mappings p : D → G, q : Tm(D,Ap).

A logical framework, such as Martin-Löf's takes the form of closure conditions on the context dependent sets of types and terms: that there should be a type called Set, and for each set a type, that the types should be closed under forms of dependent sum and product, and so forth.

A theory such as that of predicative set theory expresses closure conditions on the types of sets and their elements: that they should be closed under operations that reflect dependent sum and product, and under various forms of inductive definition.

Extensional versus intensional

A fundamental distinction is extensional vs intensional Type Theory. In extensional Type Theory definitional (i.e. computational) equality is not distinguished from propositional equality, which requires proof. As a consequence type checking becomes undecidable in extensional type theory. This is because relying on computational equality means that the equality depends on computations that could be Turing complete in general and thus the equality itself is undecidable due to the halting problem. Some type theories enforce the restriction that all computations be decidable so that definitional equality may be used.

In contrast in intensional Type Theory type checking is decidable, but the representation of standard mathematical concepts is somewhat complex, since extensional reasoning requires using setoids or similar constructions. It is a subject of current discussion whether this tradeoff is unavoidable and whether the lack of extensional principles in intensional Type Theory is a feature or a bug.

Implementations of Type Theory

Type Theory has been the base of a number of proof assistants, such as NuPRL, LEGO and Coq. Recently, dependent types also featured in the design of programming languages such as ATS, Cayenne, Epigram and Agda.

See also

References

Further reading