Triangular matrix

From formulasearchengine
Revision as of 18:31, 27 November 2013 by en>Rschwieb (Undid revision 583513769 by 39.45.19.27 (talk) Reverting invalid edits and addition of signature.)
Jump to navigation Jump to search

In type theory, a type rule is an inference rule that describes how a type system assigns a type to a syntactic construction. These rules may be applied by the type system to determine if a program is well typed and what type expressions have. A prototypical example of the use of type rules is in defining type inference in the simply typed lambda calculus, which is the internal language of Cartesian closed categories.

Notation

An expression e of type τ is written as e:τ. The typing environment is written as Γ. The notation for inference is the usual one for sequents and inference rules, and has the following general form

Γ1e1:τ1Γnen:τnΓe:τ

The sequents above the line are the premises that must be fulfilled for the rule to be applied, yielding the conclusion: the sequents below the line. This can be read as: if expression ei has type τi in environment Γi, for all i=1..n, then the expression e will have an environment Γ and type τ.

For example, a simple language to perform arithmetic calculations on real numbers may have the following rules

Γe1:realΓe2:realΓe1+e2:realΓe1:integerΓe2:integerΓe1+e2:integer

A type rule may have no premises, and usually the line is omitted in these cases. A type rule may also change an environment by adding new variables to a previous environment; for example, a declaration may have the following type rule, where a new variable id, with type τ, is added to Γ:

Γe:τΓ,id:τe:τΓlet id = e in e end:τ

This types can be used to derive composed expressions types, much like in natural deduction.

See also

Further reading

  • Luca Cardelli, "Type Systems", ACM Computing Surveys

Template:Type-theory-stub