(Doob-Dynkin Theorem) Sigma algebra generated by a function

The idea to deal with simple functions is good.

Assume that $\phi$ is the characteristic function of an element of $\sigma(f)$, say $A$. Then we choose $g$ as the characteristic function of $f^{-1}(A)$. If $\phi$ is a linear combination with non-negative coefficients of such sets, the idea is the same. If $\phi$ is non-negative, then there is a sequence $(\phi_k)$ of simple non-negative functions such that $\phi_k(x)\uparrow \phi(x)$ for all $x$. For each $\phi_k$, there is a function $g_k$ such that $\phi_k=g_k\circ f$. Furthermore, the sequence $(g_k)_k$ is non-decreasing, hence it converges to a function $g$ (that why we dealt with the case $\phi$ non-negative separately).

This is Doob-Dynkin's theorem.