I tried to prove the exercise problem in Kunen (Chapter IV, problem 36.)
Problem. Show that there is a formula $\chi(x)$, such that
$\chi$ represents ZF; i.e.,$$\phi\in \mathsf{ZF}\to \mathsf{ZF}\vdash\chi(\ulcorner\phi\urcorner)\quad\text{and}\quad \phi\notin \mathsf{ZF}\to \mathsf{ZF}\vdash \lnot\chi(\ulcorner\phi\urcorner)$$
If $\ulcorner\mathsf{ZF}\urcorner$ is added via the definition $\ulcorner\mathsf{ZF}\urcorner=\{x:\chi(x)\}$, then $\mathsf{ZF}\vdash \mathsf{CON(\ulcorner ZF\urcorner)}$.
(where $\mathsf{CON}(\ulcorner T\urcorner)$ is consistency argument of $T$ which is formalized within formal theory $\mathsf{ZF}$.)
But I am not even understand the problem. Why the second incompleteness does not applied in that case? In page 144-145 in Kunen, he writes
(...) We now have for each such $S$, a sentence $\mathsf{CON}(\ulcorner S\urcorner)$ in the language of set theory asserting that $S$ is consistent. (...) The Gödel Incompleteness Theorem shows that if $S$ is consistent and extends $\mathsf{ZF}$, then $S\nvdash\mathsf{CON}(\ulcorner S\urcorner)$. (Caution: this presupports that we used a "reasonable" $\chi_S$ to represent $S$.)
(Add: $\chi_S$ represents $S$; it was explained the front of above comment.)
I also don't understand that comment. I would be thankful for any reasonable explanation.
Thanks to GME and Habič's comments, I understand and can prove that problem. This answer is just filling in the details of their comments.
Let define $$\chi(n)\leftrightarrow n\in \mathsf{ZF}\land \mathsf{CON}\{m\in\mathsf{ZF}:m\le n\}.$$
We regard $\mathsf{ZF}$ as the recursive set of Gödel numberings of the axioms of ZF. If $\phi\in \mathsf{ZF}$, then $\mathsf{ZF}\vdash (\ulcorner\phi\urcorner\in \mathsf{ZF})$. Also, if $\psi_1$, $\psi_2$, $\cdots$, $\psi_k$ are axioms of ZF whose Gödel number is less than the Gödel number of $\phi$ then by reflection, the consistency of $\{\psi_1,\cdots,\psi_k,\phi\}$ is provable from ZF; that is, $\mathsf{ZF}\vdash \mathsf{CON}\{m\in\mathsf{ZF}:m\le \ulcorner\phi\urcorner\}$. Therefore $\mathsf{ZF}\vdash\chi (\ulcorner\phi\urcorner)$. If $\phi\notin \mathsf{ZF}$ then $\mathsf{ZF}\vdash (\ulcorner\phi\urcorner\notin \mathsf{ZF})$ so $\mathsf{ZF}\vdash\lnot\chi(\ulcorner\phi\urcorner)$
We will prove that, if $\ulcorner\mathsf{ZF}\urcorner$ is added via the definition $$\ulcorner\mathsf{ZF}\urcorner=\{n:\chi(n)\}$$ then $\mathsf{ZF}\vdash \mathsf{CON(\ulcorner ZF\urcorner)}$. We will use the reduction to absurdity within the formal theory $\mathsf{ZF}$.
If $\lnot\mathsf{CON(\ulcorner ZF\urcorner)}$ holds, then there is a proof $\pi$ from some assumptions $a_1,a_2,\cdots,a_n\in \ulcorner \mathsf{ZF}\urcorner$ to contradiction. But we already know that $\mathsf{CON}\{a_1,a_2,\cdots a_n\}$ holds. So we cannot derive a contradiction from $a_1$, $\cdots$, $a_n$. From this, we get $\mathsf{ZF+}\lnot\mathsf{CON(\ulcorner ZF\urcorner)}$ derives contradiction so $\mathsf{ZF}\vdash \mathsf{CON(\ulcorner ZF\urcorner)}$.
It does not contradict with second imcompleteness theorem since $\chi$ is at least $\Pi_1^0$, so is not recursive.