<?xml version="1.0" encoding="UTF-8"?>

<record version="5" id="2785">
 <title>Church integer</title>
 <name>ChurchInteger</name>
 <created>2002-03-09 14:55:40</created>
 <modified>2004-09-18 16:27:28</modified>
 <type>Definition</type>
 <creator id="2727" name="mathcam"/>
 <author id="2727" name="mathcam"/>
 <author id="6" name="Logan"/>
 <classification>
	<category scheme="msc" code="03B40"/>
	<category scheme="msc" code="68N18"/>
 </classification>
 <related>
	<object name="LambdaCalculus"/>
 </related>
 <preamble>\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{listings}</preamble>
 <content>A \emph{Church integer} is a representation of integers as functions, invented by Alonzo Church.  An integer $N$ is represented as a higher-order function, which applies a given function to a given expression $N$ times.

For example, in the programming language Haskell, a function that returns a particular Church integer might be

\begin{align*}
\operatorname{church} 0 &amp;= \ f x \rightarrow x\\
\operatorname{church} n &amp;= c\\
&amp;\operatorname{where}: c f x = c' f (f x)\\
&amp;\hspace{.5in}\operatorname{where}: c' = \operatorname{church} (n - 1)\\
\end{align*}

The transformation from a Church integer to an integer might be

\begin{verbatim}
unchurch n = n (+1) 0
\end{verbatim}

Thus we can generate the integers--the \texttt{(+1)} function would be applied to an initial value of $0$ $n$ times, yielding the ordinary integer $n$.</content>
</record>
