\documentclass[11pt]{article}

\usepackage[margin=1.6in]{geometry}
\usepackage{proof}
\usepackage{amsmath,amsthm,amssymb}
\usepackage[raiselinks=false,colorlinks=true,citecolor=blue,urlcolor=blue,linkcolor=blue,bookmarksopen=true,dvips]{hyperref}

% font{
\usepackage{pxfonts}
%% fix sans serif
\renewcommand\sfdefault{cmss}
\DeclareMathAlphabet{\mathsf}{OT1}{cmss}{m}{n}
\SetMathAlphabet{\mathsf}{bold}{OT1}{cmss}{b}{n}
% }font

\theoremstyle{definition}
\newtheorem{task}{Task}

\newcommand\pimp{\mathrel{\supset}}
\newcommand\pand{\mathrel{\wedge}}
\newcommand\por{\mathrel{\vee}}
\newcommand\ptrue{\top}
\newcommand\pfalse{\bot}
\newcommand\pspades{\spadesuit}
\newcommand\pforall[3]{\forall #1{:}#2.\, #3}
\newcommand\pexists[3]{\exists #1{:}#2.\, #3}
\newcommand\qtri\blacktriangledown
\newcommand\ptri[3]{\qtri #1{:}#2.\, #3}

\newcommand\true{\;\textit{true}}
\newcommand\ddd{\raisebox{0.2em}[1.3em]{$\vdots$}}
\newcommand\com{\raisebox{0.3em}{$\ ,\ \ $}}
\newcommand\hyp[2][]{\infer[#1]{#2}{}}
\newcommand\sub[3]{\infer[#2]{#3}{#1}}

\newcommand{\lred}{\mathrel{\raisebox{0.5em}{$\Longrightarrow_R$}}}
\newcommand{\lexp}{\mathrel{\raisebox{0.5em}{$\Longrightarrow_E$}}}

\newcommand{\DD}{\mathcal{D}}
\newcommand{\EE}{\mathcal{E}}
\newcommand{\FF}{\mathcal{F}}
\newcommand{\GG}{\mathcal{G}}

% some URLs used below
\newcommand\tutchGuideURL{http://www.cs.cmu.edu/~fp/courses/15317-f09/software/tutch/doc/html/tutch_ovr.html}
\newcommand\tutchProofTermsURL{http://www.cs.cmu.edu/~fp/courses/15317-f09/software/tutch/doc/html/tutch_4.html\#SEC18}
\newcommand\tutchProofTermsRefURL{http://www.cs.cmu.edu/~fp/courses/15317-f09/software/tutch/doc/html/tutch_9.html\#SEC28}

\title{Constructive Logic (15-317), Fall 2009 \\
       Assignment 2: Quantifiers and Proof Terms}
\author{William Lovas \texttt{(wlovas@cs)}}
\date{Out: Thursday, September 10, 2009 \\
      Due: Thursday, September 17, 2009 (before class)}

\begin{document}
\maketitle

Previously, your work in this course has concerned only the propositional
fragment of intuitionistic logic.
In this homework, you will delve into the exciting world of first-order
logic by solving problems involving the quantifiers $\forall$ and
$\exists$.  Furthermore, you'll have a chance to explore the Curry-Howard
correspondence between logic and computation by writing proof terms
representing your deductions.  Finally, you'll continue to expand your
understanding of harmony in definitions of logics by playing with a new
quantifier.

The Tutch portion of your work (Section~\ref{sec:tutch}) should be
submitted electronically using the command
\begin{verbatim}
  $ /afs/andrew/course/15/317/bin/submit -r hw02 <files...>
\end{verbatim}
from any Andrew server.  You may check the status of your submission by
running the command
\begin{verbatim}
  $ /afs/andrew/course/15/317/bin/status hw02
\end{verbatim}
If you have trouble running either of these commands, email William.

The written portion of your work (Section~\ref{sec:tri}) should be
submitted at the beginning of class.  If you are familiar with \LaTeX, you
are encouraged to use this document as a template for typesetting your
solutions, but you may alternatively write your solutions \textit{neatly}
by hand.

\section{Tutch Proofs and Proof Terms (25 points)}
\label{sec:tutch}

Tutch allows you to give an \textit{annotated proof} for a proposition by
declaring it with \texttt{annotated proof}.  An annotated proof is just
like a regular Tutch proof, but each line \texttt{A} is annotated with the
term that justifies it \texttt{M : A}\@.  Such an annotated proof is
essentially a typing derivation for the proof term at its conclusion.
Here's a simple example showing that conjunction is commutative:
\begin{verbatim}
  annotated proof andComm : A & B => B & A =
  begin
    [ u : A & B;
      snd u : B;
      fst u : A;
      (snd u, fst u) : B & A ];
    fn u => (snd u, fst u) : A & B => B & A
  end;
\end{verbatim}
Since a proof term determines the structure of the proof, Tutch also allows
you to give just the proof term, by declaring it with \texttt{term}:
\begin{verbatim}
  term andComm : A & B => B & A =
    fn u => (snd u, fst u);
\end{verbatim}
For more examples, see \href{\tutchProofTermsURL}{Chapter~4} of the
\href{\tutchGuideURL}{\textit{Tutch User's Guide}}.  The proof terms are
very similar to the ones given in lecture and are summarized in
\href{\tutchProofTermsRefURL}{Section~A.2.1} of the \textit{Guide}.

\begin{task}[6 pts]
  Prove the theorem $(A \por C) \pand (B \pimp C) \pimp (A \pimp B) \pimp
  C$ using Tutch.  Give a proof, an annotated proof, and a proof term.
\begin{verbatim}
  proof implOr : (A | C) & (B => C)  =>  (A => B) => C
  annotated proof implOr : (A | C) & (B => C)  =>  (A => B) => C
  term implOr : (A | C) & (B => C)  =>  (A => B) => C
\end{verbatim}
\end{task}

\begin{task}[13 pts]
  Prove the following theorems using Tutch, and provide proof terms.
\begin{verbatim}
  proof curry : (A & B => C) => (A => B => C)
  proof qcurry : ((?x:t. B(x)) => C) => (!x:t. B(x) => C)

  term curry : (A & B => C) => (A => B => C)
  term qcurry : ((?x:t. B(x)) => C) => (!x:t. B(x) => C)

  proof compose : (!x:t. A(x) => B(x))
               => (!x:t. B(x) => C(x))
               => !x:t. A(x) => C(x)

  term compose : (!x:t. A(x) => B(x))
              => (!x:t. B(x) => C(x))
              => !x:t. A(x) => C(x)
\end{verbatim}
\end{task}

\pagebreak[2]
\begin{task}[6 pts]
  Prove the following theorems using Tutch.
\begin{verbatim}
  proof distribAllAnd
         : (!x:t. A(x) & B(x)) <=> (!x:t. A(x)) & (!x:t. B(x))
  proof distribExAnd1
         : (?x:t. A(x) & B(x)) => (?x:t. A(x)) & (?x:t. B(x))
\end{verbatim}
\end{task}

On Andrew machines, you can check your progress against the requirements
file \texttt{/afs/andrew/course/15/317/req/hw02.req} by running the command
\begin{verbatim}
  $ /afs/andrew/course/15/317/bin/tutch -r hw02 <files...>
\end{verbatim}

\section{A Mixed-Up Quantifier (15 points)}
\label{sec:tri}
In recitation, we saw that we could not prove $(\pforall x \tau {A(x)})
\pimp \pexists x \tau {A(x)} \true$---our universal quantifier permits the
domain of quantification to be empty!  We were able to hack around this by
proving a different proposition, but suppose we wanted to directly define a
universal quantifier $\ptri x \tau {A(x)}$ that did \textit{not} permit
vacuous quantification.  What would such a quantifier look like?

Its introduction rule ${\qtri}I^a$ is similar to ${\forall}I^a$: we must
prove $A(a)$ for a new parameter $a : \tau$.  However, to ensure the domain
of quantification is non-empty, we must also supply an element $t : \tau$.
\[
\infer[{\qtri}I^a]
      {\ptri x \tau {A(x)} \true}
      {t : \tau  &  \deduce[\ddd]{A(a) \true}{\hyp{a : \tau}}}
\]
Then we can give two elimination rules, one with an existential character
and one with a universal character.
\[
\infer[{\qtri}E_{\exists}^a]
      {C \true}
      {\ptri x \tau {A(x)} \true
     & \deduce[\ddd]{C \true}{\hyp{a : \tau}}}
\quad\qquad
\infer[{\qtri}E_{\forall}]
      {A(t) \true}
      {\ptri x \tau {A(x)} \true  &  t : \tau}
\]

As usual, rules that introduce a parameter restrict its scope to the
premise in which it is introduced.  In particular, in the elimination rule
${\qtri}E_\exists^a$, the parameter $a$ may not appear in the conclusion
of the rule, $C \true$.

% Take care in your deductions to respect the scopes of all parameters!

\begin{task}[2 pts]
  Show that this captures our intuition about what non-vacuous universal
  quantification should mean by giving a deduction of $(\ptri x \tau
  {A(x)}) \pimp \pexists x \tau {A(x)} \true$.
\end{task}

\begin{task}[4 pts]
  Are these elimination rules locally sound?  If so, give a local
  reduction for each elimination rule; if one does not exist, explain why.
\end{task}

\begin{task}[4 pts]
  Are these elimination rules locally complete?  If so, give a local
  expansion for for an arbitrary deduction of $\ptri x \tau {A(x)}$;
  if one does not exist, explain why.
\end{task}

\begin{task}[5 pts]
  Make up a proof term for each of the rules, and express the local
  reductions and local expansions you found above using proof terms.
\end{task}

\end{document}
