%%% This is the scribe notes template for CS611
%%% There are several comments preceded by CS611: and boxed in %%%%'s 
%%% which indicate where macros should be altered to set up the header
%%% for the paper.  Your Notes should go at the comment SCRIBE NOTES GO HERE!.

%%% In the various .sty files that accompany this .tex file you will    
%%% find LaTeX macros that make it easier to typeset inference rules    
%%% and programming language constructs.  You must make sure that the   
%%% file proof.sty is in a path searched by LaTeX when you try to       
%%% use this file.  Take a look to see what macros are available--it    
%%% will save you time and make the notes look better.  Feel free to    
%%% extend the set of macros--post them to the newsgroup and contact    
%%% the course staff if you come up with some good ones so they can be  
%%% added to the template.                                              

%%% This template includes examples of how to use some of the macros
%%% to give you an idea of how they work.  (Delete the examples when
%%% you do your scribing.)

\documentclass{article} \usepackage{611-lecture}
\usepackage{amsthm}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% CS611: Please fill in these macros as appropriate:
\lecture{7}                  %% Lecture number
\title{Inductive definitions and rule induction}   %% Title of lecture
\author{Yisong Yue, Yunsong Guo}       %% name of scribe
\date{12 September, 2005}     %% Date of lecture, e.g., 1 January 2001
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% See 611.sty for a variety of macros that will be helpful in
% typesetting the lecture. Here are a few of particular interest:
%
% "x"	 	x in keyword font (e.g., "if", "#t")
% _x_	 	x in italics
% \nm{n}   	n in slanted font (used for abbreviations)
%          	(if x is more than a single character, use \Tr{x}{y})

\begin{document}

\maketitle

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% CS611: SCRIBE NOTES GO HERE!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% CS611: Delete this example text...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Syntax}
A rule instance is of the form:
\begin{tabular}{ccc}
\infer{x}{x_1 \ x_2\ \ldots x_n}
\end{tabular} \newline
And given $\textbf{B}\subseteq \textbf{S}$, the rule operator
R(\textbf{B})=$\{\ x\ |
\begin{tabular}{ccc}
\infer{x}{x_1 \ x_2\ \ldots \ x_n}
\end{tabular}$ is a rule instance and $\{x_1 \ x_2\ \ldots \ x_n\} \subseteq
\textbf{B}$\}

The following facts can be easily verified:
\begin{itemize}
    \item R($\emptyset$)=\{axioms\}
    \item R(A)$\cup$R(B)$\subseteq$ R(A$\cup$B)
    \item R: $2^S\rightarrow 2^S$ where $2^S$=P(S) is the power set of S
\end{itemize}
Our goal is to find what set $\textbf{A}\subseteq \textbf{S}$ is
defined by the rules instances. In addition, A should be:
\begin{enumerate}
    \item Consistent: A$\subseteq$R(A)
    \item Closed \ \ \ \   : R(A)$\subseteq$A
\end{enumerate}
i.e., A=R(A). In other words, A is a fixed point of the function R.
The there are two natural questions we want to ask: 1.\emph{Is there
actually a fixed point of R?} 2.\emph{If yes, which one is A?}




\section{Definition of set A}
We define the set A as: A=$\cup_{n\in
N}R^n(\emptyset)=R(\emptyset)\cup R(R(\emptyset))$\ldots \newline Next,
we prove 3 properties of A, namely:
\begin{enumerate}
    \item A is closed
    \item A is consistent
    \item A is the least fixed point of R
\end{enumerate}

\subsection{A is closed: R(A)$\subseteq$A}
For any $x\in$R(A), we know that there is some rule instance
\begin{tabular}{ccc} \infer{x}{x_1 \ x_2\ \ldots \ x_n}
\end{tabular} where $\{x_1 \ x_2\ \ldots \ x_n\} \subseteq
A$. Thus, for some minimum m, we must have $\{x_1 \ x_2\ \ldots \ x_n\}
\subseteq R^m(\emptyset)$. Then $x\in R^{m+1}(\emptyset)\subseteq$ A

\subsection{A is consistent: A$\subseteq$R(A)}
We need to introduce a concept here: the monotonicity of the rule
operator R. We say R is monotonic if and only if A$\subseteq$B
$\Rightarrow$R(A)$\subseteq$R(B) \newline So, if x$\in$ A then x$\in
R^m(\emptyset)$ for some m, i.e. x$\in$ $R(R^{m-1}(\emptyset))$.
Since $R^{m-1}(\emptyset)\subseteq A$, by the monotonicity of R, we
have $R(R^{m-1}(\emptyset))\subseteq$ R(A). Thus x$\in$R(A) and A is
consistent.

\subsection{A is the least fixed point}
Suppose A is not the least fixed point of R, then there is some B
such that B=R(B) and B$\subset$A.\newline Since
$\emptyset\subseteq$B$\Rightarrow$R($\emptyset$)$\subseteq$R(B)=B by
the monotonicity of R. Similarly, we will have
R$^m$($\emptyset$)$\subseteq$R(B)=B where m=1,2,3,\ldots  Then if we
union the left-hand side of "$\subseteq$" we will get A by
definition. And the union of the right-hand side is just B. So
A$\subseteq$B which is a contradiction. As a result, A must be the
least fixed point of R.

\section{Rule Induction}

We use well founded induction on the sub-derivation relation to prove properties of inference rules.\newline

Note - should there exist more than one derivation, consider only the shortest derivation.\newline


\textbf{Theorem}: $(FV(e) = \emptyset \wedge e \rightarrow e') \Rightarrow (FV(e') = \emptyset)$ 

\medskip

\textbf{Proof}: by induction on derivation of $e \rightarrow e'$

\medskip


\textbf{Case 1}: \infer{(e_1~e_2)\stepsone(e'_1~e_2)}{e_1\stepsone e'_1}


Assume: $FV(e_1 \ e_2) = FV(e_1) \cup  FV(e_2) = \emptyset$, thus $FV(e_1) = FV(e_2) = \emptyset$\newline

We can use the inductive hypothesis $(FV(e_1) = \emptyset \wedge e_1 \rightarrow e'_1) \Rightarrow (FV(e'_1) = \emptyset)$ to show that that 

\[
FV(e'_1 \ e_2) = FV(e'_1) \cup FV(e_2) = \emptyset
\]

\medskip
\textbf{Case 2}: \infer{(v~e_2)\stepsone(v~e'_2)}{e_2\stepsone e'_2}


This case is symmetric to Case 1 where now $e_2$ is used in the inductive hypothesis

\medskip
\textbf{Case 3}: \infer{(\lam{x}{e})v\stepsone \subst{e}{v}{x}}{}


Assume: $FV(\lam{x}{e})v = \emptyset$, \ \ $FV(v) = \emptyset$,  \ \ $FV(\lam{x}{e}) = FV(e) - \{x\} = \emptyset$,  \ \ thus $FV(e) \in \{x\}$


This case requires a lemma (stated below) to show that $FV(\subst{e}{v}{x}) = \emptyset$.  Once that is shown, the proof for this case is complete.


We have now considered all three rules of derivation for Lambda Calculus to show that $FV(e) = \emptyset$ is preserved as derivation rules are applied to $e$ 

\qed 

\medskip

\textbf{Lemma}: $(FV(v) = \emptyset) \Rightarrow (FV(\subst{e}{v}{x}) = FV(e) - \{x\})$ (this lemma is used by Case 3 in the above theorem)


\medskip
\textbf{Proof}: by induction on derivation of the substitution relation.
Note that substitution isn't really a function because there is choice
of variable when the body of a lambda abstraction is alpha-renamed.

\medskip
\textbf{Case 1}: $e = x$, \ \ then $\subst{x}{e}{x} = e$

$$FV(\subst{e}{v}{x}) = FV(v) = \emptyset = \{x\} - \{x\} = FV(x) - \{x\}$$


\medskip
\textbf{Case 2}: $e = y$, \ \ then $\subst{y}{e}{x} = y$

$$FV(\subst{e}{v}{x}) = FV(y) = \{y\} = FV(y) - \{x\}$$


\medskip
\textbf{Case 3}: $e = e_1~e_2$


Recall that by definition: $FV(\subst{e}{v}{x}) = FV(\subst{e_1}{v}{x}~\subst{e_2}{v}{x}) = FV(\subst{e_1}{v}{x}) \cup FV(\subst{e_2}{v}{x})$


By the inductive hypothesis, $FV(\subst{e_1}{v}{x}) = FV(e_1) - \{x\}$ and $FV(\subst{e_2}{v}{x}) = FV(e_2) - \{x\}$


\begin{eqnarray*}
FV(\subst{e_1}{v}{x}) \cup FV(\subst{e_2}{v}{x}) & = & (FV(e_1) - \{x\}) \cup (FV(e_2) - \{x\}) \\
      & = &(FV(e_1) \cup FV(e_2)) - \{x\}  \\
      & = & FV(e_1~e_2) - \{x\} \\
\end{eqnarray*}

\medskip
\textbf{Case 4}: $e = \subst{(\lam{x}{e'})}{v}{x}$

\[
FV(\subst{(\lam x{e'})}{v}{x}) = FV(e) = FV(e) - \{x\}  \qquad \mbox{(because $x\not\in FV(e))$}
\]


\medskip
\textbf{Case 5}: $e = \subst{(\lam{y}{e'})}{v}{x}$ where $y \neq x$.

Note that $y\not\in FV(v)$ because $FV(v) = \emptyset$. Therefore we can
use the simpler substitution rule for lambda terms.

\begin{eqnarray*}
  FV(\subst{(\lam{y}{e'})}{v}{x}) &=& FV(\lam{y}{\subst{e'}{v}{x}}) \\
    &=& FV(\subst{e'}{v}{x})  -  \{y\} \\
    &=& FV(\subst{e'}{v}{x})  -  \{y\} \\
    &=& FV(e') - \{x\}  -  \{y\}  \qquad \mbox{(by the inductive hypothesis)}\\
    &=& FV(\lam{y}{e'}) - \{x\}   \\
    &=& FV(e) - \{x\}
\end{eqnarray*}

\qed
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
