66 lines
1.6 KiB
TeX
Raw Normal View History

2023-02-05 21:02:05 -08:00
\section{Boolean Algebra}
2022-11-13 13:02:25 -08:00
2023-04-02 09:20:18 -07:00
The Kestrel selects its first argument, and the Kite selects its second. This \say{choosing} behavior is similar to something you may have already seen...
2022-11-13 13:02:25 -08:00
2023-02-05 21:02:05 -08:00
\vspace{1ex}
2022-11-13 13:02:25 -08:00
2023-10-04 09:42:09 -07:00
Let $T = K\phantom{I} = \lm ab . a$ \par
Let $F = KI = \lm ab . b$
2022-11-13 13:02:25 -08:00
2023-02-05 21:02:05 -08:00
\problem{}
2023-10-04 09:42:09 -07:00
Write a function $\text{NOT}$ so that $(\text{NOT} ~ T) = F$ and $(\text{NOT}~F) = T$. \par
2023-02-05 21:02:05 -08:00
\hint{What is $(T~\heartsuit~\star)$? How about $(F~\heartsuit~\star)$?}
2022-11-13 13:02:25 -08:00
2023-02-05 21:02:05 -08:00
\begin{solution}
2023-10-04 09:42:09 -07:00
$\text{NOT} = \lm a . (a~F~T)$
2023-02-05 21:02:05 -08:00
\end{solution}
2022-11-13 13:02:25 -08:00
2023-02-05 21:02:05 -08:00
\vfill
2022-11-13 13:02:25 -08:00
2023-02-05 21:02:05 -08:00
\problem{}
Write functions $\text{AND}$, $\text{OR}$, and $\text{XOR}$ that satisfy the following table.
2022-11-13 13:02:25 -08:00
2023-02-05 21:02:05 -08:00
\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}
2022-11-13 13:02:25 -08:00
2023-02-05 21:02:05 -08:00
\begin{solution}
2023-10-05 11:23:03 -07:00
There's more than one way to do this, of course.
2023-02-05 21:02:05 -08:00
\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*}
2022-11-13 13:02:25 -08:00
2023-10-05 11:23:03 -07:00
Another clever solution is $\text{OR} = \lm ab.(M~a~b)$
2023-02-05 21:02:05 -08:00
\end{solution}
2022-11-13 13:02:25 -08:00
2023-02-05 21:02:05 -08:00
\vfill
2022-11-13 13:02:25 -08:00
2023-02-05 21:02:05 -08:00
\problem{}
2023-10-05 11:23:03 -07:00
To complete our boolean algebra, construct the boolean equality check EQ. \par
2023-02-05 21:02:05 -08:00
What inputs should it take? What outputs should it produce?
2022-11-13 13:02:25 -08:00
2023-02-05 21:02:05 -08:00
\begin{solution}
$\text{EQ} = \lm ab . [a~(bTF)~(bFT)] = \lm ab . [a~b~(\text{NOT}~b)]$
2022-11-13 13:02:25 -08:00
2023-02-05 21:02:05 -08:00
\vspace{1ex}
2022-11-13 13:02:25 -08:00
2023-02-05 21:02:05 -08:00
$\text{EQ} = \lm ab . [\text{NOT}~(\text{XOR}~a~b)]$
\end{solution}
2022-11-13 13:02:25 -08:00
2023-02-05 21:02:05 -08:00
\vfill
\pagebreak