- Mogensen–Scott encoding
-
In computer science, Scott encoding is a way to embed inductive datatypes in the lambda calculus. Mogensen–Scott encoding extends and slightly modifies this to an embedding of all terms of the untyped lambda calculus.
Contents
Definition
Let D be a datatype with N constructors, , such that constructor Ci has arity Ai.
Church encoding
For comparison, the Church encoding of constructor Ci of D is
Scott encoding
The Scott encoding of constructor Ci of D is
Mogensen–Scott encoding
Mogensen extends Scott encoding to all untyped lambda terms:
Comparison to the Church encoding
The Scott and Church encodings coincide on enumerated datatypes such as the boolean datatype.
Church encoded data and operations on them are typable in system F, but Scott encoded data and operations are not obviously typable in system F. Universal as well as recursive types appear to be required, and since strong normalization does not hold for recursively typed lambda calculus, termination of programs manipulating Scott-encoded data cannot be established by determining well-typedness of such programs.
References
- Directly Reflective Meta-Programming
- Torben Mogensen (1992). Efficient Self-Interpretation in Lambda Calculus. Journal of Functional Programming.
Categories:- Lambda calculus
- Computer science stubs
Wikimedia Foundation. 2010.