next up previous contents
Next: From recursive functional definitions Up: The (untyped) lambda calculus Previous: Encoding recursive functions in   Contents

Fixed points

We begin our discussion of fixed point by providing an encoding for boolean values true (tt) and false (ff) and conditional expressions. We begin with the conditional. We seek a term $\lambda
bxy.~E$ that will take three arguments, return $x$ if $b$ (the conditional expression) is true and $y$ if $b$ is false.

We claim that the expression $\lambda bxy.~bxy$ with the definitions of $\texttt{tt}$ and $\texttt{ff}$ given by $\langle{\texttt{tt}}\rangle \equiv \lambda xy.x$ and $\langle{\texttt{ff}}\rangle \equiv \lambda xy.y $ do the job. (Incidentally, note that $\langle{\texttt{ff}}\rangle $ is the same as $\langle{0}\rangle $).

Clearly

\begin{displaymath}
\begin{array}{lcl}
(\lambda bxy.bxy) \langle{\texttt{tt}}\r...
...ightarrow & (\lambda y. f) g \\
& \rightarrow & f
\end{array}\end{displaymath}

and, similarly,


\begin{displaymath}
\begin{array}{lcl}
(\lambda bxy.bxy) \langle{\texttt{ff}}\r...
...ightarrow & (\lambda y. y) g \\
& \rightarrow & g
\end{array}\end{displaymath}

Thus $\lambda bxy.bxy$ gives us an encoding of the construct if-then-else. We are now close to being able to write recursive function definitions in a syntax similar to languages like Haskell. For instance, we could aim to write


\begin{displaymath}
\mathit{factorial~} \langle{n}\rangle =
\begin{array}[t]{...
...hit{factorial}(\mathit{pred~} \langle{n}\rangle ))
\end{array}\end{displaymath}

where, of course, we still have to encode the predicate iszero and the arithmetic function pred (predecessor).

Assuming we can do this, how do we convert such a recursive definition into a lambda term?



Subsections
next up previous contents
Next: From recursive functional definitions Up: The (untyped) lambda calculus Previous: Encoding recursive functions in   Contents
Madhavan Mukund 2004-04-29