\documentclass[11pt]{article} \input{exer-defs} %\renewcommand{\thepage}{} \newcommand{\Zero}{\mathsf{zero}} \newcommand{\Succ}{\mathsf{succ}} \newcommand{\NATS}{\mathsf{Nats}} \newcommand{\PLUS}{\mathsf{Plus}} \begin{document} \begin{center}\large\bf CIS 705 --- Programming Languages --- Spring 2009 \end{center} \begin{center}\Large\bf Assignment 1 (100 Points) \end{center} \begin{center}\large\bf Due by 2:30 p.m.\ on Thursday, February 12 \end{center} \begin{center} The context for this assignment is Chapters 2-3 of \emph{TAPL}. \end{center} \section*{Definition of $\NATS$} Let $\NATS$ be the smallest set such that: \begin{description} \item[\quad(Zero)] \begin{displaymath} \Zero\in\NATS ; \end{displaymath} \item[\quad(Succ)] for all $t$, \begin{displaymath} \frac{t\in\NATS}% {\Succ\;t\in\NATS.} \end{displaymath} \end{description} (Here, $\Zero$ and $\Succ$ are constructors, so that, for all $t$, $\Zero\neq\Succ\;t$, and, for all $t_1,t_2$, $\Succ\;t_1=\Succ\;t_2$ iff $t_1=t_2$.) The \emph{inversion lemma} for $\NATS$ says that, for all $s\in\NATS$, either: \begin{description} \item[\quad(Zero)] $s = \Zero$; or \item[\quad(Succ)] $s = \Succ\;t$, for some $t\in\NATS$. \end{description} Suppose $P\sub\NATS$. The \emph{principle of structural induction on $\NATS$} says that, \begin{displaymath} \eqtxtr{for all}t\in\NATS, P(t) \end{displaymath} follows from showing \begin{description} \item[\quad(Zero)] $P(\Zero)$; \item[\quad(Succ)] for all $t\in\NATS$, if (\dag) $P(t)$, then $P(\Succ\;t)$. \end{description} We refer to (\dag) as the \emph{inductive hypothesis}. \section*{Definition of $\PLUS$} Let $\PLUS$ be the smallest subset of $\NATS\times\NATS\times\NATS$ such that: \begin{description} \item[\quad(Plus-Zero)] for all $t\in\NATS$, \begin{displaymath} (\Zero, t, t)\in\PLUS ; \end{displaymath} \item[\quad(Plus-Succ)] for all $t_1,t_2,t_3\in\NATS$, \begin{displaymath} \frac{(t_1,t_2,t_3)\in\PLUS}% {(\Succ\;t_1,t_2,\Succ\;t_3)\in\PLUS.} \end{displaymath} \end{description} The \emph{inversion lemma} for $\PLUS$ says that, for all $s_1,s_2,s_3\in\NATS$, if $(s_1,s_2,s_3)\in\PLUS$, then either: \begin{description} \item[\quad(Plus-Zero)] there is a $t\in\NATS$ such that $s_1=\Zero$, $s_2 = t$ and $s_3 = t$ (so that $s_2=s_3$); or \item[\quad(Plus-Succ)] there are $t_1,t_2,t_3\in\NATS$ such that $s_1=\Succ\;t_1$, $s_2=t_2$, $s_3=\Succ\;t_3$ and $(t_1,t_2,t_3)\in\PLUS$ (so that $(t_1,s_2,t_3)\in\PLUS$). \end{description} Suppose $P\sub\NATS\times\NATS\times\NATS$. We sometimes write ``$P(t_1,t_2,t_3)$'' for ``$(t_1,t_2,t_3)\in P$''. The \emph{principle of induction on $\PLUS$} says that, \begin{center} for all $t_1,t_2,t_3\in\NATS$, if $(t_1,t_2,t_3)\in\PLUS$, then $P(t_1,t_2,t_3)$, \end{center} follows from showing \begin{description} \item[\quad(Plus-Zero)] for all $t\in\NATS$, $P(\Zero, t, t)$; \item[\quad(Plus-Succ)] for all $t_1,t_2,t_3\in\NATS$, if $(t_1,t_2,t_3)\in\PLUS$ and (\dag) $P(t_1,t_2,t_3)$, then $P(\Succ\;t_1,t_2,\Succ\;t_3)$. \end{description} We refer to (\dag) as the \emph{inductive hypothesis}. \section*{Exercise 1 (25 Points)} Prove that, for all $t_1,t_2\in\NATS$, there is a $t_3\in\NATS$ such that $(t_1,t_2,t_3)\in\PLUS$. \section*{Exercise 2 (25 Points)} Prove that, for all $t_1,t_2,t_3,t'_3\in\NATS$, if $(t_1,t_2,t_3)\in\PLUS$ and $(t_1,t_2,t'_3)\in\PLUS$, then $t_3=t'_3$. (This completes the proof that, for all $t_1,t_2\in\NATS$, there is a unique $t_3\in\NATS$ such that $(t_1,t_2,t_3)\in\PLUS$.) \section*{Exercise 3 (25 Points)} Prove that, for all $t_1,t_2,t_3,s_1,s_2,s_3\in\NATS$, if $(t_1,t_2,s_1)\in\PLUS$, $(s_1,t_3,s_2)\in\PLUS$ and $(t_2,t_3,s_3)\in\PLUS$, then $(t_1,s_3,s_2)\in\PLUS$. \section*{Exercise 4 (25 Points)} Prove that, for all $t_1,t_2,t_3\in\NATS$, if $(t_1,t_2,t_3)\in\PLUS$, then $(t_2,t_1,t_3)\in\PLUS$. \end{document}