Typing rule
In type theory and programming language theory, a typing rule is an inference rule that specifies sufficient conditions for a typing judgment to hold.[src] A common form of typing judgment is : \Gamma \vdash e : \tau, read as “under typing context \Gamma , expression e has type \tau ”.[src] A collection of typing rules normally defines a typing relation inductively: a judgment holds when it has a finite derivation constructed from the rules.[src] A program is well-typed when its required top-level typing judgment can be derived.[src] Typing rules are relational specifications rather than necessarily functions from expressions to types.[src] Depending on the type system, an expression may have no derivable type, one type, or several types.[src] Rules may be presented as a declarative mathematical specification or organized into a procedure for type checking or type inference.[src] A common algorithmic organization is bidirectional typing, which distinguishes rules that synthesize a type from rules that check an expression against a type already known from its context.[src]
In type theory and programming language theory, a typing rule is an inference rule that specifies sufficient conditions for a typing judgment to hold.[src] A common form of typing judgment is \Gamma \vdash e : \tau, read as “under typing context \Gamma , expression e has type \tau ”.[src] A collection of typing rules normally defines a typing relation inductively: a judgment holds when it has a finite derivation constructed from the rules.[src] A program is well-typed when its required top-level typing judgment can be derived.[src] Typing rules are relational specifications rather than necessarily functions from expressions to types.[src] Depending on the type system, an expression may have no derivable type, one type, or several types.[src] Rules may be presented as a declarative mathematical specification or organized into a procedure for type checking or type inference.[src] A common algorithmic organization is bidirectional typing, which distinguishes rules that synthesize a type from rules that check an expression against a type already known from its context.[src] \Gamma = x_1{:}\tau_1,\ldots,x_n{:}\tau_n.[src] The notation \Gamma,x{:}\tau means that the context has been extended with the assumption that x has type \tau .[src] A closed expression, having no free variables, is commonly typed under the empty context \varnothing .[src] More elaborate systems may use several contexts or auxiliary judgments.[src] These can record type variables, kinds, locations, constraints, effects, modules, or resources.[src] Examples of auxiliary judgments include type formation, type equality, subtyping, and kinding.[src] The structure of a context is also significant: ordinary structural type systems often treat contexts as finite mappings, whereas linear and other substructural systems may make order or multiplicity relevant.[src] An inference rule is conventionally written \frac{J_1 \qquad \cdots \qquad J_n}{J}, where J_1,\ldots,J_n are the rule's premises and J is its conclusion.[src] The rule states that the conclusion may be derived whenever all its premises have been derived.[src] A rule with no premises is an axiom.[src] Rules can also contain side conditions, such as a freshness requirement or a membership test on a context.[src] Typing rules are generally rule schemes: their metavariables range over all expressions, types, and contexts of the language.[src] A typing derivation is a finite tree whose nodes are judgments, whose root is the judgment being established, and whose children are the premises of the rule used at that node.[src] The inductive structure of derivations is later used in proofs about the type system.[src] \tau ::= \mathsf{Bool} \mid \tau \mathbin{\to} \tau and e ::= x \mid \mathsf{true} \mid \mathsf{false} \mid \mathbf{if}\ e\ \mathbf{then}\ e\ \mathbf{else}\ e \mid \lambda x{:}\tau.\,e \mid e\ e.[src] Boolean constants are typed by axiom schemes: \frac{}{\Gamma \vdash \mathsf{true} : \mathsf{Bool}} \quad\text{(T-True)} \qquad \frac{}{\Gamma \vdash \mathsf{false} : \mathsf{Bool}} \quad\text{(T-False)}.[src] A conditional requires a Boolean condition and branches having the same type: \frac{ \Gamma \vdash e_1 : \mathsf{Bool} \qquad \Gamma \vdash e_2 : \tau \qquad \Gamma \vdash e_3 : \tau }{ \Gamma \vdash \mathbf{if}\ e_1\ \mathbf{then}\ e_2\ \mathbf{else}\ e_3 : \tau } \quad\text{(T-If)}.[src] Variables, abstractions, and applications are typed by the following rules: \frac{x{:}\tau \in \Gamma}{ \Gamma \vdash x : \tau } \quad\text{(T-Var)} \frac{ \Gamma,x{:}\tau_1 \vdash e : \tau_2 }{ \Gamma \vdash \lambda x{:}\tau_1.\,e : \tau_1 \mathbin{\to} \tau_2 } \quad\text{(T-Abs)} \frac{ \Gamma \vdash e_1 : \tau_1 \mathbin{\to} \tau_2 \qquad \Gamma \vdash e_2 : \tau_1 }{ \Gamma \vdash e_1\,e_2 : \tau_2 } \quad\text{(T-App)}.[src] These rules are schemes because \Gamma , e , and the types may be replaced by arbitrary instances.[src] For example, the rules derive \varnothing \vdash (\lambda x{:}\mathsf{Bool}.\,x)\,\mathsf{true} \mathsf{Bool}.[src] The abstraction rule checks the body under a context extended with an assumption about the bound variable.[src] In its conclusion, that assumption has been abstracted into the function type.[src] In proof-theoretic terms, T-Abs is an introduction rule for the function type and T-App is its elimination rule.[src] This correspondence with the introduction and elimination rules of natural deduction is part of the Curry–Howard correspondence.[src] \mathbf{let}\ x=e_1\ \mathbf{in}\ e_2 : \tau_2 }.[src] Here x is available in e_2 at the single type \tau_1 .[src] This is not the full rule for Hindley–Milner let-polymorphism.[src] In a Hindley–Milner system, eligible type variables in the type of e_1 can be generalized into a type scheme, whose different occurrences may subsequently be instantiated at different types.[src]
44 sentences · 44 cited inline · 0 references stored
References
No reference rows published for this article.
Cite this article
MLA
"Typing rule." encyclopegia.org, 2026, https://encyclopegia.org/wiki/typing-rule. Accessed 01 December 2026.
Chicago
"Typing rule." encyclopegia.org. Accessed December 1, 2026. https://encyclopegia.org/wiki/typing-rule.
APA
encyclopegia.org. (2026). Typing rule. Retrieved December 1, 2026, from https://encyclopegia.org/wiki/typing-rule
Accessed December 1, 2026 · CC BY-SA 4.0 · citation page · JSON