\documentclass{article}

\usepackage{fullpage,parskip}
\usepackage{amsmath,amssymb}
\usepackage{xcolor}

\newcommand{\XXX}{
  {\color{red} \textsf{\textbf{XXX}}}
}

\begin{document}

% To run this file, you'll need to have LaTeX installed. All of the
% lab computers have it. You can download a complete LaTeX
% distribution from
% https://www.tug.org/texlive/acquire-netinstall.html.

% Once you have LaTeX, you can either build your PDF on the
% command-line by running 'pdflatex hwXX.tex' to generate hwXX.pdf, or
% you can use an editor like LyX, TeXShop, or ShareLaTeX which
% automates the building of your PDF.

% Please submit your PDF on Gradescope.

% LATEX CHEAT SHEET:
%
% put math between dollar signs.
%
% true        === \top
% false       === \bot
% p   and   q === p \wedge q
% p    or   q === p \vee q
% p implies q === p \rightarrow q
% not p       === \neg p
%
% COQ/LATEX/MATH NOTATION HINTS
%
% Coq syntax isn't the same as mathematical notation or LaTeX syntax
% as we'd like you to use it. Some important differences:
%
% Coq                   Math                     Latex
% --------------        ------------------       -------------------
% eqb 0 1               eqb(0, 1)                \texttt{eqb}(0, 1)
% O                     0                        0
% S O                   1                        1 or S(0), depending on context
% S n                   S(n) or 1+n or n+1       S(n)

\noindent
% fill in the XXXs below
{\Large CS054 Informal HW Basics \\ \\ Name: \XXX \\ \\ CAS ID: \XXX} \\[.5em]
% We encourage you to collaborate, but please list any other students
% you talked to about the homework. If you worked alone, please just
% remove the XXXs.
%
% NOTE: However much you work with other students, you must write your
% solution yourself.
Collaborators: \XXX

% Okay! Solve the problems below. please don't delete the problem
% statement after `\item` or the `enumerate' bracketing which provides
% the numbering. Make sure the `\clearpage` comes after your answer.

\begin{enumerate}
\item Which CS courses have you taken?

  \textbf{Answer:} \XXX

\item Which math courses have you taken? If you have taken no math
  classes at Pomona, what's the most advanced math course you've
  completed?

  \textbf{Answer:} \XXX

  \clearpage

\item Write a truth table for the expression \texttt{orb (negb a) b}, i.e., $\neg a \vee b$.

  \textbf{Answer:} \XXX
  \clearpage

\item Write a truth table for the function \texttt{andb3}; call the
  arguments $b_1$, $b_2$, and $b_3$.

  \textbf{Answer:} \XXX
  \clearpage

\item The digital logic NAND operation (\underline{n}egated
  \underline{and}, which we called \texttt{nandb} in Coq) is
  functionally complete, i.e., all boolean formulae can be expressed
  using only NAND. We can prove that NAND is functionally complete by
  showing how it can \textit{encode} another set of functionally
  complete operators: in this case, negation ($\neg$
  a/k/a \texttt{negb}), conjunction ($\wedge$ a/k/a \texttt{andb}),
  and disjunction ($\vee$ a/k/a \texttt{orb}).

  In math, NAND is typically written with the Sheffer stroke, $p \mid
  q$. We have $p \mid q$ when one or both of $p$ and $q$ are false;
  $p \mid q$ is false when both $p$ and $q$ are true.

  \begin{enumerate}
  \item Write the truth table for $p \mid q$.

    \textbf{Answer:} \XXX

    \clearpage


  \item Find an expression $r$ using only $a$, $\mid$, $\top$, and
    $\bot$ that is equivalent to $\neg a$ (i.e., write an expression
    using those terms to find something equivalent to \texttt{negb
    a}). Prove your formula is equivalent to \texttt{negb} using a
    truth table.

    \textbf{Answer:} \XXX \\
    \textbf{Proof:} \XXX
\clearpage
  \item Find a formula $s$ using only $a$, $b$, $\mid$, $\top$, and
    $\bot$ that is equivalent to $a \wedge b$. Prove your formula is
    equivalent using a truth table.

    \textbf{Answer:} \XXX \\
    \textbf{Proof:} \XXX
\clearpage
  \item Find a formula $t$ using only $a$, $b$, $\mid$, $\top$, and
    $\bot$ that is equivalent to $a \vee b$. Prove your formula is
    equivalent using a truth table.

    \textbf{Answer:} \XXX \\
    \textbf{Proof:} \XXX
    \clearpage

  \item Prove that $a \mid b = \neg (a \wedge b)$ using an informal
    proof (\emph{not} a truth table). (It may help to look
    at \texttt{nandb\_\_negb\_andb} in Coq, but don't just transcribe the proof.)

    \textbf{Proof:} \XXX
    \clearpage

  \end{enumerate}

\item Prove \texttt{zero\_nbeq\_plus\_1\_paper} on paper, i.e.,
  \[ \forall n, \texttt{eqb}(0, n + 1) = \bot \]

  \textbf{Proof:} \XXX

\end{enumerate}
\end{document}
