System F
Encyclopedia : S : SY : SYS : System F
- For the electronic dance music artist, see Ferry Corsten
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]
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: [\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 := [\Lambda \alpha.\lambda x^\alpha \lambda y^\alpha.x]
- FALSE := [\Lambda \alpha.\lambda x^\alpha \lambda y^\alpha.y]
- AND := [\lambda x^ \lambda y^.((x (Boolean)) y) FALSE]
- OR := [\lambda x^ \lambda y^.((x (Boolean)) TRUE) y]
- NOT := [\lambda x^. ((x (Boolean)) FALSE) TRUE ]
- IFTHENELSE := [\Lambda \alpha.\lambda x^\lambda y^\lambda z^.((x (\alpha)) y) z ]
- ISZERO := λ n. n (λ x. FALSE) TRUE
System F Structures
System F allows recursive constructions to be embedded in a natural manner, related to that in Martin-Löf's type theory. Suppose you want to create an abstract structure (call it S). The first thing you'll need are constructors. These will be functions whose type will be
- [K_1\rightarrow K_2\rightarrow\dots\rightarrow S].
- [\forall \alpha.(K_1^1[alpha/S]\rightarrow\dots\rightarrow \alpha)\dots\rightarrow(K_1^m[alpha/S]\rightarrow\dots\rightarrow \alpha)\rightarrow \alpha]
- [\mathit : \mathrm]
- [\mathit : \mathrm \to \mathrm]
- 0 := [\Lambda \alpha . \lambda x^\alpha . \lambda f^ . x]
- 1 := [\Lambda \alpha . \lambda x^\alpha . \lambda f^ . f x]
- 2 := [\Lambda \alpha . \lambda x^\alpha . \lambda f^ . f (f x)]
- 3 := [\Lambda \alpha . \lambda x^\alpha . \lambda f^ . f (f (f x))]
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. [link] [link]
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.
References
- 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. [link]
External links
- [Summary of System F] by Frank Binard.
From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.
