The simply typed lambda calculus (λ→), a form of type theory, is a typed interpretation of the lambda calculus with only one type constructor (→) that builds function types. It is the canonical and simplest example of a typed lambda calculus. The simply typed lambda calculus was originally introduced by Alonzo Church in 1940 as an attempt to avoid paradoxical use of the untyped lambda calculus. The term simple type is also used to refer to extensions of the simply typed lambda calculus with constructs such as products, coproducts or natural numbers (System T) or even full recursion (like PCF). In contrast, systems that introduce polymorphic types (like System F) or dependent types (like the Logical Framework) are not considered simply typed. The simple types, except for full recursion, are still considered simple because the Church encodings of such structures can be done using only → and suitable type variables, while polymorphism and dependency cannot.
Syntax In the 1930s Alonzo Church sought to use the logistic method: his lambda calculus, as a formal language based on symbolic expressions, consisted of a enumerably infinite series of axioms and variables, but also a finite set of primitive symbols, denoting abstraction and scope, as well as four constants: negation, disjunction, universal quantification, and selection respectively; and also, a finite set of rules I to VI. This finite set of rules included rule V modus ponens as well as IV and VI for substitution and generalization respectively. Rules I to III are known as alpha, beta, and eta conversion in the lambda calculus. Church sought to use English only as a syntax language (that is, a metamathematical language) for describing symbolic expressions with no interpretations. In 1940 Church settled on a subscript notation for denoting the type in a symbolic expression. In his presentation, Church used only two base types: o for "the type of propositions" and ι for "the type of individuals". The type o has no term constants, whereas ι has one term constant. Frequently the calculus with only one base type, usually o, is considered. The Greek letter subscripts α, β, etc. denote type variables; the parenthesized subscripted (αβ) denotes the function type β→α. Church 1940 p.58 used 'arrow or →' to denote stands for, or is an abbreviation for. By the 1970s stand-alone arrow notation was in use; for example in this article non-subscripted symbols σ and τ can range over types. The infinite number of axioms were then seen to be a consequence of applying rules I to VI to the types (see Peano axioms). Informally, the function type σ→τ refers to the type of functions that, given an input of type σ, produce an output of type τ. By convention, → associates to the right: σ→τ→ρ is read as σ→(τ→ρ). To define the types, a set of base types, B, must first be defined. These are sometimes called atomic types or type constants. With this fixed, the syntax of types is:
τ::=τ→τ∣TwhereT∈B. For example, B={a,b}, generates an infinite set of types starting with a, b, a→a, a→b, b→b, b→a, a→(a→a), ..., (b→a)→(a→b), ... A set of term constants is also fixed for the base types. For example, it might be assumed that one of the base types is nat, and its term constants could be the natural numbers. The syntax of the simply typed lambda calculus is essentially that of the lambda calculus itself. The term x:τ denotes that the variable x is of type τ. The term syntax, in Backus–Naur form, is variable reference, abstractions, application, or constant:
e::=x∣λx:τ.e∣ee∣c where c is a term constant. A variable reference x is bound if it is inside of an abstraction binding x. A term is closed if there are no unbound variables. In comparison, the syntax of untyped lambda calculus has no such typing or term constants:
e::=x∣λx.e∣ee Whereas in typed lambda calculus every abstraction (i.e. function) must specify the type of its argument.
Typing rules To define the set of well-typed lambda terms of a given type, one defines a typing relation between terms and types. First, one introduces typing contexts, or typing environments Γ,Δ,…, which are sets of typing assumptions. A typing assumption has the form x:σ, meaning variable x has type σ. The typing relation Γ⊢e:σ indicates that e is a term of type σ in context Γ. In this case e is said to be well-typed (having type σ). Instances of the typing relation are called typing judgments. The validity of a typing judgment is shown by providing a typing derivation, constructed using typing rules (wherein the premises above the line allow us to derive the conclusion below the line). Simply typed lambda calculus uses these rules:
In words,
If x has type σ in the context, then x has type σ. Term constants have the appropriate base types. If, in a certain context with x having type σ, e has type τ, then, in the same context without x, λx:σ.e has type σ→τ. If, in a certain context, e1 has type σ→τ, and e2 has type σ, then e1e2 has type τ. Examples of closed terms, i.e. terms typable in the empty context, are:
For every type τ, a term λx:τ.x:τ→τ (identity function/I-combinator), For types σ,τ, a term λx:σ.λy:τ.x:σ→τ→σ (the K-combinator), and For types τ,τ′,τ″, a term λx:τ→τ′→τ″.λy:τ→τ′.λz:τ.xz(yz):(τ→τ′→τ″)→(τ→τ′)→τ→τ″ (the S-combinator). These are the typed lambda calculus representations of the basic combinators of combinatory logic. Each type τ is assigned an order, a number o(τ). For base types, o(T)=0; for function types, o(σ→τ)=max(o(σ)+1,o(τ)). That is, the order of a type measures the depth of the most left-nested arrow. Hence:
o(ι→ι→ι)=1 o((ι→ι)→ι)=2
Semantics
… excerpt ends here. Continue reading the full article.