\section{Boolean Algebra} The Kestrel selects its first argument, and the Kite selects its second. This \say{choosing} behavior is awfully similar to something you may have already seen... \vspace{1ex} Let $T = K\phantom{I} = \lm ab . a$ \\ Let $F = KI = \lm ab . b$ \\ \problem{} Write a function $\text{NOT}$ so that $(\text{NOT} ~ T) = F$ and $(\text{NOT}~F) = T$. \\ \hint{What is $(T~\heartsuit~\star)$? How about $(F~\heartsuit~\star)$?} \begin{solution} $\text{NOT} = \lm a . (a~F~T)$ \\ \end{solution} \vfill \problem{} Write functions $\text{AND}$, $\text{OR}$, and $\text{XOR}$ that satisfy the following table. \begin{center} \begin{tabular}{|| c c || c | c | c ||} \hline $A$ & $B$ & $(\text{AND}~A~B)$ & $(\text{OR}~A~B)$ & $(\text{XOR}~A~B)$ \\ \hline\hline F & F & F & F & F \\ \hline F & T & F & T & T \\ \hline T & F & F & T & T \\ \hline T & T & T & T & F \\ \hline \end{tabular} \end{center} \begin{solution} There's more than one way to do this, of course, but make sure the kids understand how the solutions below work. \begin{align*} \text{AND} &= \lm ab . (a~b~F) = \lm ab . aba \\ \text{OR} &= \lm ab . (a~T~b) = \lm ab . aab \\ \text{XOR} &= \lm ab . (a~ (\text{NOT}~b) ~b) \end{align*} It may be worth mentioning that OR $= \lm ab.(M~a~b)$ is also a solution. \end{solution} \vfill \problem{} To complete our boolean algebra, write the boolean equality check EQ. \\ What inputs should it take? What outputs should it produce? \begin{solution} $\text{EQ} = \lm ab . [a~(bTF)~(bFT)] = \lm ab . [a~b~(\text{NOT}~b)]$ \vspace{1ex} $\text{EQ} = \lm ab . [\text{NOT}~(\text{XOR}~a~b)]$ \end{solution} \vfill \pagebreak