Understanding variable replacement in Gödel's Incompleteness Theorem I am a High School student and I am doing a school work on the Fundamentals of Math and in the moment I am reading Gödel’s 1931 article On Formally Undecidable Propositions.
I am having a great difficulty to understand how the variable replacement works,  near the end of part 2, he defines a relation sign q with two free variables 17, 19. If I am not wrong q means:
q(x,y) = ~{x Bc Sb[y  19|Z(y)]}
Where x is the free variable 17, and y the free variable 19. So its equivalent to write:
q(17,19) = {17 Bc Sb[19  19|Z(19)]}
When we  substitute 19 for the Class Sign p we get:
Sb[q 19|Z(p)] = {17 Bc Sb[p  p|Z(p)]}
or
Sb[q 19|Z(p)] = {17 Bc Sb[p  19|Z(p)]}
The second seams to be right one, but I can’t see why some 19s becomes p and others don’t.
Or neither of the above, because the argument been replaced is Z(p) not p, so it’s actually:
Sb[q 19|p] = {17 Bc Sb[Z(p)  19|Z(Z(p))]}
If this is the case, what does Z(Z(p)) means? The Gödel number assigned to the Gödel number assigned to the Class Sign p?
 A: Exercise in substitution.
$17$ and $19$ encode respectively the first two individual variables of the language : $x_1$ and $y_1$.
$Q(x,y)$ is an arithmetical binary relation, defined by $¬[B_k(x,\text {Sb}(y^{19}_{Z(y)})]$.
By all the previous machinery in the paper, Gödel asserts (proves) that the relation is "encodable" in the language of arithmetics. 
This means that there is a formula with two free variables $q(x_1,y_1)$ that encode the relation. 
A "relation sign" is a formula with free variables, expressing an arithmetical relation. A "class sign" is a formula with one free variable, expressing a (unary) predicate. 
This means that the relation-sign $q$ (with the free variables $17, 19$ [i.e. the formula $q(x_1,y_1)$]) represents the binary relation $Q(x,y)$.
We have :

$p = 17 \text{ Gen } q$ [ i.e. $p(y_1) \equiv \forall x_1 q(x_1,y_1)$].

Thus : $p$ is a class-sign with the free variable $19$ [i.e. a formula with one free variable : $y_1$].
Thus :

$\text {Sb}(p^{19}_{Z(p)})$

is the result of the substitution into formula $p$ of the numeral [i.e. a closed term denoting a number] $Z(p)$ in place of variable $y_1$ [i.e. $\forall x_1 q(x_1,Z(p))$].
But $p$ is defined as $17 \text{ Gen } q$, and thus, we have :

$\text {Sb}(p^{19}_{Z(p)})= \text {Sb} ([17 \text { Gen } q]^{19}_{Z(p)})$

and clearly the substitution does not affect the leading quantifier, i.e.

$= 17 \text { Gen } \text {Sb}(q^{19}_{Z(p)})= 17 \text { Gen } r$,

because we have defined :

$r = \text {Sb}(q^{19}_{Z(p)})$. 

