\documentclass[11pt]{article}
\usepackage{fullpage}
\usepackage{pslatex}
\usepackage{amsmath,proof,amsthm,amssymb}

%% 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{\ttt}[1]{\texttt{#1}}
\newcommand{\true}[1]{\ensuremath{#1 \, \dsd{true}}}
\newcommand{\even}[1]{\ensuremath{\dsd{even}(#1)}}
\newcommand{\odd}[1]{\ensuremath{\dsd{odd}(#1)}}
\newcommand{\suc}[1]{\ensuremath{\dsd{s} \: #1}}

\newcommand{\seq}[2]{\ensuremath{#1 \Longrightarrow #2}}
\newcommand{\csupset}[0]{\ensuremath{\mathord{\supset}}}

\title{Assignment 8: \\
       Cut Admissibility, Meta-Interpreters}
\author{15-317: Constructive Logic}
\date{Out: Thursday, October 30, 2008 \\
Due: Tuesday, November 11, 2008, before class}

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

\maketitle

\begin{center}
\textbf{You do not need to hand in this homework until Tuesday Nov 11.
  However, we encourage you to work through the problems before the
  midterm: there may be questions about this material on the exam!}
\end{center}

\section{Cut and Identity}

Recall the rules for disjunction and implication:

\[
\begin{array}{cc}
\infer[\vee R_1]{\seq{\Gamma}{A \vee B}}{\seq{\Gamma}{A}}
\quad
\infer[\vee R_2]{\seq{\Gamma}{A \vee B}}{\seq{\Gamma}{B}}
&
\infer[\vee L]{\seq{\Gamma,A \vee B}{C}}
      {\seq{\Gamma,A \vee B,A}{C} & 
	\seq{\Gamma,A \vee B,B}{C}}
\\ \\

\infer[\csupset R]{\seq{\Gamma}{A \supset B}}{\seq{\Gamma,A}{B}}
&
\infer[\csupset L]{\seq{\Gamma,A \supset B}{C}}
      {\seq{\Gamma,A \supset B}{A} &
	\seq{\Gamma,A \supset B,B}{C}}
\end{array}
\]

\subsection{Identity}

\textbf{Identity:}   For all $A$ and $\Gamma$, the sequent
\seq{\Gamma,A}{A} is derivable.

\task{1}{10}

Prove the $\supset$ case: 

Assume 
\begin{itemize}
\item \seq{\Gamma,A}{A} for all $\Gamma$
\item \seq{\Gamma,B}{B} for all $\Gamma$
\end{itemize}
and show \seq{\Gamma,A \supset B}{A \supset B} for all $\Gamma$.

\subsection{Principal Cuts}

\begin{itemize}
\item \textbf{Weakening:}  If \seq{\Gamma}{C} then \seq{\Gamma,A}{C}.

\item \textbf{Cut:}   If \seq{\Gamma}{A} and \seq{\Gamma,A}{C} then
\seq{\Gamma}{C}.
\end{itemize}

\task{2}{10} Prove the principal cut case for $\supset$:

Given 

\[
\infer[\supset R]
      {\seq{\Gamma}{A \supset B}}
      {\deduce{\seq{\Gamma,A}{B}}{\mathcal{D}}}
\qquad
\infer[\supset L]
      {\seq{\Gamma,A \supset B}{C}}
      {\deduce{\seq{\Gamma,A \supset B}{A}}{\mathcal{E}_1} &
	\deduce{\seq{\Gamma,A \supset B,B}{C}}{\mathcal{E}_2}}
\]

construct a derivation of \seq{\Gamma}{C}.  

You may use weakening if you need to.

\task{3}{5} Prove a commutative cut case for $\vee$:

%% \[
%% \deduce{\seq{\Gamma,B_1 \vee B_2}{A_1 \vee A_2}}{\mathcal{D}}
%% \qquad
%% \infer[\vee L]{\seq{\Gamma,A_1 \vee A_2,B_1 \vee B_2}{C}}
%%       {\seq{\Gamma,A_1 \vee A_2, B_1 \vee B_2,B_1}{C} & 
%% 	\seq{\Gamma,A_1 \vee A_2, B_1 \vee B_2,B_1}{C}}
%% \]

From

\[
\begin{array}{c}
\infer[\vee E]{\seq{\Gamma,B_1 \vee B_2}{A_1 \supset A_2}}
      {\deduce{\seq{\Gamma,B_1 \vee B_2, B_1}{A_1 \supset A_2}}{\mathcal{D}_1} &
	\deduce{\seq{\Gamma,B_1 \vee B_2, B_2}{A_1 \supset A_2}}{\mathcal{D}_2}}
\qquad
\deduce
      {\seq{\Gamma,B_1 \vee B_2,A_1 \supset A_2}{C}}
      {\mathcal{E}}
%%       {\deduce{\seq{\Gamma,B_1 \vee B_2,A_1 \supset A_1}{A_1}}{\mathcal{E}_1} &
%% 	\deduce{\seq{\Gamma,B_1 \vee B_2,A_2 \supset A_2,A_2}{C}}{\mathcal{E}_2}}
\end{array}
\]

derive {\seq{\Gamma,B_1 \vee B_2}{C}}.

You may use weakening if you need to.

\section{Counting Proofs}

In class, we defined an interpreter for Prolog that made subgoal order
and backtracking explicit.  In this problem, you will extend this
interpreter to count the number of proofs of a proposition.

\subsection{Base rules}

We assume that every atomic proposition $P$ is defined by exactly one
clause $P \leftarrow B$.

\[
\infer{\true P}{P \leftarrow B & \true B}
\quad
\infer{\true \top}{}
\quad
\infer{\true {A \wedge B}}{\true A & \true B}
\quad
\infer{\true {A \vee B}}{\true A}
\quad
\infer{\true {A \vee B}}{\true B}
\quad
\text{(no rule \true \bot)}
\]

\subsection{Abstract machine}

Recall that $S$, the success stack, is a conjunction of propositions,
and $F$, the failure stack, is a disjunction of propositions of the form
$(B \wedge S)$.

\[
\infer{P / S / F}{P \leftarrow B & B / S / F}
\qquad
\infer{\top / \top / F}{}
\qquad
\infer{\top / (B \wedge S) / F}{B / S / F}
\qquad
\infer{{A \wedge B} / S / F}{A / (B \wedge S) / F}
\]

\[
\infer{{A \vee B} / S / F}{A / S / (B \wedge S) \vee F}
\qquad
\text{(no rule $\bot / S / \bot$)}
\qquad
\infer{\bot / S' / (B \wedge S) \vee F}
      {B / S / F}
\]


\subsection{Counting Proofs}

For these rules for these connectives, we can easily count the number of
proofs a proposition has:

\begin{eqnarray*}
|P| & = & |B| \text{ where $P \leftarrow B$ } \\
|\top| & = & 1 \\
|A \wedge B| & = & |A| * |B| \\
|\bot| & = & 0 \\
|A \vee B| & = & |A| + |B| \\
\end{eqnarray*}

This definition makes sense if we assume that atoms are not defined
recursively: recursive clauses can lead to propositions with infinitely
many proofs.  E.g.  $\dsd{nat} \leftarrow (\top \vee \dsd{nat})$ has
one proof for each natural number.

\begin{theorem} There are $|A|$ many derivations of \true{A}.  
\end{theorem}


\task{1}{7} Extend the interpreter so that it counts the number of
proofs of a proposition as it proves it: Define a judgement 
$A / S / F \mid n$ such that $(A \wedge S) \vee F$ has $n$ proofs.  Fill in
the ?'s in the following rules:

\[
\infer{P / S / F \mid ?}{P \leftarrow B & B / S / F \mid ?}
\qquad
\infer{\top / \top / \bot \mid ?}{}
\qquad
\infer{\top / \top / ((B \wedge S) \vee F) \mid ?}{?}
\qquad
\infer{\top / (B \wedge S) / F \mid ?}{B / S / F \mid ?}
\qquad
\infer{{A \wedge B} / S / F \mid ? }{A / (B \wedge S) / F \mid ?}
\]

\[
\infer{{A \vee B} / S / F \mid ?}{A / S / (B \wedge S) \vee F \mid ?}
\qquad
\infer{\bot / S / \bot \mid ?}{?}
\qquad
\infer{\bot / S' / (B \wedge S) \vee F \mid ?}
      {B / S / F \mid ?}
\]

\task{2}{8} Prove your revised interpreter sound by induction on the
rules: 

\begin{theorem}
If $A / S / F \mid n$ then $|(A \wedge S) \vee F| = n$.  
\end{theorem}

You may use whatever properties of arithmetic you require
(e.g. associativity of $*$, distributivity of $*$ over $+$).



\end{document}
