2023-02-05 21:02:05 -08:00
|
|
|
\section{Combinators}
|
2022-11-13 13:02:25 -08:00
|
|
|
|
2023-02-05 21:02:05 -08:00
|
|
|
\definition{}
|
2023-10-04 09:42:09 -07:00
|
|
|
A \textit{free variable} in a $\lm$-expression is a variable that isn't bound to any input. \par
|
2023-10-18 09:16:29 -07:00
|
|
|
For example, $b$ is a free variable in $(\lm a.a)~b$.
|
2022-11-13 13:02:25 -08:00
|
|
|
|
2023-10-18 09:16:29 -07:00
|
|
|
\definition{Combinators}
|
|
|
|
A \textit{combinator} is a lambda expression with no free variables.
|
2022-11-13 13:02:25 -08:00
|
|
|
|
2023-10-18 09:16:29 -07:00
|
|
|
\vspace{1mm}
|
2022-11-13 13:02:25 -08:00
|
|
|
|
2023-10-04 09:42:09 -07:00
|
|
|
Notable combinators are often named after birds.\hspace{-0.5ex}\footnotemark{} We've already met a few: \par
|
|
|
|
The \textit{Idiot}, $I = \lm a.a$ \par
|
|
|
|
The \textit{Mockingbird}, $M = \lm f.ff$ \par
|
|
|
|
The \textit{Cardinal}, $C = \lm fgx.(~ f(g(x)) ~)$
|
2023-10-18 09:16:29 -07:00
|
|
|
The \textit{Kestrel}, $K = \lm ab . a$
|
2022-11-13 13:02:25 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
2023-10-18 09:16:29 -07:00
|
|
|
\problem{}
|
|
|
|
If we give the Kestrel two arguments, it does something interesting: \par
|
|
|
|
It selects the first and rejects the second. \par
|
|
|
|
Convince yourself of this fact by evaluating $(K~\heartsuit~\star)$.
|
2023-10-16 15:06:51 -07:00
|
|
|
|
2023-10-18 09:16:29 -07:00
|
|
|
\vfill
|
2023-10-16 15:06:51 -07:00
|
|
|
|
2023-10-18 09:16:29 -07:00
|
|
|
\problem{}<kitedef>
|
|
|
|
Modify the Kestrel so that it selects its \textbf{second} argument and rejects the first. \par
|
2023-10-16 15:06:51 -07:00
|
|
|
|
2023-10-18 09:16:29 -07:00
|
|
|
\begin{solution}
|
|
|
|
$\lm ab . b$.
|
|
|
|
\end{solution}
|
2022-11-13 13:02:25 -08:00
|
|
|
|
2023-10-18 09:16:29 -07:00
|
|
|
\vfill
|
2022-11-13 13:02:25 -08:00
|
|
|
|
2023-02-05 21:02:05 -08:00
|
|
|
\problem{}
|
2023-10-18 09:16:29 -07:00
|
|
|
We'll call the combinator from \ref{kitedef} the \textit{Kite}, $KI$. \par
|
|
|
|
Show that we can also obtain the kite by evaluating $(K~I)$.
|
2022-11-13 13:02:25 -08:00
|
|
|
|
|
|
|
|
2023-02-05 21:02:05 -08:00
|
|
|
\vfill
|
|
|
|
\pagebreak
|