# Type theory

At the broadest level,**type theory**is the branch of mathematics and logic that concerns itself with classifying entities into "sets" called

*types*. In this sense, it is related to the metaphysical notion of 'type'. Modern type theory was invented partly in response to Russell's paradox, and features prominently in Russell and Whitehead's Principia Mathematica.

With the rise of powerful programmable computers, and the development of programming languages for same, type theory has found practical application in the development of programming language type systems. Definitions of "type system" in the context of programming languages vary, but the following definition due to Benjamin C. Pierce roughly corresponds to the current consensus in the type theory community:

- [A type system is a] tractable syntactic method for proving the absence of certain program behaviors by classifying phrases according to the kinds of values they compute.

(*Types and Programming Languages*, MIT Press, 2002)

"hello" + 5would be illegal. Hence, any program permitted by the type system would be provably free from the erroneous behavior of adding strings and numbers.

The design and implementation of type systems is a topic nearly as broad as the topic of programming languages itself. In fact, type theory proponents commonly proclaim that the design of type systems is the very essence of programming language design: "Design the type system correctly, and the language will design itself."

Note that type theory, as described herein, refers to static typing disciplines. Programming systems and languages that employ dynamic typing do not prove *a priori* that a program uses values correctly; instead they raise an error at runtime, when the program attempts to perform some behavior that uses values *incorrectly*. Some claim that "dynamic typing" is a misnomer for this reason. In any case, the two should not be confused.

Table of contents |

2 Practical impact of type theory 3 Connections to constructive logic 4 Related topics 5 Further reading 6 External links |

## Major historical developments

- Bertrand Russell and Alfred North Whitehead
- Lambda calculus type systems
- Polymorphic type inference (ML programming language; Hindley-Milner polymorphism)
- subtyping
- Object-oriented static typing (grew out of abstract data type and subtyping)
- F-bounded polymorphism and efforts to combine generic w/ oo polymorphism
- Set-constraint-based type systems
- module systems
- Type-driven proof systems (e.g., ELF)
- ... (much more)

## Practical impact of type theory

- Typed programming languages
- Type-driven program analysis and optimization
- Type-aided security mechanisms (e.g., TAL, Java bytecode verification)

## Connections to constructive logic

- The Curry-Howard isomorphism between logical proof systems and type systems
- Ref: Wadler's "Programs are proofs"
- Intuitionistic Type Theory

## Related topics

- The notion of abstract data types
- The relationship between types and object-oriented programming
- The interplay between types and algorithms
- A formal definition of abstract data types - precondition, postcondition, invariants
- The relationship between types and effects
- Type safety

## Further reading

- Luca Cardelli, "Type Systems,"
*The Computer Science and Engineering Handbook*, Allen B. Tucker (Ed.), chapter 103, pp. 2208-2236, CRC Press, Boca Raton, FL, 1997. (online)

## External links

- Abstract data type
- A summary paper on the formal basis of ADTs, relationship to category theory, and list of good references. Pages 3-4 appear relevant. Reference number [6] looks good, but it may not be available online.