Index: CSL16/feas-arith-wfm.tex
===================================================================
--- CSL16/feas-arith-wfm.tex	(revision 18)
+++ CSL16/feas-arith-wfm.tex	(revision 19)
@@ -54,6 +54,8 @@
 	
 	
 	%terms
+	\newcommand{\cond}{C}
+	\newcommand{\pred}{p}
 	\renewcommand{\succ}{s}
 	\renewcommand{\epsilon}{\varepsilon}
 	
@@ -634,20 +636,18 @@
 \subsection{$\nat$-hierarchy}
 
 \begin{definition}
-
-\todo{replace N with nat.}
-
-	Let us define the quantifiers $\exists x^N . A$ and $\forall x^N . A$ as $\exists x . (N(x) \land A)$ and $\forall x . (N(x) \limp A) $ respectively.
+	Let us define the quantifiers $\exists x^\nat . A$ and $\forall x^\nat . A$ as $\exists x . (\nat(x) \land A)$ and $\forall x . (\nat (x) \limp A) $ respectively.
 	
-	We define $\Sigma^N_0 = \Pi^N_0 $ as the class of formulae that are free of quantifiers. For $i\geq 0$ we define:
+	We define $\Sigma^N_0 = \Pi^N_0 $ as the class of formulae that are free of quantifiers. For $i> 0$ we define $\Sigma^\nat_i$ and $\Pi^\nat_i$ as follows:
 	\begin{itemize}
-		\item $\Sigma^N_{i+1}$ is the class of formulae $\exists x^N . A$ where $A \in \Pi^N_i$.
-		\item $\Pi^N_{i+1}$ is the class of formulae $\forall x^N . A$ where $A \in \Sigma^N_i$.
-		\item ($\Delta^N_i$ is the class $\Sigma^N_i \cap \Pi^N_i$.)
+		\item If $A \in \Sigma^\nat_{i-1} \cup \Pi^\nat_{i-1}$ then $A \in \Sigma^\nat_i$ and $A \in \Pi^\nat_i$.
+		\item If $A \in \Sigma^\nat_i$ then $\exists x^\nat . A \in \Sigma^\nat_i$.
+		\item If $A \in \Pi^\nat_i$ then $\forall x^\nat . A \in \Pi^\nat_i$.
+		\item If $A,B \in \Sigma^\nat_i$ then $A \lor B$ and $A\land B \in \Sigma^\nat_i$.
+		\item If $A,B \in \Pi^\nat_i$ then $A \lor B$ and $A\land B \in \Pi^\nat_i$.
 	\end{itemize}
 \end{definition}
 
-\todo{allow closure under positive Boolean operations?}
 
 \todo{What about prenexing rules? Should not change provably total functions!}
 
@@ -668,19 +668,59 @@
 \end{array}
 \]
 
-CHECK THESE!
 
-\todo{Also include rules for contraction and weakening.}
-
 \section{Convergence of Bellantoni-Cook programs}
 
 \subsection{Bellantoni-Cook programs}
-We first recall the notion of safe recursion on notation from BC. TODO
+We first recall the notion of safe recursion on notation from BC.
 
+\todo{reformulate below for binary words, not natural numbers?}
+
+\begin{definition}
+	[BC functions]
+	BC is the set of functions generated by the following initial functions and closure schemes.
+	
+%	\paragraph{Initial functions}
+	There are the following initial functions:
+	\begin{enumerate}
+		\item The constant function $0$ which takes no arguments and outputs $0 \in \Nat$.
+		\item The projection functions $\pi^{m,n}_k ( x_1 , \dots , x_m ; x_{m+1} , \dots, x_{m+n} )  := x_k$ for $n,m \in \Nat$ and $1 \leq k \leq m+n$.
+		\item The successor functions $\succ_i ( ; x) := xi$ for $i = 0,1$.
+		\item The predecessor function $\pred (; x) := \begin{cases}
+		0 & x = 0 \\
+		x' & x = x'i
+		\end{cases}$.
+		\item The conditional function $\cond (;x,y,z) := \begin{cases}
+		y & x \mod{2} = 0 \\
+		z & \text{otherwise}
+		\end{cases}$.
+	\end{enumerate}
+	
+	There are the following closure properties.
+	\begin{enumerate}
+	\setcounter{enumi}{5}
+	\item Predicative recursion on notation. If $g, h_0, h_1 $ are in BC then so is the function $f$ defined by,
+	\[
+	\begin{array}{rcl}
+	f(0, \vec v ; \vec x) & := & g(\vec v ; \vec x) \\
+	f (\succ_i u , \vec v ; \vec x ) & := & h_i ( u , \vec v ; \vec x , f (u , \vec v ; \vec x) )
+	\end{array}
+	\]
+	for $i = 0,1$, so long as the expressions are well-formed (i.e.\ in number/sort of arguments).
+	\item Safe composition. If $g, \vec h, \vec h'$ are in BC then so is $f$ defined by,
+	\[
+	f (\vec u ; \vec x) \quad := \quad g ( \vec h(\vec u ; ) ; \vec h' (\vec u ; \vec x) )
+	\]
+	so long as the expression is well-formed.
+	\end{enumerate}
+	\end{definition}
+
+
+
 \subsection{Convergence in arithmetic}
 \begin{theorem}
 	[Convergence]
-	If $\Phi(f)$ is an equational specification corresponding to a BC-program defining $f()$, then $\cax{\Sigma^N_1}{\pind} \proves  \ !\Phi(f) \limp \forall \vec{x}^{!N} . N(f(\vec x))$.
+	If $\Phi(f)$ is an equational specification corresponding to a BC-program defining $f$, then $\cax{\Sigma^N_1}{\pind} \proves  \ !\Phi(f) \limp \forall \vec{x}^{!N} . N(f(\vec x))$.
 \end{theorem}
 \begin{proof}
 	We show by induction on the structure of a BC-program for $f(\vec x ; \vec y)$ that:
@@ -749,59 +789,69 @@
 
 \todo{say some more here}
 
+\todo{compare with applicative theories}
+
+\anupam{in particular, need to point out that this argument is actually something in between, since usually the WFM requires programs to be defined by formulae, not equational specifications.}
+
 \newcommand{\type}{\mathtt{t}}
 \newcommand{\norm}{\nu}
 \newcommand{\safe}{\sigma}
 
-\subsection{Typing}
+\subsection{Witness/realisability predicate}
 
 \begin{definition}
-	[Types]
-	To each formula we associate a tuple type as follows:
+	[Typing]
+	To each $\Sigma^\nat_1$-formula $A$ we associate a sorted tuple of variables $\type (A)$, intended to range over $\Nat$, as follows:
 	\[
 	\begin{array}{rcll}
-	\type (\nat (t)) & := & \Nat & \\
-	\type(s = t) & := & \Nat & \\
-	\type (A \star B)  & : = & \type (A) \times \type (B) & \text{for $\star \in \{ \lor, \land, \laor, \laand \} $.} \\
-	\type (! A) & : = & \type_\norm (A) & \\
-	\type (\exists x^N . A) & := & \Nat \times \type (A) & \\
+	\type (\nat (t)) & := & (;x^{\nat (t)} ) & \\
+	\type(s = t) & := & ( ; x^{s = t}) & \\
+	\type (A \lor B)  & : = & (\vec u , \vec v ; \vec x , \vec y) & \text{if $\type(A) = (\vec u ; \vec x)$ and $\type(B) = (\vec v ; \vec y)$.} \\
+		\type (A \land B)  & : = & (\vec u , \vec v ; \vec x , \vec y) & \text{if $\type(A) = (\vec u ; \vec x)$ and $\type(B) = (\vec v ; \vec y)$.} \\
+	\type (! A) & : = & ( \vec u ,\vec x  ; ) & \text{if $\type(A) = (\vec u ; \vec x )$.} \\
+	\type (\exists x^\nat . A) & := & (\vec u ; \vec x , y) & \text{if $\type (A) = (\vec u ; \vec x)$.}
 %	\type (\forall x^N . A) & := & \Nat \to \type(A)
 	\end{array}
 	\]
-	where $\nu$ designates that the inputs are normal.
+%	where $\nu$ designates that the inputs are normal.
 	\end{definition}
 	
-	\todo{compatibility with safety. To consider.}
 	
+	\anupam{need to account for normality and safety somewhere. Attempting inlined and leaving types without this decoration.}
 	
+	\begin{remark}
+		[Distribution of $!$]
+		There is a potential issue that the $!$ contains $\lor$ symbols in its scope, whence we do not in general have $!(A \lor B) \cong !A \lor !B$. However this will not be a problem here by inspection of a convergence statement: there are no $\lor$ symbols in the scope of a $!$. Therefore, after free-cut elimination, no formula in the proof will have this property either.
+		
+		On the other hand, since we are working in affine logic, we do in general have $!(A \land B) \cong !A \land !B$.
+		\end{remark}
 	
 	
 	\newcommand{\witness}[2]{\mathit{Witness}^{#1}_{#2}}
 	\begin{definition}
 		[Witness predicate]
-		We define the following formula:
+		We define the predicate $\witness{\vec a}{A} (\vec x , \vec b)$ for a $\Sigma^\nat_1$-formula $A(\vec a)$, such that $|\vec b| = |\vec a |$ and $|\vec x | = |\type (A)|$, as follows:
 		\[
 		\begin{array}{rcll}
-		\witness{\vec a}{A} (w, \vec a) & := & A(\vec a) & \text{for $A$ quantifier-free.} \\
-		\witness{\vec a}{\exists x . A} (w, \vec w , \vec a) & := & \witness{\vec{a}, a}{A(a)}(\vec w , \vec a, w ) & \\
-		\witness{\vec a}{A \star B} ( \vec w^1 , \vec w^2 ) & := &  \witness{\vec a}{A} (\vec w^1) \star \witness{\vec a}{B} (\vec w^2) & \text{for $\star \in \{ \land, \lor, \laand , \laor\}$.} \\
+		\witness{\vec a}{A} (x, \vec b) & := & A(\vec b) & \text{$A(\vec a)$ is $s(\vec a) = t(\vec a)$.} \\
+		\witness{\vec a}{A} (x, \vec b) & := & x = t(\vec b) & \text{$A(\vec{a})$ is $\nat(t(\vec a))$.} \\
+				\witness{\vec a}{A \land B} ( \vec x^1 , \vec x^2 , \vec b ) & := &  \witness{\vec a}{A} (\vec x^1 , \vec b) \cand \witness{\vec a}{B} (\vec x^2 , \vec b) &  \\
+								\witness{\vec a}{A \lor B} ( \vec x^1 , \vec x^2 , \vec b ) & := &  \witness{\vec a}{A} (\vec x^1 , \vec b) \cor \witness{\vec a}{B} (\vec x^2 , \vec b) &  \\
+		\witness{\vec a}{\exists x^\nat . A} (x, \vec x , \vec b) & := & \witness{\vec{a}, a}{A(a)}(\vec x, \vec b, x ) & \\
 		\end{array}
 		\]
 	\end{definition}
-	\todo{problem: what about complexity of checking equality? }
 	
-	\todo{What about $\nat (t)$? What does it mean? Replace with true?}
 	
 	\todo{either use the witness predicate above, or use realizability predicate at meta-level and a model theory, like BH.}
 	
-	\anupam{Need to check above properly. $N(t)$ should be witnessed by the value of $t $ in the model. For equality of terms the witness should not do anything.}
 	
 	\subsection{The translation}
 	Need witness predicate so that we know what is being preserved.
 
 \begin{definition}
 	[Translation]
-	We give a translation of proofs $\pi$ of sequents $\Gamma(\vec a) \seqar \Delta(\vec a)$ to BC-programs for a vector of functions $\vec f^\pi : \type(\bigotimes\Gamma) \times \Nat^{|\vec a|} \to \type(\bigparr\Delta)$ such that:
+	We give a translation of free-cut free $\Sigma^\nat_1$-$\pind$ proofs $\pi$ of sequents $\Gamma(\vec a) \seqar \Delta(\vec a)$ to BC-programs for a vector of functions $\vec f^\pi : \type \left(\bigotimes\Gamma\right) \to \type\left(\bigparr\Delta\right)$ such that:
 	\[
 	\witness{\vec a}{\bigotimes \Gamma} (\vec w , \vec a) \implies \witness{\vec a}{\bigparr \Delta } (\vec f(\vec w , \vec a), \vec a)
 	\]
@@ -813,7 +863,7 @@
 	
 	\anupam{for moment try ignore decoration on right? what about negation?}
 	
-
+\todo{Consider these points at end, this should just be a choice of implementation.}
 	
 	\[
 	\vlderivation{
