Cleanup
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
\section{Numbers}
|
||||
|
||||
Since the only objects we have in $\lm$-calculus are functions, it's natural to think of quantities as \textit{adverbs} (once, twice, thrice,...) rather than \textit{nouns} (one, two, three ...)
|
||||
Since the only objects we have in $\lm$ calculus are functions, it's natural to think of quantities as \textit{adverbs} (once, twice, thrice,...) rather than \textit{nouns} (one, two, three ...)
|
||||
|
||||
\vspace{1ex}
|
||||
|
||||
@ -9,7 +9,7 @@ Here's our \textit{don't} function: given a function and an input, don't apply t
|
||||
$$
|
||||
0 = \lm fa.a
|
||||
$$
|
||||
If you look closely, you'll find that $0$ is $\alpha$-equivalent to the false function $F$.
|
||||
If you look closely, you'll find that $0$ is equivalent to the false function $F$.
|
||||
|
||||
\problem{}
|
||||
Write $1$, $2$, and $3$. We will call these \textit{Church numerals}.\hspace{-0.5ex}\footnotemark{} \\
|
||||
@ -29,16 +29,8 @@ Write $1$, $2$, and $3$. We will call these \textit{Church numerals}.\hspace{-0.
|
||||
|
||||
\vspace{1ex}
|
||||
|
||||
The round parentheses are \textit{essential}. Our lambda calculus is left-associative!
|
||||
|
||||
\vspace{2ex}
|
||||
|
||||
Also, notice that $1$ is very similar to $I$:
|
||||
$$
|
||||
I~\heartsuit~\star = 1~\heartsuit~\star
|
||||
$$
|
||||
|
||||
Zero is false, and one is the identity. Isn't that wonderful?
|
||||
The round parentheses are \textit{essential}. Our lambda calculus is left-associative! \par
|
||||
Also, note that zero is false and one is the (two-variable) identity.
|
||||
\end{solution}
|
||||
|
||||
\vfill
|
||||
@ -111,7 +103,6 @@ Define a function ADD that adds two Church numerals.
|
||||
\vfill
|
||||
|
||||
\problem{}
|
||||
Adding is nice, but we can do better. \par
|
||||
Design a function MULT that multiplies two numbers. \par
|
||||
\hint{The easy solution uses ADD, the elegant one doesn't. Find both!}
|
||||
|
||||
@ -139,10 +130,9 @@ $NZ$ does the opposite. $Z$ and $NZ$ should look fairly similar.
|
||||
\vfill
|
||||
|
||||
\problem{}
|
||||
Data structures will be useful. Design an expression PAIR that constructs two-value tuples. \par
|
||||
Design an expression PAIR that constructs two-value tuples. \par
|
||||
For example, say $A = \text{PAIR}~1~2$. Then, \par
|
||||
$(A~T)$ should reduce to $1$ \par
|
||||
$(A~F)$ should reduce to $2$
|
||||
$(A~T)$ should reduce to $1$ and $(A~F)$ should reduce to $2$.
|
||||
|
||||
\begin{solution}
|
||||
$\text{PAIR} = \lm ab . \lm i . (i~a~b) = \lm abi.iab$
|
||||
@ -150,7 +140,7 @@ $(A~F)$ should reduce to $2$
|
||||
|
||||
\vfill
|
||||
From now on, I'll write (PAIR $A$ $B$) as $\langle A,B \rangle$. \par
|
||||
Like currying, this is only notation. The underlying $\lm$ logic remains the same.
|
||||
Like currying, this is only notation. The underlying logic remains the same.
|
||||
|
||||
\pagebreak
|
||||
|
||||
@ -160,7 +150,7 @@ It does exactly what it says on the tin:
|
||||
|
||||
\vspace{1ex}
|
||||
|
||||
Given an input pair, it should shift its right argument left, then add one. \par
|
||||
Given an input pair, it should shift its second argument left, then add one. \par
|
||||
$H~\langle 0, 1 \rangle$ should reduce to $\langle 1, 2\rangle$ \par
|
||||
$H~\langle 1, 2 \rangle$ should reduce to $\langle 2, 3\rangle$ \par
|
||||
$H~\langle 10, 4 \rangle$ should reduce to $\langle 4, 5\rangle$
|
||||
@ -176,7 +166,7 @@ $H~\langle 10, 4 \rangle$ should reduce to $\langle 4, 5\rangle$
|
||||
|
||||
\vfill
|
||||
|
||||
\problem{}
|
||||
\problem{}<decrement>
|
||||
Design a function $D$ that un-does $S$. That means \par
|
||||
$D(1) = 0$, $D(2) = 1$, etc. $D(0)$ should be zero. \par
|
||||
\hint{$H$ will help you make an elegant solution.}
|
||||
|
Reference in New Issue
Block a user