System F

From Wikipedia, the free encyclopedia

For the electronic dance music artist, see Ferry Corsten.

System F, also known as the polymorphic lambda calculus or the second-order lambda calculus, is a typed lambda calculus. It was discovered independently by the logician Jean-Yves Girard and the computer scientist John C. Reynolds. System F formalizes the notion of parametric polymorphism in programming languages.

Just as the lambda calculus has variables ranging over functions, and binders for them, the second-order lambda calculus has variables ranging over types, and binders for them.

As an example, the fact that the identity function can have any type of the form A→ A would be formalized in System F as the judgement

\vdash \Lambda\alpha. \lambda x^\alpha.x: \forall\alpha.\alpha \to \alpha

where α is a type variable.

Under the Curry-Howard isomorphism, System F corresponds to a second-order logic.

System F, together with even more expressive lambda calculi, can be seen as part of the lambda cube.

Contents

The Boolean type is defined as: \forall\alpha.\alpha \to \alpha \to \alpha, where α is a type variable. This produces the following two definitions for the boolean values TRUE and FALSE:

TRUE := Λα.λxαλyα.x
FALSE := Λα.λxαλyα.y

Then, with these two λ-terms, we can define some logic operators:

AND := λxBooleanλyBoolean.((x(Boolean))y)FALSE
OR := λxBooleanλyBoolean.((x(Boolean))TRUE)y
NOT := λxBoolean.((x(Boolean))FALSE)TRUE

There really is no need for a IFTHENELSE function as one can just use raw Boolean typed terms as decision functions. However, if one is requested:

IFTHENELSE := Λα.λxBooleanλyαλzα.((x(α))y)z

will do. A predicate is a function which returns a boolean value. The most fundamental predicate is ISZERO which returns TRUE if and only if its argument is the Church numeral 0:

ISZERO := λ n. nx. FALSE) TRUE

System F allows recursive constructions to be embedded in a natural manner, related to that in Martin-Löf's type theory. Abstract structures (S) are created using constructors. These are functions typed as:

K_1\rightarrow K_2\rightarrow\dots\rightarrow S.

Recursivity is manifested when S itself appears within one of the types Ki. If you have m of these constructors, you can define the type of S as:

\forall \alpha.(K_1^1[\alpha/S]\rightarrow\dots\rightarrow \alpha)\dots\rightarrow(K_1^m[\alpha/S]\rightarrow\dots\rightarrow \alpha)\rightarrow \alpha

For instance, the natural numbers can be defined as an inductive datatype N with constructors

zero:N
\mathit{succ} : \mathrm{N} \to \mathrm{N}

The System F type corresponding to this structure is \forall \alpha. \alpha \to (\alpha \to \alpha) \to \alpha. The terms of this type comprise a typed version of the Church numerals, the first few of which are:

0 := \Lambda \alpha . \lambda x^\alpha . \lambda f^{\alpha\to\alpha} . x
1 := \Lambda \alpha . \lambda x^\alpha . \lambda f^{\alpha\to\alpha} . f x
2 := \Lambda \alpha . \lambda x^\alpha . \lambda f^{\alpha\to\alpha} . f (f x)
3 := \Lambda \alpha . \lambda x^\alpha . \lambda f^{\alpha\to\alpha} . f (f (f x))

If we reverse the order of the curried arguments (i.e., \forall \alpha. (\alpha \to \alpha) \to \alpha \to \alpha), then the Church numeral for n is a function that takes a function f as argument and returns the nth power of f. That is to say, a Church numeral is a higher-order function -- it takes a single-argument function f, and returns another single-argument function.

The version of System F used in this article is as an explicitly-typed, or Church-style, calculus. The typing information contained in λ-terms makes type-checking straightforward. Joe Wells (1994) settled an "embarrassing open problem" by proving that type checking is undecidable for a Curry-style variant of System F, that is, one that lacks explicit typing annotations. [1] [2]

Wells' result implies that type inference for System F is impossible. A restriction of System F known as "Hindley-Milner", or simply "HM", does have an easy type inference algorithm and is used for many strongly typed functional programming languages such as Haskell and ML.

  • Girard, Lafont and Taylor, 1997. Proofs and Types. Cambridge University Press.
  • J. B. Wells. "Typability and type checking in the second-order lambda-calculus are equivalent and undecidable." In Proceedings of the 9th Annual IEEE Symposium on Logic in Computer Science (LICS), pages 176-185, 1994. [3]

Advanced Search
Included Web Search Engines


Safe Search

close

Top Matching Results

Occasionally Search.com will highlight specialized results that are based on the context of your query. Examples of specialized results include specific links to news, images, or video.

Top Matching Results may highlight information from other Search.com pages, content from the CNET Network of sites, or third party content. The listings are based purely on relevance. Search.com does not receive payment for listings in this section but our partners that provide this data may get paid for listing these products.

Sponsored Links

This section contains paid listings which have been purchased by companies that want to have their sites appear for specific search terms and related content. These listings are administered, sorted and maintained by a third party and are not endorsed by Search.com.

Search Results

Search.com sends your search query to several search engines at one time and integrates the results into one list which has been sorted by relevance using Search.com's proprietary algorithm. You can customize the list of search engines included in your metasearch from the preferences.

The search engines that are used in your metasearch may allow companies to pay to have their Web sites included within the results. To view the Paid Inclusion policy for a specific search engine, please visit their Web site. Search.com does not accept payment or share revenue with any search engine partner for listings in this section.