Type rule

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 formula_1 of type formula_2 is written as formula_3. The typing environment is written as formula_4. The notation for inference is the usual one for sequents and inference rules, and has the following general form
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 formula_6 has type formula_7 in environment formula_8, for all formula_9, then the expression formula_1 will have an environment formula_4 and type formula_2".
For example, a simple language to perform arithmetic calculations on real numbers may have the following rules
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 formula_14,
with type formula_15, is added to formula_4:
Here the syntax of the let expression is that of Standard ML. Thus type rules can be used to derive the types of composed expressions, much like in natural deduction.