%! TEX root = LC.tex
% vim: tw=50
% 25/11/2024 11AM

Suppose given a sequence $x_0, x_1, \ldots, x_{n -
1}$ of natural numbers. We want numbers $m + 1, 2m
+ 1, \ldots, nm + 1$ to serve as moduli, with $x_i
< (i + 1)m + 1$, and all of which are pairwise
coprime. If we can find $m$ such that these
conditions hold, then there is a number
$a$ such that $a \equiv x_i \pmod{(i + 1)m + 1}$.

Taking $m = \max(n, x_0, \ldots, x_{m - 1})!$
works.

We say that the pair $(a, m)$ \emph{codes} the
sequence.

\begin{fcdefn}[beta indexing]
  The function $\beta : \Nbb^2 \to \Nbb$ is
  defined by $\beta(x, i) = a \% (m(i + 1) + 1)$,
  where $a$ and $m$ are the unique numbers such
  that $x = \langle a, m \rangle$.
\end{fcdefn}

\begin{remark*}
  The forumula $\beta(x, y) = z$ is given in
  \gls{PA} by a $\delz$-formula. We will use the
  notation $(x)_i$ for $\beta(x, i)$; thus the
  decoding property is that $(x)_i = x_i$ if $x =
  \langle a, m \rangle$ codes $x_0, \ldots, x_{n -
  1}$.
\end{remark*}

\begin{fclemma}[Godel's Lemma]
  \label{lemma:2.2.9}
  % Lemma 2.2.9
  Assuming:
  - $\mathcal{M} \models \PA$
  - $n \in \Nbb$
  - $x_0, \ldots, x_{n - 1} \in \mathcal{M}$
  Then:
  there is $u \in M$ such that $\mathcal{M}
  \models (u)_i = x_i$ for all $i < n$.
\end{fclemma}

\begin{fcthm}[]
  \label{thm:2.2.10}
  % Theorem 2.2.10
  Assuming:
  - $f : \Nbb^k \to \Nbb$ a partial function
  Then:
  \begin{iffc}
    \lhs
    $f$ is recursive
    \rhs
    there is a
    $\sigone$-formula $\theta(\ol{x}, y)$ such that
    $y = f(\ol{x}) \iff \Nbb \models \theta(\ol{x},
    y)$.
  \end{iffc}
\end{fcthm}

\begin{proof}
\begin{enumerate}[$\Rightarrow$]
  \item[$\Leftarrow$]
  Suppose that $y = f(\ol{x})$ is
  $\sigone$-definable by $\theta(\ol{x}, y) \defeq
  \exists \ol{z} . \varphi(\ol{x}, y, \ol{z})$ (so
  $\varphi \in \delz$).

  \newcommand\first{\mathrm{first}}
  The function $\first(x) = (\mu y \le x)
  . \exists z \le x . (x = \langle y, z \rangle)$
  is \gls{primrecive}. By \gls{minon}, the
  function
  \[
    g(\ol{x}) = \mu z . (\exists v, \ol{w} \le z .
    (z = \langle v, \ol{w} \rangle \wedge \varphi
    (\ol{x}, v, \ol{w})))
  \]
  is \gls{pr}.

  Since $\langle v, \ol{w} \rangle = \langle v,
  \langle \ol{w} \rangle \rangle$ for tuples
  $\ol{w}$, we have that $\first(\langle v, \ol{w}
  \rangle) = v$. Thus
  \[
    \first(g(\ol{x})) = \begin{cases}
      \text{The least $y$ such that $\Nbb \models
      \theta(\ol{x}, y)$} & \text{if there is such
      $y$} \\
      \text{undefined} & \text{otherwise}
    \end{cases}
  \]
  as for each $\ol{x} \in \Nbb$ there is at most
  one $y$ such that $\Nbb \models \theta(\ol{x},
  y)$. Now $\Nbb \models \theta(\ol{x}, y) \iff y
  = f(\ol{x})$, so $f(\ol{x}) = \first(g(\ol{x}))$
  whenever defined. So $f$ is \gls{pr}.

  \item[$\Rightarrow$]
  We will show that the class of all functions
  with $\sigone$-graphs contains the basic
  functions and is closed under \gls{compon},
  \gls{primrec}, and \gls{minon}.

  The graphs of zero, successor, and $i$-th
  projection are the formulae $y = 0$, $y = x +
  1$, and $y = x_i$ respectively, so are
  $\sigone$-definable.

  If $f(x_1, \ldots, x_k)$ and $g_1(\ol{z}),
  \ldots, g_k(\ol{z})$ all have $\sigone$-graphs,
  then the graph of the composite is given by:
  \[
    \exists u_1, \ldots, u_k . \bigwedge_{i = 1}^n
    (u_i = g_i(\ol{z}) \wedge y = f(u_1, \ldots,
    u_k))
  .\]
  This is equal to a $\sigone$-formula, as those
  are closed under $\wedge, \exists$. If
  $f(\ol{x}, y)$ is obtained by \gls{primrec}
  \[
    \begin{cases}
      f(\ol{x}, 0) = g(\ol{x}) \\
      f(\ol{x}, y + 1) = h(\ol{x}, y, f(\ol{x},
      y))
    \end{cases}
  \]
  where $g$ and $h$ have $\sigone$-graphs, then we
  can use \nameref{lemma:2.2.9} to show that the
  graph of $f$ is given by
  \[
    \exists u, v . (v = g(\ol{x}) \wedge (u)_0 = v
    \wedge (u)_y = z \wedge \forall i < y .
    \exists r, s . [r = (u)_i \wedge s = (u)_{i +
    1} \wedge s = h(\ol{x}, i, r)]
  .\]
  We do this by coding the sequence $f(\ol{x}, 0),
  f(\ol{x}, 1), \ldots, f(\ol{x}, y)$ by $u$. This
  formula is equal to a $\sigone$-formula since:
  \begin{enumerate}[(1)]
    \item $z = (x)_y$ is $\delz$;
    \item If the graph of $h$ is defined by
      $\exists \ol{t} . \psi(\ol{x}, i, r, s,
      \ol{t})$ with $\psi \in \delz$, then
      \[
        \forall i < y . \exists r, s [r = (u)_i
        \wedge s = (u)_{i + 1} \wedge s =
        h(\ol{x}, i, r)]
      \]
      is equal to
      \[
        \exists w . \forall i < y . \exists r, s,
        \ol{t} \le w (r = (u)_i \wedge s = (u)_{i
        + 1} \wedge \psi(\ol{x}, i, r, s, \ol{t}))
      \]
      as we can take $w$ to be the maximum between
      suitable $r, s, \ol{t}$ with $r = (u)_i$, $s
      = (u)_{i + 1}$, $\psi(\ol{x}, i, r, s,
      \ol{t})$ with $i = 0, 1, \ldots, y - 1$.

      A similar argument gives closure under
      \gls{minon}.
  \end{enumerate}
