Can you find a division by zero error in the following short proof of Gödel's incompleteness theorem?
First a little background. $\text{G($a$)}$ returns the Gödel number of the formula $a$. As in Gödel's proof the primitive recursive funtion $\text{Z}(a)$ returns the Gödel number of the number $a$ of the formal system. Example: $\text{Z}(2) =\text{G}(\underline{2})=\text{G}(S(S(0)))$.
The primitive recursive function $\text{Sb($a$, $v_1$|$\text{Z}(y)$)}$ corresponds to the substitution of the formal system's number $y$ in the place of free variable $v_1$ in the formula that corresponds to number $a$. Example: $\text{Sb($\text{G}(v_1=0)$, $v_1$|$\text{Z}(2)$)}=\text{G}(v_1=0[v_1|\underline{2}])=\text{G}(\underline{2}=0)$.
The primitive recursive relation $x\text{B}y$ says that number $x$ corresponds to a sequence of formulas that proves the formula corresponding to number $y$. $\text{Provable}$ is then equivalent to $\exists x: x\text{B}y$.
And now to the actual proof. We assume that in the system $P$ primitive recursive relations are representable.
One of the following relations hold for any number $x$ corresponding to a formula with free variable $v_1$, either the formula corresponding to number $x$ with its free variable substituted by $y$ is provable or not:
$\text{Provable}(\text{Sb}(x,v_1\space|\text{Z}(y)))$ or $\neg \text{Provable}(\text{Sb}(x,v_1\space|\text{Z}(y)))$
Let formal system formula $r=\text{$\neg$Provable}(\text{Sb}(v_1,v_1\space|\text{Z}(v_1))$, where $v_1$ is the free variable. The formula is definable in $P$ since it's a primitive recursive relation with an added quantifier. Choose $x=G(r)$, $y=G(r)$. Now consider the first case:
$\text{Provable}(\text{Sb}(x,v_1\space|\text{Z}(x)))\Rightarrow P\vdash r[v_1|\underline{\text{G}(r)}] \Rightarrow P \vdash \neg \text{Provable}(\text{Sb}(\underline{x},v_1\space|\text{Z}(\underline{x})))\Rightarrow \neg \text{Provable}(\text{Sb}(x,v_1\space|\text{Z}(x)))$
The last line comes from assuming that $P$ is consistent and doesn't prove falsities. And as such, a contradiction! Therefore the second case $\neg \text{Provable}(\text{Sb}(x,v_1\space|\text{Z}(x)))$ must hold, and $r[v_1|\underline{\text{G}(r)}]$ is true but unprovable!