
\section{Convergence of Bellantoni-Cook programs}

\anupam{In this section, use whatever form of the deduction theorem is necessary and reverse engineer precise statement later.}


\subsection{Bellantoni-Cook programs}
We first recall the notion of safe recursion on notation from BC. TODO

\anupam{Do we need simultaneous PRN? cf.\ Bellantoni's thesis.}

\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))$.
\end{theorem}
\begin{proof}
	We show by induction on the structure of a BC-program for $f(\vec x ; \vec y)$ that:
	\begin{equation}
	\Phi(f) , \cax{\Sigma^N_1}{\pind} \proves \ \forall \vec{x}^{!N} . \forall \vec{y}^N . N(f(\vec x ; \vec y))
	\end{equation}
	We give some key cases in what follows.
	
	Suppose $f$ is defined by PRN by:
	\[
	\begin{array}{rcl}
	f(0,\vec x ; \vec y) & = & g(\vec x ; \vec y) \\
	f(\succ_i x , \vec x ; \vec y) & = & h_i (x, \vec x ; \vec y , f(x , \vec x ; \vec y))
	\end{array}
	\]
	By the inductive hypothesis we already have that $g, h_0, h_1$ are provably convergent, so let us suppose that $N(\vec x)$ and prove,
	\begin{equation}
	\forall x^{!N} . ( N(\vec y) \limp N(f(x , \vec x ; \vec y)  )
	\end{equation}
	by $\cax{\Sigma^N_1}{\pind}$ on $x$.
	
	In the base case we have the following proof:
	\[
	\vlderivation{
		\vliin{}{}{N(\vec y) \limp N(f(0, \vec x ; \vec y))}{
			\vltr{IH}{N(\vec y) \limp N(g(\vec x ; \vec y))}{\vlhy{\quad}}{\vlhy{}}{\vlhy{\quad}}
		}{
		\vlin{}{}{N(g (\vec x ; \vec y) ) \limp N(f(0, \vec x ; \vec y)) }{
			\vlin{}{}{g(\vec x ; \vec y) = f(0 , \vec x ; \vec y)}{\vlhy{}}
		}
	}
}
\]

For the inductive step, we need to show that,
\[
\forall x^{!N} . (( N(\vec y) \limp N( f(x, \vec x ; \vec y) ) ) \limp N(\vec y) \limp N(f(\succ_i x , \vec x ; \vec y) )   )
\]
so let us suppose that $N(x)$ and we give the following proof:
\[
\vlderivation{
	\vlin{N\cntr}{}{N(y) \limp ( N(y ) \limp N(f( x , \vec x ; \vec y ) ) ) \limp N(f (\succ_i x , \vec x ; \vec y)  ) }{
		\vliin{}{}{N(y) \limp N(y) \limp ( N(y ) \limp N(f( x , \vec x ; \vec y ) ) ) \limp N(f (\succ_i x , \vec x ; \vec y)  ) }{
			\vliin{}{}{ N(y) \limp N(y) \limp ( N(y) \limp N( f(x, \vec x ; \vec y) ) ) \limp N( h_i (x , \vec x ; \vec y , f(x , \vec x ; \vec y) ) ) }{
				\vltr{MLL}{( N(\vec y) \limp (N (\vec y) \limp N(f(x, \vec x ; \vec y) )) \limp N(f(x, \vec x ; \vec y)) }{\vlhy{\quad }}{\vlhy{\ }}{\vlhy{\quad }}
			}{
			\vlhy{2}
		}
	}{
	\vlhy{3}
}
}
}
\]
TOFINISH
\end{proof}
