Talk:Diagonal lemma/Diagonal formula as a representation of a recursive function

Gödel numbering
Let us fix a Gödel numbering for the object language:

Sequences
Let us denote sequences of sigs
 * using the fundamental theorem of arithmetic, but we may use more sophisticated methods (Chinese remainder theorem)
 * let us store also the length of the sequence (e.g. let us store a surplus item of the sequence, which stores the length of the remaining sequence. Here, let us reserve the first (indexed as zeroth) item for this. E.g., if we use fundamental theorem, we use a pattern $$2^n \cdot p_1^{\alpha_0} \cdot \dots \cdot p_{n-1}^{\alpha_{n-1}}$$: a product of a 2-power (storing the length) and an ecoding of the remaining sequence (using fundamental theorem of artihmetic, of course, 2 is not among its primes). But, as mentioned, there are more advanced tricks for representing length-aware sequences, e.g. using the Chinese remainder theorem and the pairing function in a spohisticated way — see the main article of the section.
 * use Polish notation (prefix notation), so that we can avoid using parantheses-like auxiliary signs

If we have already selected an appropriate method for coding/decoding sequences, sometimes, let us hide the details, and denote
 * $$\epsilon$$
 * empty sequence,


 * $$x:s$$
 * the sequence made from x as first token of it and s as the reamining (tail) sequence.

In short, let us use list-like notation (like in modern functional languages). It will be useful if recursion will be discussed.

But in many other cases, we may use also the $$\left\langle \dots \right\rangle$$ notation.

Recursion
The following two facts can lead to different solutions

Obsolete section!

 * $$\mathrm{diag}(s,u) = \mathrm{subst}(s,u,s)$$
 * $$\mathrm{subst}(\epsilon,u,s) = \epsilon$$
 * $$\mathrm{subst}(x:s, u, q) = \begin{cases}\mathfrak R_q \frown \mathrm{subst}(s, u, q)&x=u+13\\ \mathfrak R_x \frown \mathrm{subst}(s, u, q)&x\neq u+13\end{cases}$$

looks lke a good (Haskell-like) definition for what we expect from diagonalization. In fact, we should take care of the scope of variables, and avoid substituion of bound variables.

But how to achieve, that the above Haskell-like definitions can be exressed
 * in the realm of recursive functions (a rather asketic world, compared to Haskell)
 * and how to represent it ith first-order formulae?

Sequences (again) can be used for this, because sequences can store the path of recursive calls, thus appropriate tricks can solve the problem of recursion.