\documentclass[11pt]{article}
\usepackage{fullpage}
\usepackage{times}
\usepackage{amsmath,proof,amsthm,amssymb}
\setlength{\inferLineSkip}{4pt}

%% part of a problem
\newcommand{\task}[2]
  {\bigskip \noindent
   {\bf Task #1} (#2 pts).}

\newcommand{\ectask}[1]
  {\bigskip \noindent
   {\bf Task #1} (Extra Credit).}

\newcommand{\dsd}[1]{\ensuremath{\mathsf{#1}}}
\newcommand{\irl}[1]{\texttt{#1}}

\newcommand{\true}[1]{\ensuremath{#1 \, \dsd{true}}}

\title{Assignment 2: \\
       Proof Terms}
\author{15-317: Constructive Logic}
\date{Out: Thursday, September 11, 2008 \\
Due: Thursday, September 18, 2008, before class}

\begin{document}
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}[theorem]{Lemma}

\maketitle

\section{Tutch Proofs (12 pts)}

For each of the following propositions:
\begin{enumerate}
\item Determine whether it is true (constructively).
\item If the proposition is true, give a Tutch proof.
\item If the proposition is not true, put a comment in your Tutch file
  explaining why your attempted proofs get stuck.  Comments are lines
  starting with \verb|%|.
\end{enumerate}

\begin{verbatim}
proof demorgan3 : ~(A | B) => ~A & ~B  
proof demorgan4 : ~(A & B) => ~A | ~B
proof imp1 : ((A => B) => C) => (A | C) & (B => C)
proof imp2 : ((A | C) & (B => C)) => ((A => B) => C)
\end{verbatim}

\section{Proof Terms (13 pts)}

Tutch can be used to check proof terms.

Here is a proof of \verb/A => (A & A)/:

\begin{verbatim}
proof dup : A => (A & A) =
begin
[A;
 A & A];
A => A & A;
end;
\end{verbatim}

Here is an \emph{annotated} proof:

\begin{verbatim}
annotated proof dup : A => (A & A) =
begin
[u : A;
 (u,u) : A & A];
fn u => (u , u) : A => A & A;
end;
\end{verbatim}

An annotated proof has the same structure as an ordinary Tutch proof,
except each line has the form \verb|proof : prop|, where the
\verb|proof| term justifies the \verb|prop|osition.  An assumptions is
justified by a variable (\verb|u| in the example above).

Annotated proofs connect proof terms to the Tutch proofs you already
understand.  But they're somewhat verbose, because you have to write the
parts of the proof term multiple times.  Tutch also allows you to write
a complete proof term directly, which is more convenient once you've
gotten used to proving as programming.  For example:

\begin{verbatim}
term dup : A => (A & A) = fn u => (u , u);
\end{verbatim}

For reference, Tutch uses the following syntax for proof terms:

\begin{tabular}{c|c}
Rule       & Proof Term \\
\hline
$\mathord{\supset} I$  & \verb|fn x => M| \\
$\mathord{\supset} E$  & \verb|M N| \\
$\wedge I$   & \verb|(M , N)| \\
$\wedge E_L$ & \verb|fst M| \\
$\wedge E_R$ & \verb|snd M| \\
$\top I$     & \verb|()| \\
$\vee I_L$   & \verb|inl M| \\
$\vee I_R$   & \verb|inr M| \\
$\vee E$     & \verb+case M of inl u => M1 | inr v => M2 end+ \\
$\bot E$     & \verb|abort M| \\
\end{tabular}

\task{1}{13} Use Tutch to give annotated proofs and proof terms for the following:

\begin{verbatim}
annotated proof orcomm : (A | B) => B | A
term orcomm : (A | B) => B | A
annotated proof curry : ((A & B) => C) => (A => (B => C))
term curry : ((A & B) => C) => (A => (B => C))
term uncurry : (A => B => C) => ((A & B) => C)
\end{verbatim}


\section{Biconditional (15 pts)}

In this problem, you will give a direct definition of ``$A$ iff $B$'',
which means ``$A$ implies $B$ and $B$ implies $A$''.  

\newcommand{\hypj}[3]{\deduce{#3}{\deduce{\vdots}{\infer[#1]{#2}{}}}}
\newcommand{\hypjt}[5]{\deduce{#5}{\deduce{\vdots}{\infer[#1]{#2}{} \:\:
      , \:\:\: \infer[#3]{#4}{}}}}

Here is the intro rule:
\[
\infer[\mathord{\equiv} I^{u,v}]
      {\true {A \equiv B}}
      {\hypj{u}{\true A}{\true B} &
	\hypj{v}{\true B}{\true A}}
\]

\task{1}{3} Give the elimination rule(s).

\task{2}{4} Annotate the introduction and elimination rules with proof
terms.  (See Lecture 4 for examples.)

\task{3}{4} Using these proof terms, give the local reduction
$\Rightarrow_R$ and local expansion $\Rightarrow_E$ rules.  (See Lecture
5 for examples.)

\task{4}{4} Show the cases of the subject reduction/expansion theorems
for these rules. (See Lecture 5 for examples.)

Recall that these theorems are stated as follows:
\begin{itemize}
\item Reduction: If $\Gamma \vdash M : A$ and $M \Rightarrow_R M'$ then
  $\Gamma \vdash M' : A$ .
\item Expansion: If $\Gamma \vdash M : A$ and $M \Rightarrow_E M'$ then
$\Gamma \vdash M' : A$ .
\end{itemize}

You may use the following substitution lemma:
\begin{quote}
If $\Gamma, x : A \vdash M : B$ and $\Gamma \vdash N : A$ then 
 $\Gamma \vdash [N/x]M : B$
\end{quote}

\section{Handin Instructions}

\begin{itemize}
\item 
To run Tutch with the requirements files, run

\begin{verbatim}
/afs/andrew/course/15/317/bin/tutch -r hw02.req <your file>
\end{verbatim}

This uses the requirements file
\verb|/afs/andrew/course/15/317/req/hw02.req|.

\item To submit your Tutch proofs, run

\begin{verbatim}
/afs/andrew/course/15/317/bin/submit -r hw02.req <your file>
\end{verbatim}

To check the status of your submission, run
\verb|/afs/andrew/course/15/317/bin/status hw02|.

It is expected for Tutch to report that you have unsolved problems
corresponding to those propositions in Problem 1 that you think are
false.

\item Submit your written work at the beginning of class, or, if you
  wish to do an electronic handin, copy a PDF to 

\begin{verbatim}
/afs/andrew/course/15/317/submit/<yourid>/hw02.pdf
\end{verbatim}

\end{itemize}

\end{document}
