TITLE: Is there a mistake in the SEP article about Godel's Incompleteness theorems?
QUESTION [9 upvotes]: Update: The mistake referred to in this question has now been corrected. The below refers to a previous version of the article:
The second supplement to the Stanford Encyclopaedia of Philosophy article  about Gödel's incompleteness theorems concerns the proof of the diagonal lemma. The author refers to a substitution function 'subst' which takes as its first argument the Gödel number of a WFF with one free variable and its second argument the Gödel number of a numeral and which results in the Gödel number of the WFF resulting from substituting the numeral in for the free variable:
subst(⌈A(x)⌉, ⌈n⌉) = ⌈A(n)⌉,
In view of the use the author makes of this function later on in the article should the function not be one that takes as its second argument, instead of the Gödel number of the numeral, the number itself, the numeral of which will be substituted in i.e.:
substA(⌈A(x)⌉, n) = ⌈A(n)⌉,
For example, if we want to replace 'x' by '0' in 'x=0', then the second argument should be the actual number 0 not the Gödel number of the numeral '0'.
The author later outlines a formula B(x) and refers to its Gödel number as 'k' and the Gödel number of B(k) as 'm'. If we use the first definition then his assertion that subst(k, k) = m is false since k is the Gödel number of the formula 'B(x)' not the Gödel number of the numeral of the Gödel number of 'B(x)'. With the second definition, though, the assertion is true i.e substA(k,k) = m.
The second substitution function can be defined by composition from the original function and another function that I shall call 'num'. This function takes a number and returns the Gödel number of the numeral for that number in the formal theory, that is:
num(n) = ⌈n⌉
'num' corresponds to the function Z in definition 17 of Gödel's original paper. 'substA' can then be defined as:
substA(⌈A(x)⌉, n) = subst(⌈A(x)⌉,num(n) )
I'd like to know if I am correct and if not where am I going wrong?

REPLY [3 votes]: I am also having trouble determining exactly what was intended in the article. The source of my confusion is the mixture of brackets and underlining on some of the numbers (and then boldface, later on). 
In the end, the function "subst" takes actual numbers as inputs. So I believe that the following revision of the SEP article seems to work, where we remember that all the inputs to subst are numbers.  In my text below, $\underline n$ is the term of the form $1 + 1 + \cdots + 1 $ that represents $n$, and $\lceil A(x)\rceil$ is the Gödel number of $A(x)$. 

The proof of the Diagonalization Lemma centers on the operation of substitution (of a numeral for a variable in a formula): If a formula with one free variable, $A(x)$, and a number $n$ are given, the operation of constructing the formula where the numeral for that number has been substituted for the (free occurrences of the) variable $x$, that is, $A(\underline n)$, is purely mechanical. So is the analogous arithmetical operation which produces, given the Gödel number of a formula (with one free variable) $⌈A(x)⌉$ and a number $n$, the Gödel number of the formula in which the numeral for that number has been substituted for the variable in the original formula, that is, $⌈A(\underline n)⌉$. The latter operation can be expressed in the language of arithmetic. Note, in particular, that nothing prevents $n$ from being the Gödel number of $A(x)$ itself, that is, $⌈A(x)⌉$ (in the usual coding schemes, though, $n$ cannot be $⌈A(\underline n)⌉$). This operation of substitution is applied here again and again.
Let us refer to the arithmetized substitution function as subst($⌈A(x)⌉$, $n$) = $⌈A(\underline n)⌉$, and let $S(x, y, z)$ be a formula which strongly represents this operation, as a relation, in the language of our theory $F$. In other words, $S$ is true of $x$, $y$, and $z$, if and only if there is a formula $A(r)$ with one free variable such that:
  $$
x = ⌈A(r)⌉ \text{ and } z = ⌈A(\underline y)⌉.
$$
  Again, nothing prevents us from considering subst($⌈A(x)⌉$, $⌈A(x)⌉$), or, analogously, $S(x, x, y)$.

I have read through the lower part of the SEP article a couple times, and it seems as if this change to the beginning of the SEP article is sufficient for the lower part to go through. This does require some changes, e.g. 
$$
F ⊢ ∀y[S(\underline k,\underline k, y) ↔ y = ⌈B(\underline k)⌉]
$$
should be
$$
F ⊢ ∀y[S(\underline k,\underline k, y) ↔ y = \underline {⌈B(\underline k)⌉}]
$$
with similar changes in the remainder of the argument.
Of course, (as the question shows) it is easy to miss fine details.