# System F

﻿
System F

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→ Awould be formalized in System F as the judgement

:$vdash Lambdaalpha. lambda x^alpha.x: forallalpha.alpha o 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.

Logic and predicates

The "Boolean" type is defined as:$forallalpha.alpha o alpha o alpha$, where α is a type variable.This produces the following two definitions for the boolean values TRUE and FALSE:

: TRUE := $Lambda alpha.lambda x^alpha lambda y^alpha.x$: FALSE := $Lambda alpha.lambda x^alpha lambda y^alpha.y$

Then, with these two λ-terms, we can define some logic operators:: AND := $lambda x^\left\{Boolean\right\} lambda y^\left\{Boolean\right\}.\left(\left(x \left(Boolean\right)\right) y\right) FALSE$: OR := $lambda x^\left\{Boolean\right\} lambda y^\left\{Boolean\right\}.\left(\left(x \left(Boolean\right)\right) TRUE\right) y$: NOT := $lambda x^\left\{Boolean\right\}. \left(\left(x \left(Boolean\right)\right) FALSE\right) 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 := $Lambda alpha.lambda x^\left\{Boolean\right\}lambda y^\left\{alpha\right\}lambda z^\left\{alpha\right\}.\left(\left(x \left(alpha\right)\right) y\right) 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". "n" (λ "x". FALSE) TRUE

ystem F Structures

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 ightarrow K_2 ightarrowdots ightarrow S$.

Recursivity is manifested when $S$ itself appears within one of the types $K_i$. If you have $m$ of these constructors, you can define the type of $S$ as::$forall alpha.\left(K_1^1 \left[alpha/S\right] ightarrowdots ightarrow alpha\right)dots ightarrow\left(K_1^m \left[alpha/S\right] ightarrowdots ightarrow alpha\right) ightarrow alpha$

For instance, the natural numbers can be defined as an inductive datatype $N$ with constructors:$mathit\left\{zero\right\} : mathrm\left\{N\right\}$:$mathit\left\{succ\right\} : mathrm\left\{N\right\} o mathrm\left\{N\right\}$The System F type corresponding to this structure is$forall alpha. alpha o \left(alpha o alpha\right) o 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^\left\{alpha oalpha\right\} . x$: 1 := $Lambda alpha . lambda x^alpha . lambda f^\left\{alpha oalpha\right\} . f x$: 2 := $Lambda alpha . lambda x^alpha . lambda f^\left\{alpha oalpha\right\} . f \left(f x\right)$: 3 := $Lambda alpha . lambda x^alpha . lambda f^\left\{alpha oalpha\right\} . f \left(f \left(f x\right)\right)$

If we reverse the order of the curried arguments ("i.e.," $forall alpha. \left(alpha o alpha\right) o alpha o alpha$), then the Church numeral for $n$ is a function that takes a function "f" as argument and returns the $n^ extrm\left\{th\right\}$ 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.

Use in programming languages

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. [http://www.macs.hw.ac.uk/~jbw/research-summary.html] [http://www.church-project.org/reports/Wells:APAL-1999-v98-no-note.html]

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 98 and ML. Over time, as the restrictions of HM-style type systems have become apparent, languages have steadily moved to more expressive logics for their type systems. As of 2008, the Haskell compiler, GHC, goes beyond HM, and now uses System F extended with non-syntactic type equality, for example.

System $F_omega$

System $F_1$ is the simply-typed lambda calculus; it includes no mappings from types to types. The System F described in this article is technically System $F_2$; that is, the system wherein all mappings from types to types take arguments which are strictly first-order (not functions themselves).

In general, there is a family of systems defined inductively by the "kinds" permitted in each system:

* $F_1$ does not permit any kinds (only types)
* $F_n$ permits kinds:
** $star$ (the kind of types) and
** $JRightarrow K$ where $Jin F_\left\{n-1\right\}$ and $Kin F_n$ (the kind of functions from types to types, where the argument type is of a lower order)

In the limit, we can define system $F_omega$ to be

*

That is, $F_omega$ is the system which allows functions from types to types where the argument (and result) may be of any order.

Note that although $F_omega$ places no restrictions on the "order" of the arguments in these mappings, it does restrict the "universe" of the arguments for these mappings -- they must be types rather than values. System $F_omega$ does not permit mappings from values to types (Dependent types), though it does permit mappings from values to values ($lambda$ abstraction), mappings from types to values ($Lambda$ abstraction, sometimes written $forall$) and mappings from types to types ($lambda$ abstraction at the level of types)

References

*Girard, Lafont and Taylor, [http://www.PaulTaylor.EU/stable/Proofs%2BTypes.html "Proofs and Types"] . Cambridge University Press, 1989, ISBN 0 521 37181 3.
*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. [http://www.macs.hw.ac.uk/~jbw/papers/Wells:Typability-and-Type-Checking-in-the-Second-Order-Lambda-Calculus-Are-Equivalent-and-Undecidable:LICS-1994.ps.gz]

* [http://www.site.uottawa.ca/~fbinard/Intuitionism/TypeTheory/SystemF/ Summary of System F] by Franck Binard.

Wikimedia Foundation. 2010.

### Look at other dictionaries:

• system — sys‧tem [ˈsɪstm] noun [countable] an arrangement or organization of ideas, methods, or ways of working: • Deregulation has created worries about the stability of the country s financial system. • All staff will benefit from a well run… …   Financial and business terms

• System — (from Latin systēma , in turn from Greek polytonic|σύστημα systēma) is a set of interacting or interdependent entities, real or abstract, forming an integrated whole. The concept of an integrated whole can also be stated in terms of a system… …   Wikipedia

• System i — Modell 570 mit Power 6 Prozessoren (Oktober 2007) i5 Modell 570 (2006) Syst …   Deutsch Wikipedia

• System i5 — System i Modell 570 mit Power 6 Prozessoren (Oktober 2007) i5 Modell 570 (2006) System i (frühere Namen AS/400 oder eServer iSeries oder System i5) ist eine Computer Baureihe der Firma IBM. IBMs Systeme …   Deutsch Wikipedia

• System z — System z9 Typ 2094 System z9 Typ 2094, mit geöffneten Fronttüren und ausgeklapptem Suppor …   Deutsch Wikipedia

• System — of a Down System of a Down System of a Down au Download Festival en mai 2005. Pays d’origine …   Wikipédia en Français

• System 22.5 — System 23 Le System 23 est un système de jeux vidéo pour borne d arcade compatible JAMMA destiné aux salles d arcade, créé par la société japonaise Namco en 1997. Logo du système Gorgon Sommaire …   Wikipédia en Français

• System p — линейка серверов и рабочих станций компании IBM, ранее известна как RS/6000. В Апреле 2008 года компания IBM заявила о слиянии платформ System p и System i. Объединенный продукт носит название IBM Power Systems. Содержание 1 История 2 Процессоры …   Википедия

• System 7 — (nombre clave Big Bang y a veces llamado Mac OS 7) es una versión de Mac OS, el sistema operativo de los ordenadores personales Macintosh introducido el 13 de mayo de 1991. Sucede al System 6, y fue el principal sistema operativo de los Mac hasta …   Wikipedia Español

• System 7 — Bildschirmfoto Basisdaten Entwickler …   Deutsch Wikipedia